Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. ##########################################################################################################################
  2. # File automatically-generated by tool: [projectgenerator] version: [3.5.2] date: [Tue May 26 23:27:59 OMST 2020]
  3. ##########################################################################################################################
  4. # ------------------------------------------------
  5. # Generic Makefile (based on gcc)
  6. #
  7. # ChangeLog :
  8. # 2017-02-10 - Several enhancements + project update mode
  9. # 2015-07-22 - first version
  10. # ------------------------------------------------
  11. ######################################
  12. # target
  13. ######################################
  14. TARGET = target_prod
  15. ######################################
  16. # building variables
  17. ######################################
  18. # debug build?
  19. DEBUG = 1
  20. # optimization
  21. OPT = -Og
  22. #######################################
  23. # paths
  24. #######################################
  25. PROJECT_DIR = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
  26. # Build path
  27. BUILD_DIR = build
  28. ######################################
  29. # source
  30. ######################################
  31. C_SOURCES =
  32. CPP_SOURCES =
  33. ASM_SOURCES =
  34. C_DEFS =
  35. # Target
  36. C_SOURCES += \
  37. Src/main.c \
  38. Src/boot.c \
  39. Src/freertos.c \
  40. Src/stm32l4xx_it.c \
  41. Src/stm32l4xx_hal_msp.c \
  42. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c \
  43. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c \
  44. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \
  45. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \
  46. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \
  47. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \
  48. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \
  49. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \
  50. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \
  51. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \
  52. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \
  53. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \
  54. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \
  55. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \
  56. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \
  57. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \
  58. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \
  59. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_comp.c \
  60. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac.c \
  61. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac_ex.c \
  62. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi.c \
  63. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c \
  64. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \
  65. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \
  66. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pcd.c \
  67. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pcd_ex.c \
  68. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_usb.c \
  69. Src/system_stm32l4xx.c \
  70. Middlewares/Third_Party/FreeRTOS/Source/croutine.c \
  71. Middlewares/Third_Party/FreeRTOS/Source/event_groups.c \
  72. Middlewares/Third_Party/FreeRTOS/Source/list.c \
  73. Middlewares/Third_Party/FreeRTOS/Source/queue.c \
  74. Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c \
  75. Middlewares/Third_Party/FreeRTOS/Source/tasks.c \
  76. Middlewares/Third_Party/FreeRTOS/Source/timers.c \
  77. Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c \
  78. Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_1.c \
  79. Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c \
  80. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c \
  81. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c \
  82. Src/usb_device.c \
  83. Src/usbd_conf.c \
  84. Src/usbd_desc.c \
  85. Src/usbd_cdc_if.c \
  86. Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c \
  87. Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c \
  88. Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c \
  89. Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c
  90. C_SOURCES += Src/flipper_hal.c
  91. C_DEFS += \
  92. -DUSE_HAL_DRIVER \
  93. -DSTM32L476xx \
  94. -DBUTON_INVERT=false \
  95. -DDEBUG_UART=huart1 \
  96. -DUSE_INPUT
  97. ASM_SOURCES += \
  98. startup_stm32l476xx.s
  99. # Core
  100. CPP_SOURCES += ../core/app.cpp
  101. C_SOURCES += ../core/log.c
  102. C_SOURCES += ../core/tty_uart.c
  103. C_SOURCES += ../core/furi.c
  104. C_SOURCES += ../core/furi_ac.c
  105. C_SOURCES += ../lib/u8g2/u8x8_d_st7565.c \
  106. ../lib/u8g2/u8g2_d_setup.c \
  107. ../lib/u8g2/u8g2_intersection.c \
  108. ../lib/u8g2/u8g2_setup.c \
  109. ../lib/u8g2/u8g2_d_memory.c \
  110. ../lib/u8g2/u8x8_cad.c \
  111. ../lib/u8g2/u8x8_byte.c \
  112. ../lib/u8g2/u8x8_gpio.c \
  113. ../lib/u8g2/u8x8_display.c \
  114. ../lib/u8g2/u8x8_setup.c \
  115. ../lib/u8g2/u8g2_hvline.c \
  116. ../lib/u8g2/u8g2_ll_hvline.c \
  117. ../lib/u8g2/u8g2_circle.c \
  118. ../lib/u8g2/u8g2_box.c \
  119. ../lib/u8g2/u8g2_buffer.c \
  120. ../lib/u8g2/u8g2_font.c \
  121. ../lib/u8g2/u8g2_fonts.c \
  122. ../lib/u8g2/u8x8_8x8.c \
  123. ../lib/u8g2/u8g2_bitmap.c
  124. # System applications
  125. C_SOURCES += ../applications/display-u8g2/display-u8g2.c \
  126. ../applications/input/input.c \
  127. # Examples
  128. # TODO example without condition
  129. C_SOURCES += ../applications/examples/u8g2_example.c
  130. ifeq ($(TEST), 1)
  131. C_SOURCES += ../applications/tests/furiac_test.c
  132. C_SOURCES += ../applications/tests/furi_record_test.c
  133. C_SOURCES += ../applications/tests/test_index.c
  134. C_DEFS += -DTEST
  135. endif
  136. # Examples
  137. ifeq ($(EXAMPLE_BLINK), 1)
  138. C_SOURCES += ../applications/examples/blink.c
  139. C_DEFS += -DEXAMPLE_BLINK
  140. endif
  141. ifeq ($(EXAMPLE_UART_WRITE), 1)
  142. C_SOURCES += ../applications/examples/uart_write.c
  143. C_DEFS += -DEXAMPLE_UART_WRITE
  144. endif
  145. ifeq ($(EXAMPLE_IPC), 1)
  146. C_SOURCES += ../applications/examples/ipc.c
  147. C_DEFS += -DEXAMPLE_IPC
  148. endif
  149. ifeq ($(EXAMPLE_INPUT_DUMP), 1)
  150. C_SOURCES += ../applications/examples/input_dump.c
  151. C_DEFS += -DEXAMPLE_INPUT_DUMP
  152. endif
  153. ifeq ($(EXAMPLE_QRCODE), 1)
  154. C_SOURCES += ../applications/examples/u8g2_qrcode.c
  155. C_SOURCES += ../lib/qrcode/qrcode.c
  156. C_DEFS += -DEXAMPLE_QRCODE
  157. endif
  158. # User application
  159. C_SOURCES += ../applications/coreglitch_demo_0/coreglitch_demo_0.c
  160. # Add C_SOURCES +=, C_DEFS += or CPP_SOURCES += here
  161. #######################################
  162. # binaries
  163. #######################################
  164. PREFIX = arm-none-eabi-
  165. # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
  166. # either it can be added to the PATH environment variable.
  167. ifdef GCC_PATH
  168. CC = $(GCC_PATH)/$(PREFIX)gcc
  169. CPP = $(GCC_PATH)/$(PREFIX)g++
  170. AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
  171. CP = $(GCC_PATH)/$(PREFIX)objcopy
  172. SZ = $(GCC_PATH)/$(PREFIX)size
  173. else
  174. CC = $(PREFIX)gcc
  175. CPP = $(PREFIX)g++
  176. AS = $(PREFIX)gcc -x assembler-with-cpp
  177. CP = $(PREFIX)objcopy
  178. SZ = $(PREFIX)size
  179. endif
  180. HEX = $(CP) -O ihex
  181. BIN = $(CP) -O binary -S
  182. #######################################
  183. # Rust library
  184. #######################################
  185. RUST_LIB_SRC = $(realpath $(PROJECT_DIR)/../core-rs)
  186. RUST_LIB_NAME = flipper_core
  187. RUST_LIB_TARGET = thumbv7em-none-eabihf
  188. RUST_LIB_FLAGS = --target=$(RUST_LIB_TARGET)
  189. ifeq ($(DEBUG), 1)
  190. RUST_LIB_PATH = $(RUST_LIB_SRC)/target/$(RUST_LIB_TARGET)/debug
  191. else
  192. RUST_LIB_FLAGS += --release
  193. RUST_LIB_PATH = $(RUST_LIB_SRC)/target/$(RUST_LIB_TARGET)/release
  194. endif
  195. RUST_LIB_CMD = cd $(RUST_LIB_SRC) && cargo build -p flipper-core $(RUST_LIB_FLAGS)
  196. #######################################
  197. # CFLAGS
  198. #######################################
  199. # cpu
  200. CPU = -mcpu=cortex-m4
  201. # fpu
  202. FPU = -mfpu=fpv4-sp-d16
  203. # float-abi
  204. FLOAT-ABI = -mfloat-abi=hard
  205. # mcu
  206. MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
  207. # macros for gcc
  208. # AS defines
  209. AS_DEFS =
  210. # AS includes
  211. AS_INCLUDES = \
  212. -IInc
  213. # C includes
  214. C_INCLUDES = \
  215. -IInc \
  216. -I../applications \
  217. -I../lib \
  218. -I../core \
  219. -IDrivers/STM32L4xx_HAL_Driver/Inc \
  220. -IDrivers/STM32L4xx_HAL_Driver/Inc/Legacy \
  221. -IMiddlewares/Third_Party/FreeRTOS/Source/include \
  222. -IMiddlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS \
  223. -IMiddlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F \
  224. -IDrivers/CMSIS/Device/ST/STM32L4xx/Include \
  225. -IDrivers/CMSIS/Include \
  226. -IMiddlewares/ST/STM32_USB_Device_Library/Core/Inc \
  227. -IMiddlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc \
  228. -I../core-rs/flipper-core/bindings
  229. # compile gcc flags
  230. ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  231. CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  232. ifeq ($(DEBUG), 1)
  233. CFLAGS += -g -gdwarf-2
  234. endif
  235. # Generate dependency information
  236. CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
  237. CPPFLAGS = -fno-threadsafe-statics
  238. #######################################
  239. # LDFLAGS
  240. #######################################
  241. # link script
  242. LDSCRIPT = STM32L476RGTx_FLASH.ld
  243. # libraries
  244. LIBS = -lc -lm -lnosys -l$(RUST_LIB_NAME)
  245. LIBDIR = -L$(RUST_LIB_PATH)
  246. LDFLAGS = $(MCU) -specs=nano.specs -specs=nosys.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
  247. # default action: build all
  248. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
  249. rust_lib:
  250. $(RUST_LIB_CMD)
  251. example_blink:
  252. EXAMPLE_BLINK=1 make
  253. rm $(BUILD_DIR)/app.o
  254. example_uart_write:
  255. EXAMPLE_UART_WRITE=1 make
  256. rm $(BUILD_DIR)/app.o
  257. example_ipc:
  258. EXAMPLE_IPC=1 make
  259. rm $(BUILD_DIR)/app.o
  260. example_input_dump:
  261. EXAMPLE_INPUT_DUMP=1 make
  262. rm $(BUILD_DIR)/app.o
  263. example_qrcode:
  264. EXAMPLE_QRCODE=1 make
  265. rm $(BUILD_DIR)/app.o
  266. test:
  267. TEST=1 make
  268. rm $(BUILD_DIR)/app.o
  269. .PHONY: all rust_lib example_blink example_uart_write test
  270. #######################################
  271. # build the application
  272. #######################################
  273. # list of objects
  274. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  275. vpath %.c $(sort $(dir $(C_SOURCES)))
  276. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o)))
  277. vpath %.cpp $(sort $(dir $(CPP_SOURCES)))
  278. # list of ASM program objects
  279. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  280. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  281. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  282. $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  283. $(BUILD_DIR)/%.o: %.cpp Makefile | $(BUILD_DIR)
  284. $(CPP) -c $(CFLAGS) $(CPPFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  285. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  286. $(AS) -c $(CFLAGS) $< -o $@
  287. $(BUILD_DIR)/%.pb.c $(BUILD_DIR)/%.pb.h: ../flipper_proto/%.proto
  288. $(PROTOC) $(PROTOC_OPTS) --nanopb_out=$(BUILD_DIR) $<
  289. $(RUST_LIB_PATH)/lib$(RUST_LIB_NAME).a: rust_lib
  290. $(BUILD_DIR)/$(TARGET).elf: $(RUST_LIB_PATH)/lib$(RUST_LIB_NAME).a $(OBJECTS) Makefile
  291. $(CPP) $(OBJECTS) $(LDFLAGS) -o $@
  292. $(SZ) $@
  293. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  294. $(HEX) $< $@
  295. $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  296. $(BIN) $< $@
  297. $(BUILD_DIR):
  298. mkdir $@
  299. #######################################
  300. # clean up
  301. #######################################
  302. clean:
  303. -rm -fR $(BUILD_DIR)
  304. cd $(RUST_LIB_SRC) && cargo clean
  305. #######################################
  306. # dependencies
  307. #######################################
  308. -include $(wildcard $(BUILD_DIR)/*.d)
  309. # *** EOF ***