Makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. ######################################
  2. # Makefile by CubeMX2Makefile.py
  3. ######################################
  4. ######################################
  5. # target
  6. ######################################
  7. TARGET = w5500-usr-es1
  8. ######################################
  9. # building variables
  10. ######################################
  11. # debug build?
  12. DEBUG = 1
  13. # optimization
  14. OPT = -O0
  15. #######################################
  16. # pathes
  17. #######################################
  18. # source path
  19. # Build path
  20. BUILD_DIR = build
  21. ######################################
  22. # source
  23. ######################################
  24. C_SOURCES = \
  25. Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c \
  26. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c \
  27. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c \
  28. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \
  29. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c \
  30. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c \
  31. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c \
  32. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c \
  33. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c \
  34. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \
  35. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c \
  36. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \
  37. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c \
  38. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c \
  39. Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c \
  40. Src/main.c \
  41. Src/stm32f4xx_hal_msp.c \
  42. Src/stm32f4xx_it.c \
  43. Wiznet-ioLibrary_Driver/Ethernet/wizchip_conf.c \
  44. Wiznet-ioLibrary_Driver/Ethernet/socket.c \
  45. Wiznet-ioLibrary_Driver/Ethernet/W5500/w5500.c \
  46. ASM_SOURCES = \
  47. Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f401xe.s
  48. #######################################
  49. # binaries
  50. #######################################
  51. CC = arm-none-eabi-gcc
  52. AS = arm-none-eabi-gcc -x assembler-with-cpp
  53. CP = arm-none-eabi-objcopy
  54. AR = arm-none-eabi-ar
  55. SZ = arm-none-eabi-size
  56. HEX = $(CP) -O ihex
  57. BIN = $(CP) -O binary -S
  58. #######################################
  59. # CFLAGS
  60. #######################################
  61. # macros for gcc
  62. AS_DEFS =
  63. C_DEFS = -D__weak=__attribute__\(\(weak\)\) -D__packed=__attribute__\(\(__packed__\)\) -DUSE_HAL_DRIVER -DSTM32F401xE
  64. # includes for gcc
  65. AS_INCLUDES =
  66. C_INCLUDES = -IInc
  67. C_INCLUDES += -IDrivers/STM32F4xx_HAL_Driver/Inc
  68. C_INCLUDES += -IDrivers/STM32F4xx_HAL_Driver/Inc/Legacy
  69. C_INCLUDES += -IDrivers/CMSIS/Include
  70. C_INCLUDES += -IDrivers/CMSIS/Device/ST/STM32F4xx/Include
  71. C_INCLUDES += -IWiznet-ioLibrary_Driver
  72. C_INCLUDES += -IWiznet-ioLibrary_Driver/Ethernet
  73. # compile gcc flags
  74. ASFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  75. CFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  76. ifeq ($(DEBUG), 1)
  77. CFLAGS += -g -gdwarf-2
  78. endif
  79. # Generate dependency information
  80. CFLAGS += -MD -MP -MF .dep/$(@F).d
  81. #######################################
  82. # LDFLAGS
  83. #######################################
  84. # link script
  85. LDSCRIPT = arm-gcc-link.ld
  86. # libraries
  87. LIBS = -lc -lm -lnosys
  88. LIBDIR =
  89. LDFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
  90. # default action: build all
  91. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
  92. #######################################
  93. # build the application
  94. #######################################
  95. # list of objects
  96. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  97. vpath %.c $(sort $(dir $(C_SOURCES)))
  98. # list of ASM program objects
  99. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  100. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  101. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  102. $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  103. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  104. $(AS) -c $(CFLAGS) $< -o $@
  105. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
  106. $(CC) $(OBJECTS) $(LDFLAGS) -o $@
  107. $(SZ) $@
  108. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  109. $(HEX) $< $@
  110. $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  111. $(BIN) $< $@
  112. $(BUILD_DIR):
  113. mkdir -p $@
  114. #######################################
  115. # clean up
  116. #######################################
  117. clean:
  118. -rm -fR .dep $(BUILD_DIR)
  119. #######################################
  120. # dependencies
  121. #######################################
  122. -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
  123. # *** EOF ***