lchown: Avoid "unused variable" warning.
[gnulib.git] / gnulib-tool
index 73aa49e..493dfa3 100755 (executable)
@@ -40,6 +40,9 @@ AUTOMAKEPATH=
 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
 GETTEXTPATH=
 
+# You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
+LIBTOOLPATH=
+
 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
@@ -63,6 +66,11 @@ if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
   AUTOPOINT="${GETTEXTPATH}autopoint"
 fi
 
+# If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
+if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
+  LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
+fi
+
 # You can set MAKE.
 if test -z "${MAKE}"; then
   MAKE=make
@@ -181,6 +189,20 @@ General options:
       --verbose             Increase verbosity. May be repeated.
       --quiet               Decrease verbosity. May be repeated.
 
+Options for --import, --update:
+      --dry-run             Only print what would have been done.
+
+Options for --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
+                            modules are ignored.
+      --avoid=MODULE        Avoid including the given MODULE. Useful if you
+                            have code that provides equivalent functionality.
+                            This option can be repeated.
+      --libtool             Use libtool rules.
+      --no-libtool          Don't use libtool rules.
+
 Options for --import:
       --lib=LIBRARY         Specify the library name.  Defaults to 'libgnu'.
       --source-base=DIRECTORY
@@ -197,13 +219,6 @@ Options for --import:
                             placed (default \"tests\").
       --aux-dir=DIRECTORY   Directory relative to --dir where auxiliary build
                             tools are placed (default \"build-aux\").
-      --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
-                            modules are ignored.
-      --avoid=MODULE        Avoid including the given MODULE. Useful if you
-                            have code that provides equivalent functionality.
-                            This option can be repeated.
       --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;
@@ -211,8 +226,6 @@ Options for --import:
       --makefile-name=NAME  Name of makefile in automake syntax in the
                             source-base and tests-base directories
                             (default \"Makefile.am\").
-      --libtool             Use libtool rules.
-      --no-libtool          Don't use libtool rules.
       --macro-prefix=PREFIX  Specify the prefix of the macros 'gl_EARLY' and
                             'gl_INIT'. Default is 'gl'.
       --po-domain=NAME      Specify the prefix of the i18n domain. Usually use
@@ -222,11 +235,12 @@ Options for --import:
                             (.gitignore and/or .cvsignore).
       --no-changelog        Don't update or create ChangeLog files.
 
-Options for --import and --update:
-      --dry-run             For --import, only print what would have been done.
+Options for --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:
   -S, --more-symlinks       Make symbolic links instead of copying files, and
                             don't replace copyright notices.
 
@@ -661,7 +675,7 @@ func_ln_if_changed ()
   fi
 }
 
-# Ensure an 'echo' command
+# Ensure an 'echo' command that
 #   1. does not interpret backslashes and
 #   2. does not print an error message "broken pipe" when writing into a pipe
 #      with no writers.
@@ -727,7 +741,10 @@ fi
 # For bash >= 2.0: define echo to a function that uses the printf built-in.
 # For bash < 2.0: define echo to a function that uses cat of a here document.
 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
-if test -z "$have_echo" \
+# Also handle problem 2, specific to bash 3.2, here.
+if { test -z "$have_echo" \
+     || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
+   } \
    && test -n "$BASH_VERSION"; then \
   if type printf 2>/dev/null | grep / > /dev/null; then
     # 'printf' is not a shell built-in.
@@ -810,15 +827,6 @@ if test -z "$have_echo" \
   exec /bin/sh "$0" --no-reexec "$@"
   exit 127
 fi
-# Now handle problem 2, specific to bash 3.2.
-case "$BASH_VERSION" in
-  3.2*)
-    echo ()
-    {
-      printf '%s\n' "$*"
-    }
-    ;;
-esac
 if test -z "$have_echo"; then
   func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
 fi
@@ -2549,6 +2557,7 @@ func_emit_lib_Makefile_am ()
       if test -n "$module"; then
         {
           func_get_automake_snippet "$module" |
+            LC_ALL=C \
             sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
                 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
                 -e "$sed_eliminate_LDFLAGS" \
@@ -2808,6 +2817,7 @@ func_emit_tests_Makefile_am ()
       if test -n "$module"; then
         {
           func_get_automake_snippet "$module" |
+            LC_ALL=C \
             sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
                 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
                 -e "$sed_eliminate_LDFLAGS" \
@@ -4076,6 +4086,7 @@ s,//*$,/,'
     for module in $final_modules; do
       func_verify_module
       if test -n "$module"; then
+        echo "# Code from module $module:"
         func_get_autoconf_early_snippet "$module"
       fi
     done \
@@ -4110,6 +4121,7 @@ s,//*$,/,'
     for module in $main_modules; do
       func_verify_module
       if test -n "$module"; then
+        echo "  # Code from module $module:"
         func_get_autoconf_snippet "$module" \
           | sed -e '/^$/d;' -e 's/^/  /' \
                 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
@@ -4122,6 +4134,7 @@ s,//*$,/,'
         fi
       fi
     done
+    echo "  # End of code from modules"
     func_emit_initmacro_end $macro_prefix
     echo "  gltests_libdeps="
     echo "  gltests_ltlibdeps="
@@ -4406,6 +4419,15 @@ s,//*$,/,'
 # - local_gnulib_dir  from --local-dir
 # - modcache        true or false, from --cache-modules/--no-cache-modules
 # - auxdir          directory relative to destdir where to place build aux files
+# - inctests        true if tests should be included, blank otherwise
+# - incobsolete     true if obsolete modules among dependencies should be
+#                   included, blank otherwise
+# - avoidlist       list of modules to avoid
+# - libtool         true if --libtool was given, false if --no-libtool was
+#                   given, blank otherwise
+# - symbolic        true if files should be symlinked, copied otherwise
+# - lsymbolic       true if files from local_gnulib_dir should be symlinked,
+#                   copied otherwise
 func_create_testdir ()
 {
   testdir="$1"
@@ -4414,8 +4436,9 @@ func_create_testdir ()
     # All modules together.
     # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
     # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
+    # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
     modules=`func_all_modules`
-    modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist) ;; *) echo $m;; esac; done`
+    modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
   fi
   modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
 
@@ -4631,6 +4654,8 @@ func_create_testdir ()
      done \
        | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
      if test "$libtool" = true; then
+       echo "LT_INIT([win32-dll])"
+       echo "LT_LANG([C++])"
        echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
        echo "gl_cond_libtool=true"
      else
@@ -4754,6 +4779,8 @@ func_create_testdir ()
    done \
      | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
    if test "$libtool" = true; then
+     echo "LT_INIT([win32-dll])"
+     echo "LT_LANG([C++])"
      echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
      echo "gl_cond_libtool=true"
    else
@@ -4832,6 +4859,9 @@ func_create_testdir ()
        fi
      done
    fi
+   if test "$libtool" = true; then
+     func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
+   fi
    func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
    if ! test -d build-aux; then
      func_execute_command mkdir build-aux || func_exit 1