Advertisement
Guest User

Untitled

a guest
Feb 4th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 4.75 KB | None | 0 0
  1. # ------------------------------------------------
  2. # Generic Makefile (based on gcc)
  3. #
  4. # ------------------------------------------------
  5.  
  6. ######################################
  7. # target
  8. ######################################
  9. TARGET = LivingRoomClock
  10.  
  11.  
  12. ######################################
  13. # building variables
  14. ######################################
  15. # debug build?
  16. DEBUG = 1
  17. # optimization
  18. OPT = -Og
  19.  
  20.  
  21. #######################################
  22. # paths
  23. #######################################
  24. # source path
  25. SOURCES_DIR =  \
  26. Application/MAKEFILE \
  27. Drivers \
  28. Drivers/CMSIS \
  29. Drivers/STM32F1xx_HAL_Driver \
  30.  
  31.  
  32. # firmware library path
  33. PERIFLIB_PATH =
  34.  
  35. # Build path
  36. BUILD_DIR = build
  37.  
  38. ######################################
  39. # source
  40. ######################################
  41. # C sources
  42. C_SOURCES =  \
  43. main.c \
  44. stm32f1xx_it.c \
  45. ws2812b.c \
  46. clock.c \
  47. uart.c \
  48. debug.c \
  49. sys_init.c \
  50. system_stm32f1xx.c \
  51. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \
  52. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \
  53. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \
  54. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \
  55. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \
  56. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \
  57. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \
  58. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \
  59. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \
  60. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \
  61. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \
  62. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \
  63. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \
  64. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rtc.c \
  65. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rtc_ex.c \
  66. stm32f1xx_hal_msp.c \
  67.  
  68. # ASM sources
  69. ASM_SOURCES =  \
  70. startup_stm32f103xb.s
  71.  
  72.  
  73. ######################################
  74. # firmware library
  75. ######################################
  76. PERIFLIB_SOURCES =
  77.  
  78.  
  79. #######################################
  80. # binaries
  81. #######################################
  82. PREFIX = arm-none-eabi-
  83. CC = $(PREFIX)gcc
  84. AS = $(PREFIX)gcc -x assembler-with-cpp
  85. CP = $(PREFIX)objcopy
  86. AR = $(PREFIX)ar
  87. SZ = $(PREFIX)size
  88. HEX = $(CP) -O ihex
  89. BIN = $(CP) -O binary -S
  90.  
  91. #######################################
  92. # CFLAGS
  93. #######################################
  94. # cpu
  95. CPU = -mcpu=cortex-m3
  96.  
  97. # fpu
  98. # NONE for Cortex-M0/M0+/M3
  99.  
  100. # float-abi
  101.  
  102.  
  103. # mcu
  104. MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
  105.  
  106. # macros for gcc
  107. # AS defines
  108. AS_DEFS =
  109.  
  110. # C defines
  111. C_DEFS =  \
  112. -DUSE_HAL_DRIVER \
  113. -DSTM32F103xB
  114.  
  115.  
  116. # AS includes
  117. AS_INCLUDES =
  118.  
  119. # C includes
  120. C_INCLUDES =  \
  121. -I. \
  122. -IIncludes \
  123. -IDrivers/STM32F1xx_HAL_Driver/Inc \
  124. -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \
  125. -IDrivers/CMSIS/Device/ST/STM32F1xx/Include \
  126. -IDrivers/CMSIS/Include
  127.  
  128.  
  129. # compile gcc flags
  130. ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  131.  
  132. CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  133.  
  134. ifeq ($(DEBUG), 1)
  135. CFLAGS += -g -gdwarf-2
  136. endif
  137.  
  138.  
  139. # Generate dependency information
  140. CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)"
  141.  
  142.  
  143. #######################################
  144. # LDFLAGS
  145. #######################################
  146. # link script
  147. LDSCRIPT = STM32F103RBTx_FLASH.ld
  148.  
  149. # libraries
  150. LIBS = -lc -lm -lnosys
  151. LIBDIR =
  152. LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
  153.  
  154. # default action: build all
  155. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
  156.  
  157.  
  158. #######################################
  159. # build the application
  160. #######################################
  161. # list of objects
  162. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  163. vpath %.c $(sort $(dir $(C_SOURCES)))
  164. # list of ASM program objects
  165. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  166. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  167.  
  168. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  169.     $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  170.  
  171. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  172.     $(AS) -c $(CFLAGS) $< -o $@
  173.  
  174. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
  175.     $(CC) $(OBJECTS) $(LDFLAGS) -o $@
  176.     $(SZ) $@
  177.  
  178. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  179.     $(HEX) $< $@
  180.    
  181. $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  182.     $(BIN) $< $@   
  183.    
  184. $(BUILD_DIR):
  185.     mkdir $@       
  186.  
  187. #######################################
  188. # clean up
  189. #######################################
  190. clean:
  191.     -rm -fR .dep $(BUILD_DIR)
  192.  
  193. #######################################
  194. # dependencies
  195. #######################################
  196. -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
  197.  
  198. # *** EOF ***
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement