Makefile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. ######################################
  2. # Makefile by CubeMX2Makefile.py
  3. ######################################
  4. ######################################
  5. # target
  6. ######################################
  7. TARGET = V01
  8. ######################################
  9. # building variables
  10. ######################################
  11. # debug build?
  12. DEBUG = 1
  13. # optimization
  14. OPT = -O0
  15. #######################################
  16. # pathes
  17. #######################################
  18. # Build path
  19. BUILD_DIR = build
  20. ######################################
  21. # source
  22. ######################################
  23. C_SOURCES = \
  24. Src/stm32f0xx_it.c \
  25. Src/main.c \
  26. Src/stm32f0xx_hal_msp.c \
  27. Drivers/CMSIS/Device/ST/STM32F0xx/Source/Templates/system_stm32f0xx.c \
  28. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c_ex.c \
  29. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash.c \
  30. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr_ex.c \
  31. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_cortex.c \
  32. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim_ex.c \
  33. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_gpio.c \
  34. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc.c \
  35. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc_ex.c \
  36. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart.c \
  37. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash_ex.c \
  38. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr.c \
  39. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_dma.c \
  40. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_adc.c \
  41. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_adc_ex.c \
  42. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c.c \
  43. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim.c \
  44. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal.c \
  45. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart_ex.c
  46. ASM_SOURCES = \
  47. Drivers/CMSIS/Device/ST/STM32F0xx/Source/Templates/gcc/startup_stm32f030x6.s
  48. #######################################
  49. # binaries
  50. #######################################
  51. CC = arm-none-eabi-gcc
  52. AS = arm-none-eabi-gcc -x assembler-with-cpp
  53. CP = arm-none-eabi-objcopy
  54. AR = arm-none-eabi-ar
  55. SZ = arm-none-eabi-size
  56. HEX = $(CP) -O ihex
  57. BIN = $(CP) -O binary -S
  58. #######################################
  59. # CFLAGS
  60. #######################################
  61. # macros for gcc
  62. AS_DEFS =
  63. C_DEFS = -D__weak="__attribute__((weak))" -D__packed="__attribute__((__packed__))" -DUSE_HAL_DRIVER -DSTM32F030x6
  64. # includes for gcc
  65. AS_INCLUDES =
  66. C_INCLUDES = -IDrivers/CMSIS/Include
  67. C_INCLUDES += -IDrivers/CMSIS/Device/ST/STM32F0xx/Include
  68. C_INCLUDES += -IDrivers/STM32F0xx_HAL_Driver/Inc
  69. C_INCLUDES += -IDrivers/STM32F0xx_HAL_Driver/Inc/Legacy
  70. C_INCLUDES += -IInc
  71. # compile gcc flags
  72. ASFLAGS = -mthumb -mcpu=cortex-m0 $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  73. CFLAGS = -mthumb -mcpu=cortex-m0 $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  74. ifeq ($(DEBUG), 1)
  75. CFLAGS += -g -gdwarf-2
  76. endif
  77. # Generate dependency information
  78. CFLAGS += -std=c99 -MD -MP -MF .dep/$(@F).d
  79. #######################################
  80. # LDFLAGS
  81. #######################################
  82. # link script
  83. LDSCRIPT = STM32F030F4Px_FLASH.ld
  84. # libraries
  85. LIBS = -lc -lm -lnosys
  86. LIBDIR =
  87. LDFLAGS = -mthumb -mcpu=cortex-m0 -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
  88. # default action: build all
  89. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
  90. #######################################
  91. # build the application
  92. #######################################
  93. # list of objects
  94. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  95. vpath %.c $(sort $(dir $(C_SOURCES)))
  96. # list of ASM program objects
  97. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  98. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  99. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  100. $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  101. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  102. $(AS) -c $(CFLAGS) $< -o $@
  103. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
  104. $(CC) $(OBJECTS) $(LDFLAGS) -o $@
  105. $(SZ) $@
  106. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  107. $(HEX) $< $@
  108. $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  109. $(BIN) $< $@
  110. $(BUILD_DIR):
  111. mkdir -p $@
  112. #######################################
  113. # clean up
  114. #######################################
  115. clean:
  116. -rm -fR .dep $(BUILD_DIR)
  117. #######################################
  118. # dependencies
  119. #######################################
  120. -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
  121. .PHONY: clean all
  122. # *** EOF ***