From: Akim Demaille <akim@epita.fr>
Date: Sun, 4 Nov 2007 20:40:50 +0000 (+0000)
Subject: Find sha1sum when named gsha1sum.
X-Git-Tag: v2.3b~68
X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/d7be40857659eb85f3e9926cc94c08bf1d94929e

Find sha1sum when named gsha1sum.
* bootstrap (find_tool): New.
($SHA1SUM): New.
---

diff --git a/ChangeLog b/ChangeLog
index 07db04d6..33b0aa9f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-11-04  Akim Demaille  <demaille@gostai.com>
+
+	Find sha1sum when named gsha1sum.
+	* bootstrap (find_tool): New.
+	($SHA1SUM): New.
+
 2007-10-28  Joel E. Denny  <jdenny@ces.clemson.edu>
 
 	Deprecate %pure-parser and add `%define api.pure'.  Discussed starting
diff --git a/bootstrap b/bootstrap
index 295e92a3..e0ac7c75 100755
--- a/bootstrap
+++ b/bootstrap
@@ -41,16 +41,16 @@ Bootstrap this package from the checked-out sources.
 
 Options:
  --gnulib-srcdir=DIRNAME  Specify the local directory where gnulib
-                          sources reside.  Use this if you already
-                          have gnulib sources on your machine, and
-                          do not want to waste your bandwidth downloading
-                          them again.
+			  sources reside.  Use this if you already
+			  have gnulib sources on your machine, and
+			  do not want to waste your bandwidth downloading
+			  them again.
  --copy                   Copy files instead of creating symbolic links.
  --force                  Attempt to bootstrap even if the sources seem
-                          not to have been checked out.
+			  not to have been checked out.
  --skip-po                Do not download po files.
  --cvs-user=USERNAME      Set the username to use when checking out
-                          sources from the gnulib repository.
+			  sources from the gnulib repository.
 
 If the file bootstrap.conf exists in the current working directory, its
 contents are read as shell variables to configure the bootstrap.
@@ -139,6 +139,37 @@ copy=false
 # on which version control system (if any) is used in the source directory.
 vc_ignore=auto
 
+# find_tool ENVVAR NAMES...
+# -------------------------
+find_tool ()
+{
+  # Find sha1sum, named gsha1sum on MacPorts.
+  find_tool_envvar=$1
+  shift
+  if eval test x"\$$find_tool_envvar" = x; then
+    for i
+    do
+      if ($i --version </dev/null) >/dev/null 2>&1; then
+	find_tool_res=$i
+	break
+      fi
+    done
+  fi
+  if test x"$find_tool_res" = x; then
+    echo >&2 "$0: $find_tool_name is required"
+    exit 1
+  fi
+  ($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
+    echo >&2 "$0: cannot run $find_tool_res --version"
+    exit 1
+  }
+  eval "$find_tool_envvar=\"$find_tool_res\""
+  eval "export $find_tool_envvar"
+}
+
+# Find sha1sum, named gsha1sum on MacPorts.
+find_tool SHA1SUM sha1sum gsha1sum
+
 # Override the default configuration, if necessary.
 test -r bootstrap.conf && . ./bootstrap.conf
 
@@ -284,9 +315,9 @@ update_po_files() {
   for po in `cd $ref_po_dir && echo *.po|sed 's/\.po//g'`; do
      new_po="$ref_po_dir/$po.po"
      cksum_file="$ref_po_dir/$po.s1"
-     if ! sha1sum -c --status "$cksum_file" < "$new_po" > /dev/null; then
+     if ! "$SHA1SUM" -c --status "$cksum_file" < "$new_po" > /dev/null; then
        echo "updated $po_dir/$po.po..."
-       cp "$new_po" "$po_dir/$po.po" && sha1sum < "$new_po" > "$cksum_file"
+       cp "$new_po" "$po_dir/$po.po" && "$SHA1SUM" < "$new_po" > "$cksum_file"
      fi
   done
 }
@@ -435,9 +466,9 @@ slurp() {
 	test "$dir/$file" = "$excluded_file" && continue 2
       done
       if test $file = Makefile.am; then
-        copied=$copied${sep}$gnulib_mk; sep=$nl
+	copied=$copied${sep}$gnulib_mk; sep=$nl
 	remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
-        sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || {
+	sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || {
 	  echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
 	  rm -f $dir/$gnulib_mk &&
 	  sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk