From a9a90f32fc4c790dd0c43fa8af61789087bca957 Mon Sep 17 00:00:00 2001
From: rtoy <rtoy>
Date: Tue, 27 Nov 2007 03:32:23 +0000
Subject: [PATCH] Handle the case where which returns nothing if it can't find
 the program, but does set the exit code appropriately.

---
 tools/build.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/build.sh b/tools/build.sh
index 8f00d879e..aa88dac0d 100755
--- a/tools/build.sh
+++ b/tools/build.sh
@@ -49,7 +49,15 @@ SKIPUTILS=no
 # If gmake exists, assume it is GNU make and use it.
 if [ -z "$MAKE" ]; then
     MAKE="`which gmake`"
-    if echo $MAKE | grep '^no' > /dev/null; then
+
+    # Some versions of which set an error code if it fails.  Others
+    # say "no foo in <path>".  In either of these cases, just assume
+    # make is GNU make.
+
+    if [ $? -ne 0 ]; then
+	MAKE="make"
+    fi
+    if echo "X$MAKE" | grep '^Xno' > /dev/null; then
 	MAKE="make"
     fi
 fi
@@ -96,6 +104,7 @@ buildit ()
 
     if [ "$ENABLE" = "yes" ]; 
     then
+set -x
 	$TOOLDIR/clean-target.sh $TARGET
 	$TIMER $TOOLDIR/build-world.sh $TARGET $OLDLISP $BOOT
 	(cd $TARGET/lisp; $MAKE)
-- 
GitLab