Rev 3 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | ########################################################################################################################## |
2 | # File automatically-generated by tool: [projectgenerator] version: [3.16.0] date: [Sun Apr 30 17:33:50 BST 2023] |
||
3 | ########################################################################################################################## |
||
4 | |||
5 | # ------------------------------------------------ |
||
6 | # Generic Makefile (based on gcc) |
||
7 | # |
||
8 | # ChangeLog : |
||
9 | # 2017-02-10 - Several enhancements + project update mode |
||
10 | # 2015-07-22 - first version |
||
11 | # ------------------------------------------------ |
||
12 | |||
13 | ###################################### |
||
14 | # target |
||
15 | ###################################### |
||
16 | TARGET = canSerial |
||
17 | |||
18 | |||
19 | ###################################### |
||
20 | # building variables |
||
21 | ###################################### |
||
22 | # debug build? |
||
23 | DEBUG = 1 |
||
24 | # optimization |
||
25 | OPT = -Og |
||
26 | |||
27 | |||
28 | ####################################### |
||
29 | # paths |
||
30 | ####################################### |
||
31 | # Build path |
||
32 | BUILD_DIR = build |
||
33 | |||
34 | ###################################### |
||
35 | # source |
||
36 | ###################################### |
||
37 | # C sources |
||
38 | C_SOURCES = \ |
||
39 | Core/Src/main.c \ |
||
40 | Core/Src/stm32f1xx_it.c \ |
||
41 | Core/Src/stm32f1xx_hal_msp.c \ |
||
42 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \ |
||
43 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c \ |
||
44 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \ |
||
45 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \ |
||
46 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \ |
||
47 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \ |
||
48 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \ |
||
49 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \ |
||
50 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \ |
||
51 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \ |
||
52 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \ |
||
53 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c \ |
||
54 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \ |
||
55 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \ |
||
56 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \ |
||
57 | Core/Src/system_stm32f1xx.c |
||
58 | |||
59 | # ASM sources |
||
60 | ASM_SOURCES = \ |
||
61 | startup_stm32f103x6.s |
||
62 | |||
63 | C_SOURCES += \ |
||
64 | Core/Src/base64.c |
||
65 | |||
66 | |||
67 | ####################################### |
||
68 | # binaries |
||
69 | ####################################### |
||
70 | PREFIX = arm-none-eabi- |
||
71 | # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx) |
||
72 | # either it can be added to the PATH environment variable. |
||
73 | ifdef GCC_PATH |
||
74 | CC = $(GCC_PATH)/$(PREFIX)gcc |
||
75 | AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp |
||
76 | CP = $(GCC_PATH)/$(PREFIX)objcopy |
||
77 | SZ = $(GCC_PATH)/$(PREFIX)size |
||
78 | else |
||
79 | CC = $(PREFIX)gcc |
||
80 | AS = $(PREFIX)gcc -x assembler-with-cpp |
||
81 | CP = $(PREFIX)objcopy |
||
82 | SZ = $(PREFIX)size |
||
83 | endif |
||
84 | HEX = $(CP) -O ihex |
||
85 | BIN = $(CP) -O binary -S |
||
86 | |||
87 | ####################################### |
||
88 | # CFLAGS |
||
89 | ####################################### |
||
90 | # cpu |
||
91 | CPU = -mcpu=cortex-m3 |
||
92 | |||
93 | # fpu |
||
94 | # NONE for Cortex-M0/M0+/M3 |
||
95 | |||
96 | # float-abi |
||
97 | |||
98 | |||
99 | # mcu |
||
100 | MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) |
||
101 | |||
102 | # macros for gcc |
||
103 | # AS defines |
||
104 | AS_DEFS = |
||
105 | |||
106 | # C defines |
||
107 | C_DEFS = \ |
||
108 | -DUSE_HAL_DRIVER \ |
||
109 | -DSTM32F103xB |
||
110 | |||
111 | |||
112 | # AS includes |
||
113 | AS_INCLUDES = |
||
114 | |||
115 | # C includes |
||
116 | C_INCLUDES = \ |
||
117 | -ICore/Inc \ |
||
118 | -IDrivers/STM32F1xx_HAL_Driver/Inc \ |
||
119 | -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \ |
||
120 | -IDrivers/CMSIS/Device/ST/STM32F1xx/Include \ |
||
121 | -IDrivers/CMSIS/Include |
||
122 | |||
123 | ################################################################ |
||
124 | # Add serial driver |
||
125 | C_DEFS+=-DSERIAL_UART1 |
||
126 | LIBSERIAL = ../libSerial |
||
127 | include $(LIBSERIAL)/libSerial.mk |
||
128 | |||
129 | # Add small printf libtrary |
||
130 | LIBSMALLPRINTF = ../libSmallPrintf |
||
131 | include $(LIBSMALLPRINTF)/libSmallPrintf.mk |
||
132 | ################################################################ |
||
133 | |||
134 | |||
135 | # compile gcc flags |
||
136 | ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections |
||
137 | |||
138 | CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections |
||
139 | |||
140 | ifeq ($(DEBUG), 1) |
||
141 | CFLAGS += -g -gdwarf-2 |
||
142 | endif |
||
143 | |||
144 | |||
145 | # Generate dependency information |
||
146 | CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" |
||
147 | |||
148 | |||
149 | ####################################### |
||
150 | # LDFLAGS |
||
151 | ####################################### |
||
152 | # link script |
||
153 | LDSCRIPT = STM32F103CBTx_FLASH.ld |
||
154 | |||
155 | # libraries |
||
156 | LIBS = -lc -lm -lnosys |
||
157 | LIBDIR = |
||
158 | LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections |
||
159 | |||
160 | # default action: build all |
||
161 | all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin |
||
162 | |||
163 | |||
164 | ####################################### |
||
165 | # build the application |
||
166 | ####################################### |
||
167 | # list of objects |
||
168 | OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) |
||
169 | vpath %.c $(sort $(dir $(C_SOURCES))) |
||
170 | # list of ASM program objects |
||
171 | OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) |
||
172 | vpath %.s $(sort $(dir $(ASM_SOURCES))) |
||
173 | |||
174 | $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) |
||
175 | $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ |
||
176 | |||
177 | $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) |
||
178 | $(AS) -c $(CFLAGS) $< -o $@ |
||
179 | |||
180 | $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile |
||
181 | $(CC) $(OBJECTS) $(LDFLAGS) -o $@ |
||
182 | $(SZ) $@ |
||
183 | |||
184 | $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) |
||
185 | $(HEX) $< $@ |
||
186 | |||
187 | $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) |
||
188 | $(BIN) $< $@ |
||
189 | |||
190 | $(BUILD_DIR): |
||
191 | mkdir $@ |
||
192 | |||
193 | ####################################### |
||
194 | # clean up |
||
195 | ####################################### |
||
196 | clean: |
||
197 | -rm -fR $(BUILD_DIR) |
||
198 | |||
199 | ####################################### |
||
200 | # dependencies |
||
201 | ####################################### |
||
202 | -include $(wildcard $(BUILD_DIR)/*.d) |
||
203 | |||
204 | # *** EOF *** |