#!/bin/sh
#
# Create Mathematica command file.

cd $TARGET/Executables

if [ $2 = DEC-AXP ]; then
   fonttype="PCF"
else
   fonttype="X"
fi

cat - > $1/$2 <<.
#!/bin/sh
#
#  Mathematica 4 command file
#
#  Copyright 1988 - 1998  Wolfram Research, Inc.
#

topdir=$TARGET
sysid=$1

PATH=\$topdir/Executables/\$sysid:\$PATH
export PATH

XFILESEARCHPATH=\$topdir/SystemFiles/FrontEnd/SystemResources/X/%N:$topdir/SystemFiles/FrontEnd/SystemResources/X/%T/%N%S
export XFILESEARCHPATH

havefonts=\`xlsfonts -fn '-wri-*-*-*-*-*-*-*-*-*-*-*-*-*' 2>&1 | grep -c "wri"\`

font=\$topdir/SystemFiles/Fonts/Type1

[ \$havefonts -lt 2 ] && xset fp+ \$font

font=\$topdir/SystemFiles/Fonts/$fonttype

[ \$havefonts -lt 2 ] && xset fp+ \$font

xset fp rehash

bindir=\$topdir/SystemFiles/FrontEnd/Binaries/\$sysid
if [ ! -f \$bindir/Mathematica ] ; then
   echo "Mathematica front end executable"
   echo "\$bindir/Mathematica"
   echo "not found. Your Mathematica installation may be incomplete"
   echo "or corrupted."
   exit
fi

exec \$bindir/Mathematica -topDirectory \$topdir "\$@"

.

chmod 755 $1/$2
