Subversion Repositories DevTools

Rev

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

###############################################################################
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
#
# File:         TOOLSET/m16c.rul[e]
# Contents:     m16c rules
#               Make definitions for the m16c tools.
#
# Description:
#       This file provides Toolset rules for the target makefiles
#       The file is dropped into the target makefile
#
# Revision History:
#       26-Oct-05   DDP     Started Work
###############################################################################

###############################################################################
#..     Remove "undef" warnings
#
cc_includes     +=
cc_defines      +=
cc_opts         +=
cxx_includes    +=
cxx_defines     +=

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

###############################################################################
#..     C Compiler definition
#
#
#   Compiler flags
#
#
#   -c              - Compile only
#   -Dxxx           - Preprocessor define
#   -Uxxx           - Preprocessor undefine
#   -Ixxx           - Extends include file path ( limit to 8 )
#   -g              - Outputs debug info to an assembler source file (extension .a30).
#   -silent         - Suppresses the copyright message display at startup.
#   -fETI           - Extends char-type or signed char-type data to int-type
#                     data to perform operation (extension as per ANSI rules)
#   -OS             - Optimise for Speed
#   -OR             - Optimise for Rom size
#   -dir xxx        - Output directory name

#
cc              = $(CC_PRE) $(Compiler)
cc_init         =
cc_o_switch     = -dir $(@D)
cc_source_file  = $<
cc_source       =  $(subst /,\\,$(cc_source_file))
cc_flags        = -silent -c -fETI $(CFLAGS)
cc_flags       += $(cc_opts) $(cc_defines) $(cc_includes)

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

ifneq ($(SHOWARGS),NONE)
cc_opts       += -v
endif

ifdef LEAVETMP
cc_opts       += -g
endif

#ifdef USE_STRICT_ANSI
#cc_opts       +=
#else
#cc_opts       +=
#endif

ifdef USE_OPTIMISE
cc_opts       += -OS
else
endif

ifdef USE_DEBUGINFO
cc_opts       += -g -DDEBUG
else
cc_opts       += -DNDEBUG -UDEBUG
endif

ifeq "$(DEBUG)" "1"
cc_opts       += -DKD30=1
else
cc_opts       += -DKD30=0
endif

ifdef ALVL
cc_opts       += -DALVL=$(ALVL)
endif

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

cc_opts       += -D__SOURCE__=$(notdir $<)

cc_includes    = $(patsubst %,-I%,$(INCDIRS))

cc_pre = @$(echo) [$<] compiling..
cc_post =

###############################################################################
#       Compiler sanity test
#       It can only handle 16 include paths
#       Create an error if there are too many
#
ifneq ($(word 17, $(INCDIRS)),)
$(info ERROR. Too many included directories for the MCR compiler)
$(info $(space)      The limit is 16. Complete list is:)
$(foreach aa,$(INCDIRS), $(info $(space)       $(aa)))
$(error Too many included directories for the MCR compiler)
endif

###############################################################################
#..     C/C++ dependencies
#       depend and depend.err
#
ccdep           = $(XX_PRE) $(GBE_BIN)/mkdepend
ccdep_init      =
ccdep_o_switch  = -f -
ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $@ 2> $@.err
ccdep_flags     = -MM -b -p \$$\(OBJDIR\)/ \
                  $(foreach shname,$(SHNAMES),-p '$$(OBJDIR)/$(shname)/') \
                  -o .$(o) \
                  $(patsubst %,%,$(CFLAGS)) \
                  $(patsubst %,-D%,$(cc_defines)) \
                  $(patsubst %,-I %,$(INCDIRS)) \
                  $(patsubst %,-Y %,$(subst \,/,$(INC30))) \
                  $(patsubst %,-Y %,$(NODEPDIRS))
ccdep_pre       =
ccdep_post      =


###############################################################################
#..     Assembler definition
#
#   Note: The assembler command line is limited in length and the command
#         does not accept a command file
#
#         Do not include INCDIRS as this will blow the command line length
#         The assumption is that assember use is trivial and does not
#         need include paths
#

as              = $(XX_PRE) $(Assembler)
as_init         =
as_o_switch     = -O$(subst /,\\,$(@D))
as_source       = $(subst /,\\,$<)

as_flags       = -M -. -L
as_flags      += $(ASFLAGS)

ifeq "$(DEBUG)" "1"
as_flags       += -DKD30=1
else
as_flags       += -DKD30=0
endif

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

as_pre          = @$(echo) [$@] Assembling file ...
as_post         =


#..     Archiver
#
ar              = $(XX_PRE) $(m16c_librarian)
ar_init         =
ar_cmdfile      = $(basename $@).ar
ar_flags        =
ar_o_switch     = @$(ar_cmdfile)

define ar_pre
        @$(echo) [\$@] Creating library archive.. ; \
        $(rm) -f $@ ;\
        $(cmdfile) -ko$(ar_cmdfile) \
                -. -C $@\\n\
                $(subst /,\\\\,$(patsubst %,%\\n,$(filter %.R30, $^)))\
                \\n
endef

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


#..     Archive Merge
#       Not currently supported
#       No reason for this - just no need yet


#..     Linker
#
ld              = $(XX_PRE) $(Linker)
ld_cmdfile      = $(basename $@).ld
ld_flags        = @$(ld_cmdfile)
ld_o_switch     =

define ld_pre
        $(echo) [$@] Linking program .. ;\
        export M16C_LIB; \
                M16C_LIB="$(subst /,\\,$(subst $(space),;,$(LIBDIRS)))"; \
        $(cmdfile) -ko$(ld_cmdfile) "$($(notdir $(SHBASE))_ld)"
endef

ifndef LEAVETMP
define ld_post
        $(call MCRFLASHEND,$@,$(BINDIR)/${SHBASE}.map,$($(notdir $(SHBASE))_FlashEnd))
        @$(rm) -f $(ld_cmdfile)
endef
else
define ld_post
        $(call MCRFLASHEND,$@,$(BINDIR)/${SHBASE}.map,$($(notdir $(SHBASE))_FlashEnd))
endef
endif

#..     Create Library dependency file
#
define LDDEPEND
        $(XX_PRE) export M16C_LIB; \
                M16C_LIB="$(subst $(space),;,$(LIBDIRS))"; \
        $(cmdfile) -ko$(@) "$($(DPLIST))";
endef

#
#   Use the mcrflashend.pl tool to verify that the flash memory has not overflowed
#       $1      - Name of the build target
#       $2      - Map file
#       $3      - The first invalid flash address in hex
#
ifdef TOOL_MCRFLASHEND
define MCRFLASHEND
        $(XX_PRE)$(GBE_PERL) $(TOOL_MCRFLASHEND) -n "$1" -m "$2" -e "$3" 
endef
else
define MCRFLASHEND
endef
endif

#
#   Use the LMC utility to convert an .X30 file into a .mot file
#       $1      - Name of target .bin file
#
define  LMC
    @$(echo) "[$@] Convert to binary.."
    $(XX_PRE)$(LinkerLMC) -. $<
    $(XX_PRE)$(TOOL_APPCRC) $(basename $@).mot
    $(XX_PRE)$(cp) $(basename $@).bin $(basename $@).raw
    $(XX_PRE)$(cp) $(basename $@).bin $1
endef

#
#   Use the LMC_MOT utility to convert an .X30 file into a .mot file
#       $1      - Name of target .mot file
#
define  LMC_MOT
    @$(echo) "[$@] Convert to MOT.."
    $(XX_PRE)$(LinkerLMC) -. $<
    $(XX_PRE)$(cp) $(basename $<).mot $1
endef


#
#   Use the modcrc utility to convert an .raw file into a .thx file
#   $1 is the name 'rel' file
#
define  MODCRC
    @$(echo) "[$@] Add CRC information.."
    $(XX_PRE)$(TOOL_MODCRC) -m=$(basename $@) -i=raw -o=thx -f=$1
    $(XX_PRE)( $(rm) -f dummy.thx; $(cp) -f $(basename $@).thx dummy.thx; $(chmod) -f +w dummy.thx )
    $(XX_PRE)$(TOOL_MODCRC) -m=dummy -i=thx -o=bin
    $(XX_PRE)$(mv) dummy.bin $(basename $@).mod
    $(XX_PRE)$(rm) -f dummy.thx
endef


#
#   Convert a THX file to an R30 object file
#   This is done by
#       .thx    -> modcrc      ->   .bin
#       .bin    -> fontcrc     ->   .c
#       .c      -> compiler    ->   .r30
#
#       $1  - source filename
#       $2  - target file ( without extension )
#
#   Note: Silly modcrc requires that its input file is writable
#         Must transfer it to another directory
#
define  THX2R30
    @$(echo) "[$@] Convert THX to object.."
    $(XX_PRE)( $(rm) -f $2.thx; $(cp) -f $1 $2.thx; $(chmod) -f +w $2.thx )
    $(XX_PRE)$(TOOL_MODCRC) -m=$2 -i=thx -o=bin > $2.nul || rm -f $2.null
    $(XX_PRE)$(TOOL_FONTCONV) $2.bin
    $(CC)
endef

#
#   Convert a BIN file into a PAYLOAD file
#
#   $1      - Version string
define MCRPLD
    @$(echo) "[$@] Convert BIN to Payload.."
    $(XX_PRE)$(GBE_PERL) $(TOOL_MCRPLD) -v $1 -i $< -o $@
endef

#