--- config/install.sh.orig	Fri Feb 15 23:17:39 2002
+++ config/install.sh	Wed Feb 20 03:36:14 2002
@@ -92,6 +92,17 @@
     return 0
 }
 
+isin() {
+    tested_x=$1
+    shift
+    for set_y in "$@" ; do
+	if [ ${tested_x} = ${set_y} ] ; then
+	    return 0
+	fi
+    done
+    return 1
+}
+
 require() {
     require_who=$1
     shift
@@ -105,8 +116,10 @@
 }
 
 onepass() {
-    while read depline ; do
-	require $depline
+    while read depwho depon ; do
+	if isin $depwho ${TARGETS} ; then
+		require $depwho $depon
+	fi
     done
 }
 
@@ -123,9 +136,7 @@
 #
 NEWTARGETS=""
 for t in ${ALLTARGETS} ; do
-    if isnotin $t ${TARGETS} ; then
-	:
-    else
+    if isin $t ${TARGETS} ; then
 	NEWTARGETS="$NEWTARGETS $t"
     fi
 done
@@ -552,6 +563,28 @@
 ######################################################################
 
 #
+# do_patch patch-file
+# apply a patch file
+do_patch() {
+	patchfile=$FILESDIR/$1
+
+	if [ ! -r $patchfile ]; then
+		echo "$this: !!! patch file $patchfile not found."
+		exit 1;
+	fi
+
+	if [ ! -f $CONFIGDIR/.patch_$1 ]; then 
+		$PATCH $PATCH_ARGS < $patchfile || {\
+			echo "$this: !!! patch file $patchfile failed to patch."
+			exit 1;
+		}
+		echo > $CONFIGDIR/.patch_$1
+	else
+		echo "$this: patch $patchfile already installed."
+	fi
+}
+
+#
 # create the various sub directories
 #
 for dir in $BINDIR $HEAPDIR $RUNDIR $LIBDIR $SRCDIR ; do
@@ -668,7 +701,7 @@
     $MAKE -f mk.$ARCH-$OPSYS $EXTRA_DEFS
     if [ -x run.$ARCH-$OPSYS ]; then
 	mv run.$ARCH-$OPSYS $RUNDIR
-	$MAKE MAKE=$MAKE clean
+	[ "$MLNORUNTIMECLEAN" ] || $MAKE MAKE=$MAKE clean
     else
 	complain "$this: !!! Run-time system build failed for some reason."
     fi
@@ -732,6 +765,8 @@
 	do
 	    unpack $src $ROOT/src $src $src
         done
+	do_patch do-patch-src-makeml
+	do_patch do-patch-src-installml
 	;;
       ml-yacc)
 	standalone ml-yacc ML-Yacc src
