Makefile 7.8 KB

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