#! /bin/sh

cppsim_root=${CPPSIMHOME-$HOME/CppSim}
if [ -z "$CPPSIMHOME" ]; then export CPPSIMHOME=$cppsim_root; fi
cppsimshared_root=${CPPSIMSHAREDHOME-$cppsim_root/CppSimShared}
if [ -z "$CPPSIMSHAREDHOME" ]; then export CPPSIMSHAREDHOME=$cppsimshared_root; fi

expand_tilde () { eval "$1=$2" ; }
expand_tilde cppsimshared_root $cppsimshared_root

ARCH=`arch`

if [ "$ARCH" = "i686" ] 
   then
   type -P "wine" &>/dev/null || { echo -e "Error: wine command not found!\n--> You must install wine before running CppSimView (http://www.winehq.org)"; exit 1; }
   WINEPREFIX=$CPPSIMHOME/Wine/CppSimView wine $CPPSIMHOME/Wine/CppSimView/drive_c/CppSimView/CppSimShared/MatlabGui/v65_win32/cppsimview.exe   
else
if [ "$ARCH" = "x86_64" ] 
   then
   type -P "wine" &>/dev/null || { echo -e "Error: wine command not found!\n--> You must install wine before running CppSimView (http://www.winehq.org)"; exit 1; }
   WINEPREFIX=$CPPSIMHOME/Wine/CppSimView wine $CPPSIMHOME/Wine/CppSimView/drive_c/CppSimView/CppSimShared/MatlabGui/v65_win32/cppsimview.exe
else
if [ "$ARCH" = "i386" ] 
   then
   echo "running CppSimView from command line is not supported in Mac OS X"
else
   echo "Error: architecture $ARCH unknown"
fi
fi
fi
