#
# usage:        .matlabrc.sh
#
# abstract:     This Bourne Shell script is sourced by the matlab script
#		to obtain certain site/user dependent information
#		as explained below. The first occurrence of this file
#		in the directory list:
#
#			. 		(current)
#			$HOME		(home)
#			matlab/bin	(default location)
#
#		is used. Most of the time this file in the default location
#		need not be modified at all and nothing needs to be done.
#		However, if matlab does not work properly with the default
#		values then this file may need to be modified and different
#		values inserted.
#
#		Currently, the following variables are available to
#		change on each platform.
#
#		MATLAB			(MATLAB root directory)
#		AUTOMOUNT_MAP		(Path prefix map for automounting)
#		DISPLAY			(DISPLAY variable for X Window System)
#		ARCH			(machine architecture)
#		LM_LICENSE_FILE		(FLEXlm license file)
#				        (ignored on convex and cray)
#		TOOLBOX			(toolbox path)
#		MATLABPATH		(matlab search path)
#    		XAPPLRESDIR		(X Application Resource Directory)
#		XKEYSYMDB		(X keysym Database file)
#		SHELL			(which shell to use for ! in MATLAB)
#
#		NOTE: Run matlab -n to get the values used to run matlab.
#		      matlab is NOT executed.
#
#		Place architecture dependent commands in this file.
#
#		The strategy behind the use of this file is to keep
#		the site wide changes in the matlab/bin/.matlabrc.sh version
#		and have the individual user start with a copy in their
#		$HOME directory and modify it for their special circumstances.
#
#		IMPORTANT: Please understand that The MathWorks cannot
#			   anticipate every possible installation. If
#			   your situation does not fit into the current
#			   model of using this .matlabrc.sh file then
#			   we would like to hear from you. Please
#			   contact The MathWorks Technical Support.
#
# note(s):	1. The default values are
#
#		   MATLAB		(MATLAB root directory)
#
#			This is set by install_matlab. The matlab script
#			fixes this directory using the automount map
#			specified by AUTOMOUNT_MAP if it is not null.
#
#		        NOTE: The value of MATLAB called MATLABdefault is
#			      determined first by the matlab script before
#			      this file is sourced. If the value of MATLAB
#			      placed in this script by install_matlab is
#			      different than MATLABdefault then
#			      MATLABdefault is used as the value of MATLAB
#			      and an AUTOMOUNT_MAP value of '/ -> /' is used.
#
#		   AUTOMOUNT_MAP	(Path prefix map for automounting)
#
#			This is set by install_matlab if possible. This is
#			null unless you are running the automounter. This
#			may have to be set manually if installation is done
#			on a machine that doesn't have automouting, yet
#			machines that execute MATLAB do.
#
#		   DISPLAY		(DISPLAY variable for X Window System)
#
#			This is set to "$DISPLAY" where DISPLAY is
#		        taken from the environment.
#		        
#		   ARCH			(machine architecture)
#
#			This is the machine architecture determined by
#			the arch utility script.
#
#		   LM_LICENSE_FILE	(FLEXlm license file)
#
#			Ignored on convex and cray.
#		
#			This is set to '$MATLAB/etc/license.dat'
#
#		        WATCH OUT! Those are single quotes. Because this
#				   will evaluated later! 
#
#			NOTE: You can put complicated code in here to
#			      switch between various license.dat files.
#
#		   TOOLBOX		(toolbox path)
#
#			This is set to "$TOOLBOX" where TOOLBOX is
#			taken from the environment.
#			
#		   MATLABPATH		(matlab search path)
#
#			This is set to "$MATLABPATH" where MATLABPATH is
#			taken from the environment.
#
#    		   XAPPLRESDIR		(X Application Resource Directory)
#
#			This is set to '$MATLAB/app-defaults'.
#			
#		        WATCH OUT! Those are single quotes. Because this
#				   will evaluated later! 
#
#		   XKEYSYMDB		(X keysym Database file)
#
#			This is set to '$MATLAB/app-defaults/XKeysymDB'.
#
#		        WATCH OUT! Those are single quotes. Because this
#				   will evaluated later! 
#
#		   SHELL		(which shell to use for ! in MATLAB)
#
#		        This is set to "$SHELL" where SHELL is taken from
#			the environment. SHELL has no effect on some platforms
#			and does not exit on others. See the table below.
#
#			TABLE:
#
#			      platform          SHELL used for !
#			      --------          ----------------
#				sun4		    yes
#				hp700		    no
#				ibm_rs		    yes 
#				sgi		    yes
#				dec_risc	    no
#				hp300		    no
#				sol2		    no (no SHELL variable)
#				alpha		    yes
#				c2mp		    yes
#				cray		    yes
#
# Copyright (c) 1986-1995 by The MathWorks, Inc.
# $Revision: 1.12 $  $Date: 1995/04/03 18:50:46 $
#----------------------------------------------------------------------------
#
# Determine the arch.
#
#   -------------------------------------------------------------
#
    MATLAB_UTIL_DIR=
#
#   -------------------------------------------------------------
#
    if [ ! "$MATLAB_UTIL_DIR" ]; then
	MATLAB_UTIL_DIR=$MATLAB_UTIL_DIRdefault
    fi
#
# arch.sh requires MATLAB - save temporarily
#
    MATLABsave="$MATLAB"
    MATLAB="$MATLABdefault"
#
    . $MATLAB_UTIL_DIR/arch.sh
    if [ "$Arch" = "unknown" ]; then
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo ''
    echo '    Sorry! We could not determine the machine architecture for your'
    echo '           host. Please contact:'
    echo ''
    echo '               MathWorks Technical Support'
    echo ''
    echo '           for further assistance.'
    echo ''
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        trap ""
        exit 1
    fi
    MATLAB="$MATLABsave"
#
# Determine if licensed
#
    license=1
    if [ "$Arch" = "c2mp" -o "$Arch" = "cray" ]; then
        license=0
    fi
#
#	IMPORTANT! Modify ONLY if you don't like the defaults after running
#		   matlab.
#
    case "$Arch" in
	sun4)
#----------------------------------------------------------------------------
# MATLAB and AUTOMOUNT_MAP originally set by install_matlab
#
	    MATLAB=/opt/matlab
	    AUTOMOUNT_MAP=
#
	    if [ "$MATLAB" != "$MATLABdefault" ]; then
		MATLAB=$MATLABdefault
	        AUTOMOUNT_MAP='/ -> /'
	    fi
#
	    DISPLAY="$DISPLAY"
	    ARCH="$Arch"
	    LM_LICENSE_FILE='$MATLAB/etc/license.dat'
	    TOOLBOX="$TOOLBOX"
	    MATLABPATH="$MATLABPATH"
	    XAPPLRESDIR='$MATLAB/app-defaults'
	    XKEYSYMDB='$MATLAB/app-defaults/XKeysymDB'
	    SHELL="$SHELL"
#----------------------------------------------------------------------------
	    ;;
	hp700)
#----------------------------------------------------------------------------
# MATLAB and AUTOMOUNT_MAP originally set by install_matlab
#
	    MATLAB=/opt/matlab
	    AUTOMOUNT_MAP=
#
	    if [ "$MATLAB" != "$MATLABdefault" ]; then
		MATLAB=$MATLABdefault
	        AUTOMOUNT_MAP='/ -> /'
	    fi
#
	    DISPLAY="$DISPLAY"
	    ARCH="$Arch"
	    LM_LICENSE_FILE='$MATLAB/etc/license.dat'
	    TOOLBOX="$TOOLBOX"
	    MATLABPATH="$MATLABPATH"
	    XAPPLRESDIR='$MATLAB/app-defaults'
	    XKEYSYMDB='$MATLAB/app-defaults/XKeysymDB'
	    SHELL="$SHELL"
#----------------------------------------------------------------------------
	    ;;
	ibm_rs)
#----------------------------------------------------------------------------
# MATLAB and AUTOMOUNT_MAP originally set by install_matlab
#
	    MATLAB=/opt/matlab
	    AUTOMOUNT_MAP=
#
	    if [ "$MATLAB" != "$MATLABdefault" ]; then
		MATLAB=$MATLABdefault
	        AUTOMOUNT_MAP='/ -> /'
	    fi
#
	    DISPLAY="$DISPLAY"
	    ARCH="$Arch"
	    LM_LICENSE_FILE='$MATLAB/etc/license.dat'
	    TOOLBOX="$TOOLBOX"
	    MATLABPATH="$MATLABPATH"
	    XAPPLRESDIR='$MATLAB/app-defaults'
	    XKEYSYMDB='$MATLAB/app-defaults/XKeysymDB'
	    SHELL="$SHELL"
#----------------------------------------------------------------------------
	    ;;
	sgi)
#----------------------------------------------------------------------------
# MATLAB and AUTOMOUNT_MAP originally set by install_matlab
#
	    MATLAB=/opt/matlab
	    AUTOMOUNT_MAP=
#
	    if [ "$MATLAB" != "$MATLABdefault" ]; then
		MATLAB=$MATLABdefault
	        AUTOMOUNT_MAP='/ -> /'
	    fi
#
	    DISPLAY="$DISPLAY"
	    ARCH="$Arch"
	    LM_LICENSE_FILE='$MATLAB/etc/license.dat'
	    TOOLBOX="$TOOLBOX"
	    MATLABPATH="$MATLABPATH"
	    XAPPLRESDIR='$MATLAB/app-defaults'
	    XKEYSYMDB='$MATLAB/app-defaults/XKeysymDB'
	    SHELL="$SHELL"
#----------------------------------------------------------------------------
	    ;;
	dec_risc)
#----------------------------------------------------------------------------
# MATLAB and AUTOMOUNT_MAP originally set by install_matlab
#
	    MATLAB=/opt/matlab
	    AUTOMOUNT_MAP=
#
	    if [ "$MATLAB" != "$MATLABdefault" ]; then
		MATLAB=$MATLABdefault
	        AUTOMOUNT_MAP='/ -> /'
	    fi
#
	    DISPLAY="$DISPLAY"
	    ARCH="$Arch"
	    LM_LICENSE_FILE='$MATLAB/etc/license.dat'
	    TOOLBOX="$TOOLBOX"
	    MATLABPATH="$MATLABPATH"
	    XAPPLRESDIR='$MATLAB/app-defaults'
	    XKEYSYMDB='$MATLAB/app-defaults/XKeysymDB'
	    SHELL="$SHELL"
#----------------------------------------------------------------------------
	    ;;
	hp300)
#----------------------------------------------------------------------------
# MATLAB and AUTOMOUNT_MAP originally set by install_matlab
#
	    MATLAB=/opt/matlab
	    AUTOMOUNT_MAP=
#
	    if [ "$MATLAB" != "$MATLABdefault" ]; then
		MATLAB=$MATLABdefault
	        AUTOMOUNT_MAP='/ -> /'
	    fi
#
	    DISPLAY="$DISPLAY"
	    ARCH="$Arch"
	    LM_LICENSE_FILE='$MATLAB/etc/license.dat'
	    TOOLBOX="$TOOLBOX"
	    MATLABPATH="$MATLABPATH"
	    XAPPLRESDIR='$MATLAB/app-defaults'
	    XKEYSYMDB='$MATLAB/app-defaults/XKeysymDB'
	    SHELL="$SHELL"
#----------------------------------------------------------------------------
	    ;;
	sol2)
#----------------------------------------------------------------------------
# MATLAB and AUTOMOUNT_MAP originally set by install_matlab
#
	    MATLAB=/opt/matlab
	    AUTOMOUNT_MAP=
#
	    if [ "$MATLAB" != "$MATLABdefault" ]; then
		MATLAB=$MATLABdefault
	        AUTOMOUNT_MAP='/ -> /'
	    fi
#
	    DISPLAY="$DISPLAY"
	    ARCH="$Arch"
	    LM_LICENSE_FILE='$MATLAB/etc/license.dat'
	    TOOLBOX="$TOOLBOX"
	    MATLABPATH="$MATLABPATH"
	    XAPPLRESDIR='$MATLAB/app-defaults'
	    XKEYSYMDB='$MATLAB/app-defaults/XKeysymDB'
	    SHELL="$SHELL"
	    LD_PRELOAD="$MATLAB/faketime/faketime-$Arch.so"
#
# Set support for the Compose Key and international keyboards
#
	    stty cs8 > /dev/null 2>&1
#----------------------------------------------------------------------------
	    ;;
	alpha)
#----------------------------------------------------------------------------
# MATLAB and AUTOMOUNT_MAP originally set by install_matlab
#
	    MATLAB=/opt/matlab
	    AUTOMOUNT_MAP=
#
	    if [ "$MATLAB" != "$MATLABdefault" ]; then
		MATLAB=$MATLABdefault
	        AUTOMOUNT_MAP='/ -> /'
	    fi
#
	    DISPLAY="$DISPLAY"
	    ARCH="$Arch"
	    LM_LICENSE_FILE='$MATLAB/etc/license.dat'
	    TOOLBOX="$TOOLBOX"
	    MATLABPATH="$MATLABPATH"
	    XAPPLRESDIR='$MATLAB/app-defaults'
	    XKEYSYMDB='$MATLAB/app-defaults/XKeysymDB'
	    SHELL="$SHELL"
#----------------------------------------------------------------------------
	    ;;
	c2mp)
#----------------------------------------------------------------------------
# MATLAB and AUTOMOUNT_MAP originally set by install_matlab
#
	    MATLAB=/opt/matlab
	    AUTOMOUNT_MAP=
#
	    if [ "$MATLAB" != "$MATLABdefault" ]; then
		MATLAB=$MATLABdefault
	        AUTOMOUNT_MAP='/ -> /'
	    fi
#
	    DISPLAY="$DISPLAY"
	    ARCH="$Arch"
	    LM_LICENSE_FILE=""
	    TOOLBOX="$TOOLBOX"
	    MATLABPATH="$MATLABPATH"
	    XAPPLRESDIR='$MATLAB/app-defaults'
	    XKEYSYMDB='$MATLAB/app-defaults/XKeysymDB'
	    SHELL="$SHELL"
#
# Set stacksize to unlimited - requires Korn Shell
#
            ulimit -s unlimited
#----------------------------------------------------------------------------
	    ;;
	cray)
#----------------------------------------------------------------------------
# MATLAB and AUTOMOUNT_MAP originally set by install_matlab
#
	    MATLAB=/opt/matlab
	    AUTOMOUNT_MAP=
#
	    if [ "$MATLAB" != "$MATLABdefault" ]; then
		MATLAB=$MATLABdefault
	        AUTOMOUNT_MAP='/ -> /'
	    fi
#
	    DISPLAY="$DISPLAY"
	    ARCH="$Arch"
	    LM_LICENSE_FILE=""
	    TOOLBOX="$TOOLBOX"
	    MATLABPATH="$MATLABPATH"
	    XAPPLRESDIR='$MATLAB/app-defaults'
	    XKEYSYMDB='$MATLAB/app-defaults/XKeysymDB'
	    SHELL="$SHELL"
#----------------------------------------------------------------------------
	    ;;
	lnx86)
#----------------------------------------------------------------------------
# MATLAB and AUTOMOUNT_MAP originally set by install_matlab
#
	    MATLAB=/opt/matlab
	    AUTOMOUNT_MAP=
#
	    if [ "$MATLAB" != "$MATLABdefault" ]; then
		MATLAB=$MATLABdefault
	        AUTOMOUNT_MAP='/ -> /'
	    fi
#
	    DISPLAY="$DISPLAY"
	    ARCH="$Arch"
	    LM_LICENSE_FILE='$MATLAB/etc/license.dat'
	    TOOLBOX="$TOOLBOX"
	    MATLABPATH="$MATLABPATH"
	    XAPPLRESDIR='$MATLAB/app-defaults'
	    XKEYSYMDB='$MATLAB/app-defaults/XKeysymDB'
	    SHELL="$SHELL"
#----------------------------------------------------------------------------
	    ;;
	*)
#----------------------------------------------------------------------------
# MATLAB and AUTOMOUNT_MAP originally set by install_matlab
#
	    MATLAB=/opt/matlab
	    AUTOMOUNT_MAP=
#
	    if [ "$MATLAB" != "$MATLABdefault" ]; then
		MATLAB=$MATLABdefault
	        AUTOMOUNT_MAP='/ -> /'
	    fi
#
	    DISPLAY="$DISPLAY"
	    ARCH="$Arch"
	    LM_LICENSE_FILE='$MATLAB/etc/license.dat'
	    TOOLBOX="$TOOLBOX"
	    MATLABPATH="$MATLABPATH"
	    XAPPLRESDIR='$MATLAB/app-defaults'
	    XKEYSYMDB='$MATLAB/app-defaults/XKeysymDB'
	    SHELL="$SHELL"
#----------------------------------------------------------------------------
	    ;;
    esac
