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

toolset = msp430

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

.SUFFIXES:  .asm
.PHONY:     msp430

#
#   Ensure that the compiler can be found
#   Use the environment varibales
#       GBE_MSP430          - Root of the CC Studio
#       GBE_MSP430_TOOLS    - Compiler tools
#       GBE_MSP430_CORE     - Some more header files
#
GBE_MSP430         ?= C:/Texas Instruments/ccsv4
GBE_MSP430_TOOLS   ?= $(GBE_MSP430)/tools/compiler/MSP430 Code Generation Tools 3.2.3
GBE_MSP430_CORE    ?= $(GBE_MSP430)/msp430

export GBE_MSP430 GBE_MSP430_TOOLS GBE_MSP430_CORE

msp430:
	@echo "[Toolset TI MSP430]";\
    if [   -z "$$GBE_MSP430" ]; then echo 'GBE_MSP430 env var not set'; exit 2; fi; \
	if [ ! -d "$$GBE_MSP430" ]; then echo "ERROR: GBE_MSP430 directory not found ($$GBE_MSP430). Compiler not available"; exit 2; fi; \
	if [   -z "$$GBE_MSP430_TOOLS" ]; then echo 'GBE_MSP430_TOOLS env var not set'; exit 2; fi; \
	if [ ! -d "$$GBE_MSP430_TOOLS" ]; then echo "ERROR: GBE_MSP430_TOOLS directory not found ($$GBE_MSP430_TOOLS). Compiler not available"; exit 2; fi; \
	if [   -z "$$GBE_MSP430_CORE" ]; then echo 'GBE_MSP430_CORE env var not set'; exit 2; fi; \
	if [ ! -d "$$GBE_MSP430_CORE" ]; then echo "ERROR: GBE_MSP430_CORE directory not found ($$GBE_MSP430_CORE). Compiler not available"; exit 2; fi;

#
#   Define the compiler specfic names and paths for the various tools
#
msp430_compiler        := $(GBE_MSP430_TOOLS)/bin/cl430.exe
msp430_librarian       := $(GBE_MSP430_TOOLS)/bin/ar430.exe
msp430_hex             := $(GBE_MSP430_TOOLS)/bin/hex430.exe

#
#   Extend the PATH used by the toolset
#
MSP430_PATH := $(GBE_MSP430_TOOLS)/bin

ifeq "$(findstring $(VB_PATH),$(PATH))" ""
PATH    := $(MSP430_PATH);$(PATH)
endif
Path    := $(PATH)
export PATH

#
#   Define the toolset specific include and library directories
#   Careful. They will have spaces in them
#
MSP430_INCLUDES   := $(GBE_MSP430_CORE)/include;$(GBE_MSP430_TOOLS)/include
MSP430_LIBS       := $(GBE_MSP430_TOOLS)/lib


# EnvVars used by the toolchain
# Do not use
#
C_OPTION :=
C_DIR :=
MSP430_C_OPTION :=
MSP430_C_DIR :=
export C_OPTION C_DIR MSP430_C_OPTION MSP430_C_DIR

