modfiles="int/tran/Makefile int/iconx/Makefile int/h/config.h cmp/h/config.h   int/bin/icont.c cmp/bin/iconc.c int/link/ulink.h int/bin/ixhdr.c int/bin/Makefile"
editor=ed
iroot=`pwd`
echo Icon root directory is $iroot
echo Getting generic copies of all files...
for i in $modfiles
do
	cp $i.gen $i
done
wholist=
ldlist=
hoststr=
somehost=
hzrate=60
nofp=
sys=
ibin="$iroot/int/bin"
cbin="$iroot/cmp/bin"
echo Scanning Arguments...
while test $1
do
	case $1 in
		-pdp11)
			sys=pdp11
			wholist="$wholist PDP11"
			ldlist="$ldlist -i";;
		-vax)
			sys=vax
			wholist="$wholist VAX";;
		-ext)
			ext=yes
			wholist="$wholist EXT";;
		-nofp)
			wholist="$wholist NOFP"
			nofp=yes;;
		-directex)
			wholist="$wholist DIREX";;
		-host)
			somehost=x
			shift
			case $1 in
				gethost*)
					wholist="$wholist GETHOST";;
				uname)
					wholist="$wholist UNAME";;
				whoami)
					wholist="$wholist WHOHOST";;
				*)
					hoststr=$1;;
			esac;;
		-hz)
			shift
			hzrate=$1;;
		-ibin)
			shift
			ibin=$1;;
		-cbin)
			shift
			cbin=$1;;
		-iconx)
			shift
			iconx=$1;;
		*)
			echo Bad option \"$1\"
			exit;;
	esac
	shift
done
if test -z "$sys"
then
	echo You must specify either -vax or -pdp11, try again.
	exit
fi
if test -z "$somehost"
then
	echo You must specify a value for -host, try again.
	exit
fi
iconx=${iconx-"$ibin/iconx"}

echo Editing Appropriate files...
for i in int/h/config.h cmp/h/config.h
do
	for def in $wholist
	do
		echo "#define $def" >>$i
	done
	if test -n "$ext"
	then
	echo $editor $i
	$editor $i <<EOF
	/VERSION/s/\(Version \)\(...\) /\1\2x /p
	w
	q
EOF
	fi
done
for i in int/h/config.h cmp/h/config.h
do
	echo "#define HZ $hzrate" >>$i
	if test -n "$hoststr"
	then
		echo "#define HOSTSTR \"$hoststr\"" >>$i
	fi
done
for i in int/bin/icont.c int/link/ulink.h
do
	echo $editor $i
	$editor $i <<EOF
	/IntBin/s?IntBin?$ibin?p
	w
	q
EOF
done
for i in int/bin/icont.c int/bin/ixhdr.c
do
	echo $editor $i
	$editor $i <<EOF
	/Iconx/s?Iconx?$iconx?p
	w
	q
EOF
done
echo $editor cmp/bin/iconc.c
$editor cmp/bin/iconc.c <<EOF
/CmpBin/s?CmpBin?$cbin?p
w
q
EOF
for i in int/iconx/Makefile int/tran/Makefile
do
	echo $editor $i
	$editor $i <<EOF
	/LDFLAGS/s/LDFLAGS=/LDFLAGS=$ldlist/p
	w
	q
EOF
done
if test -n "$nofp"
then
	echo $editor int/iconx/Makefile
	$editor int/iconx/Makefile << EOF
	/-lc$/s/$/ -lfpsim/p
	w
	q
EOF
fi
if test $sys = "pdp11"
then
	echo $editor int/bin/Makefile
	$editor int/bin/Makefile <<EOF
	/cc -O -N/s/-N//p
	w
	q
EOF
fi
echo All Done...
