]> mj.ucw.cz Git - home-hw.git/blob - Makefile
Split to low/high-level part
[home-hw.git] / Makefile
1 ##########################################################################################################################
2 # File automatically-generated by tool: [projectgenerator] version: [2.27.0] date: [Sat Jun 23 19:52:50 CEST 2018] 
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 = testusb
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 # source path
32 SOURCES_DIR =  \
33 Drivers \
34 Application/User/Src/main.c \
35 Application/User/Src \
36 Application/User/Src/stm32f1xx_hal_msp.c \
37 Drivers/STM32F1xx_HAL_Driver \
38 Application/User/Src/stm32f1xx_it.c \
39 Application/User \
40 Drivers/CMSIS \
41 Application
42
43 # firmware library path
44 PERIFLIB_PATH = 
45
46 # Build path
47 BUILD_DIR = build
48
49 ######################################
50 # source
51 ######################################
52 # C sources
53 C_SOURCES =  \
54 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_exti.c \
55 Src/main.c \
56 Src/debug.c \
57 Src/usb.c \
58 Src/usbdev.c \
59 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_rcc.c \
60 /Src/system_stm32f1xx.c \
61 Src/stm32f1xx_it.c \
62 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_utils.c \
63 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_gpio.c \
64 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \
65 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \
66 Src/stm32f1xx_hal_msp.c \
67 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \
68 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \
69 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd_ex.c \
70 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \
71 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \
72 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \
73 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \
74 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \
75 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \
76 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \
77 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_dma.c \
78 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \
79 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd.c \
80 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usb.c \
81 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_i2c.c
82
83 # ASM sources
84 ASM_SOURCES =  \
85 startup_stm32f103xb.s
86
87
88 ######################################
89 # firmware library
90 ######################################
91 PERIFLIB_SOURCES = 
92
93
94 #######################################
95 # binaries
96 #######################################
97 BINPATH = /usr/bin
98 PREFIX = arm-none-eabi-
99 CC = $(BINPATH)/$(PREFIX)gcc
100 AS = $(BINPATH)/$(PREFIX)gcc -x assembler-with-cpp
101 CP = $(BINPATH)/$(PREFIX)objcopy
102 AR = $(BINPATH)/$(PREFIX)ar
103 SZ = $(BINPATH)/$(PREFIX)size
104 HEX = $(CP) -O ihex
105 BIN = $(CP) -O binary -S
106  
107 #######################################
108 # CFLAGS
109 #######################################
110 # cpu
111 CPU = -mcpu=cortex-m3
112
113 # fpu
114 # NONE for Cortex-M0/M0+/M3
115
116 # float-abi
117
118
119 # mcu
120 MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
121
122 # macros for gcc
123 # AS defines
124 AS_DEFS = 
125
126 # C defines
127 C_DEFS =  \
128 -DUSE_FULL_LL_DRIVER \
129 -DSTM32F103xB \
130 -DUSE_HAL_DRIVER
131
132
133 # AS includes
134 AS_INCLUDES = 
135
136 # C includes
137 C_INCLUDES =  \
138 -IInc \
139 -I/aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Inc \
140 -I/aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy \
141 -I/aux/misc/stm/F1-package/Drivers/CMSIS/Include \
142 -I/aux/misc/stm/F1-package/Drivers/CMSIS/Device/ST/STM32F1xx/Include
143
144
145 # compile gcc flags
146 ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
147
148 CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
149
150 ifeq ($(DEBUG), 1)
151 CFLAGS += -g -gdwarf-2
152 endif
153
154
155 # Generate dependency information
156 CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)"
157
158
159 #######################################
160 # LDFLAGS
161 #######################################
162 # link script
163 LDSCRIPT = STM32F103C8Tx_FLASH.ld
164
165 # libraries
166 LIBS = -lc -lm -lnosys 
167 LIBDIR = 
168 LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
169
170 # default action: build all
171 all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
172
173 flash: all
174         LD_LIBRARY_PATH=../stlink ../stlink/st-flash write $(BUILD_DIR)/$(TARGET).bin 0x8000000
175
176 #######################################
177 # build the application
178 #######################################
179 # list of objects
180 OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
181 vpath %.c $(sort $(dir $(C_SOURCES)))
182 # list of ASM program objects
183 OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
184 vpath %.s $(sort $(dir $(ASM_SOURCES)))
185
186 $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 
187         $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
188
189 $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
190         $(AS) -c $(CFLAGS) $< -o $@
191
192 $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
193         $(CC) $(OBJECTS) $(LDFLAGS) -o $@
194         $(SZ) $@
195
196 $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
197         $(HEX) $< $@
198         
199 $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
200         $(BIN) $< $@    
201         
202 $(BUILD_DIR):
203         mkdir $@                
204
205 #######################################
206 # clean up
207 #######################################
208 clean:
209         -rm -fR .dep $(BUILD_DIR)
210   
211 #######################################
212 # dependencies
213 #######################################
214 -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
215
216 # *** EOF ***