From 1deef26d0ca3df3d1c845a8cf41fc0cdef009d79 Mon Sep 17 00:00:00 2001
From: Akim Demaille <demaille@gostai.com>
Date: Thu, 3 Sep 2009 10:50:32 +0200
Subject: [PATCH 1/1] bootstrap: fix/improve find_tool.

	* bootstrap (find_tool): Improve error messages.
	Fix typo about find_tool_names.
---
 ChangeLog |  6 ++++++
 bootstrap | 20 ++++++++++++++------
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3e6fd1b9..3a1c6c79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-09-03  Akim Demaille  <demaille@gostai.com>
+
+	bootstrap: fix/improve find_tool.
+	* bootstrap (find_tool): Improve error messages.
+	Fix typo about find_tool_names.
+
 2009-08-29  Joel E. Denny  <jdenny@clemson.edu>
 
 	Fix gcc 3.4.4 shadowing warning reported by Eric Blake.
diff --git a/bootstrap b/bootstrap
index 031ecf75..00ea4bc1 100755
--- a/bootstrap
+++ b/bootstrap
@@ -142,29 +142,37 @@ vc_ignore=auto
 
 # find_tool ENVVAR NAMES...
 # -------------------------
+# Look for some needed program.  Use the value of the ENVVAR if set,
+# otherwise look for the first of the NAMES that can be run (i.e.,
+# supports --version).  If found, set ENVVAR to the program name,
+# die otherwise.
 find_tool ()
 {
+  # Find sha1sum, named gsha1sum on MacPorts.
   find_tool_envvar=$1
   shift
-  find_tool_name=$@
-  if eval test x"\$$find_tool_envvar" = x; then
+  find_tool_names=$@
+  eval "find_tool_res=\$$find_tool_envvar"
+  if test x"$find_tool_res" = x; then
     for i
     do
       if ($i --version </dev/null) >/dev/null 2>&1; then
-	find_tool_res=$i
-	break
+       find_tool_res=$i
+       break
       fi
     done
+  else
+    find_tool_error_prefix="\$$find_tool_envvar: "
   fi
   if test x"$find_tool_res" = x; then
     echo >&2 "$0: one of these is required: $find_tool_names"
     exit 1
   fi
   ($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
-    echo >&2 "$0: cannot run $find_tool_res --version"
+    echo >&2 "$0: ${find_tool_error_prefix}cannot run $find_tool_res --version"
     exit 1
   }
-  eval "$find_tool_envvar=\"$find_tool_res\""
+  eval "$find_tool_envvar=\$find_tool_res"
   eval "export $find_tool_envvar"
 }
 
-- 
2.45.2