FYI: [PATCH 1/5] bootstrap: make sure patch is available to bootstrap if necessary.

2011-12-07 Thread Gary V. Vaughan
A short series of improvements to bootstrap, inspired by the recent
enhancement to gnulib bootstrap to diagnose a missing patch binary
in the cases where that is required for bootstrap to operate.

All applied as obvious.


Make sure we're not lacking any functionality provided by the
incumbent gnulib bootstrap script, and where it's easy to do so
(like it is here), provide better functionality!
* bootstrap (require_patch): Make sure that PATCH expands to the
best `patch' command available on the system, honouring
overrides in the users environment.
(require_patch_buildreq): Automatically add a requirement for a
patch command to buildreq when there are diff files in
$local_gl_dir.
(func_require_buildtools_uptodate): Call require_patch_buildreq
before testing build tool versions.
(func_gnulib_tool_copy_file): Make sure PATCH is set before using
gnulib-tool to copy files.

Signed-off-by: Gary V. Vaughan 
---
 bootstrap |   55 +++
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/bootstrap b/bootstrap
index ae65e37..81a4a0d 100755
--- a/bootstrap
+++ b/bootstrap
@@ -556,6 +556,7 @@ func_gnulib_tool_copy_file ()
 
 $require_gnulib_path
 $require_gnulib_tool
+$require_patch
 
 gnulib_copy_cmd="$gnulib_tool --copy-file"
 $opt_copy || func_append gnulib_copy_cmd " --symlink"
@@ -1080,6 +1081,7 @@ func_require_buildtools_uptodate ()
 $require_automake_buildreq
 $require_libtoolize_buildreq
 $require_autopoint_buildreq
+$require_patch_buildreq
 
 test -n "$buildreq" && {
   _G_error_hdr=
@@ -1613,6 +1615,59 @@ func_gnulib_tool has installed the \`git-version-gen' 
script."
 }
 
 
+# require_patch
+# -
+# Find patch, according to the PATCH environment variable, or else
+# searching the user's PATH.
+require_patch=func_require_patch
+func_require_patch ()
+{
+$debug_cmd
+
+test -n "$PATCH" || {
+  # Find a patch program, preferring gpatch which is usually better
+  # than the vendor patch.
+  func_find_tool PATCH gpatch patch
+}
+
+func_verbose "export PATCH='$PATCH'"
+
+# Make sure the search result is visible to subshells
+export PATCH
+
+require_patch=:
+}
+
+
+# require_patch_buildreq
+# --
+# Automatically add a patch build-requirement if there are diff files
+# in $local_gl_dir.
+require_patch_buildreq=func_require_patch_buildreq
+func_require_patch_buildreq ()
+{
+$debug_cmd
+
+# This ensures PATCH is set appropriately by the time
+# func_check_versions enforces $buildreq.
+$require_patch
+
+# If patch is not already listed in $buildreq...
+printf '%s\n' "$buildreq" |func_grep_q '^[  ]*patch' || {
+  # The ugly find invocation is necessary to exit with non-zero
+  # status for old find binaries that don't support -exec fully.
+  if test ! -d "$local_gl_dir" \
+  || find "$local_gl_dir" -name *.diff -exec false {} +; then :
+  else
+  func_append buildreq 'patch - http://www.gnu.org/s/patch/
+'
+  fi
+}
+
+require_patch_buildreq=:
+}
+
+
 # require_source_base
 # ---
 # Ensure that source_base has a sensible value, extracted from
-- 
1.7.7.4

Cheers,
-- 
Gary V. Vaughan (gary AT gnu DOT org)



FYI: [PATCH 2/5] bootstrap: ensure consistent function header comments.

2011-12-07 Thread Gary V. Vaughan
* bootstrap (require_bootstrap_uptodate)
(require_buildtools_uptodate): Use `require_...' in header
comment for these functions to be consistent with the rest,
rather than `func_require_...'.

Signed-off-by: Gary V. Vaughan 
---
 bootstrap |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/bootstrap b/bootstrap
index 81a4a0d..8aba09b 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1013,8 +1013,8 @@ func_require_autopoint ()
 }
 
 
-# func_require_bootstrap_uptodate
-# ---
+# require_bootstrap_uptodate
+# --
 # Complain if the version of bootstrap in the gnulib directory differs
 # from the one we are running.
 require_bootstrap_uptodate=func_require_bootstrap_uptodate
@@ -1067,8 +1067,8 @@ func_require_build_aux ()
 }
 
 
-# func_require_buildtools_uptodate
-# 
+# require_buildtools_uptodate
+# ---
 # Ensure all the packages listed in BUILDREQS are available on the build
 # machine at the minimum versions or better.
 require_buildtools_uptodate=func_require_buildtools_uptodate
-- 
1.7.7.4

Cheers,
-- 
Gary V. Vaughan (gary AT gnu DOT org)



FYI:[PATCH 3/5] bootstrap: use _buildreq as a prefix for better ordering.

2011-12-07 Thread Gary V. Vaughan
* bootstrap (require_autobuild_buildreq)
(require_autoconf_buildreq, require_automake_buildreq)
(require_autopoint_buildreq, require_libtoolize_buildreq)
(require_patch_buildreq): Rename from these...
(require_buildreq_autobuild, require_buildreq_autoconf)
(require_buildreq_automake, require_buildreq_autopoint)
(require_buildreq_libtoolize, require_buildreq_patch): ...to
these, respectively.  Adjust all callers.

Signed-off-by: Gary V. Vaughan 
---
 bootstrap |   44 ++--
 1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/bootstrap b/bootstrap
index 8aba09b..0c2bbc2 100755
--- a/bootstrap
+++ b/bootstrap
@@ -862,11 +862,11 @@ func_require_aclocal_amflags ()
 }
 
 
-# require_autobuild_buildreq
+# require_buildreq_autobuild
 # --
 # Try to find whether the bootstrap requires autobuild.
-require_autobuild_buildreq=func_require_autobuild_buildreq
-func_require_autobuild_buildreq ()
+require_buildreq_autobuild=func_require_buildreq_autobuild
+func_require_buildreq_autobuild()
 {
 $debug_cmd
 
@@ -883,19 +883,19 @@ func_require_autobuild_buildreq ()
   }
 }
 
-require_autobuild_buildreq=:
+require_buildreq_autobuild=:
 }
 
 
-# require_autoconf_buildreq
-# require_autopoint_buildreq
-# require_libtoolize_buildreq
+# require_buildreq_autoconf
+# require_buildreq_autopoint
+# require_buildreq_libtoolize
 # ---
 # Try to find the minimum compatible version of autoconf/libtool
 # required to bootstrap successfully, and add it to `$buildreq'.
 for tool in autoconf libtoolize autopoint; do
   b=$tool
-  v=require_${tool}_buildreq
+  v=require_buildreq_${tool}
   f=func_$v
   case $tool in
 autoconf) m=AC_PREREQ ;;
@@ -957,12 +957,12 @@ func_require_autoheader ()
 }
 
 
-# require_automake_buildreq
+# require_buildreq_automake
 # -
 # Try to find the minimum compatible version of automake required to
 # bootstrap successfully, and add it to `$buildreq'.
-require_automake_buildreq=func_require_automake_buildreq
-func_require_automake_buildreq ()
+require_buildreq_automake=func_require_buildreq_automake
+func_require_buildreq_automake()
 {
 $debug_cmd
 
@@ -984,7 +984,7 @@ func_require_automake_buildreq ()
   }
 }
 
-require_automake_buildreq=:
+require_buildreq_automake=:
 }
 
 
@@ -1076,12 +1076,12 @@ func_require_buildtools_uptodate ()
 {
 $debug_cmd
 
-$require_autobuild_buildreq
-$require_autoconf_buildreq
-$require_automake_buildreq
-$require_libtoolize_buildreq
-$require_autopoint_buildreq
-$require_patch_buildreq
+$require_buildreq_autobuild
+$require_buildreq_autoconf
+$require_buildreq_automake
+$require_buildreq_libtoolize
+$require_buildreq_autopoint
+$require_buildreq_patch
 
 test -n "$buildreq" && {
   _G_error_hdr=
@@ -1639,12 +1639,12 @@ func_require_patch ()
 }
 
 
-# require_patch_buildreq
+# require_buildreq_patch
 # --
 # Automatically add a patch build-requirement if there are diff files
 # in $local_gl_dir.
-require_patch_buildreq=func_require_patch_buildreq
-func_require_patch_buildreq ()
+require_buildreq_patch=func_require_buildreq_patch
+func_require_buildreq_patch ()
 {
 $debug_cmd
 
@@ -1664,7 +1664,7 @@ func_require_patch_buildreq ()
   fi
 }
 
-require_patch_buildreq=:
+require_buildreq_patch=:
 }
 
 
-- 
1.7.7.4

Cheers,
-- 
Gary V. Vaughan (gary AT gnu DOT org)



FYI: [PATCH 4/5] bootstrap: reorder function definitions to keep func_buildreq_* together.

2011-12-07 Thread Gary V. Vaughan
From: "Gary V. Vaughan" 

* bootstrap: Restore asciibetical order, so that all the
buildreq function definitions are together.

Signed-off-by: Gary V. Vaughan 
---
 bootstrap |  252 ++--
 1 files changed, 126 insertions(+), 126 deletions(-)

diff --git a/bootstrap b/bootstrap
index 0c2bbc2..5cd9cb0 100755
--- a/bootstrap
+++ b/bootstrap
@@ -862,6 +862,112 @@ func_require_aclocal_amflags ()
 }
 
 
+# require_autoheader
+# --
+# Skip autoheader if it's not needed.
+require_autoheader=func_require_autoheader
+func_require_autoheader ()
+{
+$debug_cmd
+
+test true = "$AUTOHEADER" || {
+  func_extract_trace AC_CONFIG_HEADERS
+  test -n "$func_extract_trace_result" \
+ || func_extract_trace AC_CONFIG_HEADER
+
+  test -n "$func_extract_trace_result" || {
+AUTOHEADER=true
+
+func_verbose "export AUTOHEADER='$AUTOHEADER'"
+
+# Make sure the search result is visible to subshells
+export AUTOHEADER
+  }
+}
+
+require_autoheader=:
+}
+
+
+# require_autopoint
+# -
+# Skip autopoint if it's not needed.
+require_autopoint=func_require_autopoint
+func_require_autopoint ()
+{
+$debug_cmd
+
+test true = "$AUTOPOINT" || {
+  func_extract_trace AM_GNU_GETTEXT_VERSION
+
+  test -n "$func_extract_trace_result" || {
+AUTOPOINT=true
+
+func_verbose "export AUTOPOINT='$AUTOPOINT'"
+
+# Make sure the search result is visible to subshells
+export AUTOPOINT
+  }
+}
+
+require_autopoint=:
+}
+
+
+# require_bootstrap_uptodate
+# --
+# Complain if the version of bootstrap in the gnulib directory differs
+# from the one we are running.
+require_bootstrap_uptodate=func_require_bootstrap_uptodate
+func_require_bootstrap_uptodate ()
+{
+$debug_cmd
+
+$require_gnulib_path
+
+test x = x"$gnulib_path" \
+|| func_cmp_s $progpath $gnulib_path/build-aux/bootstrap \
+|| func_warning upgrade "\
+\`$progpath' differs from \`./$gnulib_path/build-aux/bootstrap',
+please consider adopting the canonical version from gnulib."
+
+require_bootstrap_uptodate=:
+}
+
+
+# require_build_aux
+# -
+# Ensure that `$build_aux' is set, and if it doesn't already point to an
+# existing directory, create one.
+require_build_aux=func_require_build_aux
+func_require_build_aux ()
+{
+$debug_cmd
+
+test -n "$build_aux" || {
+  func_extract_trace AC_CONFIG_AUX_DIR
+  build_aux=$func_extract_trace_result
+  func_check_configuration build_aux \
+  "AC_CONFIG_AUX_DIR([name of a directory for build scripts])"
+
+  func_verbose "build_aux='$build_aux'"
+}
+
+$require_vc_ignore_files
+
+# If the build_aux directory doesn't exist, create it now, and mark it
+# as ignored for the VCS.
+if test ! -d "$build_aux"; then
+  func_show_eval "mkdir '$build_aux'"
+
+  test -n "$vc_ignore_files" \
+  || func_insert_sorted_if_absent "$build_aux" $vc_ignore_files
+fi
+
+require_build_aux=:
+}
+
+
 # require_buildreq_autobuild
 # --
 # Try to find whether the bootstrap requires autobuild.
@@ -930,33 +1036,6 @@ for tool in autoconf libtoolize autopoint; do
 done
 
 
-# require_autoheader
-# --
-# Skip autoheader if it's not needed.
-require_autoheader=func_require_autoheader
-func_require_autoheader ()
-{
-$debug_cmd
-
-test true = "$AUTOHEADER" || {
-  func_extract_trace AC_CONFIG_HEADERS
-  test -n "$func_extract_trace_result" \
- || func_extract_trace AC_CONFIG_HEADER
-
-  test -n "$func_extract_trace_result" || {
-AUTOHEADER=true
-
-func_verbose "export AUTOHEADER='$AUTOHEADER'"
-
-# Make sure the search result is visible to subshells
-export AUTOHEADER
-  }
-}
-
-require_autoheader=:
-}
-
-
 # require_buildreq_automake
 # -
 # Try to find the minimum compatible version of automake required to
@@ -988,82 +1067,32 @@ func_require_buildreq_automake()
 }
 
 
-# require_autopoint
-# -
-# Skip autopoint if it's not needed.
-require_autopoint=func_require_autopoint
-func_require_autopoint ()
-{
-$debug_cmd
-
-test true = "$AUTOPOINT" || {
-  func_extract_trace AM_GNU_GETTEXT_VERSION
-
-  test -n "$func_extract_trace_result" || {
-AUTOPOINT=true
-
-func_verbose "export AUTOPOINT='$AUTOPOINT'"
-
-# Make sure the search result is visible to subshells
-export AUTOPOINT
-  }
-}
-
-require_autopoint=:
-}
-
-
-# require_bootstrap_uptodate
-# --
-# Complain if the version of bootstrap in the gnulib directory differs
-# from the one we are running.
-require_bootstrap_uptodate=func_require_bootstrap_uptodate
-func_require_bootstrap_uptodate ()
-{
-$debug_cmd
-
-$require_gnulib_path
-
-test x = x"$gnu

FYI: [PATCH 5/5] bootstrap: escape quotes properly in generated functions.

2011-12-07 Thread Gary V. Vaughan
* bootstrap: Although not a real bug, for consistency, be sure
to correctly escape single quotes inside a single quoted
function generator.

Signed-off-by: Gary V. Vaughan 
---
 bootstrap |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/bootstrap b/bootstrap
index 5cd9cb0..d0567be 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1018,7 +1018,7 @@ for tool in autoconf libtoolize autopoint; do
 # in order for `func_find_tool` to run.
 ${require_'$tool'-:}
 
-printf '%s\n' "$buildreq" |func_grep_q '\''^[   ]*'$tool\'' || {
+printf '\''%s\n'\'' "$buildreq" |func_grep_q '\''^[ ]*'$tool\'' || 
{
   func_extract_trace '$m'
   _G_version=$func_extract_trace_result
   test -n "$_G_version" && {
-- 
1.7.7.4

Cheers,
-- 
Gary V. Vaughan (gary AT gnu DOT org)