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