Makefile 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. ######################################
  2. # Makefile by CubeMX2Makefile.py
  3. ######################################
  4. ######################################
  5. # target
  6. ######################################
  7. TARGET = CardLogger
  8. ######################################
  9. # building variables
  10. ######################################
  11. # debug build?
  12. DEBUG = 1
  13. #######################################
  14. # pathes
  15. #######################################
  16. # Build path
  17. BUILD_DIR = build
  18. ######################################
  19. # source
  20. ######################################
  21. ETHERNET=ENC28J60
  22. #ETHERNET=WIZNET
  23. #ETHERNET=ETH_DISABLED
  24. C_SOURCES = \
  25. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_cortex.c \
  26. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal.c \
  27. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim_ex.c \
  28. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_spi_ex.c \
  29. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc_ex.c \
  30. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash.c \
  31. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_spi.c \
  32. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_tim.c \
  33. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr.c \
  34. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c_ex.c \
  35. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_gpio.c \
  36. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_dma.c \
  37. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc.c \
  38. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash_ex.c \
  39. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_i2c.c \
  40. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr_ex.c \
  41. Src/main.c \
  42. Src/stm32f0xx_it.c \
  43. Src/system_stm32f0xx.c \
  44. Src/stm32f0xx_hal_msp.c
  45. ASM_SOURCES = \
  46. startup/startup_stm32f030x6.s
  47. #######################################
  48. # binaries
  49. #######################################
  50. CC = arm-none-eabi-gcc
  51. AS = arm-none-eabi-gcc -x assembler-with-cpp
  52. CP = arm-none-eabi-objcopy
  53. AR = arm-none-eabi-ar
  54. SZ = arm-none-eabi-size
  55. HEX = $(CP) -O ihex
  56. BIN = $(CP) -O binary -S
  57. #######################################
  58. # CFLAGS
  59. #######################################
  60. # macros for gcc
  61. AS_DEFS =
  62. C_DEFS = -D__weak="__attribute__((weak))" -D__packed="__attribute__((__packed__))" -DUSE_HAL_DRIVER -DSTM32F030x6 -D__weak="__attribute__((weak))" -D__packed="__attribute__((__packed__))" -DUSE_HAL_DRIVER -DSTM32F030x6 -DETH_MODULE=$(ETHERNET) -DETHERNET_LED_GPIO=GPIOA -DETHERNET_LED_PIN=LED_STATUS_Pin -DETHERNET_CS_GPIO=GPIOB -DETHERNET_CS_PIN=SPI1_NSS_Pin -DETHERNET_CS_DELAY=2
  63. # includes for gcc
  64. AS_INCLUDES =
  65. C_INCLUDES = -IInc
  66. C_INCLUDES += -IDrivers/CMSIS/Device/ST/STM32F0xx/Include
  67. C_INCLUDES += -IDrivers/CMSIS/Include
  68. C_INCLUDES += -IDrivers/STM32F0xx_HAL_Driver/Inc
  69. C_INCLUDES += -IDrivers/STM32F0xx_HAL_Driver/Inc/Legacy
  70. ifeq ($(ETHERNET),ENC28J60)
  71. C_SOURCES += Drivers/enc28j60/src/enc28j60.c
  72. C_SOURCES += Drivers/enc28j60/src/EtherShield.c
  73. C_SOURCES += Drivers/enc28j60/src/ip_arp_udp_tcp.c
  74. C_INCLUDES += -IDrivers/enc28j60/inc
  75. OPT = -O0
  76. endif
  77. ifeq ($(ETHERNET),WIZNET)
  78. C_SOURCES += \
  79. Drivers/wiznet/Ethernet/wizchip_conf.c \
  80. Drivers/wiznet/Ethernet/socket.c \
  81. Drivers/wiznet/Ethernet/W5500/w5500.c \
  82. C_INCLUDES += -IDrivers/wiznet
  83. C_INCLUDES += -IDrivers/wiznet/Ethernet
  84. DEBUG = 0
  85. endif
  86. # compile gcc flags
  87. ASFLAGS = -mthumb -mcpu=cortex-m0 $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  88. CFLAGS = -mthumb -mcpu=cortex-m0 $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  89. ifeq ($(DEBUG), 1)
  90. CFLAGS += -g -gdwarf-2
  91. else
  92. CFLAGS += -Os -flto
  93. endif
  94. # Generate dependency information
  95. CFLAGS += -std=c99 -MD -MP -MF .dep/$(@F).d
  96. #######################################
  97. # LDFLAGS
  98. #######################################
  99. # link script
  100. LDSCRIPT = STM32F030F4Px_FLASH.ld
  101. # libraries
  102. LIBS = -lc -lm -lnosys
  103. LIBDIR =
  104. LDFLAGS = -mthumb -mcpu=cortex-m0 -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
  105. # default action: build all
  106. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
  107. #######################################
  108. # build the application
  109. #######################################
  110. # list of objects
  111. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  112. vpath %.c $(sort $(dir $(C_SOURCES)))
  113. # list of ASM program objects
  114. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  115. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  116. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  117. $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  118. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  119. $(AS) -c $(CFLAGS) $< -o $@
  120. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
  121. $(CC) $(OBJECTS) $(LDFLAGS) -o $@
  122. $(SZ) $@
  123. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  124. $(HEX) $< $@
  125. $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  126. $(BIN) $< $@
  127. $(BUILD_DIR):
  128. mkdir -p $@
  129. #######################################
  130. # clean up
  131. #######################################
  132. clean:
  133. -rm -fR .dep $(BUILD_DIR)
  134. #######################################
  135. # dependencies
  136. #######################################
  137. -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
  138. .PHONY: clean all
  139. # *** EOF ***