Makefile 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. ##########################################################################################################################
  2. # File automatically-generated by tool: [projectgenerator] version: [4.3.0-B58] date: [Tue Jun 04 12:43:50 MSK 2024]
  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 = nucleo_l0
  15. ######################################
  16. # building variables
  17. ######################################
  18. # debug build?
  19. DEBUG = 1
  20. # optimization
  21. OPT = -Og
  22. #######################################
  23. # paths
  24. #######################################
  25. # Build path
  26. BUILD_DIR = build
  27. ######################################
  28. # source
  29. ######################################
  30. # C sources
  31. C_SOURCES = \
  32. Core/Src/main.c \
  33. Core/Src/stm32l0xx_it.c \
  34. Core/Src/stm32l0xx_hal_msp.c \
  35. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_tim.c \
  36. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_tim_ex.c \
  37. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_uart.c \
  38. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_uart_ex.c \
  39. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal.c \
  40. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_i2c.c \
  41. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_i2c_ex.c \
  42. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_rcc.c \
  43. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_rcc_ex.c \
  44. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_flash_ramfunc.c \
  45. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_flash.c \
  46. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_flash_ex.c \
  47. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_gpio.c \
  48. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_dma.c \
  49. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_pwr.c \
  50. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_pwr_ex.c \
  51. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_cortex.c \
  52. Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_exti.c \
  53. Core/Src/system_stm32l0xx.c \
  54. Core/Src/sysmem.c \
  55. Core/Src/syscalls.c
  56. # ASM sources
  57. ASM_SOURCES = \
  58. startup_stm32l053xx.s
  59. # ASM sources
  60. ASMM_SOURCES =
  61. #######################################
  62. # binaries
  63. #######################################
  64. PREFIX = arm-none-eabi-
  65. # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
  66. # either it can be added to the PATH environment variable.
  67. ifdef GCC_PATH
  68. CC = $(GCC_PATH)/$(PREFIX)gcc
  69. AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
  70. CP = $(GCC_PATH)/$(PREFIX)objcopy
  71. SZ = $(GCC_PATH)/$(PREFIX)size
  72. else
  73. CC = $(PREFIX)gcc
  74. AS = $(PREFIX)gcc -x assembler-with-cpp
  75. CP = $(PREFIX)objcopy
  76. SZ = $(PREFIX)size
  77. endif
  78. HEX = $(CP) -O ihex
  79. BIN = $(CP) -O binary -S
  80. #######################################
  81. # CFLAGS
  82. #######################################
  83. # cpu
  84. CPU = -mcpu=cortex-m0plus
  85. # fpu
  86. # NONE for Cortex-M0/M0+/M3
  87. # float-abi
  88. # mcu
  89. MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
  90. # macros for gcc
  91. # AS defines
  92. AS_DEFS =
  93. # C defines
  94. C_DEFS = \
  95. -DUSE_HAL_DRIVER \
  96. -DSTM32L053xx
  97. # AS includes
  98. AS_INCLUDES =
  99. # C includes
  100. C_INCLUDES = \
  101. -ICore/Inc \
  102. -IDrivers/STM32L0xx_HAL_Driver/Inc \
  103. -IDrivers/STM32L0xx_HAL_Driver/Inc/Legacy \
  104. -IDrivers/CMSIS/Device/ST/STM32L0xx/Include \
  105. -IDrivers/CMSIS/Include
  106. # compile gcc flags
  107. ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  108. CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  109. ifeq ($(DEBUG), 1)
  110. CFLAGS += -g -gdwarf-2
  111. endif
  112. # Generate dependency information
  113. CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
  114. #######################################
  115. # LDFLAGS
  116. #######################################
  117. # link script
  118. LDSCRIPT = STM32L053R8Tx_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 $(BUILD_DIR)/$(TARGET).bin
  125. #######################################
  126. # build the application
  127. #######################################
  128. # list of objects
  129. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  130. vpath %.c $(sort $(dir $(C_SOURCES)))
  131. # list of ASM program objects
  132. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  133. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  134. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASMM_SOURCES:.S=.o)))
  135. vpath %.S $(sort $(dir $(ASMM_SOURCES)))
  136. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  137. $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  138. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  139. $(AS) -c $(CFLAGS) $< -o $@
  140. $(BUILD_DIR)/%.o: %.S Makefile | $(BUILD_DIR)
  141. $(AS) -c $(CFLAGS) $< -o $@
  142. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
  143. $(CC) $(OBJECTS) $(LDFLAGS) -o $@
  144. $(SZ) $@
  145. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  146. $(HEX) $< $@
  147. $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  148. $(BIN) $< $@
  149. $(BUILD_DIR):
  150. mkdir $@
  151. #######################################
  152. # clean up
  153. #######################################
  154. clean:
  155. -rm -fR $(BUILD_DIR)
  156. #######################################
  157. # dependencies
  158. #######################################
  159. -include $(wildcard $(BUILD_DIR)/*.d)
  160. # *** EOF ***