xref: /btstack/port/stm32-l073rz-nucleo-em9304/Makefile (revision cd5f23a3250874824c01a2b3326a9522fea3f99f)
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_run_loop_base.c \
73${BTSTACK_ROOT}/src/btstack_tlv.c \
74${BTSTACK_ROOT}/src/btstack_util.c \
75${BTSTACK_ROOT}/src/hci.c \
76${BTSTACK_ROOT}/src/hci_cmd.c \
77${BTSTACK_ROOT}/src/hci_dump.c \
78${BTSTACK_ROOT}/src/l2cap.c \
79${BTSTACK_ROOT}/src/l2cap_signaling.c \
80${BTSTACK_ROOT}/src/hci_transport_h4.c \
81port/port.c \
82Src/main.c \
83Src/stm32l0xx_it.c \
84Src/stm32l0xx_hal_msp.c \
85Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_spi.c \
86Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_tim.c \
87Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_tim_ex.c \
88Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_uart.c \
89Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_uart_ex.c \
90Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal.c \
91Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_i2c.c \
92Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_i2c_ex.c \
93Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_rcc.c \
94Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_rcc_ex.c \
95Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_flash_ramfunc.c \
96Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_flash.c \
97Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_flash_ex.c \
98Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_gpio.c \
99Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_dma.c \
100Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_pwr.c \
101Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_pwr_ex.c \
102Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_cortex.c \
103Src/system_stm32l0xx.c
104
105# port/hal_flash_bank_stm32.c \
106
107# ASM sources
108ASM_SOURCES =  \
109startup_stm32l073xx.s
110
111
112#######################################
113# binaries
114#######################################
115PREFIX = arm-none-eabi-
116# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
117# either it can be added to the PATH environment variable.
118ifdef GCC_PATH
119CC = $(GCC_PATH)/$(PREFIX)gcc
120AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
121CP = $(GCC_PATH)/$(PREFIX)objcopy
122SZ = $(GCC_PATH)/$(PREFIX)size
123else
124CC = $(PREFIX)gcc
125AS = $(PREFIX)gcc -x assembler-with-cpp
126CP = $(PREFIX)objcopy
127SZ = $(PREFIX)size
128endif
129HEX = $(CP) -O ihex
130BIN = $(CP) -O binary -S
131
132#######################################
133# CFLAGS
134#######################################
135# cpu
136CPU = -mcpu=cortex-m0plus
137
138# fpu
139# NONE for Cortex-M0/M0+/M3
140
141# float-abi
142
143
144# mcu
145MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
146
147# macros for gcc
148# AS defines
149AS_DEFS =
150
151# C defines
152C_DEFS =  \
153-DUSE_HAL_DRIVER \
154-DSTM32L073xx
155
156
157# AS includes
158AS_INCLUDES =
159
160# C includes
161C_INCLUDES =  \
162-IInc \
163-IDrivers/STM32L0xx_HAL_Driver/Inc \
164-IDrivers/STM32L0xx_HAL_Driver/Inc/Legacy \
165-IDrivers/CMSIS/Device/ST/STM32L0xx/Include \
166-IDrivers/CMSIS/Include
167
168C_INCLUDES += -I$(BUILD_DIR)
169C_INCLUDES += -I${BTSTACK_ROOT}/src/ble
170C_INCLUDES += -I${BTSTACK_ROOT}/src/ble/gatt-service
171C_INCLUDES += -I${BTSTACK_ROOT}/src
172C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/micro-ecc
173C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/segger-rtt
174C_INCLUDES += -I${BTSTACK_ROOT}/platform/embedded
175C_INCLUDES += -I bsp
176C_INCLUDES += -I pdm
177C_INCLUDES += -I port
178C_INCLUDES += -I src
179
180# compile gcc flags
181ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
182
183CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
184
185ifeq ($(DEBUG), 1)
186CFLAGS += -g -gdwarf-2
187endif
188
189
190# Generate dependency information
191CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
192
193
194#######################################
195# LDFLAGS
196#######################################
197# link script
198LDSCRIPT = STM32L073RZTx_FLASH.ld
199
200# libraries
201LIBS = -lc -lm -lnosys
202LIBDIR =
203LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
204
205# default action: build all
206EXAMPLES = 					\
207	ancs_client_demo		\
208	gap_le_advertisements   \
209	gatt_battery_query		\
210	gatt_browser            \
211	hog_keyboard_demo       \
212	hog_mouse_demo          \
213	gatt_counter            \
214	gatt_streamer_server    \
215	le_streamer_client      \
216	sm_pairing_central      \
217	sm_pairing_peripheral   \
218
219GATT_FILES = \
220	ancs_client_demo.gatt \
221	gatt_battery_query.gatt \
222	gatt_browser.gatt \
223	gatt_counter.gatt \
224	gatt_streamer_server.gatt \
225	hog_keyboard_demo.gatt \
226	hog_mouse_demo.gatt \
227	sm_pairing_central.gatt \
228	sm_pairing_peripheral.gatt \
229
230#######################################
231# build the application
232#######################################
233# list of objects
234OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
235vpath %.c $(sort $(dir $(C_SOURCES)))
236# list of ASM program objects
237OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
238vpath %.s $(sort $(dir $(ASM_SOURCES)))
239
240# default action: build all
241all: \
242	$(OBJECTS) \
243	$(addprefix $(BUILD_DIR)/,$(GATT_FILES:.gatt=.h)) \
244	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.elf)) \
245	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.hex)) \
246	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.bin)) \
247	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.jdebug)) \
248
249$(BUILD_DIR)/%.h: %.gatt
250	python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
251
252$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
253	$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
254
255$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
256	$(AS) -c $(CFLAGS) $< -o $@
257
258$(BUILD_DIR)/%.elf: Makefile $(OBJECTS) $(BUILD_DIR)/%.o
259	$(CC) $(filter-out Makefile,$^)  $(LDFLAGS) -o $@
260	$(SZ) $@
261
262$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
263	$(HEX) $< $@
264
265$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
266	$(BIN) $< $@
267
268$(BUILD_DIR)/%.jdebug: ozone.jdebug | $(BUILD_DIR)
269	sed -e "s|EXAMPLE|$(basename $(notdir $@))|" $<  > $@
270
271$(BUILD_DIR):
272	mkdir $@
273
274#######################################
275# clean up
276#######################################
277clean:
278	-rm -fR $(BUILD_DIR)
279
280#######################################
281# dependencies
282#######################################
283-include $(wildcard $(BUILD_DIR)/*.d)
284
285# *** EOF ***
286