Makefile 5.2 KB

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