Makefile 4.3 KB

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