#!/bin/sh -f

# Special settings to run MuPAD without any local modifications

MuPAD_ROOT_PATH=`dirname $0`/../..
export MuPAD_ROOT_PATH

SYSINFO=`$MuPAD_ROOT_PATH/share/bin/sysinfo`
MuPAD_BIN=$MuPAD_ROOT_PATH/$SYSINFO/bin

# Path for XView libraries distributed with MuPAD

XVP=${MuPAD_ROOT_PATH}/${SYSINFO}/xview

if test -n "$LD_LIBRARY_PATH" ; then
  LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${XVP}:/usr/local/X11/lib:/usr/openwin/lib
else
  LD_LIBRARY_PATH=${XVP}:/usr/local/X11/lib:/usr/openwin/lib
fi
export LD_LIBRARY_PATH

if [ "$SYSINFO" = "hp" ] ; then  
  if test -n "$SHLIB_PATH" ; then
    SHLIB_PATH=${XVP}:$SHLIB_PATH
  else
    SHLIB_PATH=${XVP}
  fi
  export SHLIB_PATH
fi

if test -n "$FONT_PATH" ; then  
  FONT_PATH=$MuPAD_ROOT_PATH/share/doc/hytex/fonts:$FONT_PATH
else
  FONT_PATH=$MuPAD_ROOT_PATH/share/doc/hytex/fonts
fi
export FONT_PATH

if test -n "$EXTRASMENU" ; then  
  EXTRASMENU=$MuPAD_ROOT_PATH/share/xview/text_extras_menu:$EXTRASMENU
else
  EXTRASMENU=$MuPAD_ROOT_PATH/share/xview/text_extras_menu
fi
export EXTRASMENU

if test -n "$PATH" ; then  
   PATH=$MuPAD_ROOT_PATH/share/bin:${MuPAD_BIN}:$PATH  
else  
   PATH=$MuPAD_ROOT_PATH/share/bin:${MuPAD_BIN}
fi 
export PATH

# This Bourne or Korn Shell script runs xmupad, 
# the window based MuPAD frontend for the X window system.

# These are the directories in which you installed MuPAD
 
# MuPAD_ROOT_PATH is the root directory of the MuPAD-System 
# MuPAD_BIN       is the directory of the MuPAD programms
# MuPAD_LIB       is the root directory of the MuPAD-Library
# MuPAD_HELP      is the directory of the Help dependent stuff
# MuPAD_DYNMOD    is the directory of MuPAD moduls

if test $SYSINFO = "hp" ; then
   SHLIB_PATH=$SHLIB_PATH:$MuPAD_ROOT_PATH/hp/xview
   export SHLIB_PATH
fi

MuPAD_LIB=$MuPAD_ROOT_PATH/share/lib
MuPAD_HELP=$MuPAD_ROOT_PATH/share/doc/ascii
MuPAD_HHELP=$MuPAD_ROOT_PATH/share/doc/hytex
MuPAD_DYNMOD=$MuPAD_ROOT_PATH/$SYSINFO/modules
HYTEX_PATH=$MuPAD_ROOT_PATH/share/doc/hytex
export HYTEX_PATH

# This ensures that MuPAD and hypage can open enough file descriptors.

if test $SYSINFO = "solaris" -o $SYSINFO = "i386" ; then
   ulimit -n 128
fi


# This ensures that MuPAD and Xxmupad will find all of its modules.
 
$MuPAD_BIN/Xxmupad -r $MuPAD_BIN/mupad -m $MuPAD_LIB -l $MuPAD_LIB -d $MuPAD_DYNMOD -h $MuPAD_HELP -H $MuPAD_BIN/hypage -M $MuPAD_HHELP -f $MuPAD_BIN/vcam -D $MuPAD_ROOT_PATH/share/bin/mdx -L english $* & 2> /dev/null &
