Makefile 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. # Build path
  26. BUILD_DIR = build
  27. ######################################
  28. # source
  29. ######################################
  30. C_SOURCES =
  31. CPP_SOURCES =
  32. ASM_SOURCES =
  33. C_DEFS =
  34. # Target
  35. C_SOURCES += \
  36. Src/main.c \
  37. Src/freertos.c \
  38. Src/stm32l4xx_it.c \
  39. Src/stm32l4xx_hal_msp.c \
  40. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c \
  41. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c \
  42. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \
  43. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \
  44. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \
  45. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \
  46. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \
  47. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \
  48. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \
  49. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \
  50. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \
  51. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \
  52. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \
  53. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \
  54. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \
  55. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \
  56. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \
  57. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_comp.c \
  58. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac.c \
  59. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac_ex.c \
  60. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi.c \
  61. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c \
  62. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \
  63. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \
  64. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pcd.c \
  65. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pcd_ex.c \
  66. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_usb.c \
  67. Src/system_stm32l4xx.c \
  68. Middlewares/Third_Party/FreeRTOS/Source/croutine.c \
  69. Middlewares/Third_Party/FreeRTOS/Source/event_groups.c \
  70. Middlewares/Third_Party/FreeRTOS/Source/list.c \
  71. Middlewares/Third_Party/FreeRTOS/Source/queue.c \
  72. Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c \
  73. Middlewares/Third_Party/FreeRTOS/Source/tasks.c \
  74. Middlewares/Third_Party/FreeRTOS/Source/timers.c \
  75. Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c \
  76. Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_1.c \
  77. Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c \
  78. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c \
  79. Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c \
  80. Src/usb_device.c \
  81. Src/usbd_conf.c \
  82. Src/usbd_desc.c \
  83. Src/usbd_cdc_if.c \
  84. Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c \
  85. Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c \
  86. Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c \
  87. Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c
  88. C_SOURCES += Src/flipper_hal.c
  89. C_DEFS += \
  90. -DUSE_HAL_DRIVER \
  91. -DSTM32L476xx \
  92. -DBUTON_INVERT=false \
  93. -DDEBUG_UART=huart1
  94. ASM_SOURCES += \
  95. startup_stm32l476xx.s
  96. # Core
  97. CPP_SOURCES += ../core/app.cpp
  98. C_SOURCES += ../core/debug.c
  99. C_SOURCES += ../core/furi.c
  100. C_SOURCES += ../core/furi_ac.c
  101. # System applications
  102. ifeq ($(TEST), 1)
  103. C_SOURCES += ../applications/tests/furiac_test.c
  104. C_SOURCES += ../applications/tests/furi_record_test.c
  105. C_SOURCES += ../applications/tests/test_index.c
  106. C_DEFS += -DTEST
  107. endif
  108. # Examples
  109. ifeq ($(EXAMPLE_BLINK), 1)
  110. C_SOURCES += ../applications/examples/blink.c
  111. C_DEFS += -DEXAMPLE_BLINK
  112. endif
  113. # User application
  114. # Add C_SOURCES +=, C_DEFS += or CPP_SOURCES += here
  115. #######################################
  116. # binaries
  117. #######################################
  118. PREFIX = arm-none-eabi-
  119. # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
  120. # either it can be added to the PATH environment variable.
  121. ifdef GCC_PATH
  122. CC = $(GCC_PATH)/$(PREFIX)gcc
  123. CPP = $(GCC_PATH)/$(PREFIX)g++
  124. AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
  125. CP = $(GCC_PATH)/$(PREFIX)objcopy
  126. SZ = $(GCC_PATH)/$(PREFIX)size
  127. else
  128. CC = $(PREFIX)gcc
  129. CPP = $(PREFIX)g++
  130. AS = $(PREFIX)gcc -x assembler-with-cpp
  131. CP = $(PREFIX)objcopy
  132. SZ = $(PREFIX)size
  133. endif
  134. HEX = $(CP) -O ihex
  135. BIN = $(CP) -O binary -S
  136. #######################################
  137. # CFLAGS
  138. #######################################
  139. # cpu
  140. CPU = -mcpu=cortex-m4
  141. # fpu
  142. FPU = -mfpu=fpv4-sp-d16
  143. # float-abi
  144. FLOAT-ABI = -mfloat-abi=hard
  145. # mcu
  146. MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
  147. # macros for gcc
  148. # AS defines
  149. AS_DEFS =
  150. # AS includes
  151. AS_INCLUDES = \
  152. -IInc
  153. # C includes
  154. C_INCLUDES = \
  155. -IInc \
  156. -I../applications \
  157. -I../core \
  158. -IDrivers/STM32L4xx_HAL_Driver/Inc \
  159. -IDrivers/STM32L4xx_HAL_Driver/Inc/Legacy \
  160. -IMiddlewares/Third_Party/FreeRTOS/Source/include \
  161. -IMiddlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS \
  162. -IMiddlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F \
  163. -IDrivers/CMSIS/Device/ST/STM32L4xx/Include \
  164. -IDrivers/CMSIS/Include \
  165. -IMiddlewares/ST/STM32_USB_Device_Library/Core/Inc \
  166. -IMiddlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc
  167. # compile gcc flags
  168. ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  169. CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  170. ifeq ($(DEBUG), 1)
  171. CFLAGS += -g -gdwarf-2
  172. endif
  173. # Generate dependency information
  174. CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
  175. CPPFLAGS = -fno-threadsafe-statics
  176. #######################################
  177. # LDFLAGS
  178. #######################################
  179. # link script
  180. LDSCRIPT = STM32L476RGTx_FLASH.ld
  181. # libraries
  182. LIBS = -lc -lm -lnosys
  183. LIBDIR =
  184. LDFLAGS = $(MCU) -specs=nano.specs -specs=nosys.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
  185. # default action: build all
  186. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
  187. example_blink:
  188. EXAMPLE_BLINK=1 make
  189. test:
  190. TEST=1 make
  191. #######################################
  192. # build the application
  193. #######################################
  194. # list of objects
  195. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  196. vpath %.c $(sort $(dir $(C_SOURCES)))
  197. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o)))
  198. vpath %.cpp $(sort $(dir $(CPP_SOURCES)))
  199. # list of ASM program objects
  200. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  201. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  202. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  203. $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  204. $(BUILD_DIR)/%.o: %.cpp Makefile | $(BUILD_DIR)
  205. $(CPP) -c $(CFLAGS) $(CPPFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  206. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  207. $(AS) -c $(CFLAGS) $< -o $@
  208. $(BUILD_DIR)/%.pb.c $(BUILD_DIR)/%.pb.h: ../flipper_proto/%.proto
  209. $(PROTOC) $(PROTOC_OPTS) --nanopb_out=$(BUILD_DIR) $<
  210. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
  211. $(CPP) $(OBJECTS) $(LDFLAGS) -o $@
  212. $(SZ) $@
  213. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  214. $(HEX) $< $@
  215. $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  216. $(BIN) $< $@
  217. $(BUILD_DIR):
  218. mkdir $@
  219. #######################################
  220. # clean up
  221. #######################################
  222. clean:
  223. -rm -fR $(BUILD_DIR)
  224. #######################################
  225. # dependencies
  226. #######################################
  227. -include $(wildcard $(BUILD_DIR)/*.d)
  228. # *** EOF ***