New module 'unictype/joiningtype-longname'.
[gnulib.git] / gnulib-tool
index 78828e5..9461027 100755 (executable)
@@ -1,6 +1,6 @@
 #! /bin/sh
 #
-# Copyright (C) 2002-2010 Free Software Foundation, Inc.
+# Copyright (C) 2002-2011 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
@@ -151,6 +151,7 @@ Usage: gnulib-tool --list
        gnulib-tool --copy-file file [destination]
 
 Operation modes:
+
       --list                print the available module names
       --find                find the modules which contain the specified file
       --import              import the given modules into the current package
@@ -187,6 +188,7 @@ Operation modes:
       --copy-file                  copy a file that is not part of any module
 
 General options:
+
       --dir=DIRECTORY       Specify the target directory.
                             For --import, this specifies where your
                             configure.ac can be found.  Defaults to current
@@ -198,10 +200,13 @@ General options:
       --verbose             Increase verbosity. May be repeated.
       --quiet               Decrease verbosity. May be repeated.
 
-Options for --import, --update:
+Options for --import, --add/remove-import, --update:
+
       --dry-run             Only print what would have been done.
 
-Options for --import, --create-[mega]testdir, --[mega]test:
+Options for --import, --add/remove-import,
+            --create-[mega]testdir, --[mega]test:
+
       --with-tests          Include unit tests for the included modules.
       --with-obsolete       Include obsolete modules when they occur among the
                             dependencies. By default, dependencies to obsolete
@@ -221,7 +226,8 @@ Options for --import, --create-[mega]testdir, --[mega]test:
       --libtool             Use libtool rules.
       --no-libtool          Don't use libtool rules.
 
-Options for --import:
+Options for --import, --add/remove-import:
+
       --lib=LIBRARY         Specify the library name.  Defaults to 'libgnu'.
       --source-base=DIRECTORY
                             Directory relative to --dir where source code is
@@ -236,7 +242,7 @@ Options for --import:
                             Directory relative to --dir where unit tests are
                             placed (default \"tests\").
       --aux-dir=DIRECTORY   Directory relative to --dir where auxiliary build
-                            tools are placed (default \"build-aux\").
+                            tools are placed (default comes from configure.ac).
       --lgpl[=2|=3]         Abort if modules aren't available under the LGPL.
                             Also modify license template from GPL to LGPL.
                             The version number of the LGPL can be specified;
@@ -254,6 +260,7 @@ Options for --import:
       --no-changelog        Don't update or create ChangeLog files.
 
 Options for --create-[mega]testdir, --[mega]test:
+
       --without-c++-tests   Exclude unit tests for C++ interoperability.
       --without-longrunning-tests
                             Exclude unit tests that are long-runners.
@@ -262,12 +269,15 @@ Options for --create-[mega]testdir, --[mega]test:
       --without-unportable-tests
                             Exclude unit tests that fail on some platforms.
 
-Options for --import, --update, --create-[mega]testdir, --[mega]test:
+Options for --import, --add/remove-import, --update,
+            --create-[mega]testdir, --[mega]test:
+
   -s, --symbolic, --symlink Make symbolic links instead of copying files.
       --local-symlink       Make symbolic links instead of copying files, only
                             for files from the local override directory.
 
-Options for --import, --update:
+Options for --import, --add/remove-import, --update:
+
   -S, --more-symlinks       Make symbolic links instead of copying files, and
                             don't replace copyright notices.
 
@@ -824,20 +834,24 @@ fi
 # that the top-level statement containing the test starts after the 'alias'
 # command.
 if test -z "$have_echo"; then
-bsd_echo ()
+  bsd_echo ()
 {
 cat <<EOF
 $*
 EOF
 }
-alias echo=bsd_echo 2>/dev/null
+  if (alias echo=bsd_echo) 2>/dev/null; then
+    alias echo=bsd_echo 2>/dev/null
+  fi
 fi
 if test -z "$have_echo" \
    && echo '\t' | grep t > /dev/null; then
   have_echo=yes
 fi
 if test -z "$have_echo"; then
-  unalias echo 2>/dev/null
+  if (alias echo=bsd_echo) 2>/dev/null; then
+    unalias echo 2>/dev/null
+  fi
 fi
 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
 if test -z "$have_echo" \
@@ -1591,11 +1605,11 @@ if $modcache; then
       #   ${param//pattern/replacement}
       # as a shorthand for
       #   `echo "$param" | sed -e "s/pattern/replacement/g"`.
-      # Note: The 'eval' above silences stderr output in dash.
-      func_cache_var ()
+      # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
+      eval 'func_cache_var ()
       {
         cachevar=c_${1//[!a-zA-Z0-9_]/_}
-      }
+      }'
     else
       func_cache_var ()
       {
@@ -1780,7 +1794,7 @@ if $modcache; then
   func_cache_lookup_module ()
   {
     if $have_associative; then
-      cached=${modcache_cached[$1]}
+      eval 'cached=${modcache_cached[$1]}'
     else
       func_cache_var "$1"
       eval "cached=\"\$${cachevar}_cached\""
@@ -1789,7 +1803,7 @@ if $modcache; then
       # Not found in cache. Look it up on the file system.
       func_lookup_file "modules/$1"
       if $have_associative; then
-        modcache_cached[$1]=yes
+        eval 'modcache_cached[$1]=yes'
       else
         eval "${cachevar}_cached=\"\$1\""
       fi
@@ -1824,8 +1838,8 @@ func_get_description ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_description[$1]+set}"; then
-        echo "${modcache_description[$1]}"
+      if eval 'test -n "${modcache_description[$1]+set}"'; then
+        eval 'echo "${modcache_description[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_description_set\""
@@ -1850,8 +1864,8 @@ func_get_comment ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_comment[$1]+set}"; then
-        echo "${modcache_comment[$1]}"
+      if eval 'test -n "${modcache_comment[$1]+set}"'; then
+        eval 'echo "${modcache_comment[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_comment_set\""
@@ -1876,8 +1890,8 @@ func_get_status ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_status[$1]+set}"; then
-        echo "${modcache_status[$1]}"
+      if eval 'test -n "${modcache_status[$1]+set}"'; then
+        eval 'echo "${modcache_status[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_status_set\""
@@ -1902,8 +1916,8 @@ func_get_notice ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_notice[$1]+set}"; then
-        echo "${modcache_notice[$1]}"
+      if eval 'test -n "${modcache_notice[$1]+set}"'; then
+        eval 'echo "${modcache_notice[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_notice_set\""
@@ -1929,7 +1943,7 @@ func_get_applicability ()
     func_cache_lookup_module "$1"
     # Get the field's value, without the final newline.
     if $have_associative; then
-      my_applicability="${modcache_applicability[$1]}"
+      eval 'my_applicability="${modcache_applicability[$1]}"'
     else
       eval "my_applicability=\"\$${cachevar}_applicability\""
     fi
@@ -1958,8 +1972,8 @@ func_get_filelist ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_files[$1]+set}"; then
-        echo "${modcache_files[$1]}"
+      if eval 'test -n "${modcache_files[$1]+set}"'; then
+        eval 'echo "${modcache_files[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_files_set\""
@@ -2049,8 +2063,8 @@ func_get_dependencies ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_dependson[$1]+set}"; then
-        echo "${modcache_dependson[$1]}"
+      if eval 'test -n "${modcache_dependson[$1]+set}"'; then
+        eval 'echo "${modcache_dependson[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_dependson_set\""
@@ -2075,8 +2089,8 @@ func_get_autoconf_early_snippet ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_configureac_early[$1]+set}"; then
-        echo "${modcache_configureac_early[$1]}"
+      if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
+        eval 'echo "${modcache_configureac_early[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_configureac_early_set\""
@@ -2101,8 +2115,8 @@ func_get_autoconf_snippet ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_configureac[$1]+set}"; then
-        echo "${modcache_configureac[$1]}"
+      if eval 'test -n "${modcache_configureac[$1]+set}"'; then
+        eval 'echo "${modcache_configureac[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_configureac_set\""
@@ -2127,8 +2141,8 @@ func_get_automake_snippet ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_makefile[$1]+set}"; then
-        echo "${modcache_makefile[$1]}"
+      if eval 'test -n "${modcache_makefile[$1]+set}"'; then
+        eval 'echo "${modcache_makefile[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_makefile_set\""
@@ -2165,8 +2179,8 @@ func_get_automake_snippet ()
             sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
           else
             if $have_associative; then
-              if test -n "${modcache_makefile[$1]+set}"; then
-                echo "${modcache_makefile[$1]}"
+              if eval 'test -n "${modcache_makefile[$1]+set}"'; then
+                eval 'echo "${modcache_makefile[$1]}"'
               fi
             else
               eval 'field_set="$'"${cachevar}"'_makefile_set"'
@@ -2202,6 +2216,7 @@ func_get_automake_snippet ()
       # automake will generate a useless dependency; this is harmless.
       case "$1" in
         relocatable-prog-wrapper) ;;
+        pt_chown) ;;
         *)
           func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
           if test -n "$extra_files"; then
@@ -2242,8 +2257,8 @@ func_get_include_directive ()
       func_cache_lookup_module "$1"
       # Output the field's value, including the final newline (if any).
       if $have_associative; then
-        if test -n "${modcache_include[$1]+set}"; then
-          echo "${modcache_include[$1]}"
+        if eval 'test -n "${modcache_include[$1]+set}"'; then
+          eval 'echo "${modcache_include[$1]}"'
         fi
       else
         eval "field_set=\"\$${cachevar}_include_set\""
@@ -2269,8 +2284,8 @@ func_get_link_directive ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_link[$1]+set}"; then
-        echo "${modcache_link[$1]}"
+      if eval 'test -n "${modcache_link[$1]+set}"'; then
+        eval 'echo "${modcache_link[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_link_set\""
@@ -2296,8 +2311,8 @@ func_get_license ()
       func_cache_lookup_module "$1"
       # Output the field's value, including the final newline (if any).
       if $have_associative; then
-        if test -n "${modcache_license[$1]+set}"; then
-          echo "${modcache_license[$1]}"
+        if eval 'test -n "${modcache_license[$1]+set}"'; then
+          eval 'echo "${modcache_license[$1]}"'
         fi
       else
         eval "field_set=\"\$${cachevar}_license_set\""
@@ -2325,8 +2340,8 @@ func_get_maintainer ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_maintainer[$1]+set}"; then
-        echo "${modcache_maintainer[$1]}"
+      if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
+        eval 'echo "${modcache_maintainer[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_maintainer_set\""
@@ -2904,6 +2919,18 @@ func_emit_lib_Makefile_am ()
   echo "EXTRA_${libname}_${libext}_SOURCES ="
   if test "$libtool" = true; then
     echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
+    echo "${libname}_${libext}_LDFLAGS += -no-undefined"
+    # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
+    # the link dependencies of all modules.
+    for module in $modules; do
+      func_verify_nontests_module
+      if test -n "$module"; then
+        func_get_link_directive "$module"
+      fi
+    done \
+      | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
+      | LC_ALL=C sort -u \
+      | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
   fi
   echo
   if test -n "$pobase"; then
@@ -3551,10 +3578,10 @@ func_import ()
           # Use an associative array, for O(N) worst-case run time.
           declare -A to_remove
           for m in $1; do
-            to_remove[$m]=yes
+            eval 'to_remove[$m]=yes'
           done
           for module in $cached_specified_modules; do
-            if test -z "${to_remove[$module]}"; then
+            if eval 'test -z "${to_remove[$module]}"'; then
               func_append specified_modules "$module "
             fi
           done
@@ -3816,11 +3843,16 @@ s,^\(.................................................[^ ]*\) *,
         yes | 3)
           sed_transform_main_lib_file=$sed_transform_main_lib_file'
             s/GNU General/GNU Lesser General/g
+            s/General Public License/Lesser General Public License/g
+            s/Lesser Lesser General Public License/Lesser General Public License/g
           '
           ;;
         2)
           sed_transform_main_lib_file=$sed_transform_main_lib_file'
             s/GNU General/GNU Lesser General/g
+            s/General Public License/Lesser General Public License/g
+            s/Lesser Lesser General Public License/Lesser General Public License/g
+
             s/version [23]\([ ,]\)/version 2.1\1/g
           '
           ;;
@@ -3830,7 +3862,11 @@ s,^\(.................................................[^ ]*\) *,
       # Update license.
       sed_transform_main_lib_file=$sed_transform_main_lib_file'
         s/GNU Lesser General/GNU General/g
+        s/Lesser General Public License/General Public License/g
+
         s/GNU Library General/GNU General/g
+        s/Library General Public License/General Public License/g
+
         s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
       '
     fi
@@ -3842,7 +3878,11 @@ s,^\(.................................................[^ ]*\) *,
     # Update license.
     sed_transform_build_aux_file=$sed_transform_build_aux_file'
       s/GNU Lesser General/GNU General/g
+      s/Lesser General Public License/General Public License/g
+
       s/GNU Library General/GNU General/g
+      s/Library General Public License/General Public License/g
+
       s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
     '
   fi
@@ -3853,7 +3893,11 @@ s,^\(.................................................[^ ]*\) *,
     # Update license.
     sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
       s/GNU Lesser General/GNU General/g
+      s/Lesser General Public License/General Public License/g
+
       s/GNU Library General/GNU General/g
+      s/Library General Public License/General Public License/g
+
       s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
     '
   fi
@@ -4545,7 +4589,7 @@ s,//*$,/,'
     # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
     # created using libtool, because libtool already handles the dependencies.
     if test "$libtool" != true; then
-      libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
+      libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
       echo "  ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
       echo "  AC_SUBST([${libname_upper}_LIBDEPS])"
       echo "  ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
@@ -4925,6 +4969,11 @@ func_create_testdir ()
     echo "File list:"
     echo "$files" | sed -e 's/^/  /'
   fi
+  # Add files for which the copy in gnulib is newer than the one that
+  # "automake --add-missing --copy" would provide.
+  files="$files build-aux/config.guess"
+  files="$files build-aux/config.sub"
+  files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
 
   rewritten='%REWRITTEN%'
   sed_rewrite_files="\
@@ -5097,6 +5146,12 @@ func_create_testdir ()
            *)
              func_get_autoconf_snippet "$module" \
                | sed -e "$sed_replace_build_aux"
+             if test "$module" = 'alloca' && test "$libtool" = true; then
+               echo 'changequote(,)dnl'
+               echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
+               echo 'changequote([, ])dnl'
+               echo 'AC_SUBST([LTALLOCA])'
+             fi
              ;;
          esac
        fi
@@ -5113,7 +5168,7 @@ func_create_testdir ()
      # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
      # created using libtool, because libtool already handles the dependencies.
      if test "$libtool" != true; then
-       libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
+       libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
        echo "  ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
        echo "  AC_SUBST([${libname_upper}_LIBDEPS])"
        echo "  ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
@@ -5219,13 +5274,19 @@ func_create_testdir ()
      if test -n "$module"; then
        func_get_autoconf_snippet "$module" \
          | sed -e "$sed_replace_build_aux"
+       if test "$module" = 'alloca' && test "$libtool" = true; then
+         echo 'changequote(,)dnl'
+         echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
+         echo 'changequote([, ])dnl'
+         echo 'AC_SUBST([LTALLOCA])'
+       fi
      fi
    done
    func_emit_initmacro_end $macro_prefix
    # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
    # created using libtool, because libtool already handles the dependencies.
    if test "$libtool" != true; then
-     libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
+     libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
      echo "  ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
      echo "  AC_SUBST([${libname_upper}_LIBDEPS])"
      echo "  ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
@@ -5298,7 +5359,7 @@ func_create_testdir ()
     ) || func_exit 1
   fi
   # Need to run configure and make once, to create built files that are to be
-  # distributed (such as getdate.c).
+  # distributed (such as parse-datetime.c).
   sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
   # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
   cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \