#!/bin/sh
#

cd $TARGET/Executables

cat - > $1/$2 <<.
#!/bin/sh
#
#  Mathematica 4 command file
#
#  Copyright 1988 - 1998  Wolfram Research, Inc.  
#
topdir=$TARGET
sysid=$1
bindir=\$topdir/SystemFiles/Kernel/Binaries/\$sysid

PATH=\$PATH:\$topdir/SystemFiles/Graphics/Binaries/\$sysid
export PATH

XFILESEARCHPATH=\$topdir/SystemFiles/Graphics/TextResources/English/%N
export XFILESEARCHPATH

if [ ."\$PSRESOURCEPATH" = . ]; then
   PSRESOURCEPATH=\$topdir/SystemFiles/Graphics/SystemResources:\$topdir/SystemFiles/Fonts/Type1
else
   PSRESOURCEPATH=\$PSRESOURCEPATH:\$topdir/SystemFiles/Graphics/SystemResources:\$topdir/SystemFiles/Fonts/Type1
fi
export PSRESOURCEPATH

if [ ! -f \$bindir/MathKernel ]; then
   echo "Mathematica kernel executable"
   echo "\$bindir/MathKernel"
   echo "not found.  Your Mathematica installation may be incomplete"
   echo "or corrupted."
   exit
fi
exec \$bindir/MathKernel "\$@" -runfirst "\\\$TopDirectory=\\"\$topdir\\"" -pwpath \$topdir/Configuration/Licensing
.

chmod 755 $1/$2
