Makefile 4.9 KB

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