Makefile 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. ##########################################################################################################################
  2. # File automatically-generated by tool: [projectgenerator] version: [2.29.1] date: [Fri Jun 29 16:07:09 MSK 2018]
  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 = Knife
  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/stm32f0xx_it.c \
  34. Src/stm32f0xx_hal_msp.c \
  35. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim.c \
  36. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim_ex.c \
  37. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart.c \
  38. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart_ex.c \
  39. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc.c \
  40. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc_ex.c \
  41. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal.c \
  42. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c.c \
  43. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c_ex.c \
  44. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_gpio.c \
  45. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_dma.c \
  46. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_cortex.c \
  47. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr.c \
  48. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr_ex.c \
  49. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash.c \
  50. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash_ex.c \
  51. Src/system_stm32f0xx.c
  52. # ASM sources
  53. ASM_SOURCES = \
  54. startup_stm32f030x6.s
  55. #######################################
  56. # binaries
  57. #######################################
  58. PREFIX = arm-none-eabi-
  59. # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
  60. # either it can be added to the PATH environment variable.
  61. ifdef GCC_PATH
  62. CC = $(GCC_PATH)/$(PREFIX)gcc
  63. AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
  64. CP = $(GCC_PATH)/$(PREFIX)objcopy
  65. SZ = $(GCC_PATH)/$(PREFIX)size
  66. else
  67. CC = $(PREFIX)gcc
  68. AS = $(PREFIX)gcc -x assembler-with-cpp
  69. CP = $(PREFIX)objcopy
  70. SZ = $(PREFIX)size
  71. endif
  72. HEX = $(CP) -O ihex
  73. BIN = $(CP) -O binary -S
  74. #######################################
  75. # CFLAGS
  76. #######################################
  77. # cpu
  78. CPU = -mcpu=cortex-m0
  79. # fpu
  80. # NONE for Cortex-M0/M0+/M3
  81. # float-abi
  82. # mcu
  83. MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
  84. # macros for gcc
  85. # AS defines
  86. AS_DEFS =
  87. # C defines
  88. C_DEFS = \
  89. -DUSE_HAL_DRIVER \
  90. -DSTM32F030x6
  91. # AS includes
  92. AS_INCLUDES =
  93. # C includes
  94. C_INCLUDES = \
  95. -IInc \
  96. -IDrivers/STM32F0xx_HAL_Driver/Inc \
  97. -IDrivers/STM32F0xx_HAL_Driver/Inc/Legacy \
  98. -IDrivers/CMSIS/Device/ST/STM32F0xx/Include \
  99. -IDrivers/CMSIS/Include
  100. # compile gcc flags
  101. ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  102. CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  103. ifeq ($(DEBUG), 1)
  104. CFLAGS += -g -gdwarf-2
  105. endif
  106. # Generate dependency information
  107. CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
  108. #######################################
  109. # LDFLAGS
  110. #######################################
  111. # link script
  112. LDSCRIPT = STM32F030F4Px_FLASH.ld
  113. # libraries
  114. LIBS = -lc -lm -lnosys
  115. LIBDIR =
  116. LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
  117. # default action: build all
  118. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
  119. #######################################
  120. # build the application
  121. #######################################
  122. # list of objects
  123. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  124. vpath %.c $(sort $(dir $(C_SOURCES)))
  125. # list of ASM program objects
  126. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  127. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  128. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  129. $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  130. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  131. $(AS) -c $(CFLAGS) $< -o $@
  132. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
  133. $(CC) $(OBJECTS) $(LDFLAGS) -o $@
  134. $(SZ) $@
  135. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  136. $(HEX) $< $@
  137. $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  138. $(BIN) $< $@
  139. $(BUILD_DIR):
  140. mkdir $@
  141. #######################################
  142. # clean up
  143. #######################################
  144. clean:
  145. -rm -fR $(BUILD_DIR)
  146. #######################################
  147. # dependencies
  148. #######################################
  149. -include $(wildcard $(BUILD_DIR)/*.d)
  150. # *** EOF ***