
# used to install the 4x "sgs"es
#

echo "-------------------------- 4.24 SGS set ----------------------------------\n\n\n"
echo "The SGS used to build Arix 4.24 will be installed in this directory.\n\n"
echo "		1) Arix 4"
echo "		2) Arix V.3"
echo "		3) System 90\n"
echo "What operating system is this machine running?  -> "
read OS_NUM

if [ $OS_NUM -lt 1 -o $OS_NUM -gt 3 ]
then
	echo "Invalid response.  Get out and try again."
	exit 1
fi

</dev/rmt1; </dev/rmt0		# set the tape to the beginning, skip Install

i=1
while [ $i -lt $OS_NUM ]	# skip over unneeded sections of tape
	do
	</dev/rmt0
	i=`expr $i + 1`
	done

cpio -idmuv < /dev/rmt1		# read in the correct sgs

CWD=`pwd`

BINDIR="$CWD/bin"
LIBDIR="$CWD/lib"
ULIBDIR="$CWD/usr/lib"

CPP="-Yp,$LIBDIR"	# C Pre-Processor
COMP0="-Y0,$LIBDIR"	# Frontend pass of compiler
COMP1="-Y1,$LIBDIR"	# Frontend pass of compiler
PEEP="-Y2,$LIBDIR"	# peephole optimizer
AS="-Ya,$BINDIR"	# assembler
LD="-Yl,$BINDIR"	# link-editor
START="-YS,$LIBDIR"	# the startup routines (crt1.o and crtn.o)
LIB="-YL,$LIBDIR"	# the first (root) library
ULIB="-YU,$ULIBDIR"	# the second (usr) library
INC="-YI,$CWD/usr/include"	# include files

if [ ! -d $BINDIR/bin ]
then
	mkdir -p $BINDIR/bin
	mv $BINDIR/cc $BINDIR/bin/cc
fi

echo  "$BINDIR/bin/cc $START $CPP $COMP0 $COMP1 $PEEP $AS $LD $LIB $ULIB $INC \
      \$@" > $BINDIR/cc
chmod ugo+x $BINDIR/cc

case "$OS_NAME" in
	1) OS_NAME="4.x";;
	2) OS_NAME="V.3";;
	3) OS_NAME="s90";;
esac

echo "Finished installing the 4.24 Compiler to run on $OS_NAME system"
