#!/bin/sh

declare OS_FOUND=`uname -s`-`uname -m | sed -e 's/i[0-9]/iX/' -e 's/sun4./sun4X/'`

case ${OS_FOUND} in
#    "SunOS-sun4X")
#	export TARGET_ARCH=gccsparcOS5
#	export EXE_SUFFIX=
#	;;
    "Linux-iX86")
	export TARGET_ARCH=linux
	export EXE_SUFFIX=
	;;
#    "FreeBSD-iX86")
#	export TARGET_ARCH=freebsd
#	export EXE_SUFFIX=
#	;;
#    "CYGWIN_NT-5.1-iX86")
#	export TARGET_ARCH=cygwin
#	export EXE_SUFFIX=.exe
#    	;;	
    *) 
     echo "Unknown OS found"
esac

# Export environement
export MORPHEO_TOPLEVEL=${PWD}
export MORPHEO_PLATFORMS=${MORPHEO_TOPLEVEL}/Platforms
export MORPHEO_SOFTWARE=${MORPHEO_TOPLEVEL}/Softwares
export MORPHEO_IPS=${MORPHEO_TOPLEVEL}/IPs/systemC
export MORPHEO_SCRIPT=${MORPHEO_IPS}/processor/Morpheo/Script
export MORPHEO_HOME=${HOME}/.morpheo

echo ""
echo "OS found : $OS_FOUND"
echo ""
echo "Modification of environement's variable : "
echo " - MORPHEO_TOPLEVEL    is set to ${MORPHEO_TOPLEVEL} "
echo " - MORPHEO_PLATFORMS   is set to ${MORPHEO_PLATFORMS}"
echo " - MORPHEO_SOFTWARE    is set to ${MORPHEO_SOFTWARE} "
echo " - MORPHEO_IPS         is set to ${MORPHEO_IPS}      "
echo " - MORPHEO_SCRIPT      is set to ${MORPHEO_SCRIPT}   "
echo " - MORPHEO_HOME        is set to ${MORPHEO_HOME}     "

# PATH : No multiple add
echo ${PATH} |grep -q ${MORPHEO_SCRIPT};

if test $? -eq 1; then
    export  PATH=${PATH}:${MORPHEO_SCRIPT}
    echo " - PATH                add       ${MORPHEO_SCRIPT}   "
fi;

# test if "first run"
if test ! -d ${MORPHEO_HOME}; then
    echo " - MORPHEO_HOME        don't exist : first run       "
    . ${MORPHEO_SCRIPT}/first_run.sh
fi;

echo ""
