#!/bin/sh
# This Bourne shell procedure installs the PASCAL-XSC system
#  in the current directory.

# set -x
CWD=`pwd`
if [ -s pxsc ] ; then
 echo "pxsc exists. Create a new PASCAL-XSC system in this directory (y/n)?"
 read answ
 if  [ $answ = 'n' ] ; then exit 1 ; fi
 if [ ! -d pxsc ] ; then
   echo pxsc is not a directory.
   exit 1
 fi
else
 echo "Create a new PASCAL-XSC system in `pwd`/pxsc (y/n)?"
 read answ
 if  [ $answ = "n" ] ; then
   echo "First cd to the directory, where you want to install subdirectory pxsc."
   exit 1
 fi
 mkdir pxsc
fi # directory pxsc not found

if [ ! -s pxsc.Z -a -s pxsc.z ] ; then
  mv pxsc.z pxsc.Z               # rename Z file
fi
if [ ! -s pxsc.Z -a -s PXSC.Z ] ; then
  mv PXSC.Z pxsc.Z               # rename Z file
fi
cd pxsc
CWD=`pwd`
echo "Unpacking the PASCAL-XSC system,   please wait."
zcat ../pxsc.Z | tar -xf -
chmod go=rx . bin bugs bugs/*
chmod go=x  bin/* sys
chmod go=r sys/*

if [ -s sys/stdmod.mod -a -x bin/pxsc -a -s sys/rts.a ] ; then
ranlib -t sys/rts.a
echo
echo "The following actions must be done by all authorized Users of PASCAL-XSC:"
echo "Add the directory $CWD/bin"
echo "to your \$PATH-variable in your files"
echo "    \$HOME/.profile   \$HOME/.login   and   \$HOME/.cshrc"
echo "Add the following command to your file  \$HOME/.profile"
echo "    PXSC_SYS=$CWD/sys/ ; export PXSC_SYS"
echo "Add the following command to your file  \$HOME/.login"
echo "    setenv PXSC_SYS $CWD/sys/"
echo 'Do not forget the ending "/" behind "sys"'
echo "See also file   pxsc/to.profile"
echo "PATH=\$PATH:$CWD/bin ; export PATH" >to.profile
echo "PXSC_SYS=$CWD/sys/ ; export PXSC_SYS" >>to.profile
chmod go=r to.profile
chmod -w sys/p88.env
else
echo Installation failed.
fi
