-mautoupdate
[gnulib.git] / gnulib-tool
index 67986a2..90da140 100755 (executable)
@@ -490,6 +490,13 @@ func_fatal_error ()
   func_exit 1
 }
 
+# func_warning message
+# Outputs to stderr a warning message,
+func_warning ()
+{
+  echo "gnulib-tool: warning: $1" 1>&2
+}
+
 # func_readlink SYMLINK
 # outputs the target of the given symlink.
 if (type -p readlink) > /dev/null 2>&1; then
@@ -1135,7 +1142,7 @@ fi
     func_exit 1
   fi
   if test -z "$pobase" && test -n "$po_domain"; then
-    echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
+    func_warning "--po-domain has no effect without a --po-base option"
   fi
 
   # Determine the minimum supported autoconf version from the project's
@@ -1311,7 +1318,7 @@ func_verify_module ()
     # Verify that building the module description with 'patch' succeeds.
     func_lookup_file "modules/$module"
   else
-    echo "gnulib-tool: module $module doesn't exist" 1>&2
+    func_warning "module $module doesn't exist"
     module=
   fi
 }
@@ -1428,6 +1435,7 @@ func_get_filelist ()
 # elements starting with prefix and ending with suffix are considered.
 # Processing: removed_prefix and removed_suffix are removed from each element,
 # added_prefix and added_suffix are added to each element.
+# prefix, suffix should not contain shell-special characters.
 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
 # added_prefix, added_suffix should not contain the characters \|&.
 func_filter_filelist ()
@@ -1439,8 +1447,10 @@ func_filter_filelist ()
         }; then
     ffflist=
     for fff in $3; do
+      # Do not quote possibly-empty parameters in case patterns,
+      # AIX and HP-UX ksh won't match them if they are empty.
       case "$fff" in
-        "$4"*"$5")
+        $4*$5)
           if test -n "$6"; then
             func_remove_prefix fff "$6"
           fi
@@ -1460,7 +1470,7 @@ func_filter_filelist ()
     sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
     ffflist=`for fff in $3; do
                case "$fff" in
-                 "$4"*"$5") echo "$fff" ;;
+                 $4*$5) echo "$fff" ;;
                esac
              done | sed -e "$sed_fff_filter"`
   fi
@@ -1686,7 +1696,7 @@ func_modules_transitive_closure ()
           # Duplicate dependencies are harmless, but Jim wants a warning.
           duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
           if test -n "$duplicated_deps"; then
-            echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
+            func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
           fi
           for dep in $deps; do
             if test -n "$incobsolete" \
@@ -1999,16 +2009,16 @@ func_emit_lib_Makefile_am ()
             echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
             echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
           fi
-        } > amsnippet.tmp
+        } > "$tmp"/amsnippet
         # Skip the contents if it's entirely empty.
-        if grep '[^     ]' amsnippet.tmp > /dev/null ; then
+        if grep '[^     ]' "$tmp"/amsnippet > /dev/null ; then
           echo "## begin gnulib module $module"
           echo
-          cat amsnippet.tmp
+          cat "$tmp"/amsnippet
           echo "## end   gnulib module $module"
           echo
         fi
-        rm -f amsnippet.tmp
+        rm -f "$tmp"/amsnippet
         # Test whether there are some source files in subdirectories.
         for f in `func_get_filelist "$module"`; do
           case $f in
@@ -2020,7 +2030,7 @@ func_emit_lib_Makefile_am ()
         done
       fi
     done
-  } > allsnippets.tmp
+  } > "$tmp"/allsnippets
   if test -z "$makefile_name"; then
     # If there are source files in subdirectories, prevent collision of the
     # object files (example: hash.c and libxml/hash.c).
@@ -2038,7 +2048,7 @@ func_emit_lib_Makefile_am ()
     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.
-    if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
+    if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
       echo "pkgdata_DATA ="
     fi
     echo "EXTRA_DIST ="
@@ -2072,7 +2082,7 @@ 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 \
+  if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /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; \
@@ -2100,7 +2110,7 @@ func_emit_lib_Makefile_am ()
     echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
     echo
   fi
-  cat allsnippets.tmp \
+  cat "$tmp"/allsnippets \
     | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
   echo
   echo "mostlyclean-local: mostlyclean-generic"
@@ -2110,7 +2120,7 @@ func_emit_lib_Makefile_am ()
   echo "         fi; \\"
   echo "       done; \\"
   echo "       :"
-  rm -f allsnippets.tmp
+  rm -f "$tmp"/allsnippets
 }
 
 # func_emit_po_Makevars
@@ -2255,16 +2265,16 @@ func_emit_tests_Makefile_am ()
             echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
             echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
           fi
-        } > amsnippet.tmp
+        } > "$tmp"/amsnippet
         # Skip the contents if it's entirely empty.
-        if grep '[^     ]' amsnippet.tmp > /dev/null ; then
+        if grep '[^     ]' "$tmp"/amsnippet > /dev/null ; then
           echo "## begin gnulib module $module"
           echo
-          cat amsnippet.tmp
+          cat "$tmp"/amsnippet
           echo "## end   gnulib module $module"
           echo
         fi
-        rm -f amsnippet.tmp
+        rm -f "$tmp"/amsnippet
         # Test whether there are some source files in subdirectories.
         for f in `func_get_filelist "$module"`; do
           case $f in
@@ -2276,7 +2286,7 @@ func_emit_tests_Makefile_am ()
         done
       fi
     done
-  } > allsnippets.tmp
+  } > "$tmp"/allsnippets
   # 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).
@@ -2312,7 +2322,7 @@ func_emit_tests_Makefile_am ()
   fi
   # Automake versions < 1.9b create an empty pkgdatadir at installation time
   # if you specify pkgdata_DATA to empty. This is a workaround.
-  if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
+  if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
     echo "pkgdata_DATA ="
   fi
   echo "EXTRA_DIST ="
@@ -2370,7 +2380,12 @@ func_emit_tests_Makefile_am ()
     echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
     echo
   fi
-  cat allsnippets.tmp \
+  # Many test scripts use ${EXEEXT} or ${srcdir}.
+  # EXEEXT is defined by AC_PROG_CC through autoconf.
+  # srcdir is defined by autoconf and automake.
+  echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
+  echo
+  cat "$tmp"/allsnippets \
     | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
   echo "# Clean up after Solaris cc."
   echo "clean-local:"
@@ -2383,7 +2398,7 @@ func_emit_tests_Makefile_am ()
   echo "         fi; \\"
   echo "       done; \\"
   echo "       :"
-  rm -f allsnippets.tmp
+  rm -f "$tmp"/allsnippets
 }
 
 # func_emit_initmacro_start macro_prefix
@@ -3877,19 +3892,19 @@ func_create_testdir ()
               GPLv2+)
                 case "$license" in
                   GPLv2+ | LGPLv2+) ;;
-                  *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
+                  *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
                 esac
                 ;;
               LGPL)
                 case "$license" in
                   LGPL | LGPLv2+) ;;
-                  *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
+                  *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
                 esac
                 ;;
               LGPLv2+)
                 case "$license" in
                   LGPLv2+) ;;
-                  *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
+                  *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
                 esac
                 ;;
             esac