Subversion Repositories DevTools

Rev

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

########################################################################
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
#
# Module name   : MSP430.RUL
# Module type   : Makefile system
# Compiler(s)   : Perl
# Environment(s): jats
#
# Description   : Toolset Rules for the Texas Instruments CC Studio
#
#......................................................................#

###############################################################################
#..     Remove "undef" warnings
#
cc_defines      +=
as_defines      +=
cxx_includes    +=
cxx_defines     +=

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

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

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

###############################################################################
#..     C++ Compiler definition
#..     C   Compiler definition
#
#
#   Compiler flags
#
#
cc              = $(CC_PRE) $(msp430_compiler)
cc_init         =
cc_o_switch     =
cc_object       = --obj_directory=$(@D)
cc_source       = $<
cc_cmdfile      = $(basename $@).cmd
cc_flags        = --compile_only --cmd_file=$(cc_cmdfile)
cc_defines      = $(MSP430_DEFINES)
msp430_includes    = $(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(subst ;$(space),;,$(MSP430_INCLUDES)))))
msp430_flags       = $(MSP430_FLAGS)

cc_filter      := "$(notdir $(wildcard $(GBE_ROOT)/warnings.msp430*))"
ifeq ($(strip $(cc_filter)), "warnings.msp430")
cc_redirect     = 1
cc_error_filter = $(awk) -f $(GBE_ROOT)/warnings.msp430
endif

ifdef ITP_MODE
msp430_flags       += --silicon_version=msp
else
msp430_flags       += --silicon_version=mspx
msp430_flags       += --gcc
msp430_flags       += --silicon_errata=CPU21
msp430_flags       += --silicon_errata=CPU22
msp430_flags       += --silicon_errata=CPU23
endif

ifdef MSP430_PROCDEF
msp430_flags       += --define=$(MSP430_PROCDEF)
endif

#msp430_flags       += --make_global
msp430_flags       += --diag_warning=225
msp430_flags       += --printf_support=minimal

ifdef LEAVETMP
msp430_flags       += --keep_asm --asm_directory=$(@D)
endif

ifdef USE_STRICT_ANSI
msp430_flags       += --strict_ansi
endif


ifdef USE_OPTIMISE
msp430_flags       += -O2
else
msp430_flags       +=
endif

ifdef USE_DEBUGINFO
cc_defines       += DEBUG
else
cc_defines       += NDEBUG
endif

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

cc_defines      += __SOURCE__=$(notdir $<)

define cc_pre
        @$(echo) "[$<] compiling.."; \
        $(cmdfile) -ko$(cc_cmdfile) "\
                $(patsubst %,%\\n,$(CFLAGS)) \
                $(patsubst %,--define=%\\n,$(cc_defines)) \
                $(subst =,$(space),$(patsubst %,%\\n,$(msp430_flags))) \
                --include_path=$(dir $<)\\n \
                $(patsubst %,--include_path=%\\n,$(INCDIRS)) \
                $(subst $(spacealt),$(space),$(patsubst %,--include_path=\"%\"\\n,$(msp430_includes))) \
                $(cc_object)"
        $(call show_cmdfile,$(cc_cmdfile))
                
endef

ifndef LEAVETMP
define cc_post
        @$(rm) -f $(cc_cmdfile)
endef
else
define cc_post
endef
endif

###############################################################################
#..     C/C++ dependencies
#       depend and depend.err
#
msp430_depend      = -D__STDC__
ifeq "$(DEBUG)" "1"
msp430_depend      += -DDEBUG
endif
msp430_depend      += -D__SOURCE__=$(notdir $<)

ccdep           = $(XX_PRE)$(GBE_BIN)/mkdepend
ccdep_init      =
ccdep_o_switch  = -f -
ccdep_source    = $(filter %.c %.cc %.cpp, $+) > $(subst /,\\,$@) 2> $@.err
ccdep_flags     = -MM -b -We -p \$$\(OBJDIR\)/ -o .$(o) \
                  $(filter -D%, $(CFLAGS)) \
                  $(filter -U%, $(CFLAGS)) \
                  $(patsubst %,-D%,$(cc_defines)) \
                  $(patsubst %,%,$(msp430_depend)) \
                  $(patsubst %,-I %,$(INCDIRS)) \
                  $(subst $(spacealt),$(space),$(patsubst %,-Y"%",$(msp430_includes))) \
                  $(patsubst %,-Y %,$(NODEPDIRS))

ccdep_pre       =
ccdep_post      =


###############################################################################
#..     Assembler definition
#       Not used as assember files are treated as 'c' files


###############################################################################
#..     Archiver
#
#       Swicthes
#           -V              Verbose
#           -o file         Output file
#
ar              = $(XX_PRE) "$(msp430_librarian)"
ar_init         =
ar_flags        = -aq $@
ar_o_switch     = $^
ar_term         =



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

ifndef LEAVETMP
define ar_post
endef
else
define ar_post
endef
endif


###############################################################################
#..     Archive Merge
#       Not currently supported.
#       Can add if required
#


###############################################################################
#..     Linker
#
#       Add CC definitions and options
#               May(don't know) be used by the linker
#       Add the header file search path to the linker
#               Used to locate linker command files
#       Add library search path to the linker
#               Used within linker command files
#
ld              = $(XX_PRE) $(msp430_compiler)
ld_cmdfile      = $(basename $@).ld
ld_flags        = -@$(ld_cmdfile)
msp430_libs   = $(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(subst ;$(space),;,$(MSP430_LIBS)))))


define ld_pre
        $(XX_PRE)$(echo) '[$@] Linking program ..' ;\
        export LIB; \
                LIB="$(subst $(space),;,$(LIBDIRS));$(MSP430_LIBS)"; \
        $(cmdfile) -W0ko$(ld_cmdfile) "\
                $(patsubst %,%\\n,$(CFLAGS)) \
                $(patsubst %,--define=%\\n,$(cc_defines)) \
                $(subst =,$(space),$(patsubst %,%\\n,$(msp430_flags))) \
                --run_linker\\n \
                --search_path=$(dir $<)\\n \
                $(patsubst %,--search_path=%\\n,$(INCDIRS)) \
                $(subst $(spacealt),$(space),$(patsubst %,--search_path=\"%\"\\n,$(msp430_includes))) \
                $(patsubst %,--search_path=%\\n,$(LIBDIRS)) \
                $(subst $(spacealt),$(space),$(patsubst %,--search_path=\"%\"\\n,$(msp430_libs))) \
                $($(notdir $(basename $@))_ld)"
        $(call show_cmdfile,$(ld_cmdfile))
        
endef

ifndef LEAVETMP
define ld_post
        @$(rm) -f $(ld_cmdfile)
endef
else
define ld_post
endef
endif

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

################################################################################
#
#    Post Process COFF files into IMG files
#       $1 - coff file (input)
#       $2 - img file (output)
#       $3 - Build Version String (input)
#   Generates .img file and a .hex file
#   The .hex file is a buried dependency
#
define COFF2IMG
    @$(echo) "[$@] Convert COFF to IMG.."
    $(XX_PRE)$(TOOL_VXP430IMG) $1 $2 $3
endef

################################################################################
#
#    Post Process COFF files into HEX files
#       $1 - coff file (input)
#       $2 - Hex file (output)
#   Generates .hex file
#
define COFF2HEX
    @$(echo) "[$@] Convert COFF to HEX.."
    $(XX_PRE)$(msp430_hex) -i $1 -o $2 -order MS -romwidth 16
endef


#