Subversion Repositories DevTools

Rev

Rev 335 | Blame | Compare with Previous | Last modification | View Log | RSS feed

###############################################################################
# Module name   : TOOLSET/KeilArmV3
# Module type   : Makefile system
# Environment(s): KeilArmV3
#
#
###################################################################

###############################################################################
#..  Remove "undef" warnings
#
cc_includes     +=
cc_defines      +=
cxx_include     +=
cxx_defines     +=
as_includes     +=
as_defines      +=

###############################################################################
#..     Parse user options
#       Global options already parsed
#       These options extend the global options
#

ifdef OPTIONS

ifneq "$(findstring wall,$(OPTIONS))" ""        # Enable all warnings
USE_WALL        = 1
endif

ifneq "$(findstring list,$(OPTIONS))" ""        # Create Listings
USE_LIST        = 1
endif

endif

###############################################################################
#
#       Extend LIBDIRS with toolset libraries
#       Create a ';' separated list
#       Start with a space separated list
#               May need to change if KEIL_LIBS is to be installed
#               in a path with spaces in it.

LIB         := $(patsubst %,%;,$(LIBDIRS) $(KEIL_LIBS) )
export LIB


###############################################################################
#..     C Compiler definition
#

cc_filter := $(wildcard $(GBE_ROOT)/warnings.keil)
ifdef cc_filter
cc_redirect     = 1
cc_error_filter = $(awk) -f $(GBE_ROOT)/warnings.keil
endif


# Standard defines
#
#..
ifdef ALVL
arm_defines     += -DALVL=$(ALVL)
endif

ifdef DLVL
arm_defines     += -DDLVL=$(DLVL)
endif

arm_defines     += -D__SOURCE__=\"$(notdir $<)\"

# Standard flags
#
arm_flags       += --device=$(USE_DEVICE)
arm_flags       += -c --apcs=interwork

ifdef FORCE_C_COMPILE
arm_flags       += --c90
endif

ifdef FORCE_CC_COMPILE
arm_flags       += --cpp
endif

ifdef USE_THUMB
arm_flags       += --thumb
endif

ifdef USE_OPTIMISE                              # default for production
ifdef OPT_MODE
arm_flags       += -O$(OPT_MODE)
endif
else
arm_flags       += -O0
endif

ifdef USE_DEBUGINFO                             # default for debug
arm_flags       += -g
arm_defines     += -DDEBUG
else
arm_defines     += -DNDEBUG
endif

ifdef USE_STRICT_ANSI                           # default NO
arm_flags       += --strict
endif

ifdef LEAVETMP                                  # default NO
arm_flags       +=
endif

ifdef USE_LIST
arm_flags       += --list
endif

ifdef USE_WALL
arm_flags       +=
else
ifdef NOWARNLIST
arm_flags       += --diag_suppress $(subst $(comma),\$(comma),$(NOWARNLIST))
endif
endif

# Standard includes
#
#..

arm_includes    +=
arm_includes    += $(KEIL_INCLUDES)             # From Toolset Defs

###############################################################################
#..     C Compiler definition
#
cc              = $(CC_PRE) $(compiler)
cc_init         =
cc_o_switch     = -o $@
cc_source       = $<
cc_flags        = \
                $(patsubst %,%,$(CFLAGS)) \
                $(patsubst %,%,$(arm_flags)) \
                $(patsubst %,%,$(arm_defines)) \
                $(patsubst %,-D%,$(cc_defines)) \
                $(patsubst %,-I %,$(INCDIRS)) \
                $(patsubst %,-I %,$(cc_includes)) \
                $(patsubst %,-I %,$(arm_includes))
cc_term         =

define cc_pre
        @echo '[$<] compiling..'
endef

cc_post =

###############################################################################
#..     C++ Compiler definition
#
cxx             = $(CC_PRE) $(compiler)
cxx_init        =
cxx_o_switch    = -o $@
cxx_source      = $<
cxx_flags       = \
                $(patsubst %,%,$(CXXFLAGS)) \
                $(patsubst %,%,$(arm_flags)) \
                $(patsubst %,%,$(arm_defines)) \
                $(patsubst %,-d%,$(cxx_defines)) \
                $(patsubst %,-I %,$(INCDIRS)) \
                $(patsubst %,-I %,$(cxx_includes)) \
                $(patsubst %,-I %,$(arm_includes))

define cxx_pre
        @echo '[$<] compiling..'
endef

define cxx_post
endef

###############################################################################
#..     C/C++ dependencies
#
ccdep           = $(XX_PRE) $(GBE_BIN)/mkdepend
ccdep_init      =
ccdep_o_switch  = -f -
ccdep_flags     = -MM -b -We -p '$$(OBJDIR)/' -o ".$(o)"
ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $@ 2> $(OBJDIR)/depend.err

ccdep_flags     += \
                $(patsubst %,%,$(CFLAGS)) \
                $(patsubst %,%,$(arm_depend)) \
                $(patsubst %,%,$(arm_defines)) \
                $(patsubst %,-D%,$(cc_defines)) \
                $(patsubst %,-I %,$(INCDIRS)) \
                $(patsubst %,-I %,$(cc_includes)) \
                $(patsubst %,-Y %,$(arm_includes))
ccdep_pre       =
ccdep_post      =

###############################################################################
#..     Linker definition
#
ld              = $(CC_PRE) $(linker)
ld_init         =
ld_o_switch     = -o $@
ld_flags        =

ifeq ($(SHOWARGS),ALL)
ld_flags        += --show_cmdline
endif

ld_flags        += --device=$(USE_DEVICE) --strict  \
                $(patsubst %,%,$(LDFLAGS)) \
                $($(notdir $(basename $@))_ld) \
                --libpath=$(subst $(space),$(comma),$(KEIL_LIBS) ) \
                --diag_suppress L6373 \
                --summary_stderr 
                

ld_pre          = @echo '[$@] Linking..';
ld_post         =

################################################################################
#       Library dependency file generation
#       Use cmdfile to create a file that will be included in this makefile
#       The generated file will contain library path names that can only be
#       calculated on the fly
#
define LDDEPEND
        $(XX_PRE)$(cmdfile) -wkWeo$(@) "$($(DPLIST))"
endef

################################################################################
#..     Archiver Definitions
#
#..     Archiver
#
ar              = $(XX_PRE) $(librarian)
ar_init         =
ar_cmdfile      = $(basename $@).ar
ar_flags        =
ar_o_switch     = --via $(ar_cmdfile)

define ar_pre
        @$(echo) '[$@] Creating library archive..' ; \
        $(rm) -f $@ ;\
        $(cmdfile) -ko$(ar_cmdfile) \
                --create $@\\n\
                $(patsubst %,-r %\\n,$(filter %.o, $^))
endef

ifndef LEAVETMP
define ar_post
        @$(rm) -f $(ar_cmdfile)
endef
else
define ar_post
endef
endif


################################################################################
#..     Archive Merge
#       The archive tool can directly merge libaries
#
armerge              = $(XX_PRE) $(librarian)
armerge_init         =
armerge_flags        = --create $@ -r $^
armerge_o_switch     =

define armerge_pre
        @$(echo) '[$@] Creating a Merged library..' ; \
        $(rm) -f $@
endef

armerge_post         =

###############################################################################
#..     Assembler definition
#
#
as              = $(XX_PRE) $(assembler)
as_init         =
as_o_switch     = -o $@
as_source       = $<

asm_flags       += --device $(USE_DEVICE)
asm_flags       += --apcs=interwork

ifdef USE_THUMB
asm_flags       += --thumb
endif

asm_flags    += $(ASFLAGS)

ifdef as_defines
#asm_flags    += $(addprefix -D,$(as_defines))
endif

ifdef USE_DEBUGINFO
#asm_flags       += -DDEBUG
asm_flags       += --debug
else
#asm_flags       += -DNDEBUG
endif

as_flags        = $(asm_flags)
ifdef as_includes
as_flags       += "-I$(subst $(space),;,$(strip $(as_includes)))"
endif

as_flags       += $(patsubst %,-I%,$(INCDIRS))

ifdef USE_LIST
as_flags       += --xref --list $(addsuffix .lst, $(basename $(@F)))
endif

ifdef USE_WALL
as_flags        +=
else
ifdef NOWARNLIST
as_flags        += --diag_suppress $(subst $(comma),\$(comma),$(NOWARNLIST))
endif
endif

define as_pre
    @$(echo) '[$<] Assembling file..'
endef

define as_post
endef

###############################################################################
#..     Elf Conversion
#
#
define FROMELF
        @echo '[$@] Convert from ELF..';
        $(XX_PRE)$(fromelf) --bin --output $@ $<
endef