Makefile 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. ##########################################################################################################################
  2. # File automatically-generated by tool: [projectgenerator] version: [4.6.0.1-B1] date: [Wed Nov 05 17:24:10 CST 2025]
  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_PMU302_APP_
  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. ######################################
  28. # source
  29. ######################################
  30. # C sources
  31. STD_LIB = \
  32. Core/Src/main.c \
  33. Core/Src/gpio.c \
  34. Core/Src/adc.c \
  35. Core/Src/can.c \
  36. Core/Src/dma.c \
  37. Core/Src/tim.c \
  38. Core/Src/usart.c \
  39. Core/Src/stm32f3xx_it.c \
  40. Core/Src/stm32f3xx_hal_msp.c \
  41. Core/Src/stm32f3xx_hal_timebase_tim.c \
  42. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_tim.c \
  43. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_tim_ex.c \
  44. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_adc.c \
  45. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_adc_ex.c \
  46. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal.c \
  47. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_rcc.c \
  48. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_rcc_ex.c \
  49. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_gpio.c \
  50. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_dma.c \
  51. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_cortex.c \
  52. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_pwr.c \
  53. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_pwr_ex.c \
  54. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_flash.c \
  55. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_flash_ex.c \
  56. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_i2c.c \
  57. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_i2c_ex.c \
  58. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_exti.c \
  59. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_can.c \
  60. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_uart.c \
  61. Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_uart_ex.c \
  62. Core/Src/system_stm32f3xx.c
  63. # USER SOURCES
  64. USER_SOURCES += $(wildcard user_src/*.c)
  65. C_SOURCES = $(STD_LIB)
  66. C_SOURCES += $(USER_SOURCES)
  67. # ASM sources
  68. ASM_SOURCES = \
  69. startup_stm32f302xc.s
  70. # ASM sources
  71. ASMM_SOURCES =
  72. #######################################
  73. # binaries
  74. #######################################
  75. PREFIX = arm-none-eabi-
  76. # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
  77. # either it can be added to the PATH environment variable.
  78. ifdef GCC_PATH
  79. CC = $(GCC_PATH)/$(PREFIX)gcc
  80. AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
  81. CP = $(GCC_PATH)/$(PREFIX)objcopy
  82. SZ = $(GCC_PATH)/$(PREFIX)size
  83. else
  84. CC = $(PREFIX)gcc
  85. AS = $(PREFIX)gcc -x assembler-with-cpp
  86. CP = $(PREFIX)objcopy
  87. SZ = $(PREFIX)size
  88. endif
  89. HEX = $(CP) -O ihex
  90. BIN = $(CP) -O binary -S
  91. #######################################
  92. # CFLAGS
  93. #######################################
  94. # cpu
  95. CPU = -mcpu=cortex-m4
  96. # fpu
  97. FPU = -mfpu=fpv4-sp-d16
  98. # float-abi
  99. FLOAT-ABI = -mfloat-abi=hard
  100. # mcu
  101. MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
  102. # macros for gcc
  103. # AS defines
  104. AS_DEFS =
  105. # C defines
  106. C_DEFS = \
  107. -DUSE_HAL_DRIVER \
  108. -DSTM32F302xC
  109. # AS includes
  110. AS_INCLUDES = \
  111. -Iuser_inc
  112. # C includes
  113. C_INCLUDES = \
  114. -ICore/Inc \
  115. -IDrivers/STM32F3xx_HAL_Driver/Inc \
  116. -IDrivers/STM32F3xx_HAL_Driver/Inc/Legacy \
  117. -IDrivers/CMSIS/Device/ST/STM32F3xx/Include \
  118. -IDrivers/CMSIS/Include \
  119. -Iuser_inc
  120. # compile gcc flags
  121. ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  122. CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  123. ifeq ($(DEBUG), 1)
  124. CFLAGS += -g -gdwarf-2
  125. endif
  126. # Generate dependency information
  127. CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
  128. #######################################
  129. # LDFLAGS
  130. #######################################
  131. # link script
  132. LDSCRIPT = STM32F302XX_FLASH.ld
  133. # libraries
  134. LIBS = -lc -lm -lnosys
  135. LIBDIR =
  136. LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
  137. # default action: build all
  138. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
  139. #######################################
  140. # build the application
  141. #######################################
  142. # list of objects
  143. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  144. vpath %.c $(sort $(dir $(C_SOURCES)))
  145. # list of ASM program objects
  146. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  147. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  148. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASMM_SOURCES:.S=.o)))
  149. vpath %.S $(sort $(dir $(ASMM_SOURCES)))
  150. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  151. $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  152. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  153. $(AS) -c $(CFLAGS) $< -o $@
  154. $(BUILD_DIR)/%.o: %.S Makefile | $(BUILD_DIR)
  155. $(AS) -c $(CFLAGS) $< -o $@
  156. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
  157. $(CC) $(OBJECTS) $(LDFLAGS) -o $@
  158. $(SZ) $@
  159. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  160. $(HEX) $< $@
  161. $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  162. $(BIN) $< $@
  163. $(BUILD_DIR):
  164. mkdir $@
  165. #######################################
  166. # clean up
  167. #######################################
  168. clean:
  169. -rm -fR $(BUILD_DIR)
  170. #######################################
  171. # dependencies
  172. #######################################
  173. -include $(wildcard $(BUILD_DIR)/*.d)
  174. # *** EOF ***