xref: /btstack/port/stm32-f4discovery-usb/Makefile (revision a8f7f3fcbcd51f8d2e92aca076b6a9f812db358c)
1*a8f7f3fcSMatthias Ringwald##########################################################################################################################
2*a8f7f3fcSMatthias Ringwald# File automatically-generated by tool: [projectgenerator] version: [3.11.0-B13] date: [Sun Jan 17 23:15:13 CET 2021]
3*a8f7f3fcSMatthias Ringwald##########################################################################################################################
4*a8f7f3fcSMatthias Ringwald
5*a8f7f3fcSMatthias Ringwald# ------------------------------------------------
6*a8f7f3fcSMatthias Ringwald# Generic Makefile (based on gcc)
7*a8f7f3fcSMatthias Ringwald#
8*a8f7f3fcSMatthias Ringwald# ChangeLog :
9*a8f7f3fcSMatthias Ringwald#	2017-02-10 - Several enhancements + project update mode
10*a8f7f3fcSMatthias Ringwald#   2015-07-22 - first version
11*a8f7f3fcSMatthias Ringwald# ------------------------------------------------
12*a8f7f3fcSMatthias Ringwald
13*a8f7f3fcSMatthias Ringwald######################################
14*a8f7f3fcSMatthias Ringwald# target
15*a8f7f3fcSMatthias Ringwald######################################
16*a8f7f3fcSMatthias RingwaldTARGET = stm32-f4discovery-usb-blog
17*a8f7f3fcSMatthias Ringwald
18*a8f7f3fcSMatthias Ringwald
19*a8f7f3fcSMatthias Ringwald######################################
20*a8f7f3fcSMatthias Ringwald# building variables
21*a8f7f3fcSMatthias Ringwald######################################
22*a8f7f3fcSMatthias Ringwald# debug build?
23*a8f7f3fcSMatthias RingwaldDEBUG = 1
24*a8f7f3fcSMatthias Ringwald# optimization
25*a8f7f3fcSMatthias RingwaldOPT = -Og
26*a8f7f3fcSMatthias Ringwald
27*a8f7f3fcSMatthias Ringwald
28*a8f7f3fcSMatthias Ringwald#######################################
29*a8f7f3fcSMatthias Ringwald# paths
30*a8f7f3fcSMatthias Ringwald#######################################
31*a8f7f3fcSMatthias Ringwald# Build path
32*a8f7f3fcSMatthias RingwaldBUILD_DIR = build
33*a8f7f3fcSMatthias Ringwald
34*a8f7f3fcSMatthias RingwaldBTSTACK_ROOT ?= ../..
35*a8f7f3fcSMatthias Ringwald
36*a8f7f3fcSMatthias Ringwald######################################
37*a8f7f3fcSMatthias Ringwald# source
38*a8f7f3fcSMatthias Ringwald######################################
39*a8f7f3fcSMatthias Ringwald# C sources
40*a8f7f3fcSMatthias RingwaldC_SOURCES =  \
41*a8f7f3fcSMatthias RingwaldCore/Src/main.c \
42*a8f7f3fcSMatthias RingwaldCore/Src/stm32f4xx_it.c \
43*a8f7f3fcSMatthias RingwaldCore/Src/stm32f4xx_hal_msp.c \
44*a8f7f3fcSMatthias Ringwald${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT.c \
45*a8f7f3fcSMatthias Ringwald${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT_Syscalls_GCC.c \
46*a8f7f3fcSMatthias RingwaldUSB_HOST/Target/usbh_conf.c \
47*a8f7f3fcSMatthias RingwaldUSB_HOST/Target/usbh_platform.c \
48*a8f7f3fcSMatthias RingwaldUSB_HOST/App/usb_host.c \
49*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_hcd.c \
50*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c \
51*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \
52*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c \
53*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c \
54*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c \
55*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c \
56*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c \
57*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c \
58*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \
59*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \
60*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c \
61*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c \
62*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c \
63*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c \
64*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \
65*a8f7f3fcSMatthias RingwaldDrivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \
66*a8f7f3fcSMatthias RingwaldCore/Src/system_stm32f4xx.c \
67*a8f7f3fcSMatthias RingwaldMiddlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_core.c \
68*a8f7f3fcSMatthias RingwaldMiddlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c \
69*a8f7f3fcSMatthias RingwaldMiddlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ioreq.c \
70*a8f7f3fcSMatthias RingwaldMiddlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_pipes.c \
71*a8f7f3fcSMatthias RingwaldMiddlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid.c \
72*a8f7f3fcSMatthias RingwaldMiddlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_keybd.c \
73*a8f7f3fcSMatthias RingwaldMiddlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_mouse.c \
74*a8f7f3fcSMatthias RingwaldMiddlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_parser.c
75*a8f7f3fcSMatthias Ringwald
76*a8f7f3fcSMatthias Ringwald# ASM sources
77*a8f7f3fcSMatthias RingwaldASM_SOURCES =  \
78*a8f7f3fcSMatthias Ringwaldstartup_stm32f407xx.s
79*a8f7f3fcSMatthias Ringwald
80*a8f7f3fcSMatthias Ringwald
81*a8f7f3fcSMatthias Ringwald#######################################
82*a8f7f3fcSMatthias Ringwald# binaries
83*a8f7f3fcSMatthias Ringwald#######################################
84*a8f7f3fcSMatthias RingwaldPREFIX = arm-none-eabi-
85*a8f7f3fcSMatthias Ringwald# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
86*a8f7f3fcSMatthias Ringwald# either it can be added to the PATH environment variable.
87*a8f7f3fcSMatthias Ringwaldifdef GCC_PATH
88*a8f7f3fcSMatthias RingwaldCC = $(GCC_PATH)/$(PREFIX)gcc
89*a8f7f3fcSMatthias RingwaldAS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
90*a8f7f3fcSMatthias RingwaldCP = $(GCC_PATH)/$(PREFIX)objcopy
91*a8f7f3fcSMatthias RingwaldSZ = $(GCC_PATH)/$(PREFIX)size
92*a8f7f3fcSMatthias Ringwaldelse
93*a8f7f3fcSMatthias RingwaldCC = $(PREFIX)gcc
94*a8f7f3fcSMatthias RingwaldAS = $(PREFIX)gcc -x assembler-with-cpp
95*a8f7f3fcSMatthias RingwaldCP = $(PREFIX)objcopy
96*a8f7f3fcSMatthias RingwaldSZ = $(PREFIX)size
97*a8f7f3fcSMatthias Ringwaldendif
98*a8f7f3fcSMatthias RingwaldHEX = $(CP) -O ihex
99*a8f7f3fcSMatthias RingwaldBIN = $(CP) -O binary -S
100*a8f7f3fcSMatthias Ringwald
101*a8f7f3fcSMatthias Ringwald#######################################
102*a8f7f3fcSMatthias Ringwald# CFLAGS
103*a8f7f3fcSMatthias Ringwald#######################################
104*a8f7f3fcSMatthias Ringwald# cpu
105*a8f7f3fcSMatthias RingwaldCPU = -mcpu=cortex-m4
106*a8f7f3fcSMatthias Ringwald
107*a8f7f3fcSMatthias Ringwald# fpu
108*a8f7f3fcSMatthias RingwaldFPU = -mfpu=fpv4-sp-d16
109*a8f7f3fcSMatthias Ringwald
110*a8f7f3fcSMatthias Ringwald# float-abi
111*a8f7f3fcSMatthias RingwaldFLOAT-ABI = -mfloat-abi=hard
112*a8f7f3fcSMatthias Ringwald
113*a8f7f3fcSMatthias Ringwald# mcu
114*a8f7f3fcSMatthias RingwaldMCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
115*a8f7f3fcSMatthias Ringwald
116*a8f7f3fcSMatthias Ringwald# macros for gcc
117*a8f7f3fcSMatthias Ringwald# AS defines
118*a8f7f3fcSMatthias RingwaldAS_DEFS =
119*a8f7f3fcSMatthias Ringwald
120*a8f7f3fcSMatthias Ringwald# C defines
121*a8f7f3fcSMatthias RingwaldC_DEFS =  \
122*a8f7f3fcSMatthias Ringwald-DUSE_HAL_DRIVER \
123*a8f7f3fcSMatthias Ringwald-DSTM32F407xx
124*a8f7f3fcSMatthias Ringwald
125*a8f7f3fcSMatthias Ringwald
126*a8f7f3fcSMatthias Ringwald# AS includes
127*a8f7f3fcSMatthias RingwaldAS_INCLUDES =
128*a8f7f3fcSMatthias Ringwald
129*a8f7f3fcSMatthias Ringwald# C includes
130*a8f7f3fcSMatthias RingwaldC_INCLUDES =  \
131*a8f7f3fcSMatthias Ringwald-IUSB_HOST/App \
132*a8f7f3fcSMatthias Ringwald-IUSB_HOST/Target \
133*a8f7f3fcSMatthias Ringwald-ICore/Inc \
134*a8f7f3fcSMatthias Ringwald-IDrivers/STM32F4xx_HAL_Driver/Inc \
135*a8f7f3fcSMatthias Ringwald-IDrivers/STM32F4xx_HAL_Driver/Inc/Legacy \
136*a8f7f3fcSMatthias Ringwald-IMiddlewares/ST/STM32_USB_Host_Library/Core/Inc \
137*a8f7f3fcSMatthias Ringwald-IMiddlewares/ST/STM32_USB_Host_Library/Class/HID/Inc \
138*a8f7f3fcSMatthias Ringwald-IDrivers/CMSIS/Device/ST/STM32F4xx/Include \
139*a8f7f3fcSMatthias Ringwald-IDrivers/CMSIS/Include \
140*a8f7f3fcSMatthias Ringwald-Iport
141*a8f7f3fcSMatthias Ringwald
142*a8f7f3fcSMatthias Ringwald
143*a8f7f3fcSMatthias Ringwald# compile gcc flags
144*a8f7f3fcSMatthias RingwaldASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
145*a8f7f3fcSMatthias Ringwald
146*a8f7f3fcSMatthias RingwaldCFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
147*a8f7f3fcSMatthias Ringwald
148*a8f7f3fcSMatthias Ringwaldifeq ($(DEBUG), 1)
149*a8f7f3fcSMatthias RingwaldCFLAGS += -g -gdwarf-2
150*a8f7f3fcSMatthias Ringwaldendif
151*a8f7f3fcSMatthias Ringwald
152*a8f7f3fcSMatthias Ringwald
153*a8f7f3fcSMatthias Ringwald# Generate dependency information
154*a8f7f3fcSMatthias RingwaldCFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
155*a8f7f3fcSMatthias Ringwald
156*a8f7f3fcSMatthias Ringwald
157*a8f7f3fcSMatthias Ringwald#######################################
158*a8f7f3fcSMatthias Ringwald# LDFLAGS
159*a8f7f3fcSMatthias Ringwald#######################################
160*a8f7f3fcSMatthias Ringwald# link script
161*a8f7f3fcSMatthias RingwaldLDSCRIPT = STM32F407VGTx_FLASH.ld
162*a8f7f3fcSMatthias Ringwald
163*a8f7f3fcSMatthias Ringwald# libraries
164*a8f7f3fcSMatthias RingwaldLIBS = -lc -lm -lnosys
165*a8f7f3fcSMatthias RingwaldLIBDIR =
166*a8f7f3fcSMatthias RingwaldLDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
167*a8f7f3fcSMatthias Ringwald
168*a8f7f3fcSMatthias Ringwald# default action: build all
169*a8f7f3fcSMatthias Ringwaldall: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
170*a8f7f3fcSMatthias Ringwald
171*a8f7f3fcSMatthias Ringwald
172*a8f7f3fcSMatthias Ringwald#######################################
173*a8f7f3fcSMatthias Ringwald# build the application
174*a8f7f3fcSMatthias Ringwald#######################################
175*a8f7f3fcSMatthias Ringwald# list of objects
176*a8f7f3fcSMatthias RingwaldOBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
177*a8f7f3fcSMatthias Ringwaldvpath %.c $(sort $(dir $(C_SOURCES)))
178*a8f7f3fcSMatthias Ringwald# list of ASM program objects
179*a8f7f3fcSMatthias RingwaldOBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
180*a8f7f3fcSMatthias Ringwaldvpath %.s $(sort $(dir $(ASM_SOURCES)))
181*a8f7f3fcSMatthias Ringwald
182*a8f7f3fcSMatthias Ringwald$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
183*a8f7f3fcSMatthias Ringwald	$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
184*a8f7f3fcSMatthias Ringwald
185*a8f7f3fcSMatthias Ringwald$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
186*a8f7f3fcSMatthias Ringwald	$(AS) -c $(CFLAGS) $< -o $@
187*a8f7f3fcSMatthias Ringwald
188*a8f7f3fcSMatthias Ringwald$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
189*a8f7f3fcSMatthias Ringwald	$(CC) $(OBJECTS) $(LDFLAGS) -o $@
190*a8f7f3fcSMatthias Ringwald	$(SZ) $@
191*a8f7f3fcSMatthias Ringwald
192*a8f7f3fcSMatthias Ringwald$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
193*a8f7f3fcSMatthias Ringwald	$(HEX) $< $@
194*a8f7f3fcSMatthias Ringwald
195*a8f7f3fcSMatthias Ringwald$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
196*a8f7f3fcSMatthias Ringwald	$(BIN) $< $@
197*a8f7f3fcSMatthias Ringwald
198*a8f7f3fcSMatthias Ringwald$(BUILD_DIR):
199*a8f7f3fcSMatthias Ringwald	mkdir $@
200*a8f7f3fcSMatthias Ringwald
201*a8f7f3fcSMatthias Ringwald#######################################
202*a8f7f3fcSMatthias Ringwald# clean up
203*a8f7f3fcSMatthias Ringwald#######################################
204*a8f7f3fcSMatthias Ringwaldclean:
205*a8f7f3fcSMatthias Ringwald	-rm -fR $(BUILD_DIR)
206*a8f7f3fcSMatthias Ringwald
207*a8f7f3fcSMatthias Ringwald#######################################
208*a8f7f3fcSMatthias Ringwald# dependencies
209*a8f7f3fcSMatthias Ringwald#######################################
210*a8f7f3fcSMatthias Ringwald-include $(wildcard $(BUILD_DIR)/*.d)
211*a8f7f3fcSMatthias Ringwald
212*a8f7f3fcSMatthias Ringwald# *** EOF ***
213