: SYSGEN command file to produce new S
: ${F?} ${L?} ${P?} ${SHOME?} ${C?} ${A?} ${OpSys?} ${I?}
trap 'echo "SYSGEN exit ============ `date`"' 0
echo "SYSGEN entered ========= `date`"
PATH=$PATH:$A:$C
export PATH
case $OpSys in
ATT)	if test `ulimit` -lt 2000;
	then
		echo Ulimit is probably too small to write large libraries or objects
		echo Enlarge it by executing:
		echo "	su"
		echo "	ulimit 10000"
		echo "	su s"
		echo This leaves you in a shell with a large ulimit with userid s
		exit 1
	fi
	;;
esac
if test ! -f $SHOME/.SSTEP 
	 then echo 1 >$SHOME/.SSTEP;  fi
while true
	do
	case `cat $SHOME/.SSTEP` in
	1)	echo Step 1: Initialization
		if test ! -f $I/u/mach.m;
			then
			echo You must run MACHINE first
			exit 1
		fi
		if test ! -f $A/OLOGFILE
		then
			mv $A/LOGFILE $A/OLOGFILE
			mv $A/SOLUTION $A/OSOLUTION
			echo 1 >$A/LOGCOUNT
		fi
		if test ! -f $M/qpe.list;
			then
			echo $M/qpe.list is not present
			exit 1
			fi
		if test ! -f $SHOME/S; then SETUP.S; fi
		if test ! -d $L; then mkdir $L; fi
		echo Initialization Complete
		echo 1b >$SHOME/.SSTEP
		;;
	1b)	echo Step 1b: Kludges for UNIX differences
		MAKEm4 || exit 1
		cd $TEST/OLD
		if test "`$C/MAKE opsys`" != "$OpSys"
		then
			echo OpSys not defined consistently in files $SHOME/ENVIRONMENT and $I/u/mach.m
			exit 1
		fi
		cd $SHOME/src/util
		MAKE logcat
		echo Kludges Complete
		echo 2 >$SHOME/.SSTEP
		;;
	2)	echo Step 2: PSL Library for S Support - psl
		PSLSYSGEN || exit 1
		echo 2b >$SHOME/.SSTEP
		;;
	2b)	echo Step 2b: Test Primitives
		cd $TEST/OLD
		if MAKE prims; then :
			else
			echo Cannot compile or load primitives test; exit 1
			fi
		if ./prims 2>new.prims.out; then :
			else
			echo Cannot execute primitives program; exit 1
			fi
		if cmp prims.out new.prims.out; then :
			else
			echo Primitives do not run correctly; exit 1
			fi
		echo Primitives execute correctly
		echo 3 >$SHOME/.SSTEP
		;;
	3)	echo Step 3: S Language Library - lang
		cd $S
		if COMPILEALL && LIBRARY $L/lang.a
			then
			echo lang Library Created
			else
			echo ERROR in lang Library Creation; exit 1 
			fi
		echo 4 >$SHOME/.SSTEP
		;;
	4)	echo Step 4: Graphics Library - grz
		GRZSYSGEN QPE-Support || exit 1
		echo 5 >$SHOME/.SSTEP
		;;
	5)	echo Step 5: Interface Language Compiler
		cd $SHOME/src/icomp
		if make -s icomp
			then
			echo icomp Created
			else
			echo ERROR in icomp Creation; exit 1 
			fi
		echo 6 >$SHOME/.SSTEP
		;;
	6)	echo Step 6: S Functions
		cd $F
		if QPEMAKEFUNS
			then
			echo S Functions created
			else
			echo ERROR in Creating S functions ; exit 1
			fi
		echo 7 >$SHOME/.SSTEP
		;;
	7)	echo Step 7: S Function Library
		if MAKEILIST $M/load.qpe $L/Sqpe.a
			then
			echo S Function Library created
			else
			echo ERROR in Creating S function library ; exit 1
			fi
		echo 8 >$SHOME/.SSTEP
		;;
	8)	echo Step 8: New S Itself
		cd $SHOME/src/qpe
		make restart S || exit 1
		echo 9 >$SHOME/.SSTEP
		;;
	9)	echo Step 9: New S Functions
		cd $SHOME/src/qpe
		make functions || exit 1
		echo 10 >$SHOME/.SSTEP
		;;
	10)	echo Step 10: Audit and other Utilities
		cd $SHOME/src/qpe
		make audit reverse || exit 1
		echo 11 >$SHOME/.SSTEP
		;;
	11)	echo Step 11: Library Functions
		cd $SHOME/src/qpe
		make library || exit 1
		echo 12 >$SHOME/.SSTEP
		;;
	12)	echo Step 12: Local Changes
		$A/LOCAL.MODS
		echo 13 >$SHOME/.SSTEP
		;;
	*)	break
	esac
	done
echo Congratulations -- S is now ready
echo Run the tests and check results
