Makefile 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. ##########################################################################################################################
  2. # File automatically-generated by tool: [projectgenerator] version: [3.11.2] date: [Fri Feb 05 08:10:39 EET 2021]
  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 = MNC-IN12x5
  15. ######################################
  16. # building variables
  17. ######################################
  18. # debug build?
  19. DEBUG = 0
  20. # optimization
  21. OPT = -O2
  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/stm32g0xx_it.c \
  34. Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_utils.c \
  35. Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_exti.c \
  36. Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_gpio.c \
  37. Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_i2c.c \
  38. Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_dma.c \
  39. Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_rcc.c \
  40. Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_spi.c \
  41. Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_pwr.c \
  42. Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_tim.c \
  43. Src/system_stm32g0xx.c
  44. # ASM sources
  45. ASM_SOURCES = \
  46. Drivers/startup_stm32g030xx.s
  47. #######################################
  48. # binaries
  49. #######################################
  50. PREFIX = arm-none-eabi-
  51. # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
  52. # either it can be added to the PATH environment variable.
  53. #GCC_PATH = "C:/ChibiStudio/tools/GNU Tools ARM Embedded/7.0 2017q4/bin"
  54. ifdef GCC_PATH
  55. CC = $(GCC_PATH)/$(PREFIX)gcc
  56. AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
  57. CP = $(GCC_PATH)/$(PREFIX)objcopy
  58. SZ = $(GCC_PATH)/$(PREFIX)size
  59. else
  60. CC = $(PREFIX)gcc
  61. AS = $(PREFIX)gcc -x assembler-with-cpp
  62. CP = $(PREFIX)objcopy
  63. SZ = $(PREFIX)size
  64. endif
  65. HEX = $(CP) -O ihex
  66. BIN = $(CP) -O binary -S
  67. #######################################
  68. # CFLAGS
  69. #######################################
  70. # cpu
  71. CPU = -mcpu=cortex-m0plus
  72. # fpu
  73. # NONE for Cortex-M0/M0+/M3
  74. # float-abi
  75. # mcu
  76. MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
  77. # macros for gcc
  78. # AS defines
  79. AS_DEFS =
  80. # C defines
  81. C_DEFS = \
  82. -DUSE_FULL_LL_DRIVER \
  83. -DHSE_VALUE=8000000 \
  84. -DHSE_STARTUP_TIMEOUT=100 \
  85. -DLSE_STARTUP_TIMEOUT=5000 \
  86. -DLSE_VALUE=32768 \
  87. -DEXTERNAL_CLOCK_VALUE=12288000 \
  88. -DHSI_VALUE=16000000 \
  89. -DLSI_VALUE=32000 \
  90. -DVDD_VALUE=3300 \
  91. -DPREFETCH_ENABLE=0 \
  92. -DINSTRUCTION_CACHE_ENABLE=1 \
  93. -DDATA_CACHE_ENABLE=1 \
  94. -DSTM32G030xx
  95. # AS includes
  96. AS_INCLUDES =
  97. # C includes
  98. C_INCLUDES = \
  99. -IInc \
  100. -IDrivers/STM32G0xx_HAL_Driver/Inc \
  101. -IDrivers/CMSIS/Device/ST/STM32G0xx/Include \
  102. -IDrivers/CMSIS/Include
  103. # compile gcc flags
  104. ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  105. CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  106. ifeq ($(DEBUG), 1)
  107. CFLAGS += -g -gdwarf-2
  108. endif
  109. # Generate dependency information
  110. CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
  111. #######################################
  112. # LDFLAGS
  113. #######################################
  114. # link script
  115. LDSCRIPT = Drivers/STM32G030K8Tx_FLASH.ld
  116. # libraries
  117. LIBS = -lc -lm -lnosys
  118. LIBDIR =
  119. LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
  120. # default action: build all
  121. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
  122. #######################################
  123. # build the application
  124. #######################################
  125. # list of objects
  126. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  127. vpath %.c $(sort $(dir $(C_SOURCES)))
  128. # list of ASM program objects
  129. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  130. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  131. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  132. $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  133. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  134. $(AS) -c $(CFLAGS) $< -o $@
  135. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
  136. $(CC) $(OBJECTS) $(LDFLAGS) -o $@
  137. $(SZ) $@
  138. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  139. $(HEX) $< $@
  140. $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  141. $(BIN) $< $@
  142. $(BUILD_DIR):
  143. mkdir $@
  144. #######################################
  145. # clean up
  146. #######################################
  147. clean:
  148. -rm -fR $(BUILD_DIR)
  149. #######################################
  150. # dependencies
  151. #######################################
  152. -include $(wildcard $(BUILD_DIR)/*.d)
  153. #######################################
  154. # custom
  155. #######################################
  156. flash: all
  157. @flash.cmd
  158. # *** EOF ***