Makefile 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. ######################################
  2. # Makefile by CubeMX2Makefile.py
  3. ######################################
  4. ######################################
  5. # target
  6. ######################################
  7. TARGET = nucleo-f091rc-rs232-enc28j60
  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/STM32F0xx/Source/Templates/system_stm32f0xx.c \
  26. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal.c \
  27. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_cortex.c \
  28. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_dma.c \
  29. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash.c \
  30. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_flash_ex.c \
  31. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_gpio.c \
  32. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr.c \
  33. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pwr_ex.c \
  34. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc.c \
  35. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_rcc_ex.c \
  36. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_spi.c \
  37. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_spi_ex.c \
  38. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart.c \
  39. Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_uart_ex.c \
  40. $(wildcard Drivers/enc28j60/src/*.c) \
  41. Src/main.c \
  42. Src/stm32f0xx_hal_msp.c \
  43. Src/stm32f0xx_it.c
  44. ASM_SOURCES = \
  45. Drivers/CMSIS/Device/ST/STM32F0xx/Source/Templates/gcc/startup_stm32f091xc.s
  46. #######################################
  47. # binaries
  48. #######################################
  49. CC = arm-none-eabi-gcc
  50. AS = arm-none-eabi-gcc -x assembler-with-cpp
  51. CP = arm-none-eabi-objcopy
  52. AR = arm-none-eabi-ar
  53. SZ = arm-none-eabi-size
  54. HEX = $(CP) -O ihex
  55. BIN = $(CP) -O binary -S
  56. #######################################
  57. # CFLAGS
  58. #######################################
  59. # macros for gcc
  60. AS_DEFS =
  61. C_DEFS = -D__weak=__attribute__\(\(weak\)\) -D__packed=__attribute__\(\(__packed__\)\) -DUSE_HAL_DRIVER -DSTM32F091xC -DSTM32F0xx
  62. # includes for gcc
  63. AS_INCLUDES =
  64. C_INCLUDES = -IInc
  65. C_INCLUDES += -IDrivers/STM32F0xx_HAL_Driver/Inc
  66. C_INCLUDES += -IDrivers/STM32F0xx_HAL_Driver/Inc/Legacy
  67. C_INCLUDES += -IDrivers/CMSIS/Include
  68. C_INCLUDES += -IDrivers/CMSIS/Device/ST/STM32F0xx/Include
  69. C_INCLUDES += -IDrivers/enc28j60/inc
  70. # compile gcc flags
  71. ASFLAGS = -mthumb -mcpu=cortex-m0 $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  72. CFLAGS = -mthumb -mcpu=cortex-m0 $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  73. ifeq ($(DEBUG), 1)
  74. CFLAGS += -g -gdwarf-2
  75. endif
  76. # Generate dependency information
  77. CFLAGS += -MD -MP -MF .dep/$(@F).d
  78. #######################################
  79. # LDFLAGS
  80. #######################################
  81. # link script
  82. LDSCRIPT = STM32F091RCTx_FLASH.ld
  83. # libraries
  84. LIBS = -lc -lm -lnosys
  85. LIBDIR =
  86. LDFLAGS = -mthumb -mcpu=cortex-m0 -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
  87. # default action: build all
  88. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
  89. #######################################
  90. # build the application
  91. #######################################
  92. # list of objects
  93. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  94. vpath %.c $(sort $(dir $(C_SOURCES)))
  95. # list of ASM program objects
  96. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  97. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  98. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  99. $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  100. $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
  101. $(AS) -c $(CFLAGS) $< -o $@
  102. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
  103. $(CC) $(OBJECTS) $(LDFLAGS) -o $@
  104. $(SZ) $@
  105. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  106. $(HEX) $< $@
  107. $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  108. $(BIN) $< $@
  109. $(BUILD_DIR):
  110. mkdir -p $@
  111. #######################################
  112. # clean up
  113. #######################################
  114. clean:
  115. -rm -fR .dep $(BUILD_DIR)
  116. #######################################
  117. # dependencies
  118. #######################################
  119. -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
  120. # *** EOF ***