Subversion Repositories DevTools

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

# -*- mode: mak -*-
###############################################################################
# Module name   : TOOLSET/KeilC51V41
# Module type   : Makefile system
# Environment(s): KeilC51V41
#
# Version   Who   Date      Description
#           DDP   04-Jan-05 Created
#
###################################################################

###############################################################################
#..  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

endif

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

###############################################################################
#..  C Compiler definition
#   Notes:
#   The Keil compiler has a specific ordering of files on the command line
#   The standard definitions are bent to fit
#
#   The compiler does not support specification of include directories
#   on the command line. They are done via the C51INC environment variable
#
#   The compiler defines __C51__
#
#   The shell used by make needs the XX() constructs to be esacped
#
#   The compiler does not take include files on the command line
#   These MUST be passed via the environment variable C51INC
#
#   Convert user CFLAGS from -Dxxxx -> DF(xxxx)
#
#   The command line is VERY limited
#   Use abbreviations at all times
#
#

cc              = $(CC_PRE) export C51INC;\
           C51INC="$(subst $(space),$(semicolon),$(INCDIRS) $(strip $(cc_includes) $(keil_includes)))";\
           $(C51BIN)/C51.EXE
cc_init         =
cc_o_switch     =
cc_source =
cc_flags = $(cc_ksource) $(cc_kflags) 'OJ($@)'
cc_term = ; rv=$$?;if [ $$rv -gt 1 ] ; then false; else true; fi
cc_ksource      = $<

#
#   Process CFLAGS into those with a -D prefix and all others
#   Merge the -Ddefinition into one argument to save command line space
#
cc_kdefs = $(subst $(space),$(comma),$(patsubst -D%,%,$(filter -D%,$(CFLAGS)$(cc_defines))))
cc_kother = $(filter-out -D%,$(CFLAGS))

cc_kflags       = \
        $(patsubst %,'DF(%),$(cc_kdefs))' \
                $(patsubst %,'%',$(cc_kother)) \
                $(patsubst %,'%',$(keil_flags))

keil_flags      = LA RB(0)

ifdef USE_WALL
keil_flags      +=
endif

ifdef USE_STRICT_ANSI
keil_flags       += NOEXTEND
endif

ifdef USE_OPTIMISE
keil_flags += OT(5,SIZE)
else
keil_flags += OT(5,SIZE)
endif

ifdef USE_DEBUGINFO
keil_flags       += DB
cc_defines       += -DDEBUG
else
cc_defines       += -DNDEBUG
endif

ifeq "$(DEBUG)" "1"
keil_flags      +=
else
keil_flags      +=
endif

#   Removed due to command line limitations
#
#ifdef ALVL
#cc_defines     += ALVL=$(ALVL)
#endif
#
#ifdef DLVL
#cc_defines     += DLVL=$(DLVL)
#endif
#
#cc_defines  += __SOURCE__=\"$(notdir $<)\"

ifdef LEAVETMP
#keil_flags     += PRINT
else
keil_flags      += NOPR
endif

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

define cc_post
endef

###############################################################################
#..     C/C++ dependencies
#       depend and depend.err
#
#    -M         Generate make dependencies
#    -MM        As -M, but ignore system header files
#    -MG        Treat missing header files as generated
#

ifeq "$(DEBUG)" "1"
cc_depend       += -DDEBUG
endif
ifdef ALVL
cc_depend       += -DALVL=$(ALVL)
endif
ifdef DLVL
cc_depend       += -DDLVL=$(DLVL)
endif

ccdep           = $(XX_PRE) $(GBE_BIN)/mkdepend
ccdep_o_switch  = -f -
ccdep_init      =
#ccdep_source   = $(filter %.c %.cc %.cpp, $+) > $(subst /,/,$@).tmp 2> $@.err
ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $@ 2> $@.err
ccdep_flags     = -MM -b -p '$$(OBJDIR)/' -o ".$(o)" \
        -D__C51__ \
                $(patsubst %,%,$(CFLAGS)) \
                $(patsubst %,-D%,$(cc_defines)) \
                $(patsubst %,%,$(cc_depend)) \
                $(patsubst %,-I %,$(INCDIRS)) \
                $(patsubst %,-I %,$(cc_includes)) \
                $(patsubst %,-Y %,$(keil_includes))
ccdep_pre       =
ccdep_post      =


###############################################################################
#.. Archiver
#   The librarian appears to only handle one command at a time
#   The librarian has severe command line length limits
#
ar              = $(XX_PRE) $(C51BIN)/LIB51 create $@ ;\
                  for obj in $(filter %.o51, $^); do \
                    $(C51BIN)/LIB51 ADD $$obj to $@ ;\
                    rv=$$?;\
                    if [ $$rv -gt 0 ] ; then \
                        echo "Error creating library: $@";\
                        rm -f $@;\
                        exit 1 ;\
                    fi;\
                  done
ar_init         =
ar_flags        =
ar_o_switch     =
ar_term         =

define ar_pre
        $(echo) [\$@] Creating library archive.. ; \
        $(rm) -f $@
endef

ar_post =

###############################################################################
#..     Archive Merge
#   The librarian appears to only handle one command at a time
#   It does not appear to handle multiple libraries in a merge
#
armerge         = $(XX_PRE) $(C51BIN)/LIB51 create $@ ;\
                  for lib in $(filter %.lib, $^); do \
                    $(C51BIN)/LIB51 ADD $$lib to $@ ;\
                    rv=$$?;\
                    if [ $$rv -gt 0 ] ; then \
                        echo "Error creating Merge library: $@";\
                        rm -f $@;\
                        exit 1 ;\
                    fi;\
                  done
armerge_init    =
armerge_flags   =
armerge_o_switch=

define  armerge_pre
        @$(echo) [\$@] Merging library archive..
        $(XX_PRE) rm -f $@
endef

armerge_post =

###############################################################################
#..     Assembler definition
#       Although the assembler is not currently supported the following
#       definition is required by the make system
#
as_init         =



#