175 lines
5.6 KiB
Makefile
175 lines
5.6 KiB
Makefile
|
VERSION = 2.12
|
||
|
DEFAULT_AVAILABLE_TARGETS = ec618_0h00 ec618_1h10
|
||
|
|
||
|
eq = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1)))
|
||
|
|
||
|
include $(TOP)/PLAT/device/target/board/$(TARGET)/$(CORE)/$(TARGET)_$(CORE).mk
|
||
|
include $(TOP)/PLAT/device/target/board/common/macro.mk
|
||
|
|
||
|
ifndef TARGET
|
||
|
$(warning "No TARGET specified. will use default ec618_0h00")
|
||
|
TARGET ?= ec618_0h00
|
||
|
endif
|
||
|
|
||
|
ifndef $(or RELEASE,DEBUG)
|
||
|
DEBUG = 5
|
||
|
endif
|
||
|
|
||
|
|
||
|
### Expand '*' available targets from example makefiles
|
||
|
TARGETS := $(subst *,%,$(filter %*,$(AVAILABLE_TARGETS)))
|
||
|
AVAILABLE_TARGETS := $(filter-out %*,$(AVAILABLE_TARGETS))
|
||
|
TARGETS := $(foreach target,$(TARGETS),$(filter $(TARGETS),$(DEFAULT_AVAILABLE_TARGETS)))
|
||
|
AVAILABLE_TARGETS += $(TARGETS)
|
||
|
AVAILABLE_TARGETS := $(sort $(AVAILABLE_TARGETS))
|
||
|
SELECTED_TARGET = $(strip $(foreach target,$(AVAILABLE_TARGETS),$(if $(call eq,$(TARGET),$(target)),$(target))))
|
||
|
###
|
||
|
|
||
|
ifeq ($(SELECTED_TARGET),)
|
||
|
$(info The selected target "$(TARGET)" is not supported or not available)
|
||
|
$(error Please set TARGET to one value from the list above: $(AVAILABLE_TARGETS))
|
||
|
endif
|
||
|
|
||
|
ifeq ($(V),1)
|
||
|
Q :=
|
||
|
ECHO := @true
|
||
|
else
|
||
|
Q := @
|
||
|
ECHO := @echo
|
||
|
endif
|
||
|
|
||
|
ifeq ($(BUILD_UNILOG),true)
|
||
|
%.pp: CFLAGS += -DDEBUG_LOG_HEADER_FILE="\"debug_log_dummy.h\""
|
||
|
%.o: CFLAGS += -DDEBUG_LOG_HEADER_FILE="\"debug_log_$(CORE).h\""
|
||
|
else
|
||
|
%.o: CFLAGS += -DDEBUG_LOG_HEADER_FILE="\"debug_log_dummy.h\""
|
||
|
endif
|
||
|
|
||
|
#-------------------------------------------------------------------------------
|
||
|
# Setup cross-compilation tools for GCC
|
||
|
#-------------------------------------------------------------------------------
|
||
|
ifeq ($(TOOLCHAIN),GCC)
|
||
|
|
||
|
# Tool suffix when cross-compiling
|
||
|
GCCLIB_PATH ?= C:/gcc
|
||
|
|
||
|
CROSS_COMPILE := $(GCCLIB_PATH)/bin/arm-none-eabi-
|
||
|
|
||
|
# Compilation tools
|
||
|
CC = $(CROSS_COMPILE)gcc
|
||
|
LD = $(CROSS_COMPILE)gcc
|
||
|
SIZE = $(CROSS_COMPILE)size
|
||
|
STRIP = $(CROSS_COMPILE)strip
|
||
|
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||
|
OBJDUMP = $(CROSS_COMPILE)objdump
|
||
|
GDB = $(CROSS_COMPILE)gdb
|
||
|
NM = $(CROSS_COMPILE)gcc-nm
|
||
|
AR = $(CROSS_COMPILE)gcc-ar
|
||
|
|
||
|
# Setup compilation params
|
||
|
|
||
|
#LITE_FEATURE_MODE, LSPD_FEATURE_MODE, LOW_SPEED_SERVICE_ONLY are rsvd for compatibility
|
||
|
ifeq ($(OPENCPU_MODE_ENABLE),y)
|
||
|
CFLAGS_DEFS += -DOPEN_CPU_MODE -DLITE_FEATURE_MODE -DLSPD_FEATURE_MODE -DLOW_SPEED_SERVICE_ONLY
|
||
|
endif
|
||
|
|
||
|
ifeq ($(LTO_FEATURE_ENABLE),y)
|
||
|
CFLAGS_DEFS += -DLTO_FEATURE_MODE
|
||
|
endif
|
||
|
|
||
|
ifeq ($(GCF_FEATURE_ENABLE),y)
|
||
|
CFLAGS_DEFS += -DGCF_FEATURE_MODE
|
||
|
endif
|
||
|
|
||
|
ifeq ($(MID_FEATURE_ENABLE),y)
|
||
|
CFLAGS_DEFS += -DMID_FEATURE_MODE
|
||
|
endif
|
||
|
|
||
|
ifeq (,$(findstring y,$(OPENCPU_MODE_ENABLE)_$(LTO_FEATURE_ENABLE)))
|
||
|
#CFLAGS += -fno-inline
|
||
|
#CFLAGS += -mslow-flash-data
|
||
|
endif
|
||
|
|
||
|
|
||
|
ifeq ($(LTO_FEATURE_ENABLE),y)
|
||
|
DISABLE_LTO_FLAG ?=
|
||
|
CFLAGS_CPU ?= -mcpu=cortex-m3 -mthumb -f$(DISABLE_LTO_FLAG)lto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -Wno-lto-type-mismatch
|
||
|
else
|
||
|
CFLAGS_CPU ?= -mcpu=cortex-m3 -mthumb
|
||
|
endif
|
||
|
|
||
|
CFLAGS_OPTION ?= -std=gnu99 -nostartfiles -mapcs-frame -specs=nano.specs
|
||
|
ifeq ($(GCC_OPTIMIZE_OPTIONS_O3),y)
|
||
|
CFLAGS_OPTIMIZE ?= -O3 -ffunction-sections -fdata-sections -fno-isolate-erroneous-paths-dereference -freorder-blocks-algorithm=stc
|
||
|
else
|
||
|
CFLAGS_OPTIMIZE ?= -Os -ffunction-sections -fdata-sections -fno-isolate-erroneous-paths-dereference -freorder-blocks-algorithm=stc
|
||
|
endif
|
||
|
CFLAGS_ANALYSIS ?= #-fanalyzer
|
||
|
CFLAGS_WARNING ?= -Wall -Wno-format
|
||
|
|
||
|
ifeq ($(SDK_REL)_$(CORE),true_ap)
|
||
|
CFLAGS_DEBUG ?= -g0
|
||
|
else
|
||
|
CFLAGS_DEBUG ?= -gdwarf-2
|
||
|
endif
|
||
|
|
||
|
# Trace level used for compilation
|
||
|
# (can be overriden by adding TRACE_LEVEL=#number to the command-line)
|
||
|
# TRACE_LEVEL_DEBUG 5
|
||
|
# TRACE_LEVEL_INFO 4
|
||
|
# TRACE_LEVEL_WARNING 3
|
||
|
# TRACE_LEVEL_ERROR 2
|
||
|
# TRACE_LEVEL_FATAL 1
|
||
|
# TRACE_LEVEL_NO_TRACE 0
|
||
|
ifdef DEBUG
|
||
|
TRACE_LEVEL ?= 5
|
||
|
CFLAGS_DEFS += -DTRACE_LEVEL=$(TRACE_LEVEL)
|
||
|
CFLAGS += -g3
|
||
|
CFLAGS_ASM += -g3
|
||
|
else
|
||
|
TRACE_LEVEL ?= 4
|
||
|
CFLAGS_DEFS += -DNDEBUG -DTRACE_LEVEL=$(TRACE_LEVEL)
|
||
|
endif
|
||
|
|
||
|
# compiler flags
|
||
|
CFLAGS += $(CFLAGS_CPU) $(CFLAGS_OPTION) $(CFLAGS_OPTIMIZE) $(CFLAGS_WARNING) $(CFLAGS_DEBUG) $(CFLAGS_ANALYSIS) -D__CURRENT_FILE_NAME__=$(basename $(@F))
|
||
|
|
||
|
CFLAGS_ASM = -Wall -D__ASSEMBLY__ -mthumb -gdwarf-2 #-mthumb-interwork
|
||
|
CFLAGS_DEFS += -DSOFTPACK_VERSION="\"$(SOFTPACK_VERSION)\"" -DHAVE_STRUCT_TIMESPEC
|
||
|
|
||
|
DEPFLAGS = -MMD -MP -MT $(basename $@).o -MF $(basename $@).d
|
||
|
|
||
|
# linker flags
|
||
|
ifeq ($(LTO_FEATURE_ENABLE),y)
|
||
|
LDFLAGS = -specs=nano.specs -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--print-memory-usage -t -t -u _exit
|
||
|
else
|
||
|
#LDFLAGS = -specs=nano.specs -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -lc -lm -Wl,--print-memory-usage
|
||
|
LDFLAGS = -specs=nano.specs -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--print-memory-usage
|
||
|
endif
|
||
|
LDFLAGS += -L $(TOP)/PLAT/device/target/board/$(TARGET)/ap/gcc
|
||
|
endif
|
||
|
|
||
|
#-------------------------------------------------------------------------------
|
||
|
# Setup cross-compilation tools for ARMCC
|
||
|
#-------------------------------------------------------------------------------
|
||
|
ifeq ($(TOOLCHAIN),ARMCC)
|
||
|
CROSS_COMPILE ?= C:/Keil_v53/ARM/ARMCC/bin/
|
||
|
|
||
|
# Compilation tools
|
||
|
CC = $(CROSS_COMPILE)armcc
|
||
|
LD = $(CROSS_COMPILE)armlink
|
||
|
AR = $(CROSS_COMPILE)armar
|
||
|
AS = $(CROSS_COMPILE)armasm
|
||
|
ELF= $(CROSS_COMPILE)fromelf
|
||
|
|
||
|
|
||
|
CFLAGS_CPU = --cpu Cortex-M3
|
||
|
CFLAGS = --c99 -c $(CFLAGS_CPU) -D__MICROLIB --li -g -D__ASSERT_MSG -Otime --apcs=interwork --split_sections --diag_suppress A1609 -D__CURRENT_FILE_NAME__=$(basename $(@F))
|
||
|
ASMFLAGS = $(CFLAGS_CPU) --li -g --apcs=interwork --pd "__MICROLIB SETA 1" --diag_suppress A1609
|
||
|
|
||
|
# linker flags
|
||
|
LDFLAGS = $(CFLAGS_CPU) --library_type=microlib --inline --strict --summary_stderr --info summarysizes --map --callgraph --symbols --info sizes --info totals --info veneers --info inline --diag_suppress=L6314,L6329
|
||
|
ARFLAGS = -r
|
||
|
ELFFLAGS = --i32
|
||
|
|
||
|
endif
|