Makefile 5.2 KB

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