Reorganizing project
This commit is contained in:
parent
2d6567b1b2
commit
76ba80db36
51 changed files with 139 additions and 266 deletions
50
Makefile
50
Makefile
|
@ -29,6 +29,8 @@ CXXSTD = -std=c++14
|
|||
#######################################
|
||||
# Build path
|
||||
BUILD_DIR = build
|
||||
COMPONENTS = components
|
||||
CONFIG_OVERRIDES = config-overrides
|
||||
|
||||
######################################
|
||||
# source
|
||||
|
@ -49,8 +51,8 @@ Src/usart.c \
|
|||
Src/usb_otg.c \
|
||||
Src/stm32f4xx_it.c \
|
||||
Src/stm32f4xx_hal_msp.c \
|
||||
$(wildcard app/*.c) \
|
||||
$(wildcard lib/*.c) \
|
||||
$(wildcard App/*.c) \
|
||||
$(wildcard Lib/*.c) \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_gpio.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_crc.c \
|
||||
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dma.c \
|
||||
|
@ -93,8 +95,15 @@ ASM_SOURCES = \
|
|||
startup_stm32f407xx.s
|
||||
|
||||
CXX_SOURCES = \
|
||||
$(wildcard app/*.cpp) \
|
||||
$(wildcard lib/*.cpp)
|
||||
$(wildcard App/*.cpp) \
|
||||
$(wildcard Lib/*.cpp)
|
||||
|
||||
|
||||
#######################################
|
||||
# components
|
||||
#######################################
|
||||
include $(sort $(wildcard $(COMPONENTS)/*/component.mk))
|
||||
|
||||
|
||||
#######################################
|
||||
# binaries
|
||||
|
@ -104,14 +113,16 @@ PREFIX = arm-none-eabi-
|
|||
# either it can be added to the PATH environment variable.
|
||||
ifdef GCC_PATH
|
||||
CC = $(GCC_PATH)/$(PREFIX)gcc
|
||||
CXXC = $(GCC_PATH)/$(PREFIX)gcc -x c++
|
||||
CXXC = $(GCC_PATH)/$(PREFIX)g++
|
||||
LD = $(GCC_PATH)/$(PREFIX)g++
|
||||
AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
|
||||
CP = $(GCC_PATH)/$(PREFIX)objcopy
|
||||
SZ = $(GCC_PATH)/$(PREFIX)size
|
||||
else
|
||||
CC = $(PREFIX)gcc
|
||||
CXXC = $(PREFIX)gcc -x c++
|
||||
CXXC = $(PREFIX)g++
|
||||
AS = $(PREFIX)gcc -x assembler-with-cpp
|
||||
LD = $(PREFIX)g++
|
||||
CP = $(PREFIX)objcopy
|
||||
SZ = $(PREFIX)size
|
||||
endif
|
||||
|
@ -161,8 +172,8 @@ COMMON_INCLUDES = \
|
|||
-IMiddlewares/Third_Party/FatFs/src \
|
||||
-IDrivers/CMSIS/Device/ST/STM32F4xx/Include \
|
||||
-IDrivers/CMSIS/Include \
|
||||
-Ilib \
|
||||
-Iapp
|
||||
-IApp \
|
||||
-ILib
|
||||
|
||||
C_INCLUDES = \
|
||||
|
||||
|
@ -194,7 +205,22 @@ LDSCRIPT = STM32F407VETx_FLASH.ld
|
|||
# libraries
|
||||
LIBS = -lc -lm -lnosys
|
||||
LIBDIR =
|
||||
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
|
||||
#LDFLAGS = $(MCU) --specs=nosys.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections -static --specs=nano.specs
|
||||
LDFLAGS = $(MCU) -TSTM32F407VETX_FLASH.ld --specs=nosys.specs -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections -static --specs=nano.specs \
|
||||
-Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group
|
||||
|
||||
ifeq ($(MKDBG), 1)
|
||||
$(info >>--------------------------------------------)
|
||||
$(info $$C_SOURCES is [${C_SOURCES}])
|
||||
$(info .)
|
||||
$(info $$CXX_SOURCES is [${CXX_SOURCES}])
|
||||
$(info .)
|
||||
$(info $$C_DEFS is [${C_DEFS}])
|
||||
$(info .)
|
||||
$(info $$C_INCLUDES is [${C_INCLUDES}])
|
||||
$(info $$CFLAGS is [${CFLAGS}])
|
||||
$(info <<--------------------------------------------)
|
||||
endif
|
||||
|
||||
# default action: build all
|
||||
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
|
||||
|
@ -208,10 +234,10 @@ OBJECTS = $(addprefix $(BUILD_DIR)/,$(C_SOURCES:.c=.o))
|
|||
vpath %.c $(sort $(dir $(C_SOURCES)))
|
||||
|
||||
# list of ASM program objects
|
||||
OBJECTS +=$(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
|
||||
OBJECTS +=$(addprefix $(BUILD_DIR)/,$(ASM_SOURCES:.s=.o))
|
||||
vpath %.s $(sort $(dir $(ASM_SOURCES)))
|
||||
|
||||
OBJECTS +=$(addprefix $(BUILD_DIR)/,$(notdir $(CXX_SOURCES:.cpp=.o)))
|
||||
OBJECTS +=$(addprefix $(BUILD_DIR)/,$(CXX_SOURCES:.cpp=.o))
|
||||
vpath %.cpp $(sort $(dir $(CXX_SOURCES)))
|
||||
|
||||
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
|
||||
|
@ -227,7 +253,7 @@ $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
|
|||
$(AS) -c $(CFLAGS) $< -o $@
|
||||
|
||||
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
|
||||
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
|
||||
$(LD) $(OBJECTS) $(LDFLAGS) -o $@
|
||||
$(SZ) $@
|
||||
|
||||
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue