Makefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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/xprintf.c \
  38. src/stm32g0xx_it.c \
  39. src/system_stm32g0xx.c
  40. # ASM sources
  41. ASM_SOURCES = \
  42. Drivers/startup_stm32g030xx.s
  43. #######################################
  44. # binaries
  45. #######################################
  46. PREFIX = arm-none-eabi-
  47. # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
  48. # either it can be added to the PATH environment variable.
  49. #GCC_PATH = "C:/ChibiStudio/tools/GNU Tools ARM Embedded/7.0 2017q4/bin"
  50. ifdef GCC_PATH
  51. CC = $(GCC_PATH)/$(PREFIX)gcc
  52. AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
  53. CP = $(GCC_PATH)/$(PREFIX)objcopy
  54. SZ = $(GCC_PATH)/$(PREFIX)size
  55. else
  56. CC = $(PREFIX)gcc
  57. AS = $(PREFIX)gcc -x assembler-with-cpp
  58. CP = $(PREFIX)objcopy
  59. SZ = $(PREFIX)size
  60. endif
  61. HEX = $(CP) -O ihex
  62. BIN = $(CP) -O binary -S
  63. #######################################
  64. # CFLAGS
  65. #######################################
  66. # cpu
  67. CPU = -mcpu=cortex-m0plus
  68. # fpu
  69. # NONE for Cortex-M0/M0+/M3
  70. # float-abi
  71. # mcu
  72. MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
  73. # macros for gcc
  74. # AS defines
  75. AS_DEFS =
  76. # C defines
  77. C_DEFS = \
  78. -DUSE_FULL_LL_DRIVER \
  79. -DHSE_VALUE=8000000 \
  80. -DHSE_STARTUP_TIMEOUT=100 \
  81. -DLSE_STARTUP_TIMEOUT=5000 \
  82. -DLSE_VALUE=32768 \
  83. -DEXTERNAL_CLOCK_VALUE=12288000 \
  84. -DHSI_VALUE=16000000 \
  85. -DLSI_VALUE=32000 \
  86. -DVDD_VALUE=3300 \
  87. -DPREFETCH_ENABLE=0 \
  88. -DINSTRUCTION_CACHE_ENABLE=1 \
  89. -DDATA_CACHE_ENABLE=1 \
  90. -DSTM32G030xx
  91. # AS includes
  92. AS_INCLUDES =
  93. # C includes
  94. C_INCLUDES = \
  95. -Iinc \
  96. -IDrivers/STM32G0xx_HAL_Driver/Inc \
  97. -IDrivers/CMSIS/Device/ST/STM32G0xx/Include \
  98. -IDrivers/CMSIS/Include
  99. # compile gcc flags
  100. ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall
  101. CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall
  102. ifeq ($(DEBUG), 1)
  103. CFLAGS += -g -gdwarf-2
  104. endif
  105. # Generate dependency information
  106. CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
  107. CFLAGS += -std=gnu11 -pedantic
  108. #######################################
  109. # LDFLAGS
  110. #######################################
  111. # link script
  112. LDSCRIPT = Drivers/STM32G030F6Px_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
  119. # $(BUILD_DIR)/$(TARGET).bin
  120. #######################################
  121. # build the application
  122. #######################################
  123. # list of objects
  124. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  125. vpath %.c $(sort $(dir $(C_SOURCES)))
  126. # list of ASM program objects
  127. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  128. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  129. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  130. @echo Compiling: $<
  131. @$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  132. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  133. @echo Compiling: $<
  134. @$(AS) -c $(CFLAGS) $< -o $@
  135. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
  136. @echo
  137. @echo Linking: $@
  138. @$(CC) $(OBJECTS) $(LDFLAGS) -o $@
  139. # @echo ------------------------------------------------------------
  140. @$(SZ) $@
  141. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  142. @echo
  143. @echo Makeing HEX: $@
  144. @$(HEX) $< $@
  145. #$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  146. # $(BIN) $< $@
  147. $(BUILD_DIR):
  148. mkdir $@
  149. #######################################
  150. # clean up
  151. #######################################
  152. clean:
  153. -rm -fR $(BUILD_DIR)
  154. #######################################
  155. # dependencies
  156. #######################################
  157. -include $(wildcard $(BUILD_DIR)/*.d)
  158. #######################################
  159. # custom
  160. #######################################
  161. flash: all
  162. @flash.cmd
  163. default: all
  164. # *** EOF ***