Makefile 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. ######################################
  2. # STM32F10x Makefile
  3. ######################################
  4. ######################################
  5. # target
  6. ######################################
  7. TARGET = NeoClock
  8. ######################################
  9. # building variables
  10. ######################################
  11. # debug build?
  12. DEBUG = 1
  13. # build for debug in ram?
  14. RAMBUILD = 0
  15. # optimization
  16. OPT = -O0
  17. #######################################
  18. # paths
  19. #######################################
  20. # source path
  21. VPATH = src startup
  22. # firmware library path
  23. PERIPHLIBPATH = ./periphlib
  24. #VPATH += $(PERIPHLIBPATH)/CMSIS/CM3/CoreSupport
  25. #VPATH += $(PERIPHLIBPATH)/CMSIS/CM3/DeviceSupport/ST/STM32F10x
  26. #VPATH += $(PERIPHLIBPATH)/STM32F10x_StdPeriph_Driver/src
  27. VPATH += $(PERIPHLIBPATH)/CMSIS/Device/ST/STM32F30x
  28. VPATH += $(PERIPHLIBPATH)/STM32F30x_StdPeriph_Driver/src
  29. # Build path
  30. BUILD_DIR = build
  31. # #####################################
  32. # source
  33. # #####################################
  34. SRCS = \
  35. main.c \
  36. stm32f30x_it.c \
  37. system_stm32f30x.c
  38. SRCSASM = \
  39. startup_stm32f30x.s
  40. # #####################################
  41. # firmware library
  42. # #####################################
  43. # core_cm0.c
  44. PERIPHLIB_SOURCES = \
  45. dma.c \
  46. gpio.c \
  47. rtc.c \
  48. timer.c \
  49. ws2812.c \
  50. aolib.c \
  51. stm32f30x_gpio.c \
  52. stm32f30x_rcc.c \
  53. stm32f30x_tim.c \
  54. stm32f30x_pwr.c \
  55. stm32f30x_exti.c \
  56. stm32f30x_dma.c \
  57. stm32f30x_rtc.c
  58. #######################################
  59. # binaries
  60. #######################################
  61. CC = arm-none-eabi-gcc
  62. AS = arm-none-eabi-gcc -x assembler-with-cpp
  63. CP = arm-none-eabi-objcopy
  64. AR = arm-none-eabi-ar
  65. SZ = arm-none-eabi-size
  66. HEX = $(CP) -O ihex
  67. BIN = $(CP) -O binary -S
  68. #######################################
  69. # CFLAGS
  70. #######################################
  71. # macros for gcc
  72. DEFS = -DSTM32F30x -DUSE_STDPERIPH_DRIVER
  73. ifeq ($(RAMBUILD), 1)
  74. DEFS += -DVECT_TAB_SRAM
  75. endif
  76. ifeq ($(DEBUG), 1)
  77. DEFS += -DDEBUG -D_DEBUG
  78. endif
  79. # includes for gcc
  80. INCLUDES = -Iinc
  81. # INCLUDES += -I$(PERIPHLIBPATH)/CMSIS/CM3/CoreSupport
  82. # INCLUDES += -I$(PERIPHLIBPATH)/CMSIS/CM3/DeviceSupport/ST/STM32F10x
  83. # INCLUDES += -I$(PERIPHLIBPATH)/STM32F10x_StdPeriph_Driver/inc
  84. INCLUDES += -I$(PERIPHLIBPATH)/CMSIS/Device/ST/STM32F30x/Include
  85. INCLUDES += -I$(PERIPHLIBPATH)/STM32F30x_StdPeriph_Driver/inc
  86. INCLUDES += -I$(PERIPHLIBPATH)/CMSIS/Include
  87. # compile gcc flags
  88. CFLAGS = -mthumb -mcpu=cortex-m4 $(DEFS) $(INCLUDES) $(OPT) -Wall -fno-common -fdata-sections -ffunction-sections
  89. # ifeq ($(DEBUG), 1)
  90. CFLAGS += -g -gdwarf-2 -fno-common -fdata-sections -ffunction-sections
  91. # endif
  92. # Generate dependency information
  93. CFLAGS += -MD -MP -MF .dep/$(@F).d
  94. #######################################
  95. # LDFLAGS
  96. #######################################
  97. # link script
  98. LDSCRIPT = linker/STM32F303VC_FLASH.ld
  99. # libraries
  100. LIBS = -Wl,--start-group -lc -lm -lgcc -lnosys -Wl,--end-group
  101. LIBDIR =
  102. LDFLAGS = -mthumb -mcpu=cortex-m4 -specs=nano.specs -T$(LDSCRIPT) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections --static -nostartfiles
  103. # default action: build all
  104. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex
  105. #######################################
  106. # build the application
  107. #######################################
  108. # list of firmware library objects
  109. PERIPHLIB_OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(PERIPHLIB_SOURCES:.c=.o)))
  110. # list of C program objects
  111. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(SRCS:.c=.o)))
  112. # list of ASM program objects
  113. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(SRCSASM:.s=.o)))
  114. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  115. $(CC) -c $(CFLAGS) $< -o $@
  116. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  117. $(AS) -c $(CFLAGS) $< -o $@
  118. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) $(PERIPHLIB_OBJECTS) Makefile
  119. $(CC) $(OBJECTS) $(PERIPHLIB_OBJECTS) $(LDFLAGS) -o $@
  120. $(SZ) $@
  121. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  122. $(HEX) $< $@
  123. $(BUILD_DIR):
  124. mkdir -p $@
  125. #######################################
  126. # delete all user application files
  127. #######################################
  128. clean:
  129. -rm -fR .dep $(BUILD_DIR)
  130. #
  131. # Include the dependency files, should be the last of the makefile
  132. #
  133. -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
  134. # *** EOF ***