OLDPATH=`echo $PATH`
PATH=/etc:/bin:/usr/bin:/usr/local/bin:. export PATH
trap 'PATH='$OLDPATH' export PATH' 0 1 2 15
WD=`pwd`

>ENV

echo "Please specify the CPU hardware:"
echo
echo "1. SPC100, Intel80386, 16MHz"
echo "2. SPC200, Intel80386, 20MHz"
echo "3. Exit"
echo
echo "Enter the number --> \c"
read i

case $i in
1)
	echo "CPU TYPE:  SPC100, Intel80386, 16MHz" >> ENV;;
2)
	echo "CPU TYPE:  SPC200, Intel80386, 20MHz" >> ENV;;
3)
	exit;;
*)
	echo "Wrong Number, try again, byebye!!"
	exit;;
esac

echo "Please specify the cache environment:"
echo
echo "1. SPC100, none cache"
echo "2. SPC200, cache 64Kb"
echo "3. Exit"
echo
echo "Enter the number --> \c"
read i

case $i in
1)
	echo "CACHE:  none cache" >> ENV;;
2)
	echo "CACHE:  cache 64Kb" >> ENV;;
3)
	exit;;
*)
	echo "Wrong Number, try again, byebye!!"
	exit;;
esac

echo "Please specify the MEMORY TYPE:"
echo
echo "1. Parity"
echo "2. ECC"
echo "3. Exit"
echo
echo "Enter the number --> \c"
read i

case $i in
1)
	echo "MEMORY:  Parity, \c" >> ENV;;
2)
	echo "MEMORY:  ECC, \c" >> ENV;;
3)
	exit;;
*)
	echo "Wrong Number, try again, byebye!!"
	exit;;
esac

echo "Please specify the MEMORY SIZE:"
echo
echo "Enter the number (Mega Byte) --> \c"
read i

echo "$i Mega Byte, \c" >> ENV

echo "Please specify the MEMORY ACCESS TIME:"
echo
echo "1. 100ns"
echo "2. 120ns"
echo "3. Exit"
echo
echo "Enter the number --> \c"
read i

case $i in
1)
	echo "100ns" >> ENV;;
2)
	echo "120ns" >> ENV;;
3)
	exit;;
*)
	echo "Wrong Number, try again, byebye!!"
	exit;;
esac

echo "Please specify the DISK TYPE:"
echo
echo "1. Micropolis 1375 (145MB), 23ms seek, SCSI"
echo "2. Quantum Q280 (80MB), 30ms seek, SCSI"
echo "3. Exit"
echo
echo "Enter the number --> \c"
read i

case $i in
1)
	echo "DISK:  Micropolis 1375 (145MB), 23ms seek, SCSI" >> ENV;;
2)
	echo "DISK:  Quantum Q280 (80MB), 30ms seek, SCSI" >> ENV;;
3)
	exit;;
*)
	echo "Wrong Number, try again, byebye!!"
	exit;;
esac

echo "Please specify the floating point environment:"
echo
echo "1. 80387 hardware"
echo "2. Weitek hardware"
echo "3. 80387 software emulator"
echo "4. Weitek software emulator"
echo "5. Exit"
echo
echo "Enter the number --> \c"
read FLOATING

case $FLOATING in
1)
	echo "FPU:  Intel 80387" >> ENV
	FPT=""
	echo "Make sure that you install 80387 hardware"
	echo "Type <RETURN> when you are ready \c"
	read j;;
2)
	echo "FPU:  Weitek 1167" >> ENV
	FPT="-f1167"
	echo "Make sure that you install Weitek 1167 hardware"
	echo "Type <RETURN> when you are ready \c"
	read j;;
3)
	echo "FPU:  None" >> ENV
	FPT="";;
4)
	echo "FPU:  None" >> ENV
	FPT="-f1167";;
*)
	echo "Wrong Number, try again, byebye!!"
	exit;;
esac

echo "OS:  CTIX-386 (UNIX System V, Release 3)" >> ENV
echo "Make sure that Merge is not loaded, type <CR> to continue \c"
read i

echo "Please specify the compiler:"
echo
echo "1. AT&T CC"
echo "2. Green Hill CC"
echo "3. Exit"
echo
echo "Enter the number --> \c"
read i

case $i in
1)
	echo "COMPILER:  SVR 3 cc" >> ENV
	COMPILER="cc";;
2)
	echo "COMPILER:  Green Hill C 1.8.3A" >> ENV
	COMPILER="gcc";;
3)
	exit;;
*)
	echo "Wrong Number, try again, byebye!!"
	exit;;
esac

sed 's/$(CC)/'$COMPILER'/' makefile | sed 's/	cc/	'$COMPILER'/' | sed '/cc /s/$/ \/lib\/libc.a/' | sed '/blend/s/ \/lib\/libc.a$//' | sed '/^FLT =/s/$/ '$FPT'/' > makef_CT

case $FLOATING in
1)
	;;
2)
	sed '/(CFLAGS)/s/$/ \/lib\/libc1167.a/' makef_CT > makef_tmp
	mv makef_tmp makef_CT;;
3)
	;;
4)
	sed '/(CFLAGS)/s/$/ \/lib\/libc1167.a/' makef_CT > makef_tmp
	mv makef_tmp makef_CT;;
esac

echo "Please enter this machines name --> \c"
read i
echo "$i" > Parameter

echo "Please enter the number of iterations to run --> \c"
read j
echo "$j" >> Parameter

while	[ $j -gt 0 ]
do
	echo "Please enter the Max number of users to simulate --> \c"
	read i
	echo "$i" >> Parameter
	
	echo "Please enter the starting number of users to simulate --> \c"
	read i
	echo "$i" >> Parameter

	echo "Testing every how many users --> \c"
	read i
	echo "$i" >> Parameter

	j=`expr $j - 1`
done

echo "Compile the program"

cd /etc/lddrv
./lddrv -a fpe > /dev/null 2>&1
cd $WD

rm -f add_double add_float add_long add_short disk_cp disk_rd disk_wrt div_double div_float div_long div_short fun_cal fun_cal1 fun_cal2 fun_cal31 mul_double mul_float mul_long mul_short pipe_cpy ram_cchar ram_rchar ram_wchar ram_clong ram_rlong ram_wlong ram_cshort ram_rshort ram_wshort creat-clo disk_src multiuser blend plot filter vmdrvr tp_drvr lptest ttydrvr *.o

make -f makef_CT
rm -f makef_CT

case $FLOATING in
1)
	cd /etc/lddrv
	./lddrv -d fpe > /dev/null 2>&1
	cd $WD;;
2)
	cd /etc/lddrv
	./lddrv -d wemul > /dev/null 2>&1
	cd $WD;;
3)
	cd /etc/lddrv
	./lddrv -a fpe > /dev/null 2>&1
	cd $WD;;
4)
	cd /etc/lddrv
	./lddrv -a wemul > /dev/null 2>&1
	cd $WD;;
esac

./blend
ls workfile > /dev/null

>toutput
./multiuser < Parameter

PATH=$OLDPATH export PATH
