Makefile 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. ##########################################################################################################################
  2. # File automatically-generated by tool: [projectgenerator] version: [3.1.0] date: [Tue Jun 21 16:06:56 GMT+08:00 2022]
  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 = SDIO
  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/gpio.c \
  34. Src/usart.c \
  35. Src/stm32f4xx_it.c \
  36. Src/stm32f4xx_hal_msp.c \
  37. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \
  38. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \
  39. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.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. Src/system_stm32f4xx.c \
  54. Src/adc.c \
  55. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c \
  56. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c
  57. # ASM sources
  58. ASM_SOURCES = \
  59. startup_stm32f407xx.s
  60. #######################################
  61. # binaries
  62. #######################################
  63. PREFIX = arm-none-eabi-
  64. # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
  65. # either it can be added to the PATH environment variable.
  66. ifdef GCC_PATH
  67. CC = $(GCC_PATH)/$(PREFIX)gcc
  68. AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
  69. CP = $(GCC_PATH)/$(PREFIX)objcopy
  70. SZ = $(GCC_PATH)/$(PREFIX)size
  71. else
  72. CC = $(PREFIX)gcc
  73. AS = $(PREFIX)gcc -x assembler-with-cpp
  74. CP = $(PREFIX)objcopy
  75. SZ = $(PREFIX)size
  76. endif
  77. HEX = $(CP) -O ihex
  78. BIN = $(CP) -O binary -S
  79. #######################################
  80. # CFLAGS
  81. #######################################
  82. # cpu
  83. CPU = -mcpu=cortex-m4
  84. # fpu
  85. FPU = -mfpu=fpv4-sp-d16
  86. # float-abi
  87. FLOAT-ABI = -mfloat-abi=hard
  88. # mcu
  89. MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
  90. # macros for gcc
  91. # AS defines
  92. AS_DEFS =
  93. # C defines
  94. C_DEFS = \
  95. -DUSE_HAL_DRIVER \
  96. -DSTM32F407xx
  97. # AS includes
  98. AS_INCLUDES =
  99. # C includes
  100. C_INCLUDES = \
  101. -IInc \
  102. -IDrivers/STM32F4xx_HAL_Driver/Inc \
  103. -IDrivers/STM32F4xx_HAL_Driver/Inc/Legacy \
  104. -IDrivers/CMSIS/Device/ST/STM32F4xx/Include \
  105. -IDrivers/CMSIS/Include \
  106. -IDrivers/CMSIS/Include
  107. # compile gcc flags
  108. ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  109. CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  110. ifeq ($(DEBUG), 1)
  111. CFLAGS += -g -gdwarf-2
  112. endif
  113. # Generate dependency information
  114. CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
  115. #######################################
  116. # LDFLAGS
  117. #######################################
  118. # link script
  119. LDSCRIPT = STM32F407VGTx_FLASH.ld
  120. # libraries
  121. LIBS = -lc -lm -lnosys
  122. LIBDIR =
  123. LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
  124. # default action: build all
  125. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
  126. #######################################
  127. # build the application
  128. #######################################
  129. # list of objects
  130. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  131. vpath %.c $(sort $(dir $(C_SOURCES)))
  132. # list of ASM program objects
  133. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  134. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  135. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  136. $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  137. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  138. $(AS) -c $(CFLAGS) $< -o $@
  139. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
  140. $(CC) $(OBJECTS) $(LDFLAGS) -o $@
  141. $(SZ) $@
  142. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  143. $(HEX) $< $@
  144. $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  145. $(BIN) $< $@
  146. $(BUILD_DIR):
  147. mkdir $@
  148. #######################################
  149. # clean up
  150. #######################################
  151. clean:
  152. -rm -fR $(BUILD_DIR)
  153. #######################################
  154. # dependencies
  155. #######################################
  156. -include $(wildcard $(BUILD_DIR)/*.d)
  157. # *** EOF ***