digests, copy-file: increase the IO buffer size from 4KiB to 32KiB
[gnulib.git] / gnulib-tool
index 0b059e1..397f442 100755 (executable)
@@ -703,7 +703,7 @@ if test -z "$have_echo" \
    && test "X$1" != "X--no-reexec" \
    && test -n "$CONFIG_SHELL" \
    && test -f "$CONFIG_SHELL" \
-   && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
+   && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
   exec $CONFIG_SHELL "$0" --no-reexec "$@"
   exit 127
 fi
@@ -1953,7 +1953,14 @@ func_emit_lib_Makefile_am ()
   echo "## Process this file with automake to produce Makefile.in."
   func_emit_copyright_notice
   if test -n "$actioncmd"; then
-    echo "# Reproduce by: $actioncmd"
+    # The maximum line length (excluding the terminating newline) of any file
+    # that is to be preprocessed by config.status is 3070.  config.status uses
+    # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
+    # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
+    len=`echo "$actioncmd" | wc -c`
+    if test -n "$len" && test "$len" -le 3000; then
+      echo "# Reproduce by: $actioncmd"
+    fi
   fi
   echo
   uses_subdirs=
@@ -2047,9 +2054,14 @@ func_emit_lib_Makefile_am ()
     echo "AM_CFLAGS ="
   fi
   echo
-  if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
-    # One of the snippets already specifies an installation location for the
-    # library. Don't confuse automake by saying it should not be installed.
+  if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null \
+     || { test -n "$makefile_name" \
+          && test -f "$sourcebase/Makefile.am" \
+          && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
+        }; then
+    # One of the snippets or the user's Makefile.am already specifies an
+    # installation location for the library. Don't confuse automake by saying
+    # it should not be installed.
     :
   else
     # By default, the generated library should not be installed.
@@ -2204,7 +2216,7 @@ func_emit_tests_Makefile_am ()
   func_emit_copyright_notice
   echo
   uses_subdirs=
-  (
+  {
     for module in $modules; do
       if $for_test; then
         func_verify_tests_module
@@ -2246,7 +2258,7 @@ func_emit_tests_Makefile_am ()
         done
       fi
     done
-  ) > allsnippets.tmp
+  } > allsnippets.tmp
   # Generate dependencies here, since it eases the debugging of test failures.
   # If there are source files in subdirectories, prevent collision of the
   # object files (example: hash.c and libxml/hash.c).
@@ -2731,9 +2743,10 @@ func_import ()
   # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
   # is specified, it will consist only of LGPLed source.
   # The tests-related module list is the transitive closure of the specified
-  # modules, including tests modules, minus the main module list. Its lib/*
-  # sources (brought in through dependencies of *-tests modules) go into
-  # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
+  # modules, including tests modules, minus the main module list excluding
+  # 'link-warning'. Its lib/* sources (brought in through dependencies of
+  # *-tests modules) go into $testsbase/. It may contain GPLed source, even if
+  # --lgpl is specified.
   # Determine main module list.
   saved_inctests="$inctests"
   inctests=""
@@ -2747,7 +2760,8 @@ func_import ()
   fi
   # Determine tests-related module list.
   echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
-  testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
+  sed_remove_link_warning='/^link-warning$/d'
+  testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | sed -e "$sed_remove_link_warning" | LC_ALL=C join -v 2 - "$tmp"/final-modules`
   if test $verbose -ge 1; then
     echo "Tests-related module list:"
     echo "$testsrelated_modules" | sed -e 's/^/  /'
@@ -2857,11 +2871,22 @@ s,^\(.................................................[^ ]*\) *,
       sed_transform_main_lib_file=$sed_transform_main_lib_file'
         s/GNU Lesser General/GNU General/g
         s/GNU Library General/GNU General/g
-        s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
+        s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
       '
     fi
   fi
 
+  # Determine script to apply to auxiliary files that go into $auxdir/.
+  sed_transform_build_aux_file=
+  if test -n "$do_copyrights"; then
+    # Update license.
+    sed_transform_build_aux_file=$sed_transform_build_aux_file'
+      s/GNU Lesser General/GNU General/g
+      s/GNU Library General/GNU General/g
+      s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
+    '
+  fi
+
   # Determine script to apply to library files that go into $testsbase/.
   sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
   if test -n "$do_copyrights"; then
@@ -2869,7 +2894,7 @@ s,^\(.................................................[^ ]*\) *,
     sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
       s/GNU Lesser General/GNU General/g
       s/GNU Library General/GNU General/g
-      s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
+      s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
     '
   fi
 
@@ -2905,22 +2930,25 @@ s,^\(.................................................[^ ]*\) *,
     func_append old_files " m4/gnulib-tool.m4"
   fi
 
+  rewritten='%REWRITTEN%'
   sed_rewrite_old_files="\
-    s,^build-aux/,$auxdir/,
-    s,^doc/,$cached_docbase/,
-    s,^lib/,$cached_sourcebase/,
-    s,^m4/,$cached_m4base/,
-    s,^tests/,$cached_testsbase/,
-    s,^tests=lib/,$cached_testsbase/,
-    s,^top/,,"
+    s,^build-aux/,$rewritten$auxdir/,
+    s,^doc/,$rewritten$cached_docbase/,
+    s,^lib/,$rewritten$cached_sourcebase/,
+    s,^m4/,$rewritten$cached_m4base/,
+    s,^tests/,$rewritten$cached_testsbase/,
+    s,^tests=lib/,$rewritten$cached_testsbase/,
+    s,^top/,$rewritten,
+    s,^$rewritten,,"
   sed_rewrite_new_files="\
-    s,^build-aux/,$auxdir/,
-    s,^doc/,$docbase/,
-    s,^lib/,$sourcebase/,
-    s,^m4/,$m4base/,
-    s,^tests/,$testsbase/,
-    s,^tests=lib/,$testsbase/,
-    s,^top/,,"
+    s,^build-aux/,$rewritten$auxdir/,
+    s,^doc/,$rewritten$docbase/,
+    s,^lib/,$rewritten$sourcebase/,
+    s,^m4/,$rewritten$m4base/,
+    s,^tests/,$rewritten$testsbase/,
+    s,^tests=lib/,$rewritten$testsbase/,
+    s,^top/,$rewritten,
+    s,^$rewritten,,"
 
   # Create directories.
   { echo "$sourcebase"
@@ -3010,6 +3038,14 @@ s,^\(.................................................[^ ]*\) *,
           ;;
       esac
     fi
+    if test -n "$sed_transform_build_aux_file"; then
+      case "$of" in
+        build-aux/*)
+          sed -e "$sed_transform_build_aux_file" \
+            < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
+          ;;
+      esac
+    fi
     if test -n "$sed_transform_testsrelated_lib_file"; then
       case "$of" in
         tests=lib/*)
@@ -3784,10 +3820,9 @@ func_create_testdir ()
   if test -z "$modules"; then
     # All modules together.
     # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
-    # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
     # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
     modules=`func_all_modules`
-    modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
+    modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist) ;; *) echo $m;; esac; done`
   fi
   modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
 
@@ -3872,13 +3907,15 @@ func_create_testdir ()
     echo "$files" | sed -e 's/^/  /'
   fi
 
+  rewritten='%REWRITTEN%'
   sed_rewrite_files="\
-    s,^build-aux/,$auxdir/,
-    s,^doc/,$docbase/,
-    s,^lib/,$sourcebase/,
-    s,^m4/,$m4base/,
-    s,^tests/,$testsbase/,
-    s,^top/,,"
+    s,^build-aux/,$rewritten$auxdir/,
+    s,^doc/,$rewritten$docbase/,
+    s,^lib/,$rewritten$sourcebase/,
+    s,^m4/,$rewritten$m4base/,
+    s,^tests/,$rewritten$testsbase/,
+    s,^top/,$rewritten,
+    s,^$rewritten,,"
 
   # Create directories.
   for f in $files; do echo $f; done \
@@ -3975,13 +4012,17 @@ func_create_testdir ()
      echo "AC_CONFIG_AUX_DIR([$auxdir])"
      echo "AM_INIT_AUTOMAKE"
      echo
-     echo "AM_CONFIG_HEADER([config.h])"
+     echo "AC_CONFIG_HEADERS([config.h])"
      echo
      echo "AC_PROG_CC"
      echo "AC_PROG_INSTALL"
      echo "AC_PROG_MAKE_SET"
      echo "AC_PROG_RANLIB"
      echo
+     if test -n "$uses_subdirs"; then
+       echo "AM_PROG_CC_C_O"
+       echo
+     fi
      for module in $modules; do
        func_verify_module
        if test -n "$module"; then
@@ -4065,7 +4106,8 @@ func_create_testdir ()
      # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
      echo "AH_TOP([#include \"../config.h\"])"
      echo
-     echo "AC_OUTPUT([Makefile])"
+     echo "AC_CONFIG_FILES([Makefile])"
+     echo "AC_OUTPUT"
     ) > "$testdir/$testsbase/configure.ac"
     auxdir="$saved_auxdir"
     func_append subdirs " $testsbase"
@@ -4090,7 +4132,7 @@ func_create_testdir ()
    fi
    echo "AM_INIT_AUTOMAKE"
    echo
-   echo "AM_CONFIG_HEADER([config.h])"
+   echo "AC_CONFIG_HEADERS([config.h])"
    echo
    echo "AC_PROG_CC"
    echo "AC_PROG_INSTALL"
@@ -4181,7 +4223,8 @@ func_create_testdir ()
        *) func_append makefiles " $d/Makefile" ;;
      esac
    done
-   echo "AC_OUTPUT([$makefiles])"
+   echo "AC_CONFIG_FILES([$makefiles])"
+   echo "AC_OUTPUT"
   ) > "$testdir/configure.ac"
 
   # Create autogenerated files.
@@ -4276,8 +4319,7 @@ func_create_megatestdir ()
   done
   # Then, all modules all together.
   # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
-  # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
-  allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
+  allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
   func_create_testdir "$megatestdir/ALL" "$allmodules"
   func_append megasubdirs "ALL"
 
@@ -4344,7 +4386,8 @@ func_create_megatestdir ()
    echo "AC_PROG_MAKE_SET"
    echo
    echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
-   echo "AC_OUTPUT([Makefile])"
+   echo "AC_CONFIG_FILES([Makefile])"
+   echo "AC_OUTPUT"
   ) > "$megatestdir/configure.ac"
 
   # Create autogenerated files.
@@ -4383,7 +4426,7 @@ case $mode in
       if test -f "$destdir"/configure.in; then
         configure_ac="$destdir/configure.in"
       else
-        func_fatal_error "cannot find $destdir/configure.ac"
+        func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
       fi
     fi
 
@@ -4705,13 +4748,15 @@ case $mode in
     test -n "$docbase" || docbase="doc"
     test -n "$testsbase" || testsbase="tests"
     test -n "$auxdir" || auxdir="build-aux"
+    rewritten='%REWRITTEN%'
     sed_rewrite_files="\
-      s,^build-aux/,$auxdir/,
-      s,^doc/,$docbase/,
-      s,^lib/,$sourcebase/,
-      s,^m4/,$m4base/,
-      s,^tests/,$testsbase/,
-      s,^top/,,"
+      s,^build-aux/,$rewritten$auxdir/,
+      s,^doc/,$rewritten$docbase/,
+      s,^lib/,$rewritten$sourcebase/,
+      s,^m4/,$rewritten$m4base/,
+      s,^tests/,$rewritten$testsbase/,
+      s,^top/,$rewritten,
+      s,^$rewritten,,"
     if test -d "$dest"; then
       destdir="$dest"
       g=`echo "$f" | sed -e "$sed_rewrite_files"`