Makefile 4.9 KB

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