# -*- mode: mak; -*-
###############################################################################
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
#
# File:         TOOLSET/mos_mri_68k.def
# Contents:     MRI 68k rules as used for the MOS
#
# Description:
#       MRI 68k toolset for MOS
#       This file provides Toolset definitions for the target makefiles
#       The file is dropped into the top of the generated platform specfic makefile
#
#       This file is included to provide 68k support to the basic MOS_MRI toolset
#
# Revision History:
#       12-Feb-04   DDP     Started Work
###############################################################################

toolset = mos_mri68k

o       = obj
s       = asm
a       = lib
exe     =

.SUFFIXES:  .asm
.PHONY:     mri mri2

#
#   Version 5.1
#
ifeq    "$(mri_ver)" "51"       # Need version 5.1
mri:
	@if [ -z "$$MRI_68K51" ]; then echo 'MRI_68K51 env var not set'; exit 2; fi; \
	echo -n "[Toolset mri68k - Microtec Research C 5.1, C++ 3.1, ASM 7.4 "; \
	if [ -z "`$(grep) 5.1 $$MRI_68K51/version`" ]; then echo 'Not MRI_68K 5.1'; exit 2; fi;

mri = $(subst \,/,$(strip $(MRI_68K51)))

COMPILER_HOME       = $(mri)/tools
MRI_BIN             = $(COMPILER_HOME)/bin
MRI_INC             = $(COMPILER_HOME)/include/mcc68k
MRI_LIB             = $(COMPILER_HOME)/lib

endif

#
#   Version 4.5 (Rome)
#
ifeq    "$(mri_ver)" "45"       # Need version 4.5
mri:
	@if [ -z "$$MRI_68K45" ]; then echo "[MOS_68K.DEF] (E) MRI_68K45 env var not set"; exit 2; fi; \
	if [ -z "`$(grep) 7.1J $$MRI_68K45/version`" ]; then echo "[MOS_68K.DEF] (E) Not MRI_68K 4.5"; exit 2; fi; \
	echo -n "[Toolset mri68k - Microtec Research C 4.5R, ASM 7.1J ";

mri = $(subst \,/,$(strip $(MRI_68K45)))

COMPILER_HOME       = $(mri)
MRI_BIN             = $(COMPILER_HOME)
MRI_INC             = $(COMPILER_HOME)
MRI_LIB             = $(COMPILER_HOME)/68000
mri_linker_lib      = $(MRI_LIB)/mcc68ka5

endif


#
#   Default Version
#
ifeq   "$(mri_ver)" "0"
mri:
	@if [ -z "$$MRI_68K" ]; then echo 'MRI_68K env var not set'; exit 2; fi; \
	echo -n "[Toolset mri68k - Microtec Research C X.X]";

mri = $(subst \,/,$(strip $(MRI_68K)))

COMPILER_HOME       = $(mri)/tools
MRI_BIN             = $(COMPILER_HOME)/bin
MRI_INC             = $(COMPILER_HOME)/include/mcc68k
MRI_LIB             = $(COMPILER_HOME)/lib

endif

#
#   Unknown Version
#
ifndef mri
    $(error ERROR: Specfied MRI_68K compiler version ($(mri_ver)) not known to toolset.)
endif

#
#   Define the compiler specfic names and paths for the various tools
#   These can be overriden by version specific init
#
#COMPILER_HOME       = $(mri)/tools
#MRI_BIN             = $(COMPILER_HOME)/bin
#MRI_INC             = $(COMPILER_HOME)/include/mcc68k
#MRI_LIB             = $(COMPILER_HOME)/lib
MRI_TMP             ?= $(INTERFACEDIR)/mcc68k

mri_assembler       ?= $(MRI_BIN)/asm68k
mri_compiler        ?= $(MRI_BIN)/mcc68k
mri_cpp_compiler    ?= $(MRI_BIN)/ccc68k
mri_linker          ?= $(MRI_BIN)/lnk68k
mri_librarian       ?= $(MRI_BIN)/lib68k

mri_compiler_define ?= _MCC68K
mri_linker_lib      ?= $(MRI_LIB)/nze/mcc68ka5
mri_cpu_type        ?= CPU32
mri_cpu_code        ?= 68340

#
#   Setup the compiler specfic environment variables based on the required version
#   The compiler does not need to be in the users path as it will be fully pathed
#
#   The 68k compiler has a bug. It creates temp files and does not
#   delete the file before reusing an old one. The result is chaos.
#   Create temp files in the 'interface' directory.
#
#
MRI_68K_BIN=$(MRI_BIN)
MRI_68K_INC=$(MRI_INC)
MRI_68K_LIB=$(MRI_LIB)
MRI_68K_TMP=$(MRI_TMP)
export COMPILER_HOME MRI_68K_BIN MRI_68K_LIB MRI_68K_TMP

mri2:
	@if [ -n "$$VISIONCLICK" ]; then \
		echo "and VisionCLICK]"; \
	else echo "]"; fi

ifdef VISIONCLICK
est32		= $(subst \,/,$(strip $(VISIONCLICK)))
else
est32		= --dummy--
endif

RPCGEN_CPP      := $(GBE_BIN)/rpccpp.exe
RPCGEN_CFLAGS   := -e -c
export RPCGEN_CPP RPCGEN_CFLAGS


