xref: /btstack/port/stm32-l073rz-nucleo-em9304/Makefile (revision 0561b2d8d5dba972c7daa57d5e677f7a1327edfd)
1##########################################################################################################################
2# File automatically-generated by tool: [projectgenerator] version: [3.1.0] date: [Sat Mar 30 18:50:14 CET 2019]
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######################################
16TARGET = stm32-l073rz-nucleo-em9304
17
18
19######################################
20# building variables
21######################################
22# debug build?
23DEBUG = 1
24# optimization
25OPT = -Os
26
27
28#######################################
29# paths
30#######################################
31# Build path
32BUILD_DIR = build
33
34BTSTACK_ROOT ?= ../..
35VPATH += ${BTSTACK_ROOT}/example
36
37######################################
38# source
39######################################
40# C sources
41C_SOURCES =  \
42${BTSTACK_ROOT}/3rd-party/micro-ecc/uECC.c \
43${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT.c \
44${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT_Syscalls_GCC.c \
45${BTSTACK_ROOT}/chipset/em9301/btstack_chipset_em9301.c \
46${BTSTACK_ROOT}/chipset/em9301/0000000_META_hci_patches_v7.c \
47${BTSTACK_ROOT}/platform/embedded/btstack_run_loop_embedded.c \
48${BTSTACK_ROOT}/platform/embedded/btstack_stdin_embedded.c \
49${BTSTACK_ROOT}/platform/embedded/btstack_tlv_flash_bank.c \
50${BTSTACK_ROOT}/platform/embedded/btstack_uart_block_embedded.c \
51${BTSTACK_ROOT}/src/ad_parser.c \
52${BTSTACK_ROOT}/src/ble/ancs_client.c \
53${BTSTACK_ROOT}/src/ble/att_db.c \
54${BTSTACK_ROOT}/src/ble/att_dispatch.c \
55${BTSTACK_ROOT}/src/ble/att_server.c \
56${BTSTACK_ROOT}/src/ble/gatt-service/battery_service_server.c \
57${BTSTACK_ROOT}/src/ble/gatt-service/device_information_service_server.c \
58${BTSTACK_ROOT}/src/ble/gatt-service/hids_device.c \
59${BTSTACK_ROOT}/src/ble/gatt_client.c \
60${BTSTACK_ROOT}/src/ble/le_device_db_memory.c \
61${BTSTACK_ROOT}/src/ble/le_device_db_tlv.c \
62${BTSTACK_ROOT}/src/ble/sm.c \
63${BTSTACK_ROOT}/src/btstack_audio.c \
64${BTSTACK_ROOT}/src/btstack_crypto.c \
65${BTSTACK_ROOT}/src/btstack_hid_parser.c \
66${BTSTACK_ROOT}/src/btstack_linked_list.c \
67${BTSTACK_ROOT}/src/btstack_memory.c \
68${BTSTACK_ROOT}/src/btstack_memory_pool.c \
69${BTSTACK_ROOT}/src/btstack_resample.c \
70${BTSTACK_ROOT}/src/btstack_ring_buffer.c \
71${BTSTACK_ROOT}/src/btstack_run_loop.c \
72${BTSTACK_ROOT}/src/btstack_tlv.c \
73${BTSTACK_ROOT}/src/btstack_util.c \
74${BTSTACK_ROOT}/src/hci.c \
75${BTSTACK_ROOT}/src/hci_cmd.c \
76${BTSTACK_ROOT}/src/hci_dump.c \
77${BTSTACK_ROOT}/src/l2cap.c \
78${BTSTACK_ROOT}/src/l2cap_signaling.c \
79${BTSTACK_ROOT}/src/hci_transport_h4.c \
80port/port.c \
81Src/main.c \
82Src/stm32l0xx_it.c \
83Src/stm32l0xx_hal_msp.c \
84Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_spi.c \
85Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_tim.c \
86Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_tim_ex.c \
87Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_uart.c \
88Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_uart_ex.c \
89Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal.c \
90Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_i2c.c \
91Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_i2c_ex.c \
92Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_rcc.c \
93Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_rcc_ex.c \
94Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_flash_ramfunc.c \
95Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_flash.c \
96Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_flash_ex.c \
97Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_gpio.c \
98Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_dma.c \
99Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_pwr.c \
100Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_pwr_ex.c \
101Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_cortex.c \
102Src/system_stm32l0xx.c
103
104# port/hal_flash_bank_stm32.c \
105
106# ASM sources
107ASM_SOURCES =  \
108startup_stm32l073xx.s
109
110
111#######################################
112# binaries
113#######################################
114PREFIX = arm-none-eabi-
115# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
116# either it can be added to the PATH environment variable.
117ifdef GCC_PATH
118CC = $(GCC_PATH)/$(PREFIX)gcc
119AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
120CP = $(GCC_PATH)/$(PREFIX)objcopy
121SZ = $(GCC_PATH)/$(PREFIX)size
122else
123CC = $(PREFIX)gcc
124AS = $(PREFIX)gcc -x assembler-with-cpp
125CP = $(PREFIX)objcopy
126SZ = $(PREFIX)size
127endif
128HEX = $(CP) -O ihex
129BIN = $(CP) -O binary -S
130
131#######################################
132# CFLAGS
133#######################################
134# cpu
135CPU = -mcpu=cortex-m0plus
136
137# fpu
138# NONE for Cortex-M0/M0+/M3
139
140# float-abi
141
142
143# mcu
144MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
145
146# macros for gcc
147# AS defines
148AS_DEFS =
149
150# C defines
151C_DEFS =  \
152-DUSE_HAL_DRIVER \
153-DSTM32L073xx
154
155
156# AS includes
157AS_INCLUDES =
158
159# C includes
160C_INCLUDES =  \
161-IInc \
162-IDrivers/STM32L0xx_HAL_Driver/Inc \
163-IDrivers/STM32L0xx_HAL_Driver/Inc/Legacy \
164-IDrivers/CMSIS/Device/ST/STM32L0xx/Include \
165-IDrivers/CMSIS/Include
166
167C_INCLUDES += -I$(BUILD_DIR)
168C_INCLUDES += -I${BTSTACK_ROOT}/src/ble
169C_INCLUDES += -I${BTSTACK_ROOT}/src/ble/gatt-service
170C_INCLUDES += -I${BTSTACK_ROOT}/src
171C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/micro-ecc
172C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/segger-rtt
173C_INCLUDES += -I${BTSTACK_ROOT}/platform/embedded
174C_INCLUDES += -I bsp
175C_INCLUDES += -I pdm
176C_INCLUDES += -I port
177C_INCLUDES += -I src
178
179# compile gcc flags
180ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
181
182CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
183
184ifeq ($(DEBUG), 1)
185CFLAGS += -g -gdwarf-2
186endif
187
188
189# Generate dependency information
190CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
191
192
193#######################################
194# LDFLAGS
195#######################################
196# link script
197LDSCRIPT = STM32L073RZTx_FLASH.ld
198
199# libraries
200LIBS = -lc -lm -lnosys
201LIBDIR =
202LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
203
204# default action: build all
205EXAMPLES = 					\
206	ancs_client_demo		\
207	gap_le_advertisements   \
208	gatt_battery_query		\
209	gatt_browser            \
210	hog_keyboard_demo       \
211	hog_mouse_demo          \
212	gatt_counter            \
213	gatt_streamer_server    \
214	le_streamer_client      \
215	sm_pairing_central      \
216	sm_pairing_peripheral   \
217
218GATT_FILES = \
219	ancs_client_demo.gatt \
220	gatt_battery_query.gatt \
221	gatt_browser.gatt \
222	gatt_counter.gatt \
223	gatt_streamer_server.gatt \
224	hog_keyboard_demo.gatt \
225	hog_mouse_demo.gatt \
226	sm_pairing_central.gatt \
227	sm_pairing_peripheral.gatt \
228
229#######################################
230# build the application
231#######################################
232# list of objects
233OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
234vpath %.c $(sort $(dir $(C_SOURCES)))
235# list of ASM program objects
236OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
237vpath %.s $(sort $(dir $(ASM_SOURCES)))
238
239# default action: build all
240all: \
241	$(OBJECTS) \
242	$(addprefix $(BUILD_DIR)/,$(GATT_FILES:.gatt=.h)) \
243	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.elf)) \
244	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.hex)) \
245	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.bin)) \
246	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.jdebug)) \
247
248$(BUILD_DIR)/%.h: %.gatt
249	python ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
250
251$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
252	$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
253
254$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
255	$(AS) -c $(CFLAGS) $< -o $@
256
257$(BUILD_DIR)/%.elf: Makefile $(OBJECTS) $(BUILD_DIR)/%.o
258	$(CC) $(filter-out Makefile,$^)  $(LDFLAGS) -o $@
259	$(SZ) $@
260
261$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
262	$(HEX) $< $@
263
264$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
265	$(BIN) $< $@
266
267$(BUILD_DIR)/%.jdebug: ozone.jdebug | $(BUILD_DIR)
268	sed -e "s|EXAMPLE|$(basename $(notdir $@))|" $<  > $@
269
270$(BUILD_DIR):
271	mkdir $@
272
273#######################################
274# clean up
275#######################################
276clean:
277	-rm -fR $(BUILD_DIR)
278
279#######################################
280# dependencies
281#######################################
282-include $(wildcard $(BUILD_DIR)/*.d)
283
284# *** EOF ***
285