-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.common
executable file
·106 lines (68 loc) · 2.4 KB
/
Makefile.common
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# name of executable
ELF=$(notdir $(CURDIR)).elf
BIN=$(notdir $(CURDIR)).bin
HEX=$(notdir $(CURDIR)).hex
# Tool path
#TOOLROOT=$(HOME)/stm32/gcc-arm-none-eabi-4_9-2014q4/bin
TOOLROOT=$(HOME)/stm32/gcc-arm-none-eabi-4_9-2015q1/bin
# Library path
LIBROOT=$(HOME)/stm32/STM32F10x_StdPeriph_Lib_V3.5.0
# Tools
CC=$(TOOLROOT)/arm-none-eabi-gcc
CPP=$(TOOLROOT)/arm-none-eabi-g++
LD=$(TOOLROOT)/arm-none-eabi-gcc
#LD=$(TOOLROOT)/arm-none-eabi-ld
AR=$(TOOLROOT)/arm-none-eabi-ar
AS=$(TOOLROOT)/arm-none-eabi-as
OC=$(TOOLROOT)/arm-none-eabi-objcopy
# Code Paths
DEVICE=$(LIBROOT)/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x
CORE=$(LIBROOT)/Libraries/CMSIS/CM3/CoreSupport
PERIPH=$(LIBROOT)/Libraries/STM32F10x_StdPeriph_Driver
# Search path for standard files
vpath %.c $(TEMPLATEROOT)
# Search path for perpheral library
vpath %.c $(CORE)
vpath %.c $(PERIPH)/src
vpath %.c $(DEVICE)
# Search path for Library
vpath %.c $(TEMPLATEROOT)/Library/ff9/src
vpath %.c $(TEMPLATEROOT)/Library/ff9/src/option
vpath %.c $(TEMPLATEROOT)/Library
# Processor specific
PTYPE = STM32F10X_MD
LDSCRIPT = $(TEMPLATEROOT)/stm32f100.ld
STARTUP= startup_stm32f10x.o system_stm32f10x.o
# Compilation Flags
FULLASSERT = -DUSE_FULL_ASSERT
LDFLAGS+= -T$(LDSCRIPT) -mthumb -mcpu=cortex-m3 -Wl,-Map=output.map -Wl,--cref
# let linker to dump unused sections
LDFLAGS += -Wl,--gc-sections -Wl,--start-group
CFLAGS+= -mcpu=cortex-m3 -mthumb
CFLAGS+= -I$(TEMPLATEROOT) -I$(DEVICE) -I$(CORE) -I$(PERIPH)/inc -I.
CFLAGS+= -D$(PTYPE) -DUSE_STDPERIPH_DRIVER $(FULLASSERT)
CFLAGS+= -I$(TEMPLATEROOT)/Library/ff9/src -I$(TEMPLATEROOT)/Library
# keep every function in separate section. This will allow linker to dump unused functions
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
CFLAGS += -fno-builtin --short-enums
# Build executable
$(BIN) : $(ELF)
$(OC) -O binary $(ELF) $(BIN)
$(OC) -O ihex $(ELF) $(HEX)
$(ELF) : $(OBJS)
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
# compile and generate dependency info
%.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
$(CC) -MM $(CFLAGS) $< > $*.d
%.o: %.cpp
$(CPP) -c $(CFLAGS) $< -o $@
$(CPP) -MM $(CFLAGS) $< > $*.d
%.o: %.s
$(CC) -c $(CFLAGS) $< -o $@
clean:
rm -f $(OBJS) $(OBJS:.o=.d) $(ELF) $(BIN) $(HEX) output.map startup_stm32f* $(CLEANOTHER)
debug: $(ELF)
arm-none-eabi-gdb $(ELF)
# pull in dependencies
-include $(OBJS:.o=.d)