mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Update Makefile
This commit is contained in:
@@ -1,238 +1,246 @@
|
|||||||
|
|
||||||
ifndef model
|
ifndef model
|
||||||
model:=TS100
|
model:=TS100
|
||||||
endif
|
endif
|
||||||
OUTPUT_EXE=$(model)_$(lang)
|
OUTPUT_EXE=$(model)_$(lang)
|
||||||
ifndef lang
|
ifndef lang
|
||||||
lang:= EN
|
lang:= EN
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Discover the source files to build
|
# Discover the source files to build
|
||||||
SOURCE := $(shell find . -type f -name '*.c')
|
SOURCE := $(shell find . -type f -name '*.c')
|
||||||
SOURCE_CPP := $(shell find . -type f -name '*.cpp')
|
SOURCE_CPP := $(shell find . -type f -name '*.cpp')
|
||||||
SOURCES := $(shell find . -type f -name '*.c*')
|
SOURCES := $(shell find . -type f -name '*.c*')
|
||||||
S_SRCS := $(shell find . -type f -name '*.s')
|
S_SRCS := $(shell find . -type f -name '*.s')
|
||||||
|
|
||||||
APP_INC_DIR = ./Core/Inc
|
APP_INC_DIR = ./Core/Inc
|
||||||
CMSIS_DEVICE_INC_DIR = ./Drivers/CMSIS/Device/ST/STM32F1xx/Include
|
CMSIS_DEVICE_INC_DIR = ./Drivers/CMSIS/Device/ST/STM32F1xx/Include
|
||||||
CMSIS_CORE_INC_DIR = ./Drivers/CMSIS/Include
|
CMSIS_CORE_INC_DIR = ./Drivers/CMSIS/Include
|
||||||
HAL_INC_DIR = ./Drivers/STM32F1xx_HAL_Driver/Inc
|
HAL_INC_DIR = ./Drivers/STM32F1xx_HAL_Driver/Inc
|
||||||
HAL_LEGACY_INC_DIR = ./Drivers/STM32F1xx_HAL_Driver/Inc/Legacy
|
HAL_LEGACY_INC_DIR = ./Drivers/STM32F1xx_HAL_Driver/Inc/Legacy
|
||||||
FRTOS_CMIS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS
|
FRTOS_CMIS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS
|
||||||
FRTOS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/include
|
FRTOS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/include
|
||||||
FRTOS_GCC_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3
|
FRTOS_GCC_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3
|
||||||
|
DRIVER_INC_DIR =./Core/Drivers
|
||||||
INCLUDES = -I$(APP_INC_DIR) \
|
BSP_INC_DIR = ./Core/BSP
|
||||||
-I$(CMSIS_DEVICE_INC_DIR)\
|
MINIWARE_INC_DIR = ./Core/BSP/Miniware
|
||||||
-I$(CMSIS_CORE_INC_DIR) \
|
THREADS_INC_DIR = ./Core/Threads
|
||||||
-I$(HAL_INC_DIR) \
|
|
||||||
-I$(HAL_LEGACY_INC_DIR) \
|
INCLUDES = -I$(APP_INC_DIR) \
|
||||||
-I$(FRTOS_CMIS_INC_DIR) \
|
-I$(CMSIS_DEVICE_INC_DIR)\
|
||||||
-I$(FRTOS_INC_DIR) \
|
-I$(CMSIS_CORE_INC_DIR) \
|
||||||
-I$(FRTOS_GCC_INC_DIR)
|
-I$(HAL_INC_DIR) \
|
||||||
# output folder
|
-I$(HAL_LEGACY_INC_DIR) \
|
||||||
HEXFILE_DIR=Hexfile
|
-I$(FRTOS_CMIS_INC_DIR) \
|
||||||
|
-I$(FRTOS_INC_DIR) \
|
||||||
# temporary objects folder
|
-I$(FRTOS_GCC_INC_DIR) \
|
||||||
OUTPUT_DIR=Objects
|
-I$(DRIVER_INC_DIR) \
|
||||||
|
-I$(BSP_INC_DIR) \
|
||||||
# code optimisation ------------------------------------------------------------
|
-I$(MINIWARE_INC_DIR) \
|
||||||
OPTIM=-Os -flto -ffat-lto-objects -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections
|
-I$(THREADS_INC_DIR)
|
||||||
|
# output folder
|
||||||
|
HEXFILE_DIR=Hexfile
|
||||||
# global defines ---------------------------------------------------------------
|
|
||||||
GLOBAL_DEFINES += -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D LANG_$(lang) -D LANG -D MODEL_$(model)
|
# temporary objects folder
|
||||||
|
OUTPUT_DIR=Objects
|
||||||
# Enable debug code generation
|
|
||||||
DEBUG=-g3
|
# code optimisation ------------------------------------------------------------
|
||||||
# Without debug code
|
OPTIM=-Os -flto -ffat-lto-objects -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections
|
||||||
#DEBUG=
|
|
||||||
|
|
||||||
|
# global defines ---------------------------------------------------------------
|
||||||
# libs -------------------------------------------------------------------------
|
GLOBAL_DEFINES += -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D LANG_$(lang) -D LANG -D MODEL_$(model)
|
||||||
LIBS=
|
|
||||||
|
# Enable debug code generation
|
||||||
# linker script ----------------------------------------------------------------
|
DEBUG=-g3
|
||||||
LDSCRIPT=LinkerScript.ld
|
# Without debug code
|
||||||
|
#DEBUG=
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
COMPILER=gcc
|
|
||||||
# arm-none is the general ARM compiler,
|
# libs -------------------------------------------------------------------------
|
||||||
# arm-atollic is the atollic customised compilers if you have them setup
|
LIBS=
|
||||||
COMPILER_PREFIX=arm-none
|
|
||||||
# programs ---------------------------------------------------------------------
|
# linker script ----------------------------------------------------------------
|
||||||
CC=$(COMPILER_PREFIX)-eabi-gcc
|
LDSCRIPT=LinkerScript.ld
|
||||||
CPP=$(COMPILER_PREFIX)-eabi-g++
|
|
||||||
AS=$(COMPILER_PREFIX)-eabi-as
|
# ------------------------------------------------------------------------------
|
||||||
GCOV=$(COMPILER_PREFIX)-eabi-gcov
|
COMPILER=gcc
|
||||||
OBJCOPY=$(COMPILER_PREFIX)-eabi-objcopy
|
# arm-none is the general ARM compiler,
|
||||||
OBJDUMP=$(COMPILER_PREFIX)-eabi-objdump
|
# arm-atollic is the atollic customised compilers if you have them setup
|
||||||
SIZE=$(COMPILER_PREFIX)-eabi-size
|
COMPILER_PREFIX=arm-none
|
||||||
SREC=srec_cat
|
# programs ---------------------------------------------------------------------
|
||||||
SREC_INFO=srec_info
|
CC=$(COMPILER_PREFIX)-eabi-gcc
|
||||||
|
CPP=$(COMPILER_PREFIX)-eabi-g++
|
||||||
|
AS=$(COMPILER_PREFIX)-eabi-as
|
||||||
|
GCOV=$(COMPILER_PREFIX)-eabi-gcov
|
||||||
|
OBJCOPY=$(COMPILER_PREFIX)-eabi-objcopy
|
||||||
# linker flags -----------------------------------------------------------------
|
OBJDUMP=$(COMPILER_PREFIX)-eabi-objdump
|
||||||
LINKER_FLAGS=-Wl,--gc-sections \
|
SIZE=$(COMPILER_PREFIX)-eabi-size
|
||||||
-o$(OUT_HEXFILE).elf \
|
SREC=srec_cat
|
||||||
-Wl,-Map=$(OUT_HEXFILE).map \
|
SREC_INFO=srec_info
|
||||||
-mcpu=cortex-m3 \
|
|
||||||
-mthumb \
|
|
||||||
-mfloat-abi=soft \
|
|
||||||
-lm -Os -flto -Wl,--undefined=vTaskSwitchContext \
|
|
||||||
--specs=nano.specs
|
# linker flags -----------------------------------------------------------------
|
||||||
|
LINKER_FLAGS=-Wl,--gc-sections \
|
||||||
# compiler flags ---------------------------------------------------------------
|
-o$(OUT_HEXFILE).elf \
|
||||||
CPUFLAGS=-D GCC_ARMCM3 \
|
-Wl,-Map=$(OUT_HEXFILE).map \
|
||||||
-D ARM_MATH_CM3 \
|
-mcpu=cortex-m3 \
|
||||||
-D STM32F10X_MD \
|
-mthumb \
|
||||||
-mthumb \
|
-mfloat-abi=soft \
|
||||||
-mcpu=cortex-m3 \
|
-lm -Os -flto -Wl,--undefined=vTaskSwitchContext \
|
||||||
-mfloat-abi=soft
|
--specs=nano.specs
|
||||||
|
|
||||||
|
# compiler flags ---------------------------------------------------------------
|
||||||
|
CPUFLAGS=-D GCC_ARMCM3 \
|
||||||
CHECKOPTIONS= -Wall \
|
-D ARM_MATH_CM3 \
|
||||||
-Wextra \
|
-D STM32F10X_MD \
|
||||||
-Wunused \
|
-mthumb \
|
||||||
-Wcomment \
|
-mcpu=cortex-m3 \
|
||||||
-Wtrigraphs \
|
-mfloat-abi=soft
|
||||||
-Wuninitialized \
|
|
||||||
-Wmissing-braces \
|
|
||||||
-Wfloat-equal \
|
|
||||||
-Wunreachable-code \
|
CHECKOPTIONS= -Wall \
|
||||||
-Wswitch-default \
|
-Wextra \
|
||||||
-Wreturn-type \
|
-Wunused \
|
||||||
-Wundef \
|
-Wcomment \
|
||||||
-Wparentheses \
|
-Wtrigraphs \
|
||||||
-Wnonnull \
|
-Wuninitialized \
|
||||||
-Winit-self \
|
-Wmissing-braces \
|
||||||
-Wmissing-include-dirs \
|
-Wfloat-equal \
|
||||||
-Wsequence-point \
|
-Wunreachable-code \
|
||||||
-Wswitch \
|
-Wswitch-default \
|
||||||
-Wformat \
|
-Wreturn-type \
|
||||||
-Wsign-compare \
|
-Wundef \
|
||||||
-Waddress \
|
-Wparentheses \
|
||||||
-Waggregate-return \
|
-Wnonnull \
|
||||||
-Wmissing-field-initializers \
|
-Winit-self \
|
||||||
-Winline \
|
-Wmissing-include-dirs \
|
||||||
-Wshadow \
|
-Wsequence-point \
|
||||||
-Wno-unused-parameter \
|
-Wswitch \
|
||||||
-Wdouble-promotion
|
-Wformat \
|
||||||
|
-Wsign-compare \
|
||||||
|
-Waddress \
|
||||||
CHECKOPTIONS_C= -Wbad-function-cast
|
-Waggregate-return \
|
||||||
|
-Wmissing-field-initializers \
|
||||||
|
-Winline \
|
||||||
CXXFLAGS=$(CPUFLAGS) \
|
-Wshadow \
|
||||||
$(DEBUG) \
|
-Wno-unused-parameter \
|
||||||
$(INCLUDES) \
|
-Wdouble-promotion
|
||||||
$(GLOBAL_DEFINES) \
|
|
||||||
-D${COMPILER} \
|
|
||||||
-MMD \
|
CHECKOPTIONS_C= -Wbad-function-cast
|
||||||
$(CHECKOPTIONS) \
|
|
||||||
-std=c++11 \
|
|
||||||
$(OPTIM) \
|
CXXFLAGS=$(CPUFLAGS) \
|
||||||
-fno-common \
|
$(DEBUG) \
|
||||||
-ffreestanding \
|
$(INCLUDES) \
|
||||||
-fno-rtti \
|
$(GLOBAL_DEFINES) \
|
||||||
-fno-exceptions \
|
-D${COMPILER} \
|
||||||
-fno-non-call-exceptions \
|
-MMD \
|
||||||
-fno-use-cxa-atexit \
|
$(CHECKOPTIONS) \
|
||||||
-fno-strict-aliasing \
|
-std=c++11 \
|
||||||
-fno-rtti \
|
$(OPTIM) \
|
||||||
-fno-exceptions \
|
-fno-common \
|
||||||
-fno-threadsafe-statics \
|
-ffreestanding \
|
||||||
-T$(LDSCRIPT)
|
-fno-rtti \
|
||||||
|
-fno-exceptions \
|
||||||
|
-fno-non-call-exceptions \
|
||||||
CFLAGS=$(CPUFLAGS) \
|
-fno-use-cxa-atexit \
|
||||||
$(DEBUG) \
|
-fno-strict-aliasing \
|
||||||
$(INCLUDES) \
|
-fno-rtti \
|
||||||
$(CHECKOPTIONS_C) \
|
-fno-exceptions \
|
||||||
$(GLOBAL_DEFINES) \
|
-fno-threadsafe-statics \
|
||||||
-D${COMPILER} \
|
-T$(LDSCRIPT)
|
||||||
-MMD \
|
|
||||||
-std=gnu99 \
|
|
||||||
$(OPTIM) \
|
CFLAGS=$(CPUFLAGS) \
|
||||||
-fno-common \
|
$(DEBUG) \
|
||||||
-ffreestanding \
|
$(INCLUDES) \
|
||||||
-T$(LDSCRIPT) \
|
$(CHECKOPTIONS_C) \
|
||||||
-c
|
$(GLOBAL_DEFINES) \
|
||||||
|
-D${COMPILER} \
|
||||||
|
-MMD \
|
||||||
AFLAGS=$(CPUFLAGS) \
|
-std=gnu99 \
|
||||||
$(DEBUG) \
|
$(OPTIM) \
|
||||||
$(INCLUDES)
|
-fno-common \
|
||||||
|
-ffreestanding \
|
||||||
|
-T$(LDSCRIPT) \
|
||||||
ifeq (${COMPILER}, gcc)
|
-c
|
||||||
AFLAGS += -ffunction-sections -fdata-sections
|
|
||||||
CFLAGS += -ffunction-sections -fdata-sections
|
|
||||||
endif
|
AFLAGS=$(CPUFLAGS) \
|
||||||
|
$(DEBUG) \
|
||||||
|
$(INCLUDES)
|
||||||
|
|
||||||
OBJS = $(SOURCE:.c=.o)
|
|
||||||
OBJS_CPP = $(SOURCE_CPP:.cpp=.o)
|
ifeq (${COMPILER}, gcc)
|
||||||
OBJS_S = $(S_SRCS:.s=.o)
|
AFLAGS += -ffunction-sections -fdata-sections
|
||||||
|
CFLAGS += -ffunction-sections -fdata-sections
|
||||||
|
endif
|
||||||
|
|
||||||
OUT_OBJS=$(addprefix $(OUTPUT_DIR)/,$(OBJS))
|
|
||||||
OUT_OBJS_CPP=$(addprefix $(OUTPUT_DIR)/,$(OBJS_CPP))
|
|
||||||
OUT_OBJS_S=$(addprefix $(OUTPUT_DIR)/,$(OBJS_S))
|
OBJS = $(SOURCE:.c=.o)
|
||||||
OUT_HEXFILE=$(addprefix $(HEXFILE_DIR)/,$(OUTPUT_EXE))
|
OBJS_CPP = $(SOURCE_CPP:.cpp=.o)
|
||||||
|
OBJS_S = $(S_SRCS:.s=.o)
|
||||||
all: $(OUT_HEXFILE).hex $(OUT_HEXFILE).bin
|
|
||||||
|
|
||||||
#
|
|
||||||
# The rule to create the target directory
|
OUT_OBJS=$(addprefix $(OUTPUT_DIR)/,$(OBJS))
|
||||||
#
|
OUT_OBJS_CPP=$(addprefix $(OUTPUT_DIR)/,$(OBJS_CPP))
|
||||||
|
OUT_OBJS_S=$(addprefix $(OUTPUT_DIR)/,$(OBJS_S))
|
||||||
# Create hexfile
|
OUT_HEXFILE=$(addprefix $(HEXFILE_DIR)/,$(OUTPUT_EXE))
|
||||||
%.hex : %.elf
|
|
||||||
$(SIZE) $^
|
all: $(OUT_HEXFILE).hex $(OUT_HEXFILE).bin
|
||||||
$(OBJCOPY) $^ -O ihex $@
|
|
||||||
|
#
|
||||||
%.bin : %.elf
|
# The rule to create the target directory
|
||||||
$(SIZE) $^
|
#
|
||||||
$(OBJCOPY) $^ -O binary $@
|
|
||||||
|
# Create hexfile
|
||||||
$(OUT_HEXFILE).elf : $(OUT_OBJS) $(OUT_OBJS_CPP) $(OUT_OBJS_S) Makefile $(LDSCRIPT)
|
%.hex : %.elf
|
||||||
@test -d $(@D) || mkdir -p $(@D)
|
$(SIZE) $^
|
||||||
@echo Linking $(OUTPUT_EXE).elf
|
$(OBJCOPY) $^ -O ihex $@
|
||||||
@$(CPP) $(CXXFLAGS) $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) $(LIBS) $(LINKER_FLAGS)
|
|
||||||
|
%.bin : %.elf
|
||||||
$(OUT_OBJS): $(OUTPUT_DIR)/%.o : %.c Makefile
|
$(SIZE) $^
|
||||||
@test -d $(@D) || mkdir -p $(@D)
|
$(OBJCOPY) $^ -O binary $@
|
||||||
@echo Compiling ${<}
|
|
||||||
# @echo $(CFLAGS)
|
$(OUT_HEXFILE).elf : $(OUT_OBJS) $(OUT_OBJS_CPP) $(OUT_OBJS_S) Makefile $(LDSCRIPT)
|
||||||
@$(CC) -c $(CFLAGS) $< -o $@
|
@test -d $(@D) || mkdir -p $(@D)
|
||||||
@$(OBJDUMP) -d -S $@ > $@.lst
|
@echo Linking $(OUTPUT_EXE).elf
|
||||||
|
@$(CPP) $(CXXFLAGS) $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) $(LIBS) $(LINKER_FLAGS)
|
||||||
$(OUT_OBJS_CPP): $(OUTPUT_DIR)/%.o : %.cpp Makefile
|
|
||||||
@test -d $(@D) || mkdir -p $(@D)
|
$(OUT_OBJS): $(OUTPUT_DIR)/%.o : %.c Makefile
|
||||||
@echo Compiling ${<}
|
@test -d $(@D) || mkdir -p $(@D)
|
||||||
@$(CPP) -c $(CXXFLAGS) $< -o $@
|
@echo Compiling ${<}
|
||||||
@$(OBJDUMP) -d -S $@ > $@.lst
|
# @echo $(CFLAGS)
|
||||||
|
@$(CC) -c $(CFLAGS) $< -o $@
|
||||||
$(OUT_OBJS_S): $(OUTPUT_DIR)/%.o: %.s Makefile
|
@$(OBJDUMP) -d -S $@ > $@.lst
|
||||||
@test -d $(@D) || mkdir -p $(@D)
|
|
||||||
@echo 'Building file: $<'
|
$(OUT_OBJS_CPP): $(OUTPUT_DIR)/%.o : %.cpp Makefile
|
||||||
@echo 'Invoking: MCU GCC Assembler'
|
@test -d $(@D) || mkdir -p $(@D)
|
||||||
@$(AS) -mcpu=cortex-m3 -mthumb -mfloat-abi=soft $(INCLUDES) -g $< -o $@
|
@echo Compiling ${<}
|
||||||
@echo 'Finished building: $<'
|
@$(CPP) -c $(CXXFLAGS) $< -o $@
|
||||||
@echo ' '
|
@$(OBJDUMP) -d -S $@ > $@.lst
|
||||||
|
|
||||||
|
$(OUT_OBJS_S): $(OUTPUT_DIR)/%.o: %.s Makefile
|
||||||
clean :
|
@test -d $(@D) || mkdir -p $(@D)
|
||||||
rm -Rf $(OUTPUT_DIR)
|
@echo 'Building file: $<'
|
||||||
rm -Rf $(HEXFILE_DIR)
|
@echo 'Invoking: MCU GCC Assembler'
|
||||||
|
@$(AS) -mcpu=cortex-m3 -mthumb -mfloat-abi=soft $(INCLUDES) -g $< -o $@
|
||||||
# pull in dependency info for *existing* .o files
|
@echo 'Finished building: $<'
|
||||||
-include $(OUT_OBJS:.o=.d)
|
@echo ' '
|
||||||
-include $(OUT_OBJS_CPP:.o=.d)
|
|
||||||
|
|
||||||
|
clean :
|
||||||
|
rm -Rf $(OUTPUT_DIR)
|
||||||
|
rm -Rf $(HEXFILE_DIR)
|
||||||
|
|
||||||
|
# pull in dependency info for *existing* .o files
|
||||||
|
-include $(OUT_OBJS:.o=.d)
|
||||||
|
-include $(OUT_OBJS_CPP:.o=.d)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user