###############################################################################
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
#
# File:         TOOLSET/AVR32_GNU.rul[e]
# Contents:     Rules as used for the AVR32_GNU
#               Make definitions for the AVR32_GNU 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 = avr32_gnu

o       = obj
s       = asm
a       = lib
exe     = bin

.SUFFIXES:  .asm
.PHONY:     avr32

#
#   Ensure that the compiler can be found
#   Use the environment varibales
#       GBE_AVR32_GNU - Root of the compiler
#
ifndef GBE_AVR32_GNU
    GBE_AVR32_GNU := /opt/avr32-gnu-toolchain-linux_x86
    export GBE_AVR32_GNU
endif

#
#   Toolset Init Rule
#   Ensure that the toolchain is present and correct version
#
avr32:
	@$(echo)  '[Toolset AVR32 - GNU]'
	$(AA_PRE)if [ -z "$$GBE_AVR32_GNU" ]; then \
        $(echo) "$(GBE_MACHTYPE)] (E) GBE_AVR32_GNU env var not set";\
        exit 2;\
    fi
	$(AA_PRE)if [ ! -d "$$GBE_AVR32_GNU" ]; then \
        $(echo) "$(GBE_MACHTYPE)] (E) GBE_AVR32_GNU directory not found ($$GBE_AVR32_GNU). Compiler not available";\
        exit 2;\
    fi
	$(AA_PRE)if [ "$(GCC_EVERSION)" != "$(GCC_VERSION)" ] ; then \
	    $(echo) "[$(GBE_MACHTYPE)] (E) GCC version is not correct."; \
	    $(echo) "[$(GBE_MACHTYPE)] (E) Expecting:\"$(GCC_EVERSION)\". Got:\"$(GCC_VERSION)\"."; \
	    exit 1; \
	fi
	$(AA_PRE)if [ "$(GCC_EMACHINE)" != "$(GCC_MACHINE)" ] ; then \
	    $(echo) "[$(GBE_MACHTYPE)] (E) GCC machine type is not correct.";\
	    $(echo) "[$(GBE_MACHTYPE)] (E) Expecting:\"$(GCC_EMACHINE)\". Got:\"$(GCC_MACHINE)\".";\
	    exit 1; \
	fi


