Makefile 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. ##########################################################################################################################
  2. # File automatically-generated by tool: [projectgenerator] version: [3.19.2] date: [Mon Apr 15 16:54:52 CST 2024]
  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 = V9_AG_PMU_APP_EFTZ_
  15. ######################################
  16. # building variables
  17. ######################################
  18. # debug build?
  19. DEBUG = 1
  20. # optimization
  21. OPT = -O0
  22. #######################################
  23. # paths
  24. #######################################
  25. # Build path
  26. BUILD_DIR = build
  27. BIN_FILE = binfile
  28. ######################################
  29. # source
  30. ######################################
  31. # C sources
  32. STD_LIB = \
  33. Core/Src/main.c \
  34. Core/Src/stm32f4xx_it.c \
  35. Core/Src/stm32f4xx_hal_msp.c \
  36. Core/Src/stm32f4xx_hal_timebase_tim.c \
  37. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c \
  38. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c \
  39. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.c \
  40. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \
  41. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c \
  42. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c \
  43. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c \
  44. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c \
  45. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c \
  46. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c \
  47. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \
  48. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \
  49. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c \
  50. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c \
  51. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c \
  52. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c \
  53. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_can.c \
  54. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \
  55. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \
  56. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c \
  57. Core/Src/system_stm32f4xx.c \
  58. Middlewares/Third_Party/RealThread_RTOS/src/clock.c \
  59. Middlewares/Third_Party/RealThread_RTOS/src/components.c \
  60. Middlewares/Third_Party/RealThread_RTOS/src/cpu.c \
  61. Middlewares/Third_Party/RealThread_RTOS/src/idle.c \
  62. Middlewares/Third_Party/RealThread_RTOS/src/ipc.c \
  63. Middlewares/Third_Party/RealThread_RTOS/src/irq.c \
  64. Middlewares/Third_Party/RealThread_RTOS/src/kservice.c \
  65. Middlewares/Third_Party/RealThread_RTOS/src/mem.c \
  66. Middlewares/Third_Party/RealThread_RTOS/src/memheap.c \
  67. Middlewares/Third_Party/RealThread_RTOS/src/mempool.c \
  68. Middlewares/Third_Party/RealThread_RTOS/src/object.c \
  69. Middlewares/Third_Party/RealThread_RTOS/src/scheduler.c \
  70. Middlewares/Third_Party/RealThread_RTOS/src/slab.c \
  71. Middlewares/Third_Party/RealThread_RTOS/src/thread.c \
  72. Middlewares/Third_Party/RealThread_RTOS/src/timer.c \
  73. Middlewares/Third_Party/RealThread_RTOS/libcpu/arm/cortex-m4/cpuport.c \
  74. Middlewares/Third_Party/RealThread_RTOS/bsp/_template/cubemx_config/board.c \
  75. Middlewares/Third_Party/RealThread_RTOS/components/finsh/cmd.c \
  76. Middlewares/Third_Party/RealThread_RTOS/components/finsh/finsh_port.c \
  77. Middlewares/Third_Party/RealThread_RTOS/components/finsh/msh.c \
  78. Middlewares/Third_Party/RealThread_RTOS/components/finsh/shell.c \
  79. Middlewares/Third_Party/RealThread_RTOS/components/device/device.c
  80. USER_SOURCES += $(wildcard user_src/*.c)
  81. C_SOURCES = $(STD_LIB)
  82. C_SOURCES += $(USER_SOURCES)
  83. # ASM sources
  84. ASM_SOURCES = \
  85. startup_stm32f405xx.s \
  86. Middlewares/Third_Party/RealThread_RTOS/libcpu/arm/cortex-m4/context_gcc.s
  87. #######################################
  88. # binaries
  89. #######################################
  90. PREFIX = arm-none-eabi-
  91. # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
  92. # either it can be added to the PATH environment variable.
  93. ifdef GCC_PATH
  94. CC = $(GCC_PATH)/$(PREFIX)gcc
  95. AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
  96. CP = $(GCC_PATH)/$(PREFIX)objcopy
  97. SZ = $(GCC_PATH)/$(PREFIX)size
  98. else
  99. CC = $(PREFIX)gcc
  100. AS = $(PREFIX)gcc -x assembler-with-cpp
  101. CP = $(PREFIX)objcopy
  102. SZ = $(PREFIX)size
  103. endif
  104. HEX = $(CP) -O ihex
  105. BIN = $(CP) -O binary -S
  106. #######################################
  107. # CFLAGS
  108. #######################################
  109. # cpu
  110. CPU = -mcpu=cortex-m4
  111. # fpu
  112. FPU = -mfpu=fpv4-sp-d16
  113. # float-abi
  114. #FLOAT-ABI = -mfloat-abi=hard
  115. FLOAT-ABI = -mfloat-abi=soft
  116. # mcu
  117. MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
  118. # macros for gcc
  119. # AS defines
  120. AS_DEFS =
  121. # C defines
  122. C_DEFS = \
  123. -DUSE_HAL_DRIVER \
  124. -DSTM32F405xx
  125. # AS includes
  126. AS_INCLUDES =
  127. # C includes
  128. C_INCLUDES = \
  129. -IRT-Thread \
  130. -ICore/Inc \
  131. -IDrivers/STM32F4xx_HAL_Driver/Inc \
  132. -IDrivers/STM32F4xx_HAL_Driver/Inc/Legacy \
  133. -IDrivers/CMSIS/Device/ST/STM32F4xx/Include \
  134. -IDrivers/CMSIS/Include \
  135. -IMiddlewares/Third_Party/RealThread_RTOS/include/ \
  136. -IMiddlewares/Third_Party/RealThread_RTOS/bsp/_template/cubemx_config \
  137. -IMiddlewares/Third_Party/RealThread_RTOS/finsh/ \
  138. -IMiddlewares/Third_Party/RealThread_RTOS/components/finsh \
  139. -Iuser_inc \
  140. # compile gcc flags
  141. ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  142. CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  143. ifeq ($(DEBUG), 1)
  144. CFLAGS += -g -gdwarf-2
  145. endif
  146. # Generate dependency information
  147. CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
  148. #######################################
  149. # LDFLAGS
  150. #######################################
  151. # link script
  152. LDSCRIPT = STM32F405RGTx_FLASH.ld
  153. # libraries
  154. LIBS = -lc -lm -lnosys
  155. LIBDIR =
  156. LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
  157. # default action: build all
  158. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
  159. #######################################
  160. # build the application
  161. #######################################
  162. # list of objects
  163. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  164. vpath %.c $(sort $(dir $(C_SOURCES)))
  165. # list of ASM program objects
  166. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  167. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  168. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  169. @$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  170. @echo $(notdir $(<:.c=.o))
  171. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  172. @$(AS) -c $(CFLAGS) $< -o $@
  173. @echo $(notdir $(<:.s=.o))
  174. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
  175. @$(CC) $(OBJECTS) $(LDFLAGS) -o $@
  176. @echo linking...
  177. $(SZ) $@
  178. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  179. $(HEX) $< $@
  180. $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  181. $(BIN) $< $@
  182. $(BUILD_DIR):
  183. mkdir $@
  184. #######################################
  185. # clean up
  186. #######################################
  187. clean:
  188. -rm -fR $(BUILD_DIR)
  189. #######################################
  190. # dependencies
  191. #######################################
  192. -include $(wildcard $(BUILD_DIR)/*.d)
  193. # *** EOF ***