Makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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 = El12
  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 -funsigned-char
  24. OPT += -ffast-math -msoft-float -mfloat-abi=soft
  25. OPT += -fomit-frame-pointer -falign-functions=16
  26. #######################################
  27. # paths
  28. #######################################
  29. # Build path
  30. BUILD_DIR = build
  31. ######################################
  32. # source
  33. ######################################
  34. # C sources
  35. C_SOURCES = \
  36. src/main.c \
  37. src/board.c \
  38. src/rtos.c \
  39. src/i2c.c \
  40. src/ds3231.c \
  41. src/display.c \
  42. src/xprintf.c \
  43. src/event-system.c \
  44. src/clock.c \
  45. MCU/system_stm32f0xx.c
  46. # ASM sources
  47. ASM_SOURCES = \
  48. MCU/startup_stm32f030x6.s
  49. #######################################
  50. # binaries
  51. #######################################
  52. PREFIX = arm-none-eabi-
  53. # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
  54. # either it can be added to the PATH environment variable.
  55. #GCC_PATH = "C:/ChibiStudio/tools/GNU Tools ARM Embedded/7.0 2017q4/bin"
  56. ifdef GCC_PATH
  57. CC = $(GCC_PATH)/$(PREFIX)gcc
  58. AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
  59. CP = $(GCC_PATH)/$(PREFIX)objcopy
  60. SZ = $(GCC_PATH)/$(PREFIX)size
  61. else
  62. CC = $(PREFIX)gcc
  63. AS = $(PREFIX)gcc -x assembler-with-cpp
  64. CP = $(PREFIX)objcopy
  65. SZ = $(PREFIX)size
  66. endif
  67. HEX = $(CP) -O ihex
  68. BIN = $(CP) -O binary -S
  69. #######################################
  70. # CFLAGS
  71. #######################################
  72. # cpu
  73. CPU = -mcpu=cortex-m0
  74. # fpu
  75. # NONE for Cortex-M0/M0+/M3
  76. # float-abi
  77. # mcu
  78. MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
  79. # macros for gcc
  80. # AS defines
  81. AS_DEFS =
  82. # C defines
  83. C_DEFS = -DSTM32F030x6
  84. # AS includes
  85. AS_INCLUDES =
  86. # C includes
  87. C_INCLUDES = -I./inc
  88. C_INCLUDES += -IMCU/CMSIS/Include
  89. C_INCLUDES += -IMCU/CMSIS/Device/ST/STM32F0xx/Include
  90. # compile gcc flags
  91. ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall
  92. CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall
  93. ifeq ($(DEBUG), 1)
  94. CFLAGS += -g -gdwarf-2
  95. endif
  96. # Generate dependency information
  97. CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
  98. CFLAGS += -std=gnu11 -pedantic -Wall
  99. #######################################
  100. # LDFLAGS
  101. #######################################
  102. # link script
  103. LDSCRIPT = MCU/STM32F030K6_FLASH.ld
  104. # libraries
  105. LIBS = -lc -lm -lnosys
  106. LIBDIR =
  107. LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
  108. # default action: build all
  109. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex
  110. #######################################
  111. # build the application
  112. #######################################
  113. # list of objects
  114. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  115. vpath %.c $(sort $(dir $(C_SOURCES)))
  116. # list of ASM program objects
  117. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  118. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  119. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  120. @echo Compiling: $<
  121. @$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  122. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  123. @echo Compiling: $<
  124. @$(AS) -c $(CFLAGS) $< -o $@
  125. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
  126. @echo
  127. @echo Linking: $@
  128. @$(CC) $(OBJECTS) $(LDFLAGS) -o $@
  129. # @echo ------------------------------------------------------------
  130. @$(SZ) $@
  131. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  132. @echo
  133. @echo Makeing HEX: $@
  134. @$(HEX) $< $@
  135. #$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  136. # $(BIN) $< $@
  137. $(BUILD_DIR):
  138. mkdir $@
  139. #######################################
  140. # clean up
  141. #######################################
  142. clean:
  143. -rm -fR $(BUILD_DIR)
  144. #######################################
  145. # custom
  146. #######################################
  147. flash: all
  148. @flash.cmd
  149. default: all
  150. #######################################
  151. # dependencies
  152. #######################################
  153. -include $(wildcard $(BUILD_DIR)/*.d)
  154. # *** EOF ***