# 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
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
{
echo "\
Usage: gnulib-tool --list
+ gnulib-tool --find filename
gnulib-tool --import [module1 ... moduleN]
gnulib-tool --update
gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
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;
if no modules are specified, update the current
package from the current gnulib
--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
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;
--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
(.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.
fi
}
-# func_reset_sigpipe
-# Resets SIGPIPE to its default behaviour. SIGPIPE is signalled when a process
-# writes into a pipe with no readers, i.e. a pipe where all readers have
-# already closed their file descriptor that read from it or exited entirely.
-# The default behaviour is to terminate the current process without an error
-# message.
-# When "trap '' SIGPIPE" is in effect, the behaviour (at least with bash) is to
-# terminate the current process with an error message.
-# This function should be called at the beginning of a command that only
-# produces output to stdout (i.e. no side effects!), when the command that
-# will read from this pipe might prematurely exit or close its standard input
-# descriptor.
-if test -n "$BASH_VERSION"; then
- # The problem has only been reported with bash. Probably it occurs only with
- # bash-3.2. For the reasons, see
- # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>.
- # Note that Solaris sh does not understand "trap - SIGPIPE".
- func_reset_sigpipe ()
- {
- trap - SIGPIPE
- }
-else
- func_reset_sigpipe ()
- {
- :
- }
-fi
-
-# Ensure an 'echo' command that does not interpret backslashes.
-# Test cases:
+# 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.
+#
+# Test cases for problem 1:
# echo '\n' | wc -l prints 1 when OK, 2 when KO
# echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
-# This problem is a weird heritage from SVR4. BSD got it right (except that
+# Test cases for problem 2:
+# echo hi | true frequently prints
+# "bash: echo: write error: Broken pipe"
+# to standard error in bash 3.2.
+#
+# Problem 1 is a weird heritage from SVR4. BSD got it right (except that
# BSD echo interprets '-n' as an option, which is also not desirable).
# Nowadays the problem occurs in 4 situations:
# - in bash, when the shell option xpg_echo is set (bash >= 2.04)
# - otherwise: respawn using /bin/sh and rely on the workarounds.
# When respawning, we pass --no-reexec as first argument, so as to avoid
# turning this script into a fork bomb in unlucky situations.
+#
+# Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
+# the 'printf' built-in. See
+# <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
+# <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
+# The workaround is: define echo to a function that uses the printf built-in.
have_echo=
if echo '\t' | grep t > /dev/null; then
have_echo=yes # Lucky!
# 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.
--list | --lis )
mode=list
shift ;;
+ --find | --fin | --fi | --f )
+ mode=find
+ shift ;;
--import | --impor | --impo | --imp | --im | --i )
mode=import
shift ;;
fi
}
+# func_sanitize_modulelist
+# receives a list of possible module names on standard input, one per line.
+# It removes those which are just file names unrelated to modules, and outputs
+# the resulting list to standard output, one per line.
+func_sanitize_modulelist ()
+{
+ sed -e '/^CVS\//d' -e '/\/CVS\//d' \
+ -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
+ -e '/^COPYING$/d' -e '/\/COPYING$/d' \
+ -e '/^README$/d' -e '/\/README$/d' \
+ -e '/^TEMPLATE$/d' \
+ -e '/^TEMPLATE-EXTENDED$/d' \
+ -e '/^TEMPLATE-TESTS$/d' \
+ -e '/^\..*/d' \
+ -e '/~$/d'
+}
+
# func_all_modules
# Input:
# - local_gnulib_dir from --local-dir
(cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
fi
} \
- | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
- -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
- -e '/^COPYING$/d' -e '/\/COPYING$/d' \
- -e '/^README$/d' -e '/\/README$/d' \
- -e '/^TEMPLATE$/d' \
- -e '/^TEMPLATE-EXTENDED$/d' \
- -e '/^TEMPLATE-TESTS$/d' \
- -e '/^\..*/d' \
- -e '/~$/d' \
+ | func_sanitize_modulelist \
| sed -e '/-tests$/d' \
| LC_ALL=C sort -u
}
*-tests)
fgd1="$1"
func_remove_suffix fgd1 '-tests'
- echo "$fgdl"
+ echo "$fgd1"
;;
esac
# Then the explicit dependencies listed in the module description.
func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
# Remove $already_mentioned_files from $lib_files.
echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
- extra_files=`func_reset_sigpipe; \
- for f in $already_mentioned_files; do echo $f; done \
+ extra_files=`for f in $already_mentioned_files; do echo $f; done \
| LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
if test -n "$extra_files"; then
echo "EXTRA_DIST +=" $extra_files
handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
# Remove $handledmodules from $inmodules.
for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
- inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
+ inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
done
modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
rm -f "$tmp"/queued-modules
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" \
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" \
fi
# Determine tests-related module list.
echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
- testsrelated_modules=`func_reset_sigpipe
- for module in $main_modules; do
+ testsrelated_modules=`for module in $main_modules; do
if test \`func_get_applicability $module\` = main; then
echo $module
fi
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 \
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./' \
fi
fi
done
+ echo " # End of code from modules"
func_emit_initmacro_end $macro_prefix
echo " gltests_libdeps="
echo " gltests_ltlibdeps="
if test -f "$destdir/$dir$ignore"; then
if test -n "$dir_added" || test -n "$dir_removed"; then
sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
- (func_reset_sigpipe
- echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
+ (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
| LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
| LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
# - 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"
# 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`
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
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
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
func_all_modules
;;
+ find )
+ # sed expression that converts a literal to a basic regular expression.
+ # Needs to handle . [ \ * ^ $.
+ sed_literal_to_basic_regex='s/\\/\\\\/g
+s/\[/\\[/g
+s/\^/\\^/g
+s/\([.*$]\)/[\1]/g'
+ for filename
+ do
+ if test -f "$gnulib_dir/$filename" \
+ || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
+ filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
+ filename_line_regex='^'"$filename_anywhere_regex"'$'
+ module_candidates=`
+ {
+ (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
+ if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
+ (cd "$local_gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_anywhere_regex" /dev/null | sed -e 's,^modules/,,' -e 's,\.diff$,,')
+ fi
+ } \
+ | func_sanitize_modulelist \
+ | LC_ALL=C sort -u
+ `
+ for module in $module_candidates; do
+ if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
+ echo $module
+ fi
+ done
+ else
+ func_warning "file $filename does not exist"
+ fi
+ done
+ ;;
+
import | update )
# Where to import.