Makefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 = Skid
  15. ######################################
  16. # building variables
  17. ######################################
  18. # debug build?
  19. DEBUG = 0
  20. # optimization
  21. OPT = -Os
  22. OPT += -ffunction-sections -fdata-sections
  23. OPT += -fno-strict-aliasing
  24. OPT += -ffast-math -msoft-float -mfloat-abi=soft
  25. #######################################
  26. # paths
  27. #######################################
  28. # Build path
  29. BUILD_DIR = build
  30. ######################################
  31. # source
  32. ######################################
  33. # C sources
  34. C_SOURCES = \
  35. src/main.c \
  36. src/board.c \
  37. src/stm32g0xx_it.c \
  38. src/system_stm32g0xx.c
  39. # ASM sources
  40. ASM_SOURCES = \
  41. Drivers/startup_stm32g030xx.s
  42. #######################################
  43. # binaries
  44. #######################################
  45. PREFIX = arm-none-eabi-
  46. # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
  47. # either it can be added to the PATH environment variable.
  48. #GCC_PATH = "C:/ChibiStudio/tools/GNU Tools ARM Embedded/7.0 2017q4/bin"
  49. ifdef GCC_PATH
  50. CC = $(GCC_PATH)/$(PREFIX)gcc
  51. AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
  52. CP = $(GCC_PATH)/$(PREFIX)objcopy
  53. SZ = $(GCC_PATH)/$(PREFIX)size
  54. else
  55. CC = $(PREFIX)gcc
  56. AS = $(PREFIX)gcc -x assembler-with-cpp
  57. CP = $(PREFIX)objcopy
  58. SZ = $(PREFIX)size
  59. endif
  60. HEX = $(CP) -O ihex
  61. BIN = $(CP) -O binary -S
  62. #######################################
  63. # CFLAGS
  64. #######################################
  65. # cpu
  66. CPU = -mcpu=cortex-m0plus
  67. # fpu
  68. # NONE for Cortex-M0/M0+/M3
  69. # float-abi
  70. # mcu
  71. MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
  72. # macros for gcc
  73. # AS defines
  74. AS_DEFS =
  75. # C defines
  76. C_DEFS = \
  77. -DUSE_FULL_LL_DRIVER \
  78. -DHSE_VALUE=8000000 \
  79. -DHSE_STARTUP_TIMEOUT=100 \
  80. -DLSE_STARTUP_TIMEOUT=5000 \
  81. -DLSE_VALUE=32768 \
  82. -DEXTERNAL_CLOCK_VALUE=12288000 \
  83. -DHSI_VALUE=16000000 \
  84. -DLSI_VALUE=32000 \
  85. -DVDD_VALUE=3300 \
  86. -DPREFETCH_ENABLE=0 \
  87. -DINSTRUCTION_CACHE_ENABLE=1 \
  88. -DDATA_CACHE_ENABLE=1 \
  89. -DSTM32G030xx
  90. # AS includes
  91. AS_INCLUDES =
  92. # C includes
  93. C_INCLUDES = \
  94. -Iinc \
  95. -IDrivers/STM32G0xx_HAL_Driver/Inc \
  96. -IDrivers/CMSIS/Device/ST/STM32G0xx/Include \
  97. -IDrivers/CMSIS/Include
  98. # compile gcc flags
  99. ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall
  100. CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall
  101. ifeq ($(DEBUG), 1)
  102. CFLAGS += -g -gdwarf-2
  103. endif
  104. # Generate dependency information
  105. CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
  106. CFLAGS += -std=gnu11 -pedantic
  107. #######################################
  108. # LDFLAGS
  109. #######################################
  110. # link script
  111. LDSCRIPT = Drivers/STM32G030F6Px_FLASH.ld
  112. # libraries
  113. LIBS = -lc -lm -lnosys
  114. LIBDIR =
  115. LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
  116. # default action: build all
  117. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex
  118. # $(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. @echo Compiling: $<
  130. @$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  131. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  132. @echo Compiling: $<
  133. @$(AS) -c $(CFLAGS) $< -o $@
  134. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
  135. @echo
  136. @echo Linking: $@
  137. @$(CC) $(OBJECTS) $(LDFLAGS) -o $@
  138. # @echo ------------------------------------------------------------
  139. @$(SZ) $@
  140. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  141. @echo
  142. @echo Makeing HEX: $@
  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. #######################################
  158. # custom
  159. #######################################
  160. flash: all
  161. @flash.cmd
  162. default: all
  163. # *** EOF ***