+# 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
+