###############################################################################
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
#
# File:         TOOLSET/CORTEXM3_IAR.DEF
# Contents:     TOOLSET Environment definitions
#               Make definitions for the CORTEXM3_IAR tools.
#
# Description:
#       This file provides Toolset definitions for the target makefiles
#       The file is dropped into the top of the generated platform specfic makefile
#
###############################################################################

toolset = avr_iar

o       = o
s       = s
a       = a
exe     = srec

.SUFFIXES:  .asm
.PHONY:     iar

#
#   Ensure that the compiler can be found
#   Use the environment varibales
#       PROGRAMFILES - Windows Program Files (Magic happens in 64bit windows)
#       CORTEXM3_IAR - Root of the AVR workbench
#
PROGRAMFILES        ?= C:/Program Files
GBE_CORTEXM3_IAR    ?= $(PROGRAMFILES)/IAR Systems/Embedded Workbench 7.4
export GBE_CORTEXM3_IAR

cortexm3:
	$(AA_PRE)if [ -z "$$GBE_CORTEXM3_IAR" ]; then echo "GBE_CORTEXM3_IAR env var not set"; exit 2; fi; \
	if [ ! -d "$$GBE_CORTEXM3_IAR" ]; then echo "ERROR: GBE_CORTEXM3_IAR directory not found ($$GBE_CORTEXM3_IAR). Compiler not available"; exit 2; fi; \
	echo "[Toolset CORTEXM3 - IAR Systems]";

iar_avr = $(subst \,/,$(strip $(GBE_CORTEXM3_IAR)))

#
#   Define the compiler specfic names and paths for the various tools
#   Retain 'avr_iar' so we can reuse the .RUL file
#
COMPILER_HOME=$(iar_avr)
COMPILER_HOME_AVR=$(iar_avr)/arm

avr_iar_assembler       = $(COMPILER_HOME_AVR)/bin/iasmarm.exe
avr_iar_compiler        = $(COMPILER_HOME_AVR)/bin/iccarm.exe
avr_iar_cpp_compiler    = $(COMPILER_HOME_AVR)/bin/iccarm.exe
avr_iar_linker          = $(COMPILER_HOME_AVR)/bin/ilinkarm.exe
avr_iar_librarian       = $(COMPILER_HOME_AVR)/bin/iarchive.exe
avr_iar_elftool       	= $(COMPILER_HOME_AVR)/bin/ielftool.exe
avr_linker_lib_dir      = $(COMPILER_HOME_AVR)/lib
avr_linker_lib          = $(avr_linker_lib_dir)/cl6s-ec


