Merge tag 'snapshot-start' into stable
[gnulib.git] / gnulib-tool
index 23e5bb6..354b1f0 100755 (executable)
@@ -1,6 +1,6 @@
 #! /bin/sh
 #
-# Copyright (C) 2002-2011 Free Software Foundation, Inc.
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -164,11 +164,15 @@ Operation modes:
       --update              update the current package, restore files omitted
                             from version control
       --create-testdir      create a scratch package with the given modules
+                            (pass --with-tests to include the unit tests)
       --create-megatestdir  create a mega scratch package with the given modules
                             one by one and all together
+                            (pass --with-tests to include the unit tests)
       --test                test the combination of the given modules
+                            (pass --with-tests to include the unit tests)
                             (recommended to use CC=\"gcc -Wall\" here)
       --megatest            test the given modules one by one and all together
+                            (pass --with-tests to include the unit tests)
                             (recommended to use CC=\"gcc -Wall\" here)
       --extract-description        extract the description
       --extract-comment            extract the comment
@@ -186,6 +190,8 @@ Operation modes:
       --extract-maintainer         report the maintainer(s) inside gnulib
       --extract-tests-module       report the unit test module, if it exists
       --copy-file                  copy a file that is not part of any module
+      --help                Show this help text.
+      --version             Show version and authorship information.
 
 General options:
 
@@ -259,6 +265,8 @@ Options for --import, --add/remove-import:
                             'gl_INIT'. Default is 'gl'.
       --po-domain=NAME      Specify the prefix of the i18n domain. Usually use
                             the package name. A suffix '-gnulib' is appended.
+      --witness-c-macro=NAME  Specify the C macro that is defined when the
+                            sources in this directory are compiled or used.
       --vc-files            Update version control related files.
       --no-vc-files         Don't update version control related files
                             (.gitignore and/or .cvsignore).
@@ -346,10 +354,22 @@ func_emit_copyright_notice ()
                q
              }' < "$self_abspathname"
   echo "#"
-  echo "# This file is free software, distributed under the terms of the GNU"
-  echo "# General Public License.  As a special exception to the GNU General"
-  echo "# Public License, this file may be distributed as part of a program"
-  echo "# that contains a configuration script generated by Autoconf, under"
+  echo "# This file is free software; you can redistribute it and/or modify"
+  echo "# it under the terms of the GNU General Public License as published by"
+  echo "# the Free Software Foundation; either version 3 of the License, or"
+  echo "# (at your option) any later version."
+  echo "#"
+  echo "# This file is distributed in the hope that it will be useful,"
+  echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
+  echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the"
+  echo "# GNU General Public License for more details."
+  echo "#"
+  echo "# You should have received a copy of the GNU General Public License"
+  echo "# along with this file.  If not, see <http://www.gnu.org/licenses/>."
+  echo "#"
+  echo "# As a special exception to the GNU General Public License,"
+  echo "# this file may be distributed as part of a program that"
+  echo "# contains a configuration script generated by Autoconf, under"
   echo "# the same distribution terms as the rest of that program."
   echo "#"
   echo "# Generated by gnulib-tool."
@@ -928,6 +948,7 @@ fi
 #                   given, blank otherwise
 # - macro_prefix    from --macro-prefix
 # - po_domain       from --po-domain
+# - witness_c_macro  from --witness-c-macro
 # - vc_files        true if --vc-files was given, false if --no-vc-files was
 #                   given, blank otherwise
 # - autoconf_minversion  minimum supported autoconf version
@@ -970,6 +991,7 @@ fi
   libtool=
   macro_prefix=
   po_domain=
+  witness_c_macro=
   vc_files=
   do_changelog=:
   doit=:
@@ -1221,6 +1243,16 @@ fi
       --po-domain=* )
         po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
         shift ;;
+      --witness-c-macro )
+        shift
+        if test $# = 0; then
+          func_fatal_error "missing argument for --witness-c-macro"
+        fi
+        witness_c_macro="$1"
+        shift ;;
+      --witness-c-macro=* )
+        witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
+        shift ;;
       --vc-files )
         vc_files=true
         shift ;;
@@ -1303,7 +1335,7 @@ fi
        || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
        || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
        || test -n "$macro_prefix" || test -n "$po_domain" \
-       || test -n "$vc_files"; then
+       || test -n "$witness_c_macro" || test -n "$vc_files"; then
       echo "gnulib-tool: invalid options for 'update' mode" 1>&2
       echo "Try 'gnulib-tool --help' for more information." 1>&2
       echo "If you really want to modify the gnulib configuration of your project," 1>&2
@@ -2082,24 +2114,26 @@ func_get_dependencies ()
       ;;
   esac
   # Then the explicit dependencies listed in the module description.
-  if ! $modcache; then
-    func_lookup_file "modules/$1"
-    sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
-  else
-    func_cache_lookup_module "$1"
-    # Output the field's value, including the final newline (if any).
-    if $have_associative; then
-      if eval 'test -n "${modcache_dependson[$1]+set}"'; then
-        eval 'echo "${modcache_dependson[$1]}"'
-      fi
+  { if ! $modcache; then
+      func_lookup_file "modules/$1"
+      sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
     else
-      eval "field_set=\"\$${cachevar}_dependson_set\""
-      if test -n "$field_set"; then
-        eval "field_value=\"\$${cachevar}_dependson\""
-        echo "${field_value}"
+      func_cache_lookup_module "$1"
+      # Output the field's value, including the final newline (if any).
+      if $have_associative; then
+        if eval 'test -n "${modcache_dependson[$1]+set}"'; then
+          eval 'echo "${modcache_dependson[$1]}"'
+        fi
+      else
+        eval "field_set=\"\$${cachevar}_dependson_set\""
+        if test -n "$field_set"; then
+          eval "field_value=\"\$${cachevar}_dependson\""
+          echo "${field_value}"
+        fi
       fi
     fi
-  fi
+  } \
+  | sed -e '/^#/d'
 }
 
 # func_get_autoconf_early_snippet module
@@ -2347,31 +2381,50 @@ func_get_link_directive ()
   fi
 }
 
-# func_get_license module
+# func_get_license_raw module
 # Input:
 # - local_gnulib_dir  from --local-dir
 # - modcache          true or false, from --cache-modules/--no-cache-modules
-func_get_license ()
+func_get_license_raw ()
 {
-  {
-    if ! $modcache; then
-      func_lookup_file "modules/$1"
-      sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
+  if ! $modcache; then
+    func_lookup_file "modules/$1"
+    sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
+  else
+    func_cache_lookup_module "$1"
+    # Output the field's value, including the final newline (if any).
+    if $have_associative; then
+      if eval 'test -n "${modcache_license[$1]+set}"'; then
+        eval 'echo "${modcache_license[$1]}"'
+      fi
     else
-      func_cache_lookup_module "$1"
-      # Output the field's value, including the final newline (if any).
-      if $have_associative; then
-        if eval 'test -n "${modcache_license[$1]+set}"'; then
-          eval 'echo "${modcache_license[$1]}"'
-        fi
-      else
-        eval "field_set=\"\$${cachevar}_license_set\""
-        if test -n "$field_set"; then
-          eval "field_value=\"\$${cachevar}_license\""
-          echo "${field_value}"
-        fi
+      eval "field_set=\"\$${cachevar}_license_set\""
+      if test -n "$field_set"; then
+        eval "field_value=\"\$${cachevar}_license\""
+        echo "${field_value}"
       fi
     fi
+  fi
+}
+
+# func_get_license module
+# Input:
+# - local_gnulib_dir  from --local-dir
+# - modcache          true or false, from --cache-modules/--no-cache-modules
+func_get_license ()
+{
+  # Warn if the License field is missing.
+  case "$1" in
+    *-tests ) ;;
+    * )
+      license=`func_get_license_raw "$1"`
+      if test -z "$license"; then
+        func_warning "module $1 lacks a License"
+      fi
+      ;;
+  esac
+  {
+    func_get_license_raw "$1"
     # The default is GPL.
     echo "GPL"
   } | sed -e 's,^ *$,,' | sed -e 1q
@@ -2702,7 +2755,7 @@ func_modules_transitive_closure ()
                   ;;
               esac
             done
-            if $inc; then
+            if $inc && func_acceptable "$dep"; then
               func_append inmodules " $dep"
               if test "$cond_dependencies" = true; then
                 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
@@ -3098,7 +3151,7 @@ func_add_file ()
          || { test -n "$lsymbolic" \
               && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
        && test -z "$lookedup_tmp" \
-       && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
+       && cmp -s "$lookedup_file" "$tmpfile"; then
       func_ln_if_changed "$lookedup_file" "$destdir/$g"
     else
       mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
@@ -3127,7 +3180,7 @@ func_add_file ()
 # - already_present  nonempty if the file should already exist, empty otherwise
 func_update_file ()
 {
-  if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
+  if cmp -s "$destdir/$g" "$tmpfile"; then
     : # The file has not changed.
   else
     # Replace the file.
@@ -3142,7 +3195,7 @@ func_update_file ()
            || { test -n "$lsymbolic" \
                 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
          && test -z "$lookedup_tmp" \
-         && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
+         && cmp -s "$lookedup_file" "$tmpfile"; then
         func_ln_if_changed "$lookedup_file" "$destdir/$g"
       else
         mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
@@ -3170,6 +3223,7 @@ func_update_file ()
 # - libtool         true if libtool will be used, false or blank otherwise
 # - macro_prefix    prefix of gl_LIBOBJS macros to use
 # - po_domain       prefix of i18n domain to use (without -gnulib suffix)
+# - witness_c_macro  from --witness-c-macro
 # - actioncmd       (optional) command that will reproduce this invocation
 # - for_test        true if creating a package for testing, false otherwise
 # - sed_replace_include_guard_prefix
@@ -3294,8 +3348,12 @@ func_emit_lib_Makefile_am ()
     echo "noinst_HEADERS ="
     echo "noinst_LIBRARIES ="
     echo "noinst_LTLIBRARIES ="
-    # Automake versions < 1.9b create an empty pkgdatadir at installation time
-    # if you specify pkgdata_DATA to empty. This is a workaround.
+    # Automake versions < 1.11.4 create an empty pkgdatadir at
+    # installation time if you specify pkgdata_DATA to empty.
+    # See automake bugs #10997 and #11030:
+    #  * http://debbugs.gnu.org/10997
+    #  * http://debbugs.gnu.org/11030
+    # So we need this workaround.
     if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
       echo "pkgdata_DATA ="
     fi
@@ -3324,14 +3382,25 @@ func_emit_lib_Makefile_am ()
       fi
     fi
   done
+  if test -n "$witness_c_macro"; then
+    cppflags_part1=" -D$witness_c_macro=1"
+  else
+    cppflags_part1=
+  fi
+  if $for_test; then
+    cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
+  else
+    cppflags_part2=
+  fi
   if test -z "$makefile_name"; then
     echo
-    if $for_test; then
-      echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
-    else
-      echo "AM_CPPFLAGS ="
-    fi
+    echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
     echo "AM_CFLAGS ="
+  else
+    if test -n "$cppflags_part1$cppflags_part2"; then
+      echo
+      echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
+    fi
   fi
   echo
   if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
@@ -3479,6 +3548,7 @@ func_emit_po_POTFILES_in ()
 # - m4base          relative directory containing autoconf macros
 # - testsbase       relative directory containing unit test code
 # - macro_prefix    prefix of gl_LIBOBJS macros to use
+# - witness_c_macro  from --witness-c-macro
 # - for_test        true if creating a package for testing, false otherwise
 # - single_configure  true if a single configure file should be generated,
 #                     false for a separate configure file for the tests
@@ -3603,8 +3673,12 @@ func_emit_tests_Makefile_am ()
       echo "check_LIBRARIES = libtests.a"
     fi
   fi
-  # Automake versions < 1.9b create an empty pkgdatadir at installation time
-  # if you specify pkgdata_DATA to empty. This is a workaround.
+  # Automake versions < 1.11.4 create an empty pkgdatadir at
+  # installation time if you specify pkgdata_DATA to empty.
+  # See automake bugs #10997 and #11030:
+  #  * http://debbugs.gnu.org/10997
+  #  * http://debbugs.gnu.org/11030
+  # So we need this workaround.
   if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
     echo "pkgdata_DATA ="
   fi
@@ -3635,6 +3709,9 @@ func_emit_tests_Makefile_am ()
   if $for_test; then
     echo "  -DGNULIB_STRICT_CHECKING=1 \\"
   fi
+  if test -n "$witness_c_macro"; then
+    echo "  -D$witness_c_macro=1 \\"
+  fi
   if test -n "${witness_macro}"; then
     echo "  -D@${witness_macro}@=1 \\"
   fi
@@ -3808,6 +3885,8 @@ func_emit_initmacro_done ()
 # - local_gnulib_dir  from --local-dir
 # - modcache          true or false, from --cache-modules/--no-cache-modules
 # - sed_replace_build_aux  sed expression that replaces reference to build-aux
+# - sed_replace_include_guard_prefix
+#                     sed expression for resolving ${gl_include_guard_prefix}
 # - module            the module name
 # - toplevel          true or false. 'false' means a subordinate use of
 #                     gnulib-tool.
@@ -3830,6 +3909,7 @@ func_emit_autoconf_snippet ()
     func_get_autoconf_snippet "$module" \
       | sed -e '/^$/d;' -e "s/^/$indentation/" \
             -e "$sed_replace_build_aux" \
+            -e "$sed_replace_include_guard_prefix" \
       | { if $disable_libtool; then
             sed -e 's/\$gl_cond_libtool/false/g' \
                 -e 's/gl_libdeps/gltests_libdeps/g' \
@@ -3859,6 +3939,8 @@ func_emit_autoconf_snippet ()
 # - local_gnulib_dir  from --local-dir
 # - modcache          true or false, from --cache-modules/--no-cache-modules
 # - sed_replace_build_aux  sed expression that replaces reference to build-aux
+# - sed_replace_include_guard_prefix
+#                     sed expression for resolving ${gl_include_guard_prefix}
 # - modules           the list of modules.
 # - verifier          one of func_verify_module, func_verify_nontests_module,
 #                     func_verify_tests_module. It selects the subset of
@@ -3877,6 +3959,7 @@ func_emit_autoconf_snippets ()
   disable_libtool="$4"
   disable_gettext="$5"
   if test "$cond_dependencies" = true; then
+    for m in $modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
     # Emit the autoconf code for the unconditional modules.
     for module in $1; do
       eval $verifier
@@ -3913,12 +3996,14 @@ func_emit_autoconf_snippets ()
           func_emit_autoconf_snippet "      "
           echo "      $shellvar=true"
           deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
+          # Intersect $deps with the modules list $1.
+          deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
           for dep in $deps; do
             if func_cond_module_p "$dep"; then
               func_module_shellfunc_name "$dep"
               func_cond_module_condition "$module" "$dep"
               if test "$condition" != true; then
-                echo '      if $condition; then'
+                echo "      if $condition; then"
                 echo "        $shellfunc"
                 echo '      fi'
               else
@@ -3943,6 +4028,8 @@ func_emit_autoconf_snippets ()
           :
         else
           deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
+          # Intersect $deps with the modules list $1.
+          deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
           for dep in $deps; do
             if func_cond_module_p "$dep"; then
               func_module_shellfunc_name "$dep"
@@ -4022,6 +4109,7 @@ func_emit_autoconf_snippets ()
 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
 # - macro_prefix    prefix of gl_EARLY, gl_INIT macros to use
 # - po_domain       prefix of i18n domain to use (without -gnulib suffix)
+# - witness_c_macro  from --witness-c-macro
 # - vc_files        true if --vc-files was given, false if --no-vc-files was
 #                   given, blank otherwise
 # - autoconf_minversion  minimum supported autoconf version
@@ -4058,6 +4146,7 @@ func_import ()
   cached_libtool=
   cached_macro_prefix=
   cached_po_domain=
+  cached_witness_c_macro=
   cached_vc_files=
   cached_files=
   if test -f "$destdir"/$m4base/gnulib-cache.m4; then
@@ -4142,6 +4231,9 @@ func_import ()
       /gl_PO_DOMAIN(/ {
         s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
       }
+      /gl_WITNESS_C_MACRO(/ {
+        s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
+      }
       /gl_VC_FILES(/ {
         s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
       }'
@@ -4331,6 +4423,10 @@ func_import ()
     if test -z "$po_domain"; then
       po_domain="$cached_po_domain"
     fi
+    # The witness_c_macro defaults to the cached one.
+    if test -z "$witness_c_macro"; then
+      witness_c_macro="$cached_witness_c_macro"
+    fi
     # The vc_files defaults to the cached one.
     if test -z "$vc_files"; then
       vc_files="$cached_vc_files"
@@ -4730,6 +4826,9 @@ s,^\(.................................................[^ ]*\) *,
   if test -n "$po_domain"; then
     func_append actioncmd " --po-domain=$po_domain"
   fi
+  if test -n "$witness_c_macro"; then
+    func_append actioncmd " --witness-c-macro=$witness_c_macro"
+  fi
   if test -n "$vc_files"; then
     if test "$vc_files" = true; then
       func_append actioncmd " --vc-files"
@@ -4810,7 +4909,7 @@ s,//*$,/,'
   modules="$main_modules"
   func_emit_lib_Makefile_am > "$tmpfile"
   if test -f "$destdir"/$sourcebase/$makefile_am; then
-    if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
+    if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
       rm -f "$tmpfile"
     else
       if $doit; then
@@ -4841,7 +4940,7 @@ s,//*$,/,'
       func_lookup_file build-aux/po/$file
       cat "$lookedup_file" > "$tmpfile"
       if test -f "$destdir"/$pobase/$file; then
-        if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
+        if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
           rm -f "$tmpfile"
         else
           if $doit; then
@@ -4868,7 +4967,7 @@ s,//*$,/,'
     func_dest_tmpfilename $pobase/Makevars
     func_emit_po_Makevars > "$tmpfile"
     if test -f "$destdir"/$pobase/Makevars; then
-      if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
+      if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
         rm -f "$tmpfile"
       else
         if $doit; then
@@ -4894,7 +4993,7 @@ s,//*$,/,'
     func_dest_tmpfilename $pobase/POTFILES.in
     func_emit_po_POTFILES_in > "$tmpfile"
     if test -f "$destdir"/$pobase/POTFILES.in; then
-      if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
+      if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
         rm -f "$tmpfile"
       else
         if $doit; then
@@ -4943,7 +5042,7 @@ s,//*$,/,'
           }
       ) > "$tmpfile"
       if test -f "$destdir"/$pobase/LINGUAS; then
-        if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
+        if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
           rm -f "$tmpfile"
         else
           echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
@@ -5026,12 +5125,13 @@ s,//*$,/,'
     fi
     echo "gl_MACRO_PREFIX([$macro_prefix])"
     echo "gl_PO_DOMAIN([$po_domain])"
+    echo "gl_WITNESS_C_DOMAIN([$witness_c_macro])"
     if test -n "$vc_files"; then
       echo "gl_VC_FILES([$vc_files])"
     fi
   ) > "$tmpfile"
   if test -f "$destdir"/$m4base/gnulib-cache.m4; then
-    if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
+    if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
       rm -f "$tmpfile"
     else
       if $doit; then
@@ -5081,7 +5181,7 @@ s,//*$,/,'
     echo "  m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
     echo "  m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
     echo "  m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
-    echo "  AC_REQUIRE([AC_PROG_RANLIB])"
+    echo "  AC_REQUIRE([gl_PROG_AR_RANLIB])"
     if test -n "$uses_subdirs"; then
       echo "  AC_REQUIRE([AM_PROG_CC_C_O])"
     fi
@@ -5121,7 +5221,13 @@ s,//*$,/,'
     echo "  gl_m4_base='$m4base'"
     func_emit_initmacro_start $macro_prefix
     echo "  gl_source_base='$sourcebase'"
+    if test -n "$witness_c_macro"; then
+      echo "  m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
+    fi
     func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
+    if test -n "$witness_c_macro"; then
+      echo "  m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
+    fi
     echo "  # End of code from modules"
     func_emit_initmacro_end $macro_prefix
     echo "  gltests_libdeps="
@@ -5164,7 +5270,7 @@ s,//*$,/,'
     echo "])"
   ) > "$tmpfile"
   if test -f "$destdir"/$m4base/gnulib-comp.m4; then
-    if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
+    if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
       rm -f "$tmpfile"
     else
       if $doit; then
@@ -5199,7 +5305,7 @@ s,//*$,/,'
     modules="$testsrelated_modules"
     func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
     if test -f "$destdir"/$testsbase/$makefile_am; then
-      if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
+      if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
         rm -f "$tmpfile"
       else
         if $doit; then
@@ -5397,7 +5503,16 @@ s,//*$,/,'
       echo "  - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
     fi
   done
-  echo "  - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
+  if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
+    position_early_after=AC_PROG_CC_STDC
+  else
+    if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
+      position_early_after=AC_PROG_CC_C99
+    else
+      position_early_after=AC_PROG_CC
+    fi
+  fi
+  echo "  - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
   echo "  - invoke ${macro_prefix}_INIT in $configure_ac."
 }
 
@@ -5453,7 +5568,7 @@ func_create_testdir ()
   # its dependencies.
   saved_inctests="$inctests"
   # When computing transitive closures, don't consider $module to depend on
-  # $module-tests. Need this becauses tests are implicitly GPL and may depend
+  # $module-tests. Need this because tests are implicitly GPL and may depend
   # on GPL modules - therefore we don't want a warning in this case.
   inctests=""
   for requested_module in $specified_modules; do
@@ -5506,6 +5621,7 @@ func_create_testdir ()
   testsbase=gltests
   macro_prefix=gl
   po_domain=
+  witness_c_macro=
   vc_files=
 
   # Determine final module list.
@@ -5683,7 +5799,7 @@ func_create_testdir ()
        echo "AC_PROG_CC"
        echo "AC_PROG_INSTALL"
        echo "AC_PROG_MAKE_SET"
-       echo "AC_PROG_RANLIB"
+       echo "gl_PROG_AR_RANLIB"
        echo
        if test -n "$uses_subdirs"; then
          echo "AM_PROG_CC_C_O"
@@ -5798,7 +5914,7 @@ func_create_testdir ()
    echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
    echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
    echo
-   echo "AC_PROG_RANLIB"
+   echo "gl_PROG_AR_RANLIB"
    echo
    if test -n "$any_uses_subdirs"; then
      echo "AM_PROG_CC_C_O"
@@ -6292,7 +6408,8 @@ s/\([.*$]\)/[\1]/g'
                 #   inc_longrunning_tests, inc_privileged_tests,
                 #   inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
                 #   m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
-                #   makefile_name, libtool, macro_prefix, po_domain, vc_files
+                #   makefile_name, libtool, macro_prefix, po_domain,
+                #   witness_c_macro, vc_files
                 # don't propagate from one directory to another.
                 (func_import) || func_exit 1
               done
@@ -6433,6 +6550,9 @@ s/\([.*$]\)/[\1]/g'
     ;;
 
   extract-dependencies )
+    if test -n "$avoidlist"; then
+      func_fatal_error "cannot combine --avoid and --extract-dependencies"
+    fi
     for module
     do
       func_verify_module