3 # Copyright (C) 2002-2007 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # This program is meant for authors or maintainers which want to import
21 # modules from gnulib into their packages.
25 cvsdatestamp='$Date: 2007-09-16 00:41:34 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
32 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
36 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
37 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
41 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
44 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
47 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
48 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
49 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
50 AUTOCONF="${AUTOCONFPATH}autoconf"
52 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
53 AUTOHEADER="${AUTOCONFPATH}autoheader"
55 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
56 ACLOCAL="${AUTOMAKEPATH}aclocal"
58 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
59 AUTOMAKE="${AUTOMAKEPATH}automake"
61 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
62 AUTORECONF="${AUTOCONFPATH}autoreconf"
65 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
66 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
67 AUTOPOINT="${GETTEXTPATH}autopoint"
70 # When using GNU sed, turn off as many GNU extensions as possible,
71 # to minimize the risk of accidentally using non-portable features.
72 # However, do this only for gnulib-tool itself, not for the code that
73 # gnulib-tool generates, since we don't want "sed --posix" to leak
75 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
76 # Define sed as an alias.
77 # It is not always possible to use aliases. Aliases are guaranteed to work
78 # if the executing shell is bash and either it is invoked as /bin/sh or
79 # is a version >= 2.0, supporting shopt. This is the common case.
80 # Two other approaches (use of a variable $sed or of a function func_sed
81 # instead of an alias) require massive, fragile code changes.
82 # An other approach (use of function sed) requires `which sed` - but 'which'
83 # is hard to emulate, due to missing "test -x" on some platforms.
84 if test -n "$BASH_VERSION"; then
85 shopt -s expand_aliases >/dev/null 2>&1
87 alias sed='sed --posix'
91 # outputs to stdout the --help usage message.
95 Usage: gnulib-tool --list
96 gnulib-tool --import [module1 ... moduleN]
98 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
99 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
100 gnulib-tool --test --dir=directory module1 ... moduleN
101 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
102 gnulib-tool --extract-description module
103 gnulib-tool --extract-notice module
104 gnulib-tool --extract-filelist module
105 gnulib-tool --extract-dependencies module
106 gnulib-tool --extract-autoconf-snippet module
107 gnulib-tool --extract-automake-snippet module
108 gnulib-tool --extract-include-directive module
109 gnulib-tool --extract-link-directive module
110 gnulib-tool --extract-license module
111 gnulib-tool --extract-maintainer module
112 gnulib-tool --extract-tests-module module
115 --list print the available module names
116 --import import the given modules into the current package;
117 if no modules are specified, update the current
118 package from the current gnulib
119 --update update the current package, restore files omitted
121 --create-testdir create a scratch package with the given modules
122 --create-megatestdir create a mega scratch package with the given modules
123 one by one and all together
124 --test test the combination of the given modules
125 (recommended to use CC=\"gcc -Wall\" here)
126 --megatest test the given modules one by one and all together
127 (recommended to use CC=\"gcc -Wall\" here)
128 --extract-description extract the description
129 --extract-notice extract the notice or banner
130 --extract-filelist extract the list of files
131 --extract-dependencies extract the dependencies
132 --extract-autoconf-snippet extract the snippet for configure.ac
133 --extract-automake-snippet extract the snippet for library makefile
134 --extract-include-directive extract the #include directive
135 --extract-link-directive extract the linker directive
136 --extract-license report the license terms of the source files
138 --extract-maintainer report the maintainer(s) inside gnulib
139 --extract-tests-module report the unit test module, if it exists
142 --dir=DIRECTORY Specify the target directory.
143 For --import, this specifies where your
144 configure.ac can be found. Defaults to current
146 --local-dir=DIRECTORY Specify a local override directory where to look
147 up files before looking in gnulib's directory.
148 --verbose Increase verbosity. May be repeated.
149 --quiet Decrease verbosity. May be repeated.
151 Options for --import:
152 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
153 --source-base=DIRECTORY
154 Directory relative to --dir where source code is
155 placed (default \"lib\").
156 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
157 placed (default \"m4\").
158 --po-base=DIRECTORY Directory relative to --dir where *.po files are
159 placed (default \"po\").
160 --doc-base=DIRECTORY Directory relative to --dir where doc files are
161 placed (default \"doc\").
162 --tests-base=DIRECTORY
163 Directory relative to --dir where unit tests are
164 placed (default \"tests\").
165 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
166 tools are placed (default \"build-aux\").
167 --with-tests Include unit tests for the included modules.
168 --avoid=MODULE Avoid including the given MODULE. Useful if you
169 have code that provides equivalent functionality.
170 This option can be repeated.
171 --lgpl Abort if modules aren't available under the LGPL.
172 Also modify license template from GPL to LGPL.
173 --makefile-name=NAME Name of makefile in automake syntax in the
174 source-base and tests-base directories
175 (default \"Makefile.am\").
176 --libtool Use libtool rules.
177 --no-libtool Don't use libtool rules.
178 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
179 'gl_INIT'. Default is 'gl'.
180 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
181 the package name. A suffix '-gnulib' is appended.
182 --no-changelog don't update or create ChangeLog files
184 Options for --import and --update:
185 --dry-run For --import, only print what would have been done.
186 -s, --symbolic, --symlink Make symbolic links instead of copying files.
187 --local-symlink Make symbolic links instead of copying files, only
188 for files from the local override directory.
189 -S, --more-symlinks Make symbolic links instead of copying files, and
190 don't replace copyright notices.
192 Report bugs to <bug-gnulib@gnu.org>."
196 # outputs to stdout the --version message.
199 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
201 $progname (GNU $package) $version
202 Copyright (C) $year Free Software Foundation, Inc.
203 This is free software; see the source for copying conditions. There is NO
204 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
205 Written by" "Bruno Haible" "and" "Simon Josefsson"
208 # func_emit_copyright_notice
209 # outputs to stdout a header for a generated file.
210 func_emit_copyright_notice ()
212 echo "# Copyright (C) 2004-2007 Free Software Foundation, Inc."
214 echo "# This file is free software, distributed under the terms of the GNU"
215 echo "# General Public License. As a special exception to the GNU General"
216 echo "# Public License, this file may be distributed as part of a program"
217 echo "# that contains a configuration script generated by Autoconf, under"
218 echo "# the same distribution terms as the rest of that program."
220 echo "# Generated by gnulib-tool."
231 # creates a temporary directory.
233 # - tmp pathname of freshly created temporary directory
236 # Use the environment variable TMPDIR, falling back to /tmp. This allows
237 # users to specify a different temporary directory, for example, if their
238 # /tmp is filled up or too small.
241 # Use the mktemp program if available. If not available, hide the error
243 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
244 test -n "$tmp" && test -d "$tmp"
247 # Use a simple mkdir command. It is guaranteed to fail if the directory
248 # already exists. $RANDOM is bash specific and expands to empty in shells
249 # other than bash, ksh and zsh. Its use does not increase security;
250 # rather, it minimizes the probability of failure in a very cluttered /tmp
252 tmp=$TMPDIR/gl$$-$RANDOM
253 (umask 077 && mkdir "$tmp")
256 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
261 # func_append var value
262 # appends the given value to the shell variable var.
263 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
264 # Use bash's += operator. It reduces complexity of appending repeatedly to
265 # a single variable from O(n^2) to O(n).
273 eval "$1=\"\$$1\$2\""
277 # func_fatal_error message
278 # outputs to stderr a fatal error message, and terminates the program.
281 echo "gnulib-tool: *** $1" 1>&2
282 echo "gnulib-tool: *** Stop." 1>&2
286 # func_readlink SYMLINK
287 # outputs the target of the given symlink.
288 if (type -p readlink) > /dev/null 2>&1; then
291 # Use the readlink program from GNU coreutils.
297 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
298 # would do the wrong thing if the link target contains " -> ".
299 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
303 # func_relativize DIR1 DIR2
304 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
306 # - DIR1 relative pathname, relative to the current directory
307 # - DIR2 relative pathname, relative to the current directory
309 # - reldir relative pathname of DIR2, relative to DIR1
315 sed_first='s,^\([^/]*\)/.*$,\1,'
316 sed_rest='s,^[^/]*/*,,'
317 sed_last='s,^.*/\([^/]*\)$,\1,'
318 sed_butlast='s,/*[^/]*$,,'
319 while test -n "$dir1"; do
320 first=`echo "$dir1" | sed -e "$sed_first"`
321 if test "$first" != "."; then
322 if test "$first" = ".."; then
323 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
324 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
326 first2=`echo "$dir2" | sed -e "$sed_first"`
327 if test "$first2" = "$first"; then
328 dir2=`echo "$dir2" | sed -e "$sed_rest"`
332 dir0="$dir0"/"$first"
335 dir1=`echo "$dir1" | sed -e "$sed_rest"`
340 # func_relconcat DIR1 DIR2
341 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
343 # - DIR1 relative pathname, relative to the current directory
344 # - DIR2 relative pathname, relative to DIR1
346 # - relconcat DIR1/DIR2, relative to the current directory
351 sed_first='s,^\([^/]*\)/.*$,\1,'
352 sed_rest='s,^[^/]*/*,,'
353 sed_last='s,^.*/\([^/]*\)$,\1,'
354 sed_butlast='s,/*[^/]*$,,'
356 first=`echo "$dir2" | sed -e "$sed_first"`
357 if test "$first" = "."; then
358 dir2=`echo "$dir2" | sed -e "$sed_rest"`
359 if test -z "$dir2"; then
364 last=`echo "$dir1" | sed -e "$sed_last"`
365 while test "$last" = "."; do
366 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
367 last=`echo "$dir1" | sed -e "$sed_last"`
369 if test -z "$dir1"; then
373 if test "$first" = ".."; then
374 if test "$last" = ".."; then
375 relconcat="$dir1/$dir2"
378 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
379 dir2=`echo "$dir2" | sed -e "$sed_rest"`
380 if test -z "$dir1"; then
384 if test -z "$dir2"; then
389 relconcat="$dir1/$dir2"
397 # Like ln -s, except that SRC is given relative to the current directory (or
398 # absolute), not given relative to the directory of DEST.
404 *) # SRC is relative.
407 ln -s "`pwd`/$1" "$2" ;;
408 *) # DEST is relative too.
409 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
410 test -n "$ln_destdir" || ln_destdir="."
411 func_relativize "$ln_destdir" "$1"
419 # func_ln_if_changed SRC DEST
420 # Like func_ln, but avoids munging timestamps if the link is correct.
421 func_ln_if_changed ()
423 if test $# -ne 2; then
424 echo "usage: func_ln_if_changed SRC DEST" >&2
426 ln_target=`func_readlink "$2"`
427 if test -h "$2" && test "$1" = "$ln_target"; then
435 # Ensure an 'echo' command that does not interpret backslashes.
437 # echo '\n' | wc -l prints 1 when OK, 2 when KO
438 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
439 # This problem is a weird heritage from SVR4. BSD got it right (except that
440 # BSD echo interprets '-n' as an option, which is also not desirable).
441 # Nowadays the problem occurs in 4 situations:
442 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
443 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
444 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
445 # - in zsh, when sh-emulation is not set,
446 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
447 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
448 # - in Solaris /bin/sh and OSF/1 /bin/sh.
449 # We try the following workarounds:
450 # - for all: respawn using $CONFIG_SHELL if that is set and works.
451 # - for bash >= 2.04: unset the shell option xpg_echo.
452 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
453 # - for bash < 2.0: define echo to a function that uses cat of a here document.
454 # - for zsh: turn sh-emulation on.
455 # - for ksh: alias echo to 'print -r'.
456 # - for ksh: alias echo to a function that uses cat of a here document.
457 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
458 # the ksh workaround.
459 # - otherwise: respawn using /bin/sh and rely on the workarounds.
460 # When respawning, we pass --no-reexec as first argument, so as to avoid
461 # turning this script into a fork bomb in unlucky situations.
463 if echo '\t' | grep t > /dev/null; then
464 have_echo=yes # Lucky!
466 # Try the workarounds.
467 # Respawn using $CONFIG_SHELL if that is set and works.
468 if test -z "$have_echo" \
469 && test "X$1" != "X--no-reexec" \
470 && test -n "$CONFIG_SHELL" \
471 && test -f "$CONFIG_SHELL" \
472 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
473 exec $CONFIG_SHELL "$0" --no-reexec "$@"
476 # For bash >= 2.04: unset the shell option xpg_echo.
477 if test -z "$have_echo" \
478 && test -n "$BASH_VERSION" \
479 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
483 # For bash >= 2.0: define echo to a function that uses the printf built-in.
484 # For bash < 2.0: define echo to a function that uses cat of a here document.
485 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
486 if test -z "$have_echo" \
487 && test -n "$BASH_VERSION"; then \
488 if type printf 2>/dev/null | grep / > /dev/null; then
489 # 'printf' is not a shell built-in.
497 # 'printf' is a shell built-in.
503 if echo '\t' | grep t > /dev/null; then
507 # For zsh: turn sh-emulation on.
508 if test -z "$have_echo" \
509 && test -n "$ZSH_VERSION" \
510 && (emulate sh) >/dev/null 2>&1; then
513 # For ksh: alias echo to 'print -r'.
514 if test -z "$have_echo" \
515 && (type print) >/dev/null 2>&1; then
516 # A 'print' command exists.
517 if type print 2>/dev/null | grep / > /dev/null; then
520 # 'print' is a shell built-in.
521 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
522 # 'print' is the ksh shell built-in.
523 alias echo='print -r'
527 if test -z "$have_echo" \
528 && echo '\t' | grep t > /dev/null; then
531 # For ksh: alias echo to a function that uses cat of a here document.
532 # The ksh manual page says:
533 # "Aliasing is performed when scripts are read, not while they are executed.
534 # Therefore, for an alias to take effect, the alias definition command has
535 # to be executed before the command which references the alias is read."
536 # Because of this, we have to play strange tricks with have_echo, to ensure
537 # that the top-level statement containing the test starts after the 'alias'
539 if test -z "$have_echo"; then
546 alias echo=bsd_echo 2>/dev/null
548 if test -z "$have_echo" \
549 && echo '\t' | grep t > /dev/null; then
552 if test -z "$have_echo"; then
553 unalias echo 2>/dev/null
555 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
556 if test -z "$have_echo" \
557 && test "X$1" != "X--no-reexec" \
558 && test -f /bin/ksh; then
559 exec /bin/ksh "$0" --no-reexec "$@"
562 # Otherwise: respawn using /bin/sh.
563 if test -z "$have_echo" \
564 && test "X$1" != "X--no-reexec" \
565 && test -f /bin/sh; then
566 exec /bin/sh "$0" --no-reexec "$@"
569 if test -z "$have_echo"; then
570 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
572 if echo '\t' | grep t > /dev/null; then
575 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
577 if test "X$1" = "X--no-reexec"; then
581 # Command-line option processing.
582 # Removes the OPTIONS from the arguments. Sets the variables:
583 # - mode list or import or create-testdir or create-megatestdir
584 # - destdir from --dir
585 # - local_gnulib_dir from --local-dir
586 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
587 # - libname, supplied_libname from --lib
588 # - sourcebase from --source-base
589 # - m4base from --m4-base
590 # - pobase from --po-base
591 # - docbase from --doc-base
592 # - testsbase from --tests-base
593 # - auxdir from --aux-dir
594 # - inctests true if --with-tests was given, blank otherwise
595 # - avoidlist list of modules to avoid, from --avoid
596 # - lgpl true if --lgpl was given, blank otherwise
597 # - makefile_name from --makefile-name
598 # - libtool true if --libtool was given, false if --no-libtool was
599 # given, blank otherwise
600 # - macro_prefix from --macro-prefix
601 # - po_domain from --po-domain
602 # - autoconf_minversion minimum supported autoconf version
603 # - do_changelog false if --no-changelog was given, : otherwise
604 # - doit : if actions shall be executed, false if only to be printed
605 # - symbolic true if --symlink or --more-symlinks was given, blank
607 # - lsymbolic true if --local-symlink was given, blank otherwise
608 # - do_copyrights blank if --more-symlinks was given, true otherwise
637 while test $# -gt 0; do
642 --import | --impor | --impo | --imp | --im | --i )
645 --update | --updat | --upda | --upd | --up | --u )
648 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
651 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
652 mode=create-megatestdir
654 --test | --tes | --te | --t )
657 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
661 mode=`echo "X$1" | sed -e 's/^X--//'`
666 func_fatal_error "missing argument for --dir"
671 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
676 func_fatal_error "missing argument for --local-dir"
681 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
683 --verbose | --verbos | --verbo | --verb )
684 verbose=`expr $verbose + 1`
686 --quiet | --quie | --qui | --qu | --q )
687 verbose=`expr $verbose - 1`
692 func_fatal_error "missing argument for --lib"
695 supplied_libname=true
698 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
699 supplied_libname=true
704 func_fatal_error "missing argument for --source-base"
709 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
714 func_fatal_error "missing argument for --m4-base"
719 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
724 func_fatal_error "missing argument for --po-base"
729 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
734 func_fatal_error "missing argument for --doc-base"
739 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
744 func_fatal_error "missing argument for --tests-base"
749 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
754 func_fatal_error "missing argument for --aux-dir"
759 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
767 func_fatal_error "missing argument for --avoid"
769 func_append avoidlist " $1"
772 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
773 func_append avoidlist " $arg"
781 func_fatal_error "missing argument for --makefile-name"
786 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
797 func_fatal_error "missing argument for --macro-prefix"
802 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
807 func_fatal_error "missing argument for --po-domain"
812 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
814 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
820 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
823 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
826 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
830 --help | --hel | --he | --h )
833 --version | --versio | --versi | --vers )
837 # Stop option processing
841 echo "gnulib-tool: unknown option $1" 1>&2
842 echo "Try 'gnulib-tool --help' for more information." 1>&2
849 if test "$mode" = update; then
850 if test $# != 0; then
851 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
852 echo "Try 'gnulib-tool --help' for more information." 1>&2
853 echo "If you really want to modify the gnulib configuration of your project," 1>&2
854 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
857 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
858 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
859 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
860 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
861 || test -n "$makefile_name" || test -n "$macro_prefix" \
862 || test -n "$po_domain"; then
863 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
864 echo "Try 'gnulib-tool --help' for more information." 1>&2
865 echo "If you really want to modify the gnulib configuration of your project," 1>&2
866 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
871 if test -n "$pobase" && test -z "$po_domain"; then
872 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
873 echo "Try 'gnulib-tool --help' for more information." 1>&2
876 if test -z "$pobase" && test -n "$po_domain"; then
877 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
880 # Determine the minimum supported autoconf version from the project's
882 DEFAULT_AUTOCONF_MINVERSION="2.59"
885 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
886 if test -f "$destdir"/configure.ac; then
887 configure_ac="$destdir/configure.ac"
889 if test -f "$destdir"/configure.in; then
890 configure_ac="$destdir/configure.in"
894 if test -f configure.ac; then
895 configure_ac="configure.ac"
897 if test -f configure.in; then
898 configure_ac="configure.in"
902 if test -n "$configure_ac"; then
903 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
904 # because when some m4 files are omitted from a CVS repository,
905 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
906 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
907 # autom4te: m4 failed with exit status: 1
914 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
916 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
917 if test -n "$prereqs"; then
918 autoconf_minversion=`
919 for version in $prereqs; do echo $version; done |
920 LC_ALL=C sort -nru | sed 1q
924 if test -z "$autoconf_minversion"; then
925 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
927 case "$autoconf_minversion" in
928 1.* | 2.[0-4]* | 2.5[0-8]*)
929 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
932 # Remove trailing slashes from the directory names. This is necessary for
933 # m4base (to avoid an error in func_import) and optional for the others.
934 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
935 case "$local_gnulib_dir" in
936 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
938 case "$sourcebase" in
939 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
942 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
945 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
948 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
951 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
954 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
959 /*) self_abspathname="$0" ;;
960 */*) self_abspathname=`pwd`/"$0" ;;
963 # Iterate through the elements of $PATH.
964 # We use IFS=: instead of
965 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
966 # because the latter does not work when some PATH element contains spaces.
967 # We use a canonicalized $pathx instead of $PATH, because empty PATH
968 # elements are by definition equivalent to '.', however field splitting
969 # according to IFS=: loses empty fields in many shells:
970 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
971 # beginning, at the end, and in the middle),
972 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
973 # at the beginning and at the end,
974 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
975 # Solaris lose empty fields at the end.
976 # The 'case' statement is an optimization, to avoid evaluating the
977 # explicit canonicalization command when $PATH contains no empty fields.
979 if test "${PATH_SEPARATOR+set}" != set; then
981 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
982 chmod +x "$tmp"/conf.sh
983 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
990 if test "$PATH_SEPARATOR" = ";"; then
991 # On Windows, programs are searched in "." before $PATH.
994 # On Unix, we have to convert empty PATH elements to ".".
998 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
1003 IFS="$PATH_SEPARATOR"
1007 if test -x "$d/$0" && test ! -d "$d/$0"; then
1008 self_abspathname="$d/$0"
1013 if test -z "$self_abspathname"; then
1014 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
1018 while test -h "$self_abspathname"; do
1019 # Resolve symbolic link.
1020 linkval=`func_readlink "$self_abspathname"`
1021 test -n "$linkval" || break
1023 /* ) self_abspathname="$linkval" ;;
1024 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
1027 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
1030 trap 'exit_status=$?
1031 if test "$signal" != 0; then
1032 echo "caught signal $signal" >&2
1035 exit $exit_status' 0
1036 for signal in 1 2 3 13 15; do
1037 trap '{ signal='$signal'; func_exit 1; }' $signal
1041 # func_lookup_file file
1042 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1045 # - local_gnulib_dir from --local-dir
1047 # - lookedup_file name of the merged (combined) file
1048 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1052 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1053 lookedup_file="$local_gnulib_dir/$lkfile"
1056 if test -f "$gnulib_dir/$lkfile"; then
1057 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1058 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1059 rm -f "$tmp/$lkbase"
1060 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1061 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1062 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1063 lookedup_file="$tmp/$lkbase"
1066 lookedup_file="$gnulib_dir/$lkfile"
1070 func_fatal_error "file $gnulib_dir/$lkfile not found"
1077 # - local_gnulib_dir from --local-dir
1080 # Filter out metainformation files like README, which are not modules.
1081 # Filter out unit test modules; they can be retrieved through
1082 # --extract-tests-module if desired.
1084 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1085 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1086 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1089 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1090 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1091 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1092 -e '/^README$/d' -e '/\/README$/d' \
1093 -e '/^TEMPLATE$/d' \
1094 -e '/^TEMPLATE-EXTENDED$/d' \
1095 -e '/^TEMPLATE-TESTS$/d' \
1098 | sed -e '/-tests$/d' \
1102 # func_verify_module
1103 # verifies a module name
1105 # - local_gnulib_dir from --local-dir
1106 # - module module name argument
1107 func_verify_module ()
1109 if { test -f "$gnulib_dir/modules/$module" \
1110 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1111 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1112 && test "CVS" != "$module" \
1113 && test "ChangeLog" != "$module" \
1114 && test "COPYING" != "$module" \
1115 && test "README" != "$module" \
1116 && test "TEMPLATE" != "$module" \
1117 && test "TEMPLATE-EXTENDED" != "$module" \
1118 && test "TEMPLATE-TESTS" != "$module"; then
1119 # OK, $module is a correct module name.
1120 # Verify that building the module description with 'patch' succeeds.
1121 func_lookup_file "modules/$module"
1123 echo "gnulib-tool: module $module doesn't exist" 1>&2
1128 # func_verify_nontests_module
1129 # verifies a module name, excluding tests modules
1131 # - local_gnulib_dir from --local-dir
1132 # - module module name argument
1133 func_verify_nontests_module ()
1136 *-tests ) module= ;;
1137 * ) func_verify_module ;;
1141 # func_verify_tests_module
1142 # verifies a module name, considering only tests modules
1144 # - local_gnulib_dir from --local-dir
1145 # - module module name argument
1146 func_verify_tests_module ()
1149 *-tests ) func_verify_module ;;
1154 sed_extract_prog=':[ ]*$/ {
1157 s/^Description:[ ]*$//
1160 s/^Depends-on:[ ]*$//
1161 s/^configure\.ac-early:[ ]*$//
1162 s/^configure\.ac:[ ]*$//
1163 s/^Makefile\.am:[ ]*$//
1167 s/^Maintainer:[ ]*$//
1174 # func_get_description module
1176 # - local_gnulib_dir from --local-dir
1177 func_get_description ()
1179 func_lookup_file "modules/$1"
1180 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1183 # func_get_notice module
1185 # - local_gnulib_dir from --local-dir
1188 func_lookup_file "modules/$1"
1189 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1192 # func_get_filelist module
1194 # - local_gnulib_dir from --local-dir
1195 func_get_filelist ()
1197 func_lookup_file "modules/$1"
1198 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1199 echo m4/gnulib-common.m4
1200 case "$autoconf_minversion" in
1202 #echo m4/onceonly.m4
1203 echo m4/onceonly_2_57.m4
1208 # func_get_dependencies module
1210 # - local_gnulib_dir from --local-dir
1211 func_get_dependencies ()
1213 # ${module}-tests always implicitly depends on ${module}.
1214 echo "$1" | sed -n -e 's/-tests//p'
1215 # Then the explicit dependencies listed in the module description.
1216 func_lookup_file "modules/$1"
1217 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1220 # func_get_autoconf_early_snippet module
1222 # - local_gnulib_dir from --local-dir
1223 func_get_autoconf_early_snippet ()
1225 func_lookup_file "modules/$1"
1226 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1229 # func_get_autoconf_snippet module
1231 # - local_gnulib_dir from --local-dir
1232 func_get_autoconf_snippet ()
1234 func_lookup_file "modules/$1"
1235 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1238 # func_get_automake_snippet module
1240 # - local_gnulib_dir from --local-dir
1241 func_get_automake_snippet ()
1243 func_lookup_file "modules/$1"
1244 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1247 # *-tests module live in tests/, not lib/.
1250 # Synthesize an EXTRA_DIST augmentation.
1251 sed_combine_lines='/\\$/{
1258 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1259 already_mentioned_files=` \
1260 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1261 | sed -e "$sed_combine_lines" \
1262 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1263 all_files=`func_get_filelist $1`
1264 lib_files=`for f in $all_files; do \
1268 done | sed -e 's,^lib/,,'`
1269 # Remove $already_mentioned_files from $lib_files.
1270 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1271 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1272 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1273 if test -n "$extra_files"; then
1274 echo "EXTRA_DIST +=" $extra_files
1277 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1278 # This is necessary so that automake can generate the right list of
1280 # A possible approach would be to use autom4te --trace of the redefined
1281 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1282 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1283 # inside autoconf's built-in macros are not missed).
1284 # But it's simpler and more robust to do it here, based on the file list.
1285 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1286 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1287 # automake will generate a useless dependency; this is harmless.
1289 relocatable-prog-wrapper) ;;
1291 sed_extract_c_files='/\.c$/p'
1292 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1293 if test -n "$extra_files"; then
1294 echo "EXTRA_lib_SOURCES +=" $extra_files
1299 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1300 buildaux_files=`for f in $all_files; do \
1302 build-aux/*) echo $f ;; \
1304 done | sed -e 's,^build-aux/,,'`
1305 if test -n "$buildaux_files"; then
1306 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1307 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1314 # func_get_include_directive module
1316 # - local_gnulib_dir from --local-dir
1317 func_get_include_directive ()
1319 func_lookup_file "modules/$1"
1320 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1321 sed -e 's/^\(["<]\)/#include \1/'
1324 # func_get_link_directive module
1326 # - local_gnulib_dir from --local-dir
1327 func_get_link_directive ()
1329 func_lookup_file "modules/$1"
1330 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1333 # func_get_license module
1335 # - local_gnulib_dir from --local-dir
1338 func_lookup_file "modules/$1"
1339 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1340 # The default is GPL.
1342 } | sed -e 's,^ *$,,' | sed -e 1q
1345 # func_get_maintainer module
1347 # - local_gnulib_dir from --local-dir
1348 func_get_maintainer ()
1350 func_lookup_file "modules/$1"
1351 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1354 # func_get_tests_module module
1356 # - local_gnulib_dir from --local-dir
1357 func_get_tests_module ()
1359 # The naming convention for tests modules is hardwired: ${module}-tests.
1360 if test -f "$gnulib_dir/modules/$1"-tests \
1361 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1362 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1367 # func_acceptable module
1368 # tests whether a module is acceptable.
1370 # - avoidlist list of modules to avoid
1373 for avoid in $avoidlist; do
1374 if test "$avoid" = "$1"; then
1381 # func_modules_transitive_closure
1383 # - local_gnulib_dir from --local-dir
1384 # - modules list of specified modules
1385 # - inctests true if tests should be included, blank otherwise
1386 # - avoidlist list of modules to avoid
1387 # - tmp pathname of a temporary directory
1389 # - modules list of modules, including dependencies
1390 func_modules_transitive_closure ()
1392 # In order to process every module only once (for speed), process an "input
1393 # list" of modules, producing an "output list" of modules. During each round,
1394 # more modules can be queued in the input list. Once a module on the input
1395 # list has been processed, it is added to the "handled list", so we can avoid
1396 # to process it again.
1398 inmodules="$modules"
1400 while test -n "$inmodules"; do
1401 inmodules_this_round="$inmodules"
1402 inmodules= # Accumulator, queue for next round
1403 for module in $inmodules_this_round; do
1405 if test -n "$module"; then
1406 if func_acceptable $module; then
1407 func_append outmodules " $module"
1408 deps=`func_get_dependencies $module`
1409 # Duplicate dependencies are harmless, but Jim wants a warning.
1410 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1411 if test -n "$duplicated_deps"; then
1412 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1414 func_append inmodules " $deps"
1415 if test -n "$inctests"; then
1416 testsmodule=`func_get_tests_module $module`
1417 if test -n "$testsmodule"; then
1418 func_append inmodules " $testsmodule"
1424 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1425 # Remove $handledmodules from $inmodules.
1426 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1427 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1429 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1430 rm -f "$tmp"/queued-modules
1433 # func_modules_add_dummy
1435 # - local_gnulib_dir from --local-dir
1436 # - modules list of modules, including dependencies
1438 # - modules list of modules, including 'dummy' if needed
1439 func_modules_add_dummy ()
1442 sed_remove_backslash_newline=':a
1449 for module in $modules; do
1450 func_verify_nontests_module
1451 if test -n "$module"; then
1452 # Extract the value of "lib_SOURCES += ...".
1453 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1454 # Ignore .h files since they are not compiled.
1457 *) have_lib_SOURCES=yes ;;
1462 # Add the dummy module, to make sure the library will be non-empty.
1463 if test -z "$have_lib_SOURCES"; then
1464 if func_acceptable "dummy"; then
1465 func_append modules " dummy"
1470 # func_modules_notice
1472 # - local_gnulib_dir from --local-dir
1473 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1474 # - modules list of modules, including dependencies
1475 func_modules_notice ()
1477 if test $verbose -ge -1; then
1478 for module in $modules; do
1480 if test -n "$module"; then
1481 msg=`func_get_notice $module`
1482 if test -n "$msg"; then
1483 echo "Notice from module $module:"
1484 echo "$msg" | sed -e 's/^/ /'
1491 # func_modules_to_filelist
1493 # - local_gnulib_dir from --local-dir
1494 # - modules list of modules, including dependencies
1496 # - files list of files
1497 func_modules_to_filelist ()
1500 for module in $modules; do
1502 if test -n "$module"; then
1503 fs=`func_get_filelist $module`
1504 func_append files " $fs"
1507 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1510 # func_execute_command command [args...]
1511 # Executes a command.
1512 # Uses also the variables
1513 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1514 func_execute_command ()
1516 if test $verbose -ge 0; then
1520 # Commands like automake produce output to stderr even when the succeed.
1521 # Turn this output off if the command succeeds.
1522 "$@" > "$tmp"/cmdout 2>&1
1524 if test $cmdret = 0; then
1528 cat "$tmp"/cmdout 1>&2
1535 # func_emit_lib_Makefile_am
1536 # emits the contents of library makefile to standard output.
1538 # - local_gnulib_dir from --local-dir
1539 # - modules list of modules, including dependencies
1540 # - libname library name
1541 # - pobase directory relative to destdir where to place *.po files
1542 # - auxdir directory relative to destdir where to place build aux files
1543 # - makefile_name from --makefile-name
1544 # - libtool true if libtool will be used, false or blank otherwise
1545 # - macro_prefix prefix of gl_LIBOBJS macros to use
1546 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1547 # - actioncmd (optional) command that will reproduce this invocation
1548 # - for_test true if creating a package for testing, false otherwise
1550 # - uses_subdirs nonempty if object files in subdirs exist
1551 func_emit_lib_Makefile_am ()
1553 # When creating an includable Makefile.am snippet, augment variables with
1554 # += instead of assigning them.
1555 if test -n "$makefile_name"; then
1560 if test "$libtool" = true; then
1563 sed_eliminate_LDFLAGS=
1567 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1570 # When creating a package for testing: Attempt to provoke failures,
1571 # especially link errors, already during "make" rather than during
1572 # "make check", because "make check" is not possible in a cross-compiling
1573 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1574 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1576 sed_transform_check_PROGRAMS=
1578 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1579 echo "## Process this file with automake to produce Makefile.in."
1580 func_emit_copyright_notice
1581 if test -n "$actioncmd"; then
1582 echo "# Reproduce by: $actioncmd"
1587 for module in $modules; do
1588 func_verify_nontests_module
1589 if test -n "$module"; then
1591 func_get_automake_snippet "$module" |
1592 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1593 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1594 -e "$sed_eliminate_LDFLAGS" \
1595 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1596 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1597 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1598 -e "$sed_transform_check_PROGRAMS"
1599 if test "$module" = 'alloca'; then
1600 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1601 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1604 # Skip the contents if its entirely empty.
1605 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1606 echo "## begin gnulib module $module"
1609 echo "## end gnulib module $module"
1613 # Test whether there are some source files in subdirectories.
1614 for f in `func_get_filelist "$module"`; do
1616 lib/*/*.c) uses_subdirs=yes ;;
1622 if test -z "$makefile_name"; then
1623 # If there are source files in subdirectories, prevent collision of the
1624 # object files (example: hash.c and libxml/hash.c).
1626 if test -n "$uses_subdirs"; then
1627 subdir_options=' subdir-objects'
1629 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1632 if test -z "$makefile_name"; then
1633 echo "noinst_HEADERS ="
1634 echo "noinst_LIBRARIES ="
1635 echo "noinst_LTLIBRARIES ="
1636 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1637 # if you specify pkgdata_DATA to empty. This is a workaround.
1638 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1639 echo "pkgdata_DATA ="
1642 echo "BUILT_SOURCES ="
1645 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1646 if test -z "$makefile_name"; then
1647 echo "MOSTLYCLEANDIRS ="
1649 echo "DISTCLEANFILES ="
1650 echo "MAINTAINERCLEANFILES ="
1652 echo "AM_CPPFLAGS ="
1655 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1656 # One of the snippets already specifies an installation location for the
1657 # library. Don't confuse automake by saying it should not be installed.
1660 # By default, the generated library should not be installed.
1661 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1664 echo "${libname}_${libext}_SOURCES ="
1665 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1666 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1667 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1668 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1669 echo "EXTRA_${libname}_${libext}_SOURCES ="
1670 if test "$libtool" = true; then
1671 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1674 if test -n "$pobase"; then
1675 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1678 cat allsnippets.tmp \
1679 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1681 echo "mostlyclean-local: mostlyclean-generic"
1682 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1683 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1684 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1688 rm -f allsnippets.tmp
1691 # func_emit_po_Makevars
1692 # emits the contents of po/ makefile parametrization to standard output.
1694 # - local_gnulib_dir from --local-dir
1695 # - sourcebase directory relative to destdir where to place source code
1696 # - pobase directory relative to destdir where to place *.po files
1697 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1698 func_emit_po_Makevars ()
1700 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1701 func_emit_copyright_notice
1703 echo "# Usually the message domain is the same as the package name."
1704 echo "# But here it has a '-gnulib' suffix."
1705 echo "DOMAIN = ${po_domain}-gnulib"
1707 echo "# These two variables depend on the location of this directory."
1708 echo "subdir = ${pobase}"
1709 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1712 # These options get passed to xgettext.
1713 XGETTEXT_OPTIONS = \
1714 --keyword=_ --flag=_:1:pass-c-format \
1715 --keyword=N_ --flag=N_:1:pass-c-format \
1716 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1717 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1718 --flag=error:3:c-format --flag=error_at_line:5:c-format
1720 # This is the copyright holder that gets inserted into the header of the
1721 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1722 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1724 # This is the email address or URL to which the translators shall report
1725 # bugs in the untranslated strings:
1726 # - Strings which are not entire sentences, see the maintainer guidelines
1727 # in the GNU gettext documentation, section 'Preparing Strings'.
1728 # - Strings which use unclear terms or require additional context to be
1730 # - Strings which make invalid assumptions about notation of date, time or
1732 # - Pluralisation problems.
1733 # - Incorrect English spelling.
1734 # - Incorrect formatting.
1735 # It can be your email address, or a mailing list address where translators
1736 # can write to without being subscribed, or the URL of a web page through
1737 # which the translators can contact you.
1738 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1740 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1741 # message catalogs shall be used. It is usually empty.
1742 EXTRA_LOCALE_CATEGORIES =
1744 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1745 # context. Possible values are "yes" and "no". Set this to yes if the
1746 # package uses functions taking also a message context, like pgettext(), or
1747 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1752 # func_emit_po_POTFILES_in
1753 # emits the file list to be passed to xgettext to standard output.
1755 # - local_gnulib_dir from --local-dir
1756 # - sourcebase directory relative to destdir where to place source code
1757 # - files list of new files
1758 func_emit_po_POTFILES_in ()
1760 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1761 func_emit_copyright_notice
1763 echo "# List of files which contain translatable strings."
1764 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1767 # func_emit_tests_Makefile_am
1768 # emits the contents of tests makefile to standard output.
1770 # - local_gnulib_dir from --local-dir
1771 # - modules list of modules, including dependencies
1772 # - libname library name
1773 # - makefile_name from --makefile-name
1774 # - libtool true if libtool will be used, false or blank otherwise
1775 # - sourcebase relative directory containing lib source code
1776 # - m4base relative directory containing autoconf macros
1777 # - testsbase relative directory containing unit test code
1778 # - for_test true if creating a package for testing, false otherwise
1779 func_emit_tests_Makefile_am ()
1781 if test "$libtool" = true; then
1786 if test "$libtool" = true; then
1788 sed_eliminate_LDFLAGS=
1791 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1794 # When creating a package for testing: Attempt to provoke failures,
1795 # especially link errors, already during "make" rather than during
1796 # "make check", because "make check" is not possible in a cross-compiling
1797 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1798 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1800 sed_transform_check_PROGRAMS=
1802 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1803 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1804 echo "## Process this file with automake to produce Makefile.in."
1805 func_emit_copyright_notice
1807 # Generate dependencies here, since it eases the debugging of test failures.
1808 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1810 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1813 for module in $modules; do
1814 func_verify_tests_module
1815 if test -n "$module"; then
1817 func_get_automake_snippet "$module" |
1818 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1819 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1820 -e "$sed_eliminate_LDFLAGS" \
1821 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1822 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1823 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1824 -e "$sed_transform_check_PROGRAMS"
1826 # Skip the contents if its entirely empty.
1827 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1828 echo "## begin gnulib module $module"
1831 echo "## end gnulib module $module"
1838 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1839 # variable is needed to avoid an error from automake:
1840 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1843 echo "TESTS_ENVIRONMENT ="
1844 echo "noinst_PROGRAMS ="
1845 if ! $for_test; then
1846 echo "check_PROGRAMS ="
1848 echo "noinst_HEADERS ="
1849 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1850 echo "pkgdata_DATA ="
1853 echo "BUILT_SOURCES ="
1855 echo "MOSTLYCLEANFILES = core *.stackdump"
1856 echo "MOSTLYCLEANDIRS ="
1858 echo "DISTCLEANFILES ="
1859 echo "MAINTAINERCLEANFILES ="
1861 echo "AM_CPPFLAGS = \\"
1862 echo " -I. -I\$(srcdir) \\"
1863 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1864 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1866 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1869 echo "# Clean up after Solaris cc."
1871 echo " rm -rf SunWS_cache"
1873 echo "mostlyclean-local: mostlyclean-generic"
1874 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1875 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1876 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1880 rm -f allsnippets.tmp
1883 # func_emit_initmacro_start
1884 # emits the first few statements of the gl_INIT macro to standard output.
1885 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1886 func_emit_initmacro_start ()
1888 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1889 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1890 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1891 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1893 # Furthermore it avoids an automake error like this when a Makefile.am
1894 # that uses pieces of gnulib also uses $(LIBOBJ):
1895 # automatically discovered file `error.c' should not be explicitly mentioned
1896 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1897 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1898 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1899 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1900 # automatically discovered file `error.c' should not be explicitly mentioned
1901 # We let automake know about the files to be distributed through the
1902 # EXTRA_lib_SOURCES variable.
1903 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1906 # func_emit_initmacro_end
1907 # emits the last few statements of the gl_INIT macro to standard output.
1908 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1909 func_emit_initmacro_end ()
1911 echo " m4_popdef([AC_LIBSOURCES])"
1912 echo " m4_popdef([AC_REPLACE_FUNCS])"
1913 echo " m4_popdef([AC_LIBOBJ])"
1914 echo " AC_CONFIG_COMMANDS_PRE(["
1915 echo " ${macro_prefix}_libobjs="
1916 echo " ${macro_prefix}_ltlibobjs="
1917 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1918 echo " # Remove the extension."
1919 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1920 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1921 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1922 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1925 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1926 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1930 # func_emit_initmacro_done
1931 # emits a few statements after the gl_INIT macro to standard output.
1932 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1933 func_emit_initmacro_done ()
1936 echo "# Like AC_LIBOBJ, except that the module name goes"
1937 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1938 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1939 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1941 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1942 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1943 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1944 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1946 echo "# Like AC_LIBSOURCES, except that it does nothing."
1947 echo "# We rely on EXTRA_lib..._SOURCES instead."
1948 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1952 # func_import modules
1953 # Uses also the variables
1954 # - destdir target directory
1955 # - local_gnulib_dir from --local-dir
1956 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1957 # - libname library name
1958 # - sourcebase directory relative to destdir where to place source code
1959 # - m4base directory relative to destdir where to place *.m4 macros
1960 # - pobase directory relative to destdir where to place *.po files
1961 # - docbase directory relative to destdir where to place doc files
1962 # - testsbase directory relative to destdir where to place unit test code
1963 # - auxdir directory relative to destdir where to place build aux files
1964 # - inctests true if --with-tests was given, blank otherwise
1965 # - avoidlist list of modules to avoid, from --avoid
1966 # - lgpl true if library's license shall be LGPL, blank otherwise
1967 # - makefile_name from --makefile-name
1968 # - libtool true if --libtool was given, false if --no-libtool was
1969 # given, blank otherwise
1970 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1971 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1972 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1973 # - autoconf_minversion minimum supported autoconf version
1974 # - doit : if actions shall be executed, false if only to be printed
1975 # - symbolic true if files should be symlinked, copied otherwise
1976 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1978 # - do_copyrights true if copyright notices in files should be replaced,
1982 # Get the cached settings.
1983 cached_local_gnulib_dir=
1984 cached_specified_modules=
1994 cached_makefile_name=
1996 cached_macro_prefix=
1999 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2000 cached_libtool=false
2006 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
2009 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
2012 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
2015 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
2018 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
2021 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
2024 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
2027 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
2030 s,^.*$,cached_inctests=true,p
2033 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
2036 s,^.*$,cached_lgpl=true,p
2038 /gl_MAKEFILE_NAME(/ {
2039 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
2042 s,^.*$,cached_libtool=true,p
2044 /gl_MACRO_PREFIX(/ {
2045 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2048 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2050 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2051 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2056 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2057 s,^.*$,cached_files=",p
2069 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2073 # Merge the cached settings with the specified ones.
2074 # The m4base must be the same as expected from the pathname.
2075 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2076 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2078 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2079 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2080 if test -z "$local_gnulib_dir"; then
2081 if test -n "$cached_local_gnulib_dir"; then
2084 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2086 case "$cached_local_gnulib_dir" in
2088 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2090 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2091 local_gnulib_dir="$relconcat" ;;
2096 # Append the cached and the specified module names. So that
2097 # "gnulib-tool --import foo" means to add the module foo.
2098 specified_modules="$cached_specified_modules $1"
2099 # Append the cached and the specified avoidlist. This is probably better
2100 # than dropping the cached one when --avoid is specified at least once.
2101 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2102 avoidlist=`echo $avoidlist`
2104 # The sourcebase defaults to the cached one.
2105 if test -z "$sourcebase"; then
2106 sourcebase="$cached_sourcebase"
2107 if test -z "$sourcebase"; then
2108 func_fatal_error "missing --source-base option"
2111 # The pobase defaults to the cached one.
2112 if test -z "$pobase"; then
2113 pobase="$cached_pobase"
2115 # The docbase defaults to the cached one.
2116 if test -z "$docbase"; then
2117 docbase="$cached_docbase"
2118 if test -z "$docbase"; then
2119 func_fatal_error "missing --doc-base option. --doc-base has been introduced on 2006-07-11; if your last invocation of 'gnulib-tool --import' is before that date, you need to run 'gnulib-tool --import' once, with a --doc-base option."
2122 # The testsbase defaults to the cached one.
2123 if test -z "$testsbase"; then
2124 testsbase="$cached_testsbase"
2125 if test -z "$testsbase"; then
2126 func_fatal_error "missing --tests-base option"
2129 # Require the tests if specified either way.
2130 if test -z "$inctests"; then
2131 inctests="$cached_inctests"
2133 # The libname defaults to the cached one.
2134 if test -z "$supplied_libname"; then
2135 libname="$cached_libname"
2136 if test -z "$libname"; then
2137 func_fatal_error "missing --lib option"
2140 # Require LGPL if specified either way.
2141 if test -z "$lgpl"; then
2144 # The makefile_name defaults to the cached one.
2145 if test -z "$makefile_name"; then
2146 makefile_name="$cached_makefile_name"
2148 # Use libtool if specified either way, or if guessed.
2149 if test -z "$libtool"; then
2150 if test -n "$cached_m4base"; then
2151 libtool="$cached_libtool"
2153 libtool="$guessed_libtool"
2156 # The macro_prefix defaults to the cached one.
2157 if test -z "$macro_prefix"; then
2158 macro_prefix="$cached_macro_prefix"
2159 if test -z "$macro_prefix"; then
2160 func_fatal_error "missing --macro-prefix option"
2163 # The po_domain defaults to the cached one.
2164 if test -z "$po_domain"; then
2165 po_domain="$cached_po_domain"
2168 # Canonicalize the list of specified modules.
2169 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2171 # Determine final module list.
2172 modules="$specified_modules"
2173 func_modules_transitive_closure
2174 if test $verbose -ge 0; then
2175 echo "Module list with included dependencies:"
2176 echo "$modules" | sed -e 's/^/ /'
2179 # Add the dummy module if needed.
2180 func_modules_add_dummy
2182 # If --lgpl, verify that the licenses of modules are compatible.
2183 if test -n "$lgpl"; then
2184 for module in $modules; do
2185 license=`func_get_license $module`
2187 LGPL | LGPLv2+ | 'GPLed build tool') ;;
2188 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2189 *) func_fatal_error "incompatible license on module $module: $license" ;;
2194 # Show banner notice of every module.
2197 # Determine script to apply to imported library files.
2198 sed_transform_lib_file=
2199 for module in $modules; do
2200 if test $module = config-h; then
2201 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2202 sed_transform_lib_file=$sed_transform_lib_file'
2203 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2208 if test -n "$do_copyrights"; then
2209 if test -n "$lgpl"; then
2211 sed_transform_lib_file=$sed_transform_lib_file'
2212 s/GNU General/GNU Lesser General/g
2213 s/version 2\([ ,]\)/version 2.1\1/g
2218 # Determine final file list.
2219 func_modules_to_filelist
2220 if test $verbose -ge 0; then
2222 echo "$files" | sed -e 's/^/ /'
2226 || func_fatal_error "refusing to do nothing"
2228 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2229 new_files="$files m4/gnulib-tool.m4"
2230 old_files="$cached_files"
2231 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2232 func_append old_files " m4/gnulib-tool.m4"
2235 sed_rewrite_old_files="\
2236 s,^build-aux/,$auxdir/,
2237 s,^doc/,$cached_docbase/,
2238 s,^lib/,$cached_sourcebase/,
2239 s,^m4/,$cached_m4base/,
2240 s,^tests/,$cached_testsbase/,"
2241 sed_rewrite_new_files="\
2242 s,^build-aux/,$auxdir/,
2244 s,^lib/,$sourcebase/,
2246 s,^tests/,$testsbase/,"
2248 # Create directories.
2249 { echo "$sourcebase"
2251 if test -n "$pobase"; then
2254 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2255 if test -n "$docfiles"; then
2258 if test -n "$inctests"; then
2262 for f in $files; do echo $f; done \
2263 | sed -e "$sed_rewrite_new_files" \
2264 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2267 { # Rearrange file descriptors. Needed because "while ... done < ..."
2268 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2269 exec 5<&0 < "$tmp"/dirs
2271 if test ! -d "$destdir/$d"; then
2273 echo "Creating directory $destdir/$d"
2274 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2276 echo "Create directory $destdir/$d"
2283 # func_dest_tmpfilename file
2284 # determines the name of a temporary file (file is relative to destdir).
2286 # - tmpfile absolute filename of the temporary file
2287 func_dest_tmpfilename ()
2290 # Put the new contents of $file in a file in the same directory (needed
2291 # to guarantee that an 'mv' to "$destdir/$file" works).
2292 tmpfile="$destdir/$1.tmp"
2294 # Put the new contents of $file in a file in a temporary directory
2295 # (because the directory of "$file" might not exist).
2296 tmpfile="$tmp"/`basename "$1"`.tmp
2300 # Copy files or make symbolic links. Remove obsolete files.
2304 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2305 # representing the files according to the last gnulib-tool invocation.
2306 for f in $old_files; do echo $f; done \
2307 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2310 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2311 # representing the files after this gnulib-tool invocation.
2312 for f in $new_files; do echo $f; done \
2313 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2316 # First the files that are in old-files, but not in new-files:
2317 sed_take_first_column='s,'"$delimiter"'.*,,'
2318 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2319 # Remove the file. Do nothing if the user already removed it.
2320 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2322 echo "Removing file $g (backup in ${g}~)"
2323 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2325 echo "Remove file $g (backup in ${g}~)"
2327 func_append removed_files "$g$nl"
2330 # func_add_or_update handles a file that ought to be present afterwards.
2332 # - f the original file name
2333 # - g the rewritten file name
2334 # - already_present nonempty if the file already exists, empty otherwise
2335 func_add_or_update ()
2337 func_dest_tmpfilename "$g"
2338 func_lookup_file "$f"
2339 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2340 if test -n "$sed_transform_lib_file"; then
2343 sed -e "$sed_transform_lib_file" \
2344 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2348 if test -f "$destdir/$g"; then
2349 # The file already exists.
2350 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2351 : # The file has not changed.
2355 if test -n "$already_present"; then
2356 echo "Updating file $g (backup in ${g}~)"
2358 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2360 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2361 if { test -n "$symbolic" \
2362 || { test -n "$lsymbolic" \
2363 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2364 && test -z "$lookedup_tmp" \
2365 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2366 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2368 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2371 if test -n "$already_present"; then
2372 echo "Update file $g (backup in ${g}~)"
2374 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2380 # Don't protest if the file should be there but isn't: it happens
2381 # frequently that developers don't put autogenerated files into CVS.
2383 echo "Copying file $g"
2384 if { test -n "$symbolic" \
2385 || { test -n "$lsymbolic" \
2386 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2387 && test -z "$lookedup_tmp" \
2388 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2389 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2391 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2396 func_append added_files "$g$nl"
2400 # Then the files that are in new-files, but not in old-files:
2401 sed_take_last_column='s,^.*'"$delimiter"',,'
2403 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2404 | sed -e "$sed_take_last_column" \
2405 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2406 { # Rearrange file descriptors. Needed because "while ... done < ..."
2407 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2408 exec 5<&0 < "$tmp"/added-files
2414 # Then the files that are in new-files and in old-files:
2415 already_present=true
2416 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2417 | sed -e "$sed_take_last_column" \
2418 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2419 { # Rearrange file descriptors. Needed because "while ... done < ..."
2420 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2421 exec 5<&0 < "$tmp"/kept-files
2428 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2429 actioncmd="gnulib-tool --import"
2430 func_append actioncmd " --dir=$destdir"
2431 if test -n "$local_gnulib_dir"; then
2432 func_append actioncmd " --local-dir=$local_gnulib_dir"
2434 func_append actioncmd " --lib=$libname"
2435 func_append actioncmd " --source-base=$sourcebase"
2436 func_append actioncmd " --m4-base=$m4base"
2437 if test -n "$pobase"; then
2438 func_append actioncmd " --po-base=$pobase"
2440 func_append actioncmd " --doc-base=$docbase"
2441 func_append actioncmd " --aux-dir=$auxdir"
2442 if test -n "$inctests"; then
2443 func_append actioncmd " --with-tests"
2445 for module in $avoidlist; do
2446 func_append actioncmd " --avoid=$module"
2448 if test -n "$lgpl"; then
2449 func_append actioncmd " --lgpl"
2451 if test -n "$makefile_name"; then
2452 func_append actioncmd " --makefile-name=$makefile_name"
2454 if test "$libtool" = true; then
2455 func_append actioncmd " --libtool"
2457 func_append actioncmd " --no-libtool"
2459 func_append actioncmd " --macro-prefix=$macro_prefix"
2460 if test -n "$po_domain"; then
2461 func_append actioncmd " --po-domain=$po_domain"
2463 func_append actioncmd " `echo $specified_modules`"
2465 # Default the makefile name to Makefile.am.
2466 if test -n "$makefile_name"; then
2467 makefile_am=$makefile_name
2469 makefile_am=Makefile.am
2472 # Create normal Makefile.ams.
2475 # Create library makefile.
2476 func_dest_tmpfilename $sourcebase/$makefile_am
2477 func_emit_lib_Makefile_am > "$tmpfile"
2478 if test -f "$destdir"/$sourcebase/$makefile_am; then
2479 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2483 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2484 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2485 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2487 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2493 echo "Creating $sourcebase/$makefile_am"
2494 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2496 echo "Create $sourcebase/$makefile_am"
2499 func_append added_files "$sourcebase/$makefile_am$nl"
2502 # Create po/ directory.
2503 if test -n "$pobase"; then
2504 # Create po makefile and auxiliary files.
2505 for file in Makefile.in.in remove-potcdate.sin; do
2506 func_dest_tmpfilename $pobase/$file
2507 func_lookup_file build-aux/po/$file
2508 cat "$lookedup_file" > "$tmpfile"
2509 if test -f "$destdir"/$pobase/$file; then
2510 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
2514 echo "Updating $pobase/$file (backup in $pobase/$file~)"
2515 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
2516 mv -f "$tmpfile" "$destdir"/$pobase/$file
2518 echo "Update $pobase/$file (backup in $pobase/$file~)"
2524 echo "Creating $pobase/$file"
2525 mv -f "$tmpfile" "$destdir"/$pobase/$file
2527 echo "Create $pobase/$file"
2530 func_append added_files "$pobase/$file$nl"
2533 # Create po makefile parametrization, part 1.
2534 func_dest_tmpfilename $pobase/Makevars
2535 func_emit_po_Makevars > "$tmpfile"
2536 if test -f "$destdir"/$pobase/Makevars; then
2537 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
2541 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
2542 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
2543 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2545 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
2551 echo "Creating $pobase/Makevars"
2552 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2554 echo "Create $pobase/Makevars"
2557 func_append added_files "$pobase/Makevars$nl"
2559 # Create po makefile parametrization, part 2.
2560 func_dest_tmpfilename $pobase/POTFILES.in
2561 func_emit_po_POTFILES_in > "$tmpfile"
2562 if test -f "$destdir"/$pobase/POTFILES.in; then
2563 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
2567 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2568 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
2569 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2571 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2577 echo "Creating $pobase/POTFILES.in"
2578 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2580 echo "Create $pobase/POTFILES.in"
2583 func_append added_files "$pobase/POTFILES.in$nl"
2586 TP_URL="http://translationproject.org/latest/"
2587 TP_RSYNC_URI="translationproject.org::tp/latest/"
2589 echo "Fetching gnulib PO files from $TP_URL"
2590 (cd "$destdir"/$pobase \
2591 && { # Prefer rsync over wget if it is available, since it consumes
2592 # less network bandwidth, due to compression.
2593 if type rsync 2>/dev/null | grep / > /dev/null; then
2594 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
2596 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
2601 echo "Fetch gnulib PO files from $TP_URL"
2603 # Create po/LINGUAS.
2605 func_dest_tmpfilename $pobase/LINGUAS
2606 (cd "$destdir"/$pobase \
2607 && { echo '# Set of available languages.'
2608 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
2611 if test -f "$destdir"/$pobase/LINGUAS; then
2612 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
2615 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2616 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
2617 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2620 echo "Creating $pobase/LINGUAS"
2621 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2622 func_append added_files "$pobase/LINGUAS$nl"
2625 if test -f "$destdir"/$pobase/LINGUAS; then
2626 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2628 echo "Create $pobase/LINGUAS"
2633 # Create m4/gnulib-cache.m4.
2634 func_dest_tmpfilename $m4base/gnulib-cache.m4
2636 func_emit_copyright_notice
2638 echo "# This file represents the specification of how gnulib-tool is used."
2639 echo "# It acts as a cache: It is written and read by gnulib-tool."
2640 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2641 echo "# like the configure.ac and various Makefile.am files."
2644 echo "# Specification in the form of a command-line invocation:"
2647 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2648 # Store the local_gnulib_dir relative to destdir.
2649 case "$local_gnulib_dir" in
2651 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2654 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2656 # destdir, local_gnulib_dir are both relative.
2657 func_relativize "$destdir" "$local_gnulib_dir"
2658 relative_local_gnulib_dir="$reldir" ;;
2661 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2662 echo "gl_MODULES(["`echo $specified_modules`"])"
2663 echo "gl_AVOID([$avoidlist])"
2664 echo "gl_SOURCE_BASE([$sourcebase])"
2665 echo "gl_M4_BASE([$m4base])"
2666 echo "gl_PO_BASE([$pobase])"
2667 echo "gl_DOC_BASE([$docbase])"
2668 echo "gl_TESTS_BASE([$testsbase])"
2669 test -z "$inctests" || echo "gl_WITH_TESTS"
2670 echo "gl_LIB([$libname])"
2671 test -z "$lgpl" || echo "gl_LGPL"
2672 echo "gl_MAKEFILE_NAME([$makefile_name])"
2673 if test "$libtool" = true; then
2676 echo "gl_MACRO_PREFIX([$macro_prefix])"
2677 echo "gl_PO_DOMAIN([$po_domain])"
2679 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2680 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2684 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2685 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2686 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2688 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2692 echo "# gnulib-cache.m4 ends here"
2699 echo "Creating $m4base/gnulib-cache.m4"
2700 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2702 echo "Create $m4base/gnulib-cache.m4"
2708 # Create m4/gnulib-comp.m4.
2709 func_dest_tmpfilename $m4base/gnulib-comp.m4
2711 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2712 func_emit_copyright_notice
2714 echo "# This file represents the compiled summary of the specification in"
2715 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2716 echo "# to be invoked from configure.ac."
2717 echo "# In projects using CVS, this file can be treated like other built files."
2720 echo "# This macro should be invoked from $configure_ac, in the section"
2721 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2722 echo "# any checks for libraries, header files, types and library functions."
2723 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2725 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2726 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2727 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2728 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2729 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2730 if test -n "$uses_subdirs"; then
2731 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2733 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2734 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2736 for module in $modules; do
2738 if test -n "$module"; then
2739 func_get_autoconf_early_snippet "$module"
2742 | sed -e '/^$/d;' -e 's/^/ /'
2745 echo "# This macro should be invoked from $configure_ac, in the section"
2746 echo "# \"Check for header files, types and library functions\"."
2747 echo "AC_DEFUN([${macro_prefix}_INIT],"
2749 func_emit_initmacro_start
2750 if test "$libtool" = true; then
2751 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2752 echo " gl_cond_libtool=true"
2754 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2755 echo " gl_cond_libtool=false"
2757 echo " gl_ltlibdeps="
2759 echo " gl_source_base='$sourcebase'"
2760 if test "$auxdir" != "build-aux"; then
2761 sed_replace_build_aux='
2763 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2764 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2768 sed_replace_build_aux=
2770 for module in $modules; do
2772 if test -n "$module"; then
2773 func_get_autoconf_snippet "$module" \
2774 | sed -e '/^$/d;' -e 's/^/ /' \
2775 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2776 -e "$sed_replace_build_aux"
2777 if test "$module" = 'alloca' && test "$libtool" = true; then
2778 echo 'changequote(,)dnl'
2779 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2780 echo 'changequote([, ])dnl'
2781 echo 'AC_SUBST([LTALLOCA])'
2785 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2786 # created using libtool, because libtool already handles the dependencies.
2787 if test "$libtool" != true; then
2788 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
2789 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2790 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2791 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2792 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2794 func_emit_initmacro_end
2796 func_emit_initmacro_done
2798 echo "# This macro records the list of files which have been installed by"
2799 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2800 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2801 echo "$files" | sed -e 's,^, ,'
2804 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2805 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2809 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2810 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2811 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2813 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2817 echo "# gnulib-comp.m4 ends here"
2824 echo "Creating $m4base/gnulib-comp.m4"
2825 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2827 echo "Create $m4base/gnulib-comp.m4"
2833 if test -n "$inctests"; then
2834 # Create tests makefile.
2835 func_dest_tmpfilename $testsbase/$makefile_am
2836 func_emit_tests_Makefile_am > "$tmpfile"
2837 if test -f "$destdir"/$testsbase/$makefile_am; then
2838 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2842 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2843 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2844 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2846 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2852 echo "Creating $testsbase/$makefile_am"
2853 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2855 echo "Create $testsbase/$makefile_am"
2858 func_append added_files "$testsbase/$makefile_am$nl"
2862 # Update the .cvsignore and .gitignore files.
2863 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
2864 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
2865 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
2866 { # Rearrange file descriptors. Needed because "while ... done < ..."
2867 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2868 exec 5<&0 < "$tmp"/fileset-changes
2869 func_update_ignorelist ()
2872 if test -f "$destdir/$dir$ignore"; then
2873 if test -n "$dir_added" || test -n "$dir_removed"; then
2874 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
2875 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
2876 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
2877 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
2878 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
2879 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
2881 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2882 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
2883 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
2884 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
2885 | sed -f "$tmp"/sed-ignore-removed \
2886 > "$destdir/$dir$ignore"
2888 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2893 if test -n "$dir_added"; then
2895 echo "Creating $destdir/$dir$ignore"
2897 if test "$ignore" = .cvsignore; then
2899 # Automake generates Makefile rules that create .dirstamp files.
2902 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u
2903 } > "$destdir/$dir$ignore"
2905 echo "Create $destdir/$dir$ignore"
2915 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
2916 func_update_ignorelist .cvsignore
2918 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
2919 func_update_ignorelist .gitignore
2926 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
2927 next_dir=`echo "$line" | sed -e 's,|.*,,'`
2928 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
2929 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
2930 if test "$next_dir" != "$last_dir"; then
2931 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2932 last_dir="$next_dir"
2937 A) func_append last_dir_added "$file$nl";;
2938 R) func_append last_dir_removed "$file$nl";;
2941 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2947 echo "You may need to add #include directives for the following .h files."
2948 # Intersect $specified_modules and $modules
2949 # (since $specified_modules is not necessarily of subset of $modules - some
2950 # may have been skipped through --avoid, and since the elements of $modules
2951 # but not in $specified_modules can go away without explicit notice - through
2952 # changes in the module dependencies).
2953 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2954 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2955 # First the #include <...> directives without #ifs, sorted for convenience,
2956 # then the #include "..." directives without #ifs, sorted for convenience,
2957 # then the #include directives that are surrounded by #ifs. Not sorted.
2958 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2959 include_directive=`func_get_include_directive "$module"`
2960 case "$nl$include_directive" in
2962 echo "$include_directive" 1>&5
2965 echo "$include_directive" | grep -v 'include "' 1>&6
2966 echo "$include_directive" | grep 'include "' 1>&7
2969 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2971 LC_ALL=C sort -u "$tmp"/include-angles
2972 LC_ALL=C sort -u "$tmp"/include-quotes
2973 cat "$tmp"/include-if
2974 ) | sed -e '/^$/d' -e 's/^/ /'
2975 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2977 for module in $modules; do
2978 func_get_link_directive "$module"
2980 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
2981 if test `wc -l < "$tmp"/link` != 0; then
2983 echo "You may need to use the following Makefile variables when linking."
2984 echo "Use them in <program>_LDADD when linking a program, or"
2985 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
2991 echo "Don't forget to"
2992 if test "$makefile_am" = Makefile.am; then
2993 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2995 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2997 if test -n "$pobase"; then
2998 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3000 if test -n "$inctests"; then
3001 if test "$makefile_am" = Makefile.am; then
3002 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3004 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3007 if test "$makefile_am" = Makefile.am; then
3008 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3009 sourcebase_base=`basename "$sourcebase"`
3010 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
3012 if test -n "$pobase"; then
3013 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3014 pobase_base=`basename "$pobase"`
3015 echo " - mention \"${pobase_base}\" in SUBDIRS in ${pobase_dir}Makefile.am,"
3017 if test -n "$inctests"; then
3018 if test "$makefile_am" = Makefile.am; then
3019 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3020 testsbase_base=`basename "$testsbase"`
3021 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
3024 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
3025 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3026 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3029 # func_create_testdir testdir modules
3031 # - local_gnulib_dir from --local-dir
3032 # - auxdir directory relative to destdir where to place build aux files
3033 func_create_testdir ()
3037 if test -z "$modules"; then
3038 # All modules together.
3039 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3040 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3041 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3042 modules=`func_all_modules`
3043 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3045 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3047 # Check that the license of every module is consistent with the license of
3049 saved_modules="$modules"
3050 saved_inctests="$inctests"
3051 # When computing transitive closures, don't consider $module to depend on
3052 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3053 # on GPL modules - therefore we don't want a warning in this case.
3055 for requested_module in $saved_modules; do
3056 requested_license=`func_get_license "$requested_module"`
3057 if test "$requested_license" != GPL; then
3058 # Here we use func_modules_transitive_closure, not just
3059 # func_get_dependencies, so that we also detect weird situations like
3060 # an LGPL module which depends on a GPLed build tool module which depends
3062 modules="$requested_module"
3063 func_modules_transitive_closure
3064 for module in $modules; do
3065 license=`func_get_license "$module"`
3067 'GPLed build tool') ;;
3068 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3070 case "$requested_license" in
3073 GPLv2+ | LGPLv2+) ;;
3074 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3080 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3086 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3095 modules="$saved_modules"
3096 inctests="$saved_inctests"
3098 # Subdirectory names.
3107 # Determine final module list.
3108 func_modules_transitive_closure
3109 if test $verbose -ge 0; then
3110 echo "Module list with included dependencies:"
3111 echo "$modules" | sed -e 's/^/ /'
3114 # Add the dummy module if needed.
3115 func_modules_add_dummy
3117 # Show banner notice of every module.
3120 # Determine final file list.
3121 func_modules_to_filelist
3122 if test $verbose -ge 0; then
3124 echo "$files" | sed -e 's/^/ /'
3127 sed_rewrite_files="\
3128 s,^build-aux/,$auxdir/,
3130 s,^lib/,$sourcebase/,
3132 s,^tests/,$testsbase/,"
3134 # Create directories.
3135 for f in $files; do echo $f; done \
3136 | sed -e "$sed_rewrite_files" \
3137 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3138 | LC_ALL=C sort -u \
3140 { # Rearrange file descriptors. Needed because "while ... done < ..."
3141 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3142 exec 5<&0 < "$tmp"/dirs
3144 mkdir -p "$testdir/$d"
3149 # Copy files or make symbolic links.
3151 for f in $files; do echo $f; done \
3152 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3155 { # Rearrange file descriptors. Needed because "while ... done < ..."
3156 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3157 exec 5<&0 < "$tmp"/files
3159 func_lookup_file "$f"
3160 if test -n "$lookedup_tmp"; then
3161 cp -p "$lookedup_file" "$testdir/$g"
3163 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3164 if { test -n "$symbolic" \
3165 || { test -n "$lsymbolic" \
3166 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3167 func_ln "$lookedup_file" "$testdir/$g"
3169 cp -p "$lookedup_file" "$testdir/$g"
3176 # Create Makefile.ams that are for testing.
3179 # Create $sourcebase/Makefile.am.
3180 mkdir -p "$testdir/$sourcebase"
3181 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3183 # Create $m4base/Makefile.am.
3184 mkdir -p "$testdir/$m4base"
3185 (echo "## Process this file with automake to produce Makefile.in."
3191 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3194 ) > "$testdir/$m4base/Makefile.am"
3196 subdirs="$sourcebase $m4base"
3197 subdirs_with_configure_ac=""
3199 if false && test -f "$testdir"/$m4base/gettext.m4; then
3200 # Avoid stupid error message from automake:
3201 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3202 mkdir -p "$testdir/po"
3203 (echo "## Process this file with automake to produce Makefile.in."
3204 ) > "$testdir/po/Makefile.am"
3205 func_append subdirs " po"
3208 if test -n "$inctests"; then
3209 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3210 # Create $testsbase/Makefile.am.
3211 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3212 # Create $testsbase/configure.ac.
3213 (echo "# Process this file with autoconf to produce a configure script."
3214 echo "AC_INIT([dummy], [0])"
3215 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
3216 echo "AM_INIT_AUTOMAKE"
3218 echo "AM_CONFIG_HEADER([config.h])"
3221 echo "AC_PROG_INSTALL"
3222 echo "AC_PROG_MAKE_SET"
3223 echo "AC_PROG_RANLIB"
3225 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3226 echo "AC_GNU_SOURCE"
3229 for module in $modules; do
3231 if test -n "$module"; then
3232 func_get_autoconf_early_snippet "$module"
3235 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3236 if test "$libtool" = true; then
3237 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3238 echo "gl_cond_libtool=true"
3240 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3241 echo "gl_cond_libtool=false"
3243 echo "gl_ltlibdeps="
3245 # Wrap the set of autoconf snippets into an autoconf macro that is then
3246 # invoked. This is needed because autoconf does not support AC_REQUIRE
3248 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3249 # but we want the AC_REQUIRE to have its normal meaning (provide one
3250 # expansion of the required macro before the current point, and only one
3252 echo "AC_DEFUN([gl_INIT], ["
3253 func_emit_initmacro_start
3254 sed_replace_build_aux='
3256 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3257 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
3260 # We don't have explicit ordering constraints between the various
3261 # autoconf snippets. It's cleanest to put those of the library before
3262 # those of the tests.
3263 echo "gl_source_base='../$sourcebase'"
3264 for module in $modules; do
3265 func_verify_nontests_module
3266 if test -n "$module"; then
3267 func_get_autoconf_snippet "$module" \
3268 | sed -e "$sed_replace_build_aux"
3271 echo "gl_source_base='.'"
3272 for module in $modules; do
3273 func_verify_tests_module
3274 if test -n "$module"; then
3275 func_get_autoconf_snippet "$module" \
3276 | sed -e "$sed_replace_build_aux"
3279 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3280 # created using libtool, because libtool already handles the dependencies.
3281 if test "$libtool" != true; then
3282 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3283 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3284 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3285 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3286 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3288 func_emit_initmacro_end
3290 func_emit_initmacro_done
3294 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3295 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3296 echo "AH_TOP([#include \"../config.h\"])"
3298 echo "AC_OUTPUT([Makefile])"
3299 ) > "$testdir/$testsbase/configure.ac"
3300 func_append subdirs " $testsbase"
3301 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3304 # Create Makefile.am.
3305 (echo "## Process this file with automake to produce Makefile.in."
3307 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3309 echo "SUBDIRS = $subdirs"
3311 echo "ACLOCAL_AMFLAGS = -I $m4base"
3312 ) > "$testdir/Makefile.am"
3314 # Create configure.ac.
3315 (echo "# Process this file with autoconf to produce a configure script."
3316 echo "AC_INIT([dummy], [0])"
3317 if test "$auxdir" != "."; then
3318 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3320 echo "AM_INIT_AUTOMAKE"
3322 echo "AM_CONFIG_HEADER([config.h])"
3325 echo "AC_PROG_INSTALL"
3326 echo "AC_PROG_MAKE_SET"
3328 echo "# For autobuild."
3329 echo "AC_CANONICAL_BUILD"
3330 echo "AC_CANONICAL_HOST"
3332 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3333 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3334 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3335 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3337 echo "AC_PROG_RANLIB"
3339 if test -n "$uses_subdirs"; then
3340 echo "AM_PROG_CC_C_O"
3343 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3344 echo "AC_GNU_SOURCE"
3347 for module in $modules; do
3348 func_verify_nontests_module
3349 if test -n "$module"; then
3350 func_get_autoconf_early_snippet "$module"
3353 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3354 if test "$libtool" = true; then
3355 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3356 echo "gl_cond_libtool=true"
3358 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3359 echo "gl_cond_libtool=false"
3361 echo "gl_ltlibdeps="
3363 echo "gl_source_base='$sourcebase'"
3364 # Wrap the set of autoconf snippets into an autoconf macro that is then
3365 # invoked. This is needed because autoconf does not support AC_REQUIRE
3367 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3368 # but we want the AC_REQUIRE to have its normal meaning (provide one
3369 # expansion of the required macro before the current point, and only one
3371 echo "AC_DEFUN([gl_INIT], ["
3372 func_emit_initmacro_start
3373 if test "$auxdir" != "build-aux"; then
3374 sed_replace_build_aux='
3376 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3377 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3381 sed_replace_build_aux=
3383 for module in $modules; do
3384 func_verify_nontests_module
3385 if test -n "$module"; then
3386 func_get_autoconf_snippet "$module" \
3387 | sed -e "$sed_replace_build_aux"
3390 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3391 # created using libtool, because libtool already handles the dependencies.
3392 if test "$libtool" != true; then
3393 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3394 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3395 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3396 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3397 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3399 func_emit_initmacro_end
3401 func_emit_initmacro_done
3405 if test -n "$subdirs_with_configure_ac"; then
3406 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3408 makefiles="Makefile"
3409 for d in $subdirs; do
3410 # For subdirs that have a configure.ac by their own, it's the subdir's
3411 # configure.ac which creates the subdir's Makefile.am, not this one.
3412 case " $subdirs_with_configure_ac " in
3414 *) func_append makefiles " $d/Makefile" ;;
3417 echo "AC_OUTPUT([$makefiles])"
3418 ) > "$testdir/configure.ac"
3420 # Create autogenerated files.
3422 # Do not use "${AUTORECONF} --force --install", because it may invoke
3423 # autopoint, which brings in older versions of some of our .m4 files.
3424 if test -f $m4base/gettext.m4; then
3425 func_execute_command ${AUTOPOINT} --force || func_exit 1
3426 for f in $m4base/*.m4~; do
3427 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3430 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
3431 if ! test -d build-aux; then
3432 func_execute_command mkdir build-aux || func_exit 1
3434 func_execute_command ${AUTOCONF} || func_exit 1
3435 func_execute_command ${AUTOHEADER} || func_exit 1
3436 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3438 if test -n "$inctests"; then
3439 # Create autogenerated files.
3440 (cd "$testdir/$testsbase" || func_exit 1
3441 # Do not use "${AUTORECONF} --force --install", because it may invoke
3442 # autopoint, which brings in older versions of some of our .m4 files.
3443 if test -f ../$m4base/gettext.m4; then
3444 func_execute_command ${AUTOPOINT} --force || func_exit 1
3445 for f in ../$m4base/*.m4~; do
3446 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3449 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
3450 if ! test -d ../build-aux; then
3451 func_execute_command mkdir ../build-aux
3453 func_execute_command ${AUTOCONF} || func_exit 1
3454 func_execute_command ${AUTOHEADER} || func_exit 1
3455 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3458 # Need to run configure and make once, to create built files that are to be
3459 # distributed (such as getdate.c).
3460 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3461 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3462 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3463 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3464 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3465 # such $(FOO_H) because they don't refer to distributed files.
3466 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3467 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3468 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3469 | sed -e "$sed_remove_make_variables"`
3470 distributed_built_sources=`for file in $built_sources; do
3471 case "$cleaned_files" in
3476 if test -n "$distributed_built_sources"; then
3478 ./configure || func_exit 1
3480 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3481 make built_sources || func_exit 1
3483 make distclean || func_exit 1
3488 # func_create_megatestdir megatestdir allmodules
3490 # - local_gnulib_dir from --local-dir
3491 # - auxdir directory relative to destdir where to place build aux files
3492 func_create_megatestdir ()
3496 if test -z "$allmodules"; then
3497 allmodules=`func_all_modules`
3501 # First, all modules one by one.
3502 for onemodule in $allmodules; do
3503 func_create_testdir "$megatestdir/$onemodule" $onemodule
3504 func_append megasubdirs "$onemodule "
3506 # Then, all modules all together.
3507 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3508 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3509 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3510 func_create_testdir "$megatestdir/ALL" "$allmodules"
3511 func_append megasubdirs "ALL"
3514 cvsdate=`sh "$gnulib_dir/build-aux/mdate-sh" "$gnulib_dir/CVS/Entries" \
3515 | sed -e 's,January,01,' -e 's,Jan,01,' \
3516 -e 's,February,02,' -e 's,Feb,02,' \
3517 -e 's,March,03,' -e 's,Mar,03,' \
3518 -e 's,April,04,' -e 's,Apr,04,' \
3520 -e 's,June,06,' -e 's,Jun,06,' \
3521 -e 's,July,07,' -e 's,Jul,07,' \
3522 -e 's,August,08,' -e 's,Aug,08,' \
3523 -e 's,September,09,' -e 's,Sep,09,' \
3524 -e 's,October,10,' -e 's,Oct,10,' \
3525 -e 's,November,11,' -e 's,Nov,11,' \
3526 -e 's,December,12,' -e 's,Dec,12,' \
3527 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3528 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3530 echo "CVSDATE=$cvsdate"
3531 echo "test -d logs || mkdir logs"
3532 echo "for module in $megasubdirs; do"
3533 echo " echo \"Working on module \$module...\""
3534 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3535 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3538 echo " : autobuild project... \$module"
3539 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3540 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3541 echo " : autobuild hostname... \`hostname\`"
3542 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3544 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3546 ) > "$megatestdir/do-autobuild"
3547 chmod a+x "$megatestdir/do-autobuild"
3549 # Create Makefile.am.
3550 (echo "## Process this file with automake to produce Makefile.in."
3552 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3554 echo "SUBDIRS = $megasubdirs"
3556 echo "EXTRA_DIST = do-autobuild"
3557 ) > "$megatestdir/Makefile.am"
3559 # Create configure.ac.
3560 (echo "# Process this file with autoconf to produce a configure script."
3561 echo "AC_INIT([dummy], [0])"
3562 if test "$auxdir" != "."; then
3563 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3565 echo "AM_INIT_AUTOMAKE"
3567 echo "AC_PROG_MAKE_SET"
3569 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3570 echo "AC_OUTPUT([Makefile])"
3571 ) > "$megatestdir/configure.ac"
3573 # Create autogenerated files.
3575 # Do not use "${AUTORECONF} --install", because autoreconf operates
3576 # recursively, but the subdirectories are already finished, therefore
3577 # calling autoreconf here would only waste lots of CPU time.
3578 func_execute_command ${ACLOCAL} || func_exit 1
3579 func_execute_command mkdir build-aux
3580 func_execute_command ${AUTOCONF} || func_exit 1
3581 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3587 func_fatal_error "no mode specified" ;;
3596 if test -z "$destdir"; then
3599 test -d "$destdir" \
3600 || func_fatal_error "destination directory does not exist: $destdir"
3602 # Prefer configure.ac to configure.in.
3603 if test -f "$destdir"/configure.ac; then
3604 configure_ac="$destdir/configure.ac"
3606 if test -f "$destdir"/configure.in; then
3607 configure_ac="$destdir/configure.in"
3609 func_fatal_error "cannot find $destdir/configure.ac"
3613 # Analyze configure.ac.
3615 guessed_libtool=false
3620 /AC_CONFIG_AUX_DIR/ {
3621 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3623 /A[CM]_PROG_LIBTOOL/ {
3624 s,^.*$,guessed_libtool=true,p
3626 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3628 if test -z "$auxdir"; then
3629 auxdir="$guessed_auxdir"
3632 # Determine where to apply func_import.
3633 if test -n "$m4base"; then
3634 # Apply func_import to a particular gnulib directory.
3635 # Any number of additional modules can be given.
3636 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3637 # First use of gnulib in the given m4base.
3638 test -n "$supplied_libname" || supplied_libname=true
3639 test -n "$sourcebase" || sourcebase="lib"
3640 test -n "$docbase" || docbase="doc"
3641 test -n "$testsbase" || testsbase="tests"
3642 test -n "$macro_prefix" || macro_prefix="gl"
3646 # Apply func_import to all gnulib directories.
3647 # To get this list of directories, look at Makefile.am. (Not at
3648 # configure, because it may be omitted from CVS. Also, don't run
3649 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3652 if test -f "$destdir"/Makefile.am; then
3653 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3655 for arg in $aclocal_amflags; do
3656 if test -n "$m4dir_is_next"; then
3657 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3661 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3662 func_append m4dirs " $arg"
3663 m4dirs_count=`expr $m4dirs_count + 1`
3669 if test "X$arg" = "X-I"; then
3677 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3678 if test -f "$destdir"/aclocal.m4; then
3679 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3680 sedexpr2='s,^[^/]*$,.,'
3681 sedexpr3='s,/[^/]*$,,'
3682 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3683 m4dirs_count=`echo "$m4dirs" | wc -l`
3686 if test $m4dirs_count = 0; then
3687 # First use of gnulib in a package.
3688 # Any number of additional modules can be given.
3689 test -n "$supplied_libname" || supplied_libname=true
3690 test -n "$sourcebase" || sourcebase="lib"
3692 test -n "$docbase" || docbase="doc"
3693 test -n "$testsbase" || testsbase="tests"
3694 test -n "$macro_prefix" || macro_prefix="gl"
3697 if test $m4dirs_count = 1; then
3698 # There's only one use of gnulib here. Assume the user means it.
3699 # Any number of additional modules can be given.
3700 for m4base in $m4dirs; do
3704 # Ambiguous - guess what the user meant.
3705 if test $# = 0; then
3706 # No further arguments. Guess the user wants to update all of them.
3707 for m4base in $m4dirs; do
3708 # Perform func_import in a subshell, so that variable values
3710 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
3711 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
3712 # libtool, macro_prefix, po_domain
3713 # don't propagate from one directory to another.
3714 (func_import) || func_exit 1
3718 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
3726 if test -z "$destdir"; then
3727 func_fatal_error "please specify --dir option"
3730 test -d "$destdir" \
3731 || func_fatal_error "could not create destination directory"
3732 test -n "$auxdir" || auxdir="build-aux"
3733 func_create_testdir "$destdir" "$*"
3736 create-megatestdir )
3737 if test -z "$destdir"; then
3738 func_fatal_error "please specify --dir option"
3740 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3741 test -n "$auxdir" || auxdir="build-aux"
3742 func_create_megatestdir "$destdir" "$*"
3746 test -n "$destdir" || destdir=testdir$$
3747 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3748 test -n "$auxdir" || auxdir="build-aux"
3749 func_create_testdir "$destdir" "$*"
3753 ../configure || func_exit 1
3755 make check || func_exit 1
3756 make distclean || func_exit 1
3757 remaining=`find . -type f -print`
3758 if test -n "$remaining"; then
3759 echo "Remaining files:" $remaining 1>&2
3760 echo "gnulib-tool: *** Stop." 1>&2
3769 test -n "$destdir" || destdir=testdir$$
3770 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3771 test -n "$auxdir" || auxdir="build-aux"
3772 func_create_megatestdir "$destdir" "$*"
3780 remaining=`find . -type f -print`
3781 if test -n "$remaining"; then
3782 echo "Remaining files:" $remaining 1>&2
3783 echo "gnulib-tool: *** Stop." 1>&2
3791 extract-description )
3795 if test -n "$module"; then
3796 func_get_description "$module"
3805 if test -n "$module"; then
3806 func_get_notice "$module"
3815 if test -n "$module"; then
3816 func_get_filelist "$module"
3821 extract-dependencies )
3825 if test -n "$module"; then
3826 func_get_dependencies "$module"
3831 extract-autoconf-snippet )
3835 if test -n "$module"; then
3836 func_get_autoconf_snippet "$module"
3841 extract-automake-snippet )
3845 if test -n "$module"; then
3846 func_get_automake_snippet "$module"
3851 extract-include-directive )
3855 if test -n "$module"; then
3856 func_get_include_directive "$module"
3861 extract-link-directive )
3865 if test -n "$module"; then
3866 func_get_link_directive "$module"
3875 if test -n "$module"; then
3876 func_get_license "$module"
3881 extract-maintainer )
3885 if test -n "$module"; then
3886 func_get_maintainer "$module"
3891 extract-tests-module )
3895 if test -n "$module"; then
3896 func_get_tests_module "$module"
3902 func_fatal_error "unknown operation mode --$mode" ;;
3906 # Undo the effect of the previous 'trap' command. Some shellology:
3907 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3908 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3909 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3910 # 128 + signal number and is set before the trap-registered command is run.
3912 trap 'func_exit $?' 1 2 3 13 15
3917 # indent-tabs-mode: nil
3918 # whitespace-check-buffer-indent: nil