###############################################################################
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
#
# File: TOOLSET/AVR_IAR.rul[e]
# Contents: IAR rules as used for the AVR
# Make definitions for the IAR tools.
#
# Description:
# This file provides Toolset rules for the target makefiles
# The file is dropped into the target makefile
#
# Revision History:
# 16-Aug-04 DDP Created
###############################################################################
###############################################################################
#.. Remove "undef" warnings
#
cc_includes +=
cc_defines +=
as_includes +=
as_defines +=
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
# --cpu=cpu Specify cpu type
# -D Symbol Define a symbol
# --debug Include debug information
# -e Enables language extensions
# --ec++ Default language is C++
# --eprom_size=N Set eeprom size
# --enhanced_core Allow enhanced core instructions
# -f file Read commands from a file
# --initializers_in_flash Places aggregate initializers in flash memory
# --no_clustering Disables clustering of variables
# --no_code_motion Disables code motion optimization
# --no_cross_call Disables cross-call optimization
# --no_cse Disables common sub-expression elimination
# --no_inline Disables function inlining
# -lA file/dir Generate a list file
# -lC file/dir Generate a list file
# -m[stl] Memory model
# -o filename Output filename
# --require_prototypes Verifies that prototypes are proper
# -s[2369] Optimise code for speed, none,Low,Med,Hi
# --strict_ansi
# --silent Supress banner
# -v[0-6] Specify processor variant
# -y Places constants and literals
# -z[2369] Optimise code for size, none,Low,Med,Hi
#
#
cc = $(CC_PRE) "$(avr_iar_compiler)"
cc_init =
cc_o_switch =
cc_object = -o $@
cc_source = $<
cc_cmdfile = $(basename $@).cmd
cc_flags = --silent -f $(cc_cmdfile)
cc_defines = $(AVR_IAR_DEFINES)
iar_includes = $(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(subst ;$(space),;,$(AVR_IAR_INCLUDES)))))
iar_flags = $(AVR_IAR_FLAGS)
cc_filter := "$(notdir $(wildcard $(GBE_ROOT)/warnings.iar*))"
ifeq ($(strip $(cc_filter)), "warnings.iar")
cc_redirect = 1
cc_error_filter = $(awk) -f $(GBE_ROOT)/warnings.iar
endif
ifdef LEAVETMP
iar_flags += -lC=$(basename $@).lst
endif
ifdef USE_STRICT_ANSI
iar_flags += --strict_ansi
else
iar_flags += -e
endif
ifdef USE_OPTIMISE
iar_flags +=
else
iar_flags +=
endif
ifdef USE_DEBUGINFO
cc_defines += DEBUG
else
cc_defines += NDEBUG
endif
ifeq "$(DEBUG)" "1"
iar_flags += --debug
else
iar_flags +=
endif
ifdef ALVL
cc_defines += ALVL=$(ALVL)
endif
ifdef DLVL
cc_defines += DLVL=$(DLVL)
endif
cc_defines += __SOURCE__=$(notdir $<)
define cc_pre
@$(echo) "[$<] compiling..";\
$(cmdfile) -ko$(cc_cmdfile) "\
$(patsubst %,%\\n,$(CFLAGS)) \
$(patsubst %,-D%\\n,$(cc_defines)) \
$(subst =,$(space),$(patsubst %,%\\n,$(iar_flags))) \
$(subst =,$(space),$(patsubst %,%\\n,$(AVR_IAR_CC_FLAGS))) \
-I $(dir $<)\\n \
$(patsubst %,-I %\\n,$(INCDIRS)) \
$(patsubst %,-I %\\n,$(cc_includes)) \
$(subst $(spacealt),$(space),$(patsubst %,-I \"%\"\\n,$(iar_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
#
iar_depend = -D__STDC__
ifeq "$(DEBUG)" "1"
iar_depend += -DDEBUG
endif
ifdef ALVL
iar_depend += -DALVL=$(ALVL)
endif
ifdef DLVL
iar_depend += -DDLVL=$(DLVL)
endif
iar_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 %,%,$(iar_depend)) \
$(patsubst %,-I %,$(INCDIRS)) \
$(patsubst %,-Y %,$(cc_includes)) \
$(subst $(spacealt),$(space),$(patsubst %,-Y"%",$(iar_includes))) \
$(patsubst %,-Y %,$(NODEPDIRS))
ccdep_pre =
ccdep_post =
#.. C++ Compiler definition
#
cxx = $(CC_PRE) "$(avr_iar_cpp_compiler)"
cxx_init =
cxx_o_switch =
cxx_object = -o $@
cxx_source = $<
cxx_cmdfile = $(basename $@).cmd
cxx_flags = -f $(cxx_cmdfile)
define cxx_pre
@$(echo) "[$<] compiling..";\
$(cmdfile) -ko$(cxx_cmdfile) "\
$(patsubst %,%\\n,$(CXXFLAGS)) \
$(patsubst %,-D%\\n,$(cc_defines)) \
$(subst =,$(space),$(patsubst %,%\\n,$(iar_flags))) \
$(subst =,$(space),$(patsubst %,%\\n,$(AVR_IAR_CXX_FLAGS))) \
-I $(dir $<)\\n \
$(patsubst %,-I %\\n,$(INCDIRS)) \
$(patsubst %,-I %\\n,$(cc_includes)) \
$(subst $(spacealt),$(space),$(patsubst %,-I \"%\"\\n,$(iar_includes))) \
$(cxx_object)" ;\
$(call show_cmdfile,$(cxx_cmdfile))
endef
ifndef LEAVETMP
define cxx_post
@$(rm) -f $(cxx_cmdfile)
endef
else
define cxx_post
endef
endif
###############################################################################
#.. Assembler definition
#
# Note: All the options go on the command line at present so this
# passes a minimal set of definitions. (v4.3)
#
# Assembler switches
# -Ifile Extend include path
# -o file Specfify output file
# -S No messages
# -r Generate symbolic debug info
# -D symbol Define a symbol
# -f cmd_file Take options from a command file
#
as = $(XX_PRE) "$(avr_iar_assembler)"
as_init =
as_o_switch = -o $@
as_source = $<
as_cmdfile =
as_includes =
as_flags = -S $(AVR_IAR_ASFLAGS)
as_defines = $(AVR_IAR_ASDEFINES)
#ifdef ASFLAGS
as_flags += $(ASFLAGS)
#endif
ifeq "$(DEBUG)" "1"
as_flags += -r
else
as_flags +=
endif
ifdef as_defines
as_flags += $(addprefix -D,$(as_defines))
endif
#ifdef INCDIRS
as_flags += $(patsubst %,-I%,$(strip $(INCDIRS)))
#endif
ifdef as_includes
as_flags += $(patsubst %,-I%,$(strip $(as_includes)))
endif
#ifdef AVR_IAR_INCLUDES
as_flags += $(subst $(spacealt),$(space),$(patsubst %,"-I%",$(subst ;,$(space),$(subst \,/,$(subst $(space),$(spacealt),$(subst ;$(space),;,$(AVR_IAR_INCLUDES))))) ))
#endif
define as_pre
@$(echo) '[$@] Assembling file..'
endef
define as_post
endef
###############################################################################
#.. Archiver
#
# Swicthes
# -V Verbose
# -o file Output file
#
ar = $(XX_PRE) "$(avr_iar_librarian)"
ar_init =
ar_flags = $^
ar_o_switch = -o $@
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
#
armerge = $(XX_PRE) "$(avr_iar_librarian)"
armerge_init =
armerge_flags = $^
armerge_o_switch = -o $@
define armerge_pre
@$(echo) '[$@] Creating a Merged library..' ; \
$(rm) -f $@
endef
ifndef LEAVETMP
define armerge_post
endef
else
define armerge_post
endef
endif
###############################################################################
#.. Linker
#
ld = $(XX_PRE) "$(avr_iar_linker)"
ld_cmdfile = $(basename $@).ld
ld_flags = -f $(ld_cmdfile)
define ld_pre
$(XX_PRE)$(echo) '[$@] Linking program ..' ;\
export IAR_LIB; \
IAR_LIB="$(subst $(space),;,$(LIBDIRS))"; \
$(cmdfile) -W2ko$(ld_cmdfile) "$($(notdir $(basename $@))_ld)"
endef
ifndef LEAVETMP
define ld_post
@$(rm) -f $(ld_cmdfile)
endef
else
define ld_post
endef
endif
define LD_IAR
$(show_environment)
$(ld_pre)
$(ld) $(ld_flags)
$(ld_post)
endef
#
# Create Library dependency file
#
define LDDEPEND
$(XX_PRE) export IAR_LIB; \
IAR_LIB="$(subst $(space),;,$(LIBDIRS))"; \
$(cmdfile) -W1ko$(@) "$($(DPLIST))"
endef
#
# Program Loader processing
# Args: $1 Path to the exe
# $2 Path to the ProgLoader
#
# The process
# Remove last line from the executable (S9 Entry Point and Termination)
# Remove the first line from the ProgLoader (S0 Header)
# Concatenate the exe + progloader to the original file name
#
define LD_IAR_PROCESS
$(XX_PRE) $(echo) "[$@]Process Program Loader .." ;\
sed '-e$$d' $1 >$1.ed ;\
sed '-e1d' $2 >$2.ed ;\
rm -f $1.keep ;\
mv $1 $1.keep ;\
cat $1.ed $2.ed >$1 ;\
rm $1.ed $2.ed
endef
#
# Generate SREC file
# Not used by all versions of IAR
# Args: $1 Path to the out file (input)
# $2 Path to the SREC file (output)
# $3 Additional Args
#
define GENERATE_SREC
$(XX_PRE) $(echo) "[$@]Generate SREC .." ;\
rm -f $2;\
"$(avr_iar_elftool)" --srec --verbose $3 $1 $2
endef
#
# Generate SXML file
# Args: $1 Path to the S19 file
# $2 Path to the SXML file (output)
# $3 Payload Type
# $4 Major version
# $5 Minor version
# $6 Patch
# $7 Build
# $8 WrapperTag. Has _Image appended
#
define GENERATE_SXML
$(XX_PRE) $(echo) "[$@]Generate SXML .." ;\
rm -f $2;\
echo "<$8_Image>" >$2;\
echo " " >>$2;\
echo " 0" >>$2;\
echo " $$(date +%c)" >>$2;\
echo " $$(date +%s)" >>$2;\
echo " $(GBE_PLATFORM)" >>$2;\
echo " $3" >>$2;\
echo " $4" >>$2;\
echo " $5" >>$2;\
echo " $6" >>$2;\
echo " $7" >>$2;\
echo " false" >>$2;\
echo " false" >>$2;\
echo " " >>$2;\
echo " " >>$2;\
cat $1 >>$2;\
echo " " >>$2;\
echo "$8_Image>" >>$2
endef
#