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-07-23 22:08:02 $'
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 alias sed='sed --posix'
80 # outputs to stdout the --help usage message.
84 Usage: gnulib-tool --list
85 gnulib-tool --import [module1 ... moduleN]
87 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
88 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
89 gnulib-tool --test --dir=directory module1 ... moduleN
90 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
91 gnulib-tool --extract-description module
92 gnulib-tool --extract-filelist module
93 gnulib-tool --extract-dependencies module
94 gnulib-tool --extract-autoconf-snippet module
95 gnulib-tool --extract-automake-snippet module
96 gnulib-tool --extract-include-directive module
97 gnulib-tool --extract-link-directive module
98 gnulib-tool --extract-license module
99 gnulib-tool --extract-maintainer module
100 gnulib-tool --extract-tests-module module
103 --list print the available module names
104 --import import the given modules into the current package;
105 if no modules are specified, update the current
106 package from the current gnulib
107 --update update the current package, restore files omitted
109 --create-testdir create a scratch package with the given modules
110 --create-megatestdir create a mega scratch package with the given modules
111 one by one and all together
112 --test test the combination of the given modules
113 (recommended to use CC=\"gcc -Wall\" here)
114 --megatest test the given modules one by one and all together
115 (recommended to use CC=\"gcc -Wall\" here)
116 --extract-description extract the description
117 --extract-filelist extract the list of files
118 --extract-dependencies extract the dependencies
119 --extract-autoconf-snippet extract the snippet for configure.ac
120 --extract-automake-snippet extract the snippet for library makefile
121 --extract-include-directive extract the #include directive
122 --extract-link-directive extract the linker directive
123 --extract-license report the license terms of the source files
125 --extract-maintainer report the maintainer(s) inside gnulib
126 --extract-tests-module report the unit test module, if it exists
129 --dir=DIRECTORY Specify the target directory.
130 For --import, this specifies where your
131 configure.ac can be found. Defaults to current
133 --local-dir=DIRECTORY Specify a local override directory where to look
134 up files before looking in gnulib's directory.
136 Options for --import:
137 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
138 --source-base=DIRECTORY
139 Directory relative to --dir where source code is
140 placed (default \"lib\").
141 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
142 placed (default \"m4\").
143 --po-base=DIRECTORY Directory relative to --dir where *.po files are
144 placed (default \"po\").
145 --doc-base=DIRECTORY Directory relative to --dir where doc files are
146 placed (default \"doc\").
147 --tests-base=DIRECTORY
148 Directory relative to --dir where unit tests are
149 placed (default \"tests\").
150 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
151 tools are placed (default \"build-aux\").
152 --with-tests Include unit tests for the included modules.
153 --avoid=MODULE Avoid including the given MODULE. Useful if you
154 have code that provides equivalent functionality.
155 This option can be repeated.
156 --lgpl Abort if modules aren't available under the LGPL.
157 Also modify license template from GPL to LGPL.
158 --makefile-name=NAME Name of makefile in automake syntax in the
159 source-base and tests-base directories
160 (default \"Makefile.am\").
161 --libtool Use libtool rules.
162 --no-libtool Don't use libtool rules.
163 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
164 'gl_INIT'. Default is 'gl'.
165 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
166 the package name. A suffix '-gnulib' is appended.
167 --no-changelog don't update or create ChangeLog files
169 Options for --import and --update:
170 --dry-run For --import, only print what would have been done.
171 -s, --symbolic, --symlink Make symbolic links instead of copying files.
172 --local-symlink Make symbolic links instead of copying files, only
173 for files from the local override directory.
174 -S, --more-symlinks Make symbolic links instead of copying files, and
175 don't replace copyright notices.
177 Report bugs to <bug-gnulib@gnu.org>."
181 # outputs to stdout the --version message.
184 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
186 $progname (GNU $package) $version
187 Copyright (C) $year Free Software Foundation, Inc.
188 This is free software; see the source for copying conditions. There is NO
189 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
190 Written by" "Bruno Haible" "and" "Simon Josefsson"
193 # func_emit_copyright_notice
194 # outputs to stdout a header for a generated file.
195 func_emit_copyright_notice ()
197 echo "# Copyright (C) 2004-2007 Free Software Foundation, Inc."
199 echo "# This file is free software, distributed under the terms of the GNU"
200 echo "# General Public License. As a special exception to the GNU General"
201 echo "# Public License, this file may be distributed as part of a program"
202 echo "# that contains a configuration script generated by Autoconf, under"
203 echo "# the same distribution terms as the rest of that program."
205 echo "# Generated by gnulib-tool."
216 # creates a temporary directory.
218 # - tmp pathname of freshly created temporary directory
221 # Use the environment variable TMPDIR, falling back to /tmp. This allows
222 # users to specify a different temporary directory, for example, if their
223 # /tmp is filled up or too small.
226 # Use the mktemp program if available. If not available, hide the error
228 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
229 test -n "$tmp" && test -d "$tmp"
232 # Use a simple mkdir command. It is guaranteed to fail if the directory
233 # already exists. $RANDOM is bash specific and expands to empty in shells
234 # other than bash, ksh and zsh. Its use does not increase security;
235 # rather, it minimizes the probability of failure in a very cluttered /tmp
237 tmp=$TMPDIR/gl$$-$RANDOM
238 (umask 077 && mkdir "$tmp")
241 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
246 # func_append var value
247 # appends the given value to the shell variable var.
248 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
249 # Use bash's += operator. It reduces complexity of appending repeatedly to
250 # a single variable from O(n^2) to O(n).
258 eval "$1=\"\$$1\$2\""
262 # func_fatal_error message
263 # outputs to stderr a fatal error message, and terminates the program.
266 echo "gnulib-tool: *** $1" 1>&2
267 echo "gnulib-tool: *** Stop." 1>&2
271 # func_readlink SYMLINK
272 # outputs the target of the given symlink.
273 if (type -p readlink) > /dev/null 2>&1; then
276 # Use the readlink program from GNU coreutils.
282 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
283 # would do the wrong thing if the link target contains " -> ".
284 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
288 # func_relativize DIR1 DIR2
289 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
291 # - DIR1 relative pathname, relative to the current directory
292 # - DIR2 relative pathname, relative to the current directory
294 # - reldir relative pathname of DIR2, relative to DIR1
300 sed_first='s,^\([^/]*\)/.*$,\1,'
301 sed_rest='s,^[^/]*/*,,'
302 sed_last='s,^.*/\([^/]*\)$,\1,'
303 sed_butlast='s,/*[^/]*$,,'
304 while test -n "$dir1"; do
305 first=`echo "$dir1" | sed -e "$sed_first"`
306 if test "$first" != "."; then
307 if test "$first" = ".."; then
308 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
309 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
311 first2=`echo "$dir2" | sed -e "$sed_first"`
312 if test "$first2" = "$first"; then
313 dir2=`echo "$dir2" | sed -e "$sed_rest"`
317 dir0="$dir0"/"$first"
320 dir1=`echo "$dir1" | sed -e "$sed_rest"`
325 # func_relconcat DIR1 DIR2
326 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
328 # - DIR1 relative pathname, relative to the current directory
329 # - DIR2 relative pathname, relative to DIR1
331 # - relconcat DIR1/DIR2, relative to the current directory
336 sed_first='s,^\([^/]*\)/.*$,\1,'
337 sed_rest='s,^[^/]*/*,,'
338 sed_last='s,^.*/\([^/]*\)$,\1,'
339 sed_butlast='s,/*[^/]*$,,'
341 first=`echo "$dir2" | sed -e "$sed_first"`
342 if test "$first" = "."; then
343 dir2=`echo "$dir2" | sed -e "$sed_rest"`
344 if test -z "$dir2"; then
349 last=`echo "$dir1" | sed -e "$sed_last"`
350 while test "$last" = "."; do
351 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
352 last=`echo "$dir1" | sed -e "$sed_last"`
354 if test -z "$dir1"; then
358 if test "$first" = ".."; then
359 if test "$last" = ".."; then
360 relconcat="$dir1/$dir2"
363 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
364 dir2=`echo "$dir2" | sed -e "$sed_rest"`
365 if test -z "$dir1"; then
369 if test -z "$dir2"; then
374 relconcat="$dir1/$dir2"
382 # Like ln -s, except that SRC is given relative to the current directory (or
383 # absolute), not given relative to the directory of DEST.
389 *) # SRC is relative.
392 ln -s "`pwd`/$1" "$2" ;;
393 *) # DEST is relative too.
394 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
395 test -n "$ln_destdir" || ln_destdir="."
396 func_relativize "$ln_destdir" "$1"
404 # func_ln_if_changed SRC DEST
405 # Like func_ln, but avoids munging timestamps if the link is correct.
406 func_ln_if_changed ()
408 if test $# -ne 2; then
409 echo "usage: func_ln_if_changed SRC DEST" >&2
411 ln_target=`func_readlink "$2"`
412 if test -L "$2" && test "$1" = "$ln_target"; then
420 # Ensure an 'echo' command that does not interpret backslashes.
422 # echo '\n' | wc -l prints 1 when OK, 2 when KO
423 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
424 # This problem is a weird heritage from SVR4. BSD got it right (except that
425 # BSD echo interprets '-n' as an option, which is also not desirable).
426 # Nowadays the problem occurs in 4 situations:
427 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
428 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
429 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
430 # - in zsh, when sh-emulation is not set,
431 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
432 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
433 # - in Solaris /bin/sh and OSF/1 /bin/sh.
434 # We try the following workarounds:
435 # - for all: respawn using $CONFIG_SHELL if that is set and works.
436 # - for bash >= 2.04: unset the shell option xpg_echo.
437 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
438 # - for bash < 2.0: define echo to a function that uses cat of a here document.
439 # - for zsh: turn sh-emulation on.
440 # - for ksh: alias echo to 'print -r'.
441 # - for ksh: alias echo to a function that uses cat of a here document.
442 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
443 # the ksh workaround.
444 # - otherwise: respawn using /bin/sh and rely on the workarounds.
445 # When respawning, we pass --no-reexec as first argument, so as to avoid
446 # turning this script into a fork bomb in unlucky situations.
448 if echo '\t' | grep t > /dev/null; then
449 have_echo=yes # Lucky!
451 # Try the workarounds.
452 # Respawn using $CONFIG_SHELL if that is set and works.
453 if test -z "$have_echo" \
454 && test "X$1" != "X--no-reexec" \
455 && test -n "$CONFIG_SHELL" \
456 && test -f "$CONFIG_SHELL" \
457 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
458 exec $CONFIG_SHELL "$0" --no-reexec "$@"
461 # For bash >= 2.04: unset the shell option xpg_echo.
462 if test -z "$have_echo" \
463 && test -n "$BASH_VERSION" \
464 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
468 # For bash >= 2.0: define echo to a function that uses the printf built-in.
469 # For bash < 2.0: define echo to a function that uses cat of a here document.
470 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
471 if test -z "$have_echo" \
472 && test -n "$BASH_VERSION"; then \
473 if type printf 2>/dev/null | grep / > /dev/null; then
474 # 'printf' is not a shell built-in.
482 # 'printf' is a shell built-in.
488 if echo '\t' | grep t > /dev/null; then
492 # For zsh: turn sh-emulation on.
493 if test -z "$have_echo" \
494 && test -n "$ZSH_VERSION" \
495 && (emulate sh) >/dev/null 2>&1; then
498 # For ksh: alias echo to 'print -r'.
499 if test -z "$have_echo" \
500 && (type print) >/dev/null 2>&1; then
501 # A 'print' command exists.
502 if type print 2>/dev/null | grep / > /dev/null; then
505 # 'print' is a shell built-in.
506 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
507 # 'print' is the ksh shell built-in.
508 alias echo='print -r'
512 if test -z "$have_echo" \
513 && echo '\t' | grep t > /dev/null; then
516 # For ksh: alias echo to a function that uses cat of a here document.
517 # The ksh manual page says:
518 # "Aliasing is performed when scripts are read, not while they are executed.
519 # Therefore, for an alias to take effect, the alias definition command has
520 # to be executed before the command which references the alias is read."
521 # Because of this, we have to play strange tricks with have_echo, to ensure
522 # that the top-level statement containing the test starts after the 'alias'
524 if test -z "$have_echo"; then
531 alias echo=bsd_echo 2>/dev/null
533 if test -z "$have_echo" \
534 && echo '\t' | grep t > /dev/null; then
537 if test -z "$have_echo"; then
538 unalias echo 2>/dev/null
540 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
541 if test -z "$have_echo" \
542 && test "X$1" != "X--no-reexec" \
543 && test -f /bin/ksh; then
544 exec /bin/ksh "$0" --no-reexec "$@"
547 # Otherwise: respawn using /bin/sh.
548 if test -z "$have_echo" \
549 && test "X$1" != "X--no-reexec" \
550 && test -f /bin/sh; then
551 exec /bin/sh "$0" --no-reexec "$@"
554 if test -z "$have_echo"; then
555 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
557 if echo '\t' | grep t > /dev/null; then
560 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
562 if test "X$1" = "X--no-reexec"; then
566 # Command-line option processing.
567 # Removes the OPTIONS from the arguments. Sets the variables:
568 # - mode list or import or create-testdir or create-megatestdir
569 # - destdir from --dir
570 # - local_gnulib_dir from --local-dir
571 # - libname, supplied_libname from --lib
572 # - sourcebase from --source-base
573 # - m4base from --m4-base
574 # - pobase from --po-base
575 # - docbase from --doc-base
576 # - testsbase from --tests-base
577 # - auxdir from --aux-dir
578 # - inctests true if --with-tests was given, blank otherwise
579 # - avoidlist list of modules to avoid, from --avoid
580 # - lgpl true if --lgpl was given, blank otherwise
581 # - makefile_name from --makefile-name
582 # - libtool true if --libtool was given, false if --no-libtool was
583 # given, blank otherwise
584 # - macro_prefix from --macro-prefix
585 # - po_domain from --po-domain
586 # - autoconf_minversion minimum supported autoconf version
587 # - do_changelog false if --no-changelog was given, : otherwise
588 # - doit : if actions shall be executed, false if only to be printed
589 # - symbolic true if --symlink or --more-symlinks was given, blank
591 # - lsymbolic true if --local-symlink was given, blank otherwise
592 # - do_copyrights blank if --more-symlinks was given, true otherwise
620 while test $# -gt 0; do
625 --import | --impor | --impo | --imp | --im | --i )
628 --update | --updat | --upda | --upd | --up | --u )
631 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
634 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
635 mode=create-megatestdir
637 --test | --tes | --te | --t )
640 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
644 mode=`echo "X$1" | sed -e 's/^X--//'`
649 func_fatal_error "missing argument for --dir"
654 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
659 func_fatal_error "missing argument for --local-dir"
664 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
669 func_fatal_error "missing argument for --lib"
672 supplied_libname=true
675 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
676 supplied_libname=true
681 func_fatal_error "missing argument for --source-base"
686 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
691 func_fatal_error "missing argument for --m4-base"
696 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
701 func_fatal_error "missing argument for --po-base"
706 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
711 func_fatal_error "missing argument for --doc-base"
716 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
721 func_fatal_error "missing argument for --tests-base"
726 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
731 func_fatal_error "missing argument for --aux-dir"
736 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
744 func_fatal_error "missing argument for --avoid"
746 func_append avoidlist " $1"
749 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
750 func_append avoidlist " $arg"
758 func_fatal_error "missing argument for --makefile-name"
763 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
774 func_fatal_error "missing argument for --macro-prefix"
779 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
784 func_fatal_error "missing argument for --po-domain"
789 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
791 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
797 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
800 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
803 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
807 --help | --hel | --he | --h )
810 --version | --versio | --versi | --vers | --ver | --ve | --v )
814 # Stop option processing
818 echo "gnulib-tool: unknown option $1" 1>&2
819 echo "Try 'gnulib-tool --help' for more information." 1>&2
826 if test "$mode" = update; then
827 if test $# != 0; then
828 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
829 echo "Try 'gnulib-tool --help' for more information." 1>&2
830 echo "If you really want to modify the gnulib configuration of your project," 1>&2
831 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
834 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
835 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
836 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
837 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
838 || test -n "$makefile_name" || test -n "$macro_prefix" \
839 || test -n "$po_domain"; then
840 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
841 echo "Try 'gnulib-tool --help' for more information." 1>&2
842 echo "If you really want to modify the gnulib configuration of your project," 1>&2
843 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
848 if test -n "$pobase" && test -z "$po_domain"; then
849 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
850 echo "Try 'gnulib-tool --help' for more information." 1>&2
853 if test -z "$pobase" && test -n "$po_domain"; then
854 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
857 # Determine the minimum supported autoconf version from the project's
859 DEFAULT_AUTOCONF_MINVERSION="2.59"
862 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
863 if test -f "$destdir"/configure.ac; then
864 configure_ac="$destdir/configure.ac"
866 if test -f "$destdir"/configure.in; then
867 configure_ac="$destdir/configure.in"
871 if test -f configure.ac; then
872 configure_ac="configure.ac"
874 if test -f configure.in; then
875 configure_ac="configure.in"
879 if test -n "$configure_ac"; then
880 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
881 # because when some m4 files are omitted from a CVS repository,
882 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
883 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
884 # autom4te: m4 failed with exit status: 1
891 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
893 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
894 if test -n "$prereqs"; then
895 autoconf_minversion=`
896 for version in $prereqs; do echo $version; done |
897 LC_ALL=C sort -nru | sed 1q
901 if test -z "$autoconf_minversion"; then
902 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
904 case "$autoconf_minversion" in
905 1.* | 2.[0-4]* | 2.5[0-8]*)
906 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
909 # Remove trailing slashes from the directory names. This is necessary for
910 # m4base (to avoid an error in func_import) and optional for the others.
911 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
912 case "$local_gnulib_dir" in
913 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
915 case "$sourcebase" in
916 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
919 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
922 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
925 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
928 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
931 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
936 /*) self_abspathname="$0" ;;
937 */*) self_abspathname=`pwd`/"$0" ;;
940 # Iterate through the elements of $PATH.
941 # We use IFS=: instead of
942 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
943 # because the latter does not work when some PATH element contains spaces.
944 # We use a canonicalized $pathx instead of $PATH, because empty PATH
945 # elements are by definition equivalent to '.', however field splitting
946 # according to IFS=: loses empty fields in many shells:
947 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
948 # beginning, at the end, and in the middle),
949 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
950 # at the beginning and at the end,
951 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
952 # Solaris lose empty fields at the end.
953 # The 'case' statement is an optimization, to avoid evaluating the
954 # explicit canonicalization command when $PATH contains no empty fields.
956 if test "${PATH_SEPARATOR+set}" != set; then
958 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
959 chmod +x "$tmp"/conf.sh
960 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
967 if test "$PATH_SEPARATOR" = ";"; then
968 # On Windows, programs are searched in "." before $PATH.
971 # On Unix, we have to convert empty PATH elements to ".".
975 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
980 IFS="$PATH_SEPARATOR"
984 if test -x "$d/$0" && test ! -d "$d/$0"; then
985 self_abspathname="$d/$0"
990 if test -z "$self_abspathname"; then
991 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
995 while test -h "$self_abspathname"; do
996 # Resolve symbolic link.
997 linkval=`func_readlink "$self_abspathname"`
998 test -n "$linkval" || break
1000 /* ) self_abspathname="$linkval" ;;
1001 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
1004 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
1007 trap 'exit_status=$?
1008 if test "$signal" != 0; then
1009 echo "caught signal $signal" >&2
1012 exit $exit_status' 0
1013 for signal in 1 2 3 13 15; do
1014 trap '{ signal='$signal'; func_exit 1; }' $signal
1018 # func_lookup_file file
1019 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1022 # - local_gnulib_dir from --local-dir
1024 # - lookedup_file name of the merged (combined) file
1025 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1029 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1030 lookedup_file="$local_gnulib_dir/$lkfile"
1033 if test -f "$gnulib_dir/$lkfile"; then
1034 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1035 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1036 rm -f "$tmp/$lkbase"
1037 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1038 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1039 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1040 lookedup_file="$tmp/$lkbase"
1043 lookedup_file="$gnulib_dir/$lkfile"
1047 func_fatal_error "file $gnulib_dir/$lkfile not found"
1054 # - local_gnulib_dir from --local-dir
1057 # Filter out metainformation files like README, which are not modules.
1058 # Filter out unit test modules; they can be retrieved through
1059 # --extract-tests-module if desired.
1061 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1062 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1063 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1066 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1067 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1068 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1069 -e '/^README$/d' -e '/\/README$/d' \
1070 -e '/^TEMPLATE$/d' \
1071 -e '/^TEMPLATE-EXTENDED$/d' \
1072 -e '/^TEMPLATE-TESTS$/d' \
1075 | sed -e '/-tests$/d' \
1079 # func_verify_module
1080 # verifies a module name
1082 # - local_gnulib_dir from --local-dir
1083 # - module module name argument
1084 func_verify_module ()
1086 if { test -f "$gnulib_dir/modules/$module" \
1087 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1088 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1089 && test "CVS" != "$module" \
1090 && test "ChangeLog" != "$module" \
1091 && test "COPYING" != "$module" \
1092 && test "README" != "$module" \
1093 && test "TEMPLATE" != "$module" \
1094 && test "TEMPLATE-EXTENDED" != "$module" \
1095 && test "TEMPLATE-TESTS" != "$module"; then
1096 # OK, $module is a correct module name.
1097 # Verify that building the module description with 'patch' succeeds.
1098 func_lookup_file "modules/$module"
1100 echo "gnulib-tool: module $module doesn't exist" 1>&2
1105 # func_verify_nontests_module
1106 # verifies a module name, excluding tests modules
1108 # - local_gnulib_dir from --local-dir
1109 # - module module name argument
1110 func_verify_nontests_module ()
1113 *-tests ) module= ;;
1114 * ) func_verify_module ;;
1118 # func_verify_tests_module
1119 # verifies a module name, considering only tests modules
1121 # - local_gnulib_dir from --local-dir
1122 # - module module name argument
1123 func_verify_tests_module ()
1126 *-tests ) func_verify_module ;;
1131 sed_extract_prog=':[ ]*$/ {
1134 s/^Description:[ ]*$//
1136 s/^Depends-on:[ ]*$//
1137 s/^configure\.ac-early:[ ]*$//
1138 s/^configure\.ac:[ ]*$//
1139 s/^Makefile\.am:[ ]*$//
1143 s/^Maintainer:[ ]*$//
1150 # func_get_description module
1152 # - local_gnulib_dir from --local-dir
1153 func_get_description ()
1155 func_lookup_file "modules/$1"
1156 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1159 # func_get_filelist module
1161 # - local_gnulib_dir from --local-dir
1162 func_get_filelist ()
1164 func_lookup_file "modules/$1"
1165 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1166 echo m4/gnulib-common.m4
1167 case "$autoconf_minversion" in
1169 #echo m4/onceonly.m4
1170 echo m4/onceonly_2_57.m4
1175 # func_get_dependencies module
1177 # - local_gnulib_dir from --local-dir
1178 func_get_dependencies ()
1180 # ${module}-tests always implicitly depends on ${module}.
1181 echo "$1" | sed -n -e 's/-tests//p'
1182 # Then the explicit dependencies listed in the module description.
1183 func_lookup_file "modules/$1"
1184 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1187 # func_get_autoconf_early_snippet module
1189 # - local_gnulib_dir from --local-dir
1190 func_get_autoconf_early_snippet ()
1192 func_lookup_file "modules/$1"
1193 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1196 # func_get_autoconf_snippet module
1198 # - local_gnulib_dir from --local-dir
1199 func_get_autoconf_snippet ()
1201 func_lookup_file "modules/$1"
1202 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1205 # func_get_automake_snippet module
1207 # - local_gnulib_dir from --local-dir
1208 func_get_automake_snippet ()
1210 func_lookup_file "modules/$1"
1211 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1214 # *-tests module live in tests/, not lib/.
1217 # Synthesize an EXTRA_DIST augmentation.
1218 sed_combine_lines='/\\$/{
1225 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1226 already_mentioned_files=` \
1227 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1228 | sed -e "$sed_combine_lines" \
1229 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1230 all_files=`func_get_filelist $1`
1231 lib_files=`for f in $all_files; do \
1235 done | sed -e 's,^lib/,,'`
1236 # Remove $already_mentioned_files from $lib_files.
1237 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1238 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1239 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1240 if test -n "$extra_files"; then
1241 echo "EXTRA_DIST +=" $extra_files
1244 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1245 # This is necessary so that automake can generate the right list of
1247 # A possible approach would be to use autom4te --trace of the redefined
1248 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1249 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1250 # inside autoconf's built-in macros are not missed).
1251 # But it's simpler and more robust to do it here, based on the file list.
1252 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1253 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1254 # automake will generate a useless dependency; this is harmless.
1256 relocatable-prog-wrapper) ;;
1258 sed_extract_c_files='/\.c$/p'
1259 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1260 if test -n "$extra_files"; then
1261 echo "EXTRA_lib_SOURCES +=" $extra_files
1266 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1267 buildaux_files=`for f in $all_files; do \
1269 build-aux/*) echo $f ;; \
1271 done | sed -e 's,^build-aux/,,'`
1272 if test -n "$buildaux_files"; then
1273 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1274 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1281 # func_get_include_directive module
1283 # - local_gnulib_dir from --local-dir
1284 func_get_include_directive ()
1286 func_lookup_file "modules/$1"
1287 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1288 sed -e 's/^\(["<]\)/#include \1/'
1291 # func_get_link_directive module
1293 # - local_gnulib_dir from --local-dir
1294 func_get_link_directive ()
1296 func_lookup_file "modules/$1"
1297 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1300 # func_get_license module
1302 # - local_gnulib_dir from --local-dir
1305 func_lookup_file "modules/$1"
1306 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1307 # The default is GPL.
1309 } | sed -e 's,^ *$,,' | sed -e 1q
1312 # func_get_maintainer module
1314 # - local_gnulib_dir from --local-dir
1315 func_get_maintainer ()
1317 func_lookup_file "modules/$1"
1318 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1321 # func_get_tests_module module
1323 # - local_gnulib_dir from --local-dir
1324 func_get_tests_module ()
1326 # The naming convention for tests modules is hardwired: ${module}-tests.
1327 if test -f "$gnulib_dir/modules/$1"-tests \
1328 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1329 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1334 # func_acceptable module
1335 # tests whether a module is acceptable.
1337 # - avoidlist list of modules to avoid
1340 for avoid in $avoidlist; do
1341 if test "$avoid" = "$1"; then
1348 # func_modules_transitive_closure
1350 # - local_gnulib_dir from --local-dir
1351 # - modules list of specified modules
1352 # - inctests true if tests should be included, blank otherwise
1353 # - avoidlist list of modules to avoid
1354 # - tmp pathname of a temporary directory
1356 # - modules list of modules, including dependencies
1357 func_modules_transitive_closure ()
1359 # In order to process every module only once (for speed), process an "input
1360 # list" of modules, producing an "output list" of modules. During each round,
1361 # more modules can be queued in the input list. Once a module on the input
1362 # list has been processed, it is added to the "handled list", so we can avoid
1363 # to process it again.
1365 inmodules="$modules"
1367 while test -n "$inmodules"; do
1368 inmodules_this_round="$inmodules"
1369 inmodules= # Accumulator, queue for next round
1370 for module in $inmodules_this_round; do
1372 if test -n "$module"; then
1373 if func_acceptable $module; then
1374 func_append outmodules " $module"
1375 deps=`func_get_dependencies $module`
1376 # Duplicate dependencies are harmless, but Jim wants a warning.
1377 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1378 if test -n "$duplicated_deps"; then
1379 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1381 func_append inmodules " $deps"
1382 if test -n "$inctests"; then
1383 testsmodule=`func_get_tests_module $module`
1384 if test -n "$testsmodule"; then
1385 func_append inmodules " $testsmodule"
1391 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1392 # Remove $handledmodules from $inmodules.
1393 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1394 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1396 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1397 rm -f "$tmp"/queued-modules
1400 # func_modules_add_dummy
1402 # - local_gnulib_dir from --local-dir
1403 # - modules list of modules, including dependencies
1405 # - modules list of modules, including 'dummy' if needed
1406 func_modules_add_dummy ()
1409 sed_remove_backslash_newline=':a
1416 for module in $modules; do
1417 func_verify_nontests_module
1418 if test -n "$module"; then
1419 # Extract the value of "lib_SOURCES += ...".
1420 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1421 # Ignore .h files since they are not compiled.
1424 *) have_lib_SOURCES=yes ;;
1429 # Add the dummy module, to make sure the library will be non-empty.
1430 if test -z "$have_lib_SOURCES"; then
1431 if func_acceptable "dummy"; then
1432 func_append modules " dummy"
1437 # func_modules_to_filelist
1439 # - local_gnulib_dir from --local-dir
1440 # - modules list of modules, including dependencies
1442 # - files list of files
1443 func_modules_to_filelist ()
1446 for module in $modules; do
1448 if test -n "$module"; then
1449 fs=`func_get_filelist $module`
1450 func_append files " $fs"
1453 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1456 # func_emit_lib_Makefile_am
1457 # emits the contents of library makefile to standard output.
1459 # - local_gnulib_dir from --local-dir
1460 # - modules list of modules, including dependencies
1461 # - libname library name
1462 # - pobase directory relative to destdir where to place *.po files
1463 # - auxdir directory relative to destdir where to place build aux files
1464 # - makefile_name from --makefile-name
1465 # - libtool true if libtool will be used, false or blank otherwise
1466 # - macro_prefix prefix of gl_LIBOBJS macros to use
1467 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1468 # - actioncmd (optional) command that will reproduce this invocation
1469 # - for_test true if creating a package for testing, false otherwise
1471 # - uses_subdirs nonempty if object files in subdirs exist
1472 func_emit_lib_Makefile_am ()
1474 # When creating an includable Makefile.am snippet, augment variables with
1475 # += instead of assigning them.
1476 if test -n "$makefile_name"; then
1481 if test "$libtool" = true; then
1484 sed_eliminate_LDFLAGS=
1488 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1491 # When creating a package for testing: Attempt to provoke failures,
1492 # especially link errors, already during "make" rather than during
1493 # "make check", because "make check" is not possible in a cross-compiling
1494 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1495 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1497 sed_transform_check_PROGRAMS=
1499 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1500 echo "## Process this file with automake to produce Makefile.in."
1501 func_emit_copyright_notice
1502 if test -n "$actioncmd"; then
1503 echo "# Reproduce by: $actioncmd"
1508 for module in $modules; do
1509 func_verify_nontests_module
1510 if test -n "$module"; then
1512 func_get_automake_snippet "$module" |
1513 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1514 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1515 -e "$sed_eliminate_LDFLAGS" \
1516 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1517 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1518 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1519 -e "$sed_transform_check_PROGRAMS"
1520 if test "$module" = 'alloca'; then
1521 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1522 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1525 # Skip the contents if its entirely empty.
1526 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1527 echo "## begin gnulib module $module"
1530 echo "## end gnulib module $module"
1534 # Test whether there are some source files in subdirectories.
1535 for f in `func_get_filelist "$module"`; do
1537 lib/*/*.c) uses_subdirs=yes ;;
1543 if test -z "$makefile_name"; then
1544 # If there are source files in subdirectories, prevent collision of the
1545 # object files (example: hash.c and libxml/hash.c).
1547 if test -n "$uses_subdirs"; then
1548 subdir_options=' subdir-objects'
1550 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1553 if test -z "$makefile_name"; then
1554 echo "noinst_HEADERS ="
1555 echo "noinst_LIBRARIES ="
1556 echo "noinst_LTLIBRARIES ="
1557 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1558 # if you specify pkgdata_DATA to empty. This is a workaround.
1559 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1560 echo "pkgdata_DATA ="
1563 echo "BUILT_SOURCES ="
1566 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1567 if test -z "$makefile_name"; then
1568 echo "MOSTLYCLEANDIRS ="
1570 echo "DISTCLEANFILES ="
1571 echo "MAINTAINERCLEANFILES ="
1573 echo "AM_CPPFLAGS ="
1576 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1577 # One of the snippets already specifies an installation location for the
1578 # library. Don't confuse automake by saying it should not be installed.
1581 # By default, the generated library should not be installed.
1582 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1585 echo "${libname}_${libext}_SOURCES ="
1586 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1587 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1588 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1589 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1590 echo "EXTRA_${libname}_${libext}_SOURCES ="
1591 if test "$libtool" = true; then
1592 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1595 if test -n "$pobase"; then
1596 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1599 cat allsnippets.tmp \
1600 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1602 echo "mostlyclean-local: mostlyclean-generic"
1603 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1604 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1605 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1609 rm -f allsnippets.tmp
1612 # func_emit_po_Makevars
1613 # emits the contents of po/ makefile parametrization to standard output.
1615 # - local_gnulib_dir from --local-dir
1616 # - sourcebase directory relative to destdir where to place source code
1617 # - pobase directory relative to destdir where to place *.po files
1618 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1619 func_emit_po_Makevars ()
1621 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1622 func_emit_copyright_notice
1624 echo "# Usually the message domain is the same as the package name."
1625 echo "# But here it has a '-gnulib' suffix."
1626 echo "DOMAIN = ${po_domain}-gnulib"
1628 echo "# These two variables depend on the location of this directory."
1629 echo "subdir = ${pobase}"
1630 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1633 # These options get passed to xgettext.
1634 XGETTEXT_OPTIONS = \
1635 --keyword=_ --flag=_:1:pass-c-format \
1636 --keyword=N_ --flag=N_:1:pass-c-format \
1637 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1638 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1639 --flag=error:3:c-format --flag=error_at_line:5:c-format
1641 # This is the copyright holder that gets inserted into the header of the
1642 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1643 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1645 # This is the email address or URL to which the translators shall report
1646 # bugs in the untranslated strings:
1647 # - Strings which are not entire sentences, see the maintainer guidelines
1648 # in the GNU gettext documentation, section 'Preparing Strings'.
1649 # - Strings which use unclear terms or require additional context to be
1651 # - Strings which make invalid assumptions about notation of date, time or
1653 # - Pluralisation problems.
1654 # - Incorrect English spelling.
1655 # - Incorrect formatting.
1656 # It can be your email address, or a mailing list address where translators
1657 # can write to without being subscribed, or the URL of a web page through
1658 # which the translators can contact you.
1659 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1661 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1662 # message catalogs shall be used. It is usually empty.
1663 EXTRA_LOCALE_CATEGORIES =
1665 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1666 # context. Possible values are "yes" and "no". Set this to yes if the
1667 # package uses functions taking also a message context, like pgettext(), or
1668 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1673 # func_emit_po_POTFILES_in
1674 # emits the file list to be passed to xgettext to standard output.
1676 # - local_gnulib_dir from --local-dir
1677 # - sourcebase directory relative to destdir where to place source code
1678 # - files list of new files
1679 func_emit_po_POTFILES_in ()
1681 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1682 func_emit_copyright_notice
1684 echo "# List of files which contain translatable strings."
1685 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1688 # func_emit_tests_Makefile_am
1689 # emits the contents of tests makefile to standard output.
1691 # - local_gnulib_dir from --local-dir
1692 # - modules list of modules, including dependencies
1693 # - libname library name
1694 # - makefile_name from --makefile-name
1695 # - libtool true if libtool will be used, false or blank otherwise
1696 # - sourcebase relative directory containing lib source code
1697 # - m4base relative directory containing autoconf macros
1698 # - testsbase relative directory containing unit test code
1699 # - for_test true if creating a package for testing, false otherwise
1700 func_emit_tests_Makefile_am ()
1702 if test "$libtool" = true; then
1707 if test "$libtool" = true; then
1709 sed_eliminate_LDFLAGS=
1712 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1715 # When creating a package for testing: Attempt to provoke failures,
1716 # especially link errors, already during "make" rather than during
1717 # "make check", because "make check" is not possible in a cross-compiling
1718 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1719 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1721 sed_transform_check_PROGRAMS=
1723 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1724 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1725 echo "## Process this file with automake to produce Makefile.in."
1726 func_emit_copyright_notice
1728 # Generate dependencies here, since it eases the debugging of test failures.
1729 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1731 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1734 for module in $modules; do
1735 func_verify_tests_module
1736 if test -n "$module"; then
1738 func_get_automake_snippet "$module" |
1739 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1740 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1741 -e "$sed_eliminate_LDFLAGS" \
1742 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1743 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1744 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1745 -e "$sed_transform_check_PROGRAMS"
1747 # Skip the contents if its entirely empty.
1748 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1749 echo "## begin gnulib module $module"
1752 echo "## end gnulib module $module"
1759 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1760 # variable is needed to avoid an error from automake:
1761 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1764 echo "TESTS_ENVIRONMENT ="
1765 echo "noinst_PROGRAMS ="
1766 if ! $for_test; then
1767 echo "check_PROGRAMS ="
1769 echo "noinst_HEADERS ="
1770 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1771 echo "pkgdata_DATA ="
1774 echo "BUILT_SOURCES ="
1776 echo "MOSTLYCLEANFILES = core *.stackdump"
1777 echo "MOSTLYCLEANDIRS ="
1779 echo "DISTCLEANFILES ="
1780 echo "MAINTAINERCLEANFILES ="
1782 echo "AM_CPPFLAGS = \\"
1783 echo " -I. -I\$(srcdir) \\"
1784 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1785 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1787 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1790 echo "# Clean up after Solaris cc."
1792 echo " rm -rf SunWS_cache"
1794 echo "mostlyclean-local: mostlyclean-generic"
1795 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1796 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1797 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1801 rm -f allsnippets.tmp
1804 # func_emit_initmacro_start
1805 # emits the first few statements of the gl_INIT macro to standard output.
1806 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1807 func_emit_initmacro_start ()
1809 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1810 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1811 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1812 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1814 # Furthermore it avoids an automake error like this when a Makefile.am
1815 # that uses pieces of gnulib also uses $(LIBOBJ):
1816 # automatically discovered file `error.c' should not be explicitly mentioned
1817 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1818 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1819 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1820 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1821 # automatically discovered file `error.c' should not be explicitly mentioned
1822 # We let automake know about the files to be distributed through the
1823 # EXTRA_lib_SOURCES variable.
1824 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1827 # func_emit_initmacro_end
1828 # emits the last few statements of the gl_INIT macro to standard output.
1829 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1830 func_emit_initmacro_end ()
1832 echo " m4_popdef([AC_LIBSOURCES])"
1833 echo " m4_popdef([AC_REPLACE_FUNCS])"
1834 echo " m4_popdef([AC_LIBOBJ])"
1835 echo " AC_CONFIG_COMMANDS_PRE(["
1836 echo " ${macro_prefix}_libobjs="
1837 echo " ${macro_prefix}_ltlibobjs="
1838 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1839 echo " # Remove the extension."
1840 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1841 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1842 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1843 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1846 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1847 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1851 # func_emit_initmacro_done
1852 # emits a few statements after the gl_INIT macro to standard output.
1853 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1854 func_emit_initmacro_done ()
1857 echo "# Like AC_LIBOBJ, except that the module name goes"
1858 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1859 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1860 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1862 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1863 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1864 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1865 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1867 echo "# Like AC_LIBSOURCES, except that it does nothing."
1868 echo "# We rely on EXTRA_lib..._SOURCES instead."
1869 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1873 # func_import modules
1874 # Uses also the variables
1875 # - destdir target directory
1876 # - local_gnulib_dir from --local-dir
1877 # - libname library name
1878 # - sourcebase directory relative to destdir where to place source code
1879 # - m4base directory relative to destdir where to place *.m4 macros
1880 # - pobase directory relative to destdir where to place *.po files
1881 # - docbase directory relative to destdir where to place doc files
1882 # - testsbase directory relative to destdir where to place unit test code
1883 # - auxdir directory relative to destdir where to place build aux files
1884 # - inctests true if --with-tests was given, blank otherwise
1885 # - avoidlist list of modules to avoid, from --avoid
1886 # - lgpl true if library's license shall be LGPL, blank otherwise
1887 # - makefile_name from --makefile-name
1888 # - libtool true if --libtool was given, false if --no-libtool was
1889 # given, blank otherwise
1890 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1891 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1892 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1893 # - autoconf_minversion minimum supported autoconf version
1894 # - doit : if actions shall be executed, false if only to be printed
1895 # - symbolic true if files should be symlinked, copied otherwise
1896 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1898 # - do_copyrights true if copyright notices in files should be replaced,
1902 # Get the cached settings.
1903 cached_local_gnulib_dir=
1904 cached_specified_modules=
1914 cached_makefile_name=
1916 cached_macro_prefix=
1919 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1920 cached_libtool=false
1926 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1929 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1932 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1935 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1938 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1941 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
1944 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1947 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1950 s,^.*$,cached_inctests=true,p
1953 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1956 s,^.*$,cached_lgpl=true,p
1958 /gl_MAKEFILE_NAME(/ {
1959 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1962 s,^.*$,cached_libtool=true,p
1964 /gl_MACRO_PREFIX(/ {
1965 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1968 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
1970 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1971 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1976 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1977 s,^.*$,cached_files=",p
1989 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1993 # Merge the cached settings with the specified ones.
1994 # The m4base must be the same as expected from the pathname.
1995 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1996 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1998 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1999 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2000 if test -z "$local_gnulib_dir"; then
2001 if test -n "$cached_local_gnulib_dir"; then
2004 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2006 case "$cached_local_gnulib_dir" in
2008 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2010 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2011 local_gnulib_dir="$relconcat" ;;
2016 # Append the cached and the specified module names. So that
2017 # "gnulib-tool --import foo" means to add the module foo.
2018 specified_modules="$cached_specified_modules $1"
2019 # Append the cached and the specified avoidlist. This is probably better
2020 # than dropping the cached one when --avoid is specified at least once.
2021 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2022 avoidlist=`echo $avoidlist`
2024 # The sourcebase defaults to the cached one.
2025 if test -z "$sourcebase"; then
2026 sourcebase="$cached_sourcebase"
2027 if test -z "$sourcebase"; then
2028 func_fatal_error "missing --source-base option"
2031 # The pobase defaults to the cached one.
2032 if test -z "$pobase"; then
2033 pobase="$cached_pobase"
2035 # The docbase defaults to the cached one.
2036 if test -z "$docbase"; then
2037 docbase="$cached_docbase"
2038 if test -z "$docbase"; then
2039 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."
2042 # The testsbase defaults to the cached one.
2043 if test -z "$testsbase"; then
2044 testsbase="$cached_testsbase"
2045 if test -z "$testsbase"; then
2046 func_fatal_error "missing --tests-base option"
2049 # Require the tests if specified either way.
2050 if test -z "$inctests"; then
2051 inctests="$cached_inctests"
2053 # The libname defaults to the cached one.
2054 if test -z "$supplied_libname"; then
2055 libname="$cached_libname"
2056 if test -z "$libname"; then
2057 func_fatal_error "missing --lib option"
2060 # Require LGPL if specified either way.
2061 if test -z "$lgpl"; then
2064 # The makefile_name defaults to the cached one.
2065 if test -z "$makefile_name"; then
2066 makefile_name="$cached_makefile_name"
2068 # Use libtool if specified either way, or if guessed.
2069 if test -z "$libtool"; then
2070 if test -n "$cached_m4base"; then
2071 libtool="$cached_libtool"
2073 libtool="$guessed_libtool"
2076 # The macro_prefix defaults to the cached one.
2077 if test -z "$macro_prefix"; then
2078 macro_prefix="$cached_macro_prefix"
2079 if test -z "$macro_prefix"; then
2080 func_fatal_error "missing --macro-prefix option"
2083 # The po_domain defaults to the cached one.
2084 if test -z "$po_domain"; then
2085 po_domain="$cached_po_domain"
2088 # Canonicalize the list of specified modules.
2089 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2091 # Determine final module list.
2092 modules="$specified_modules"
2093 func_modules_transitive_closure
2094 echo "Module list with included dependencies:"
2095 echo "$modules" | sed -e 's/^/ /'
2097 # Add the dummy module if needed.
2098 func_modules_add_dummy
2100 # If --lgpl, verify that the licenses of modules are compatible.
2101 if test -n "$lgpl"; then
2102 for module in $modules; do
2103 license=`func_get_license $module`
2105 LGPL | LGPLv2+ | 'GPLed build tool') ;;
2106 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2107 *) func_fatal_error "incompatible license on module $module: $license" ;;
2112 # Determine script to apply to imported library files.
2113 sed_transform_lib_file=
2114 for module in $modules; do
2115 if test $module = config-h; then
2116 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2117 sed_transform_lib_file=$sed_transform_lib_file'
2118 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2123 if test -n "$do_copyrights"; then
2124 if test -n "$lgpl"; then
2126 sed_transform_lib_file=$sed_transform_lib_file'
2127 s/GNU General/GNU Lesser General/g
2128 s/version 2\([ ,]\)/version 2.1\1/g
2133 # Determine final file list.
2134 func_modules_to_filelist
2136 echo "$files" | sed -e 's/^/ /'
2139 || func_fatal_error "refusing to do nothing"
2141 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2142 new_files="$files m4/gnulib-tool.m4"
2143 old_files="$cached_files"
2144 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2145 func_append old_files " m4/gnulib-tool.m4"
2148 sed_rewrite_old_files="\
2149 s,^build-aux/,$auxdir/,
2150 s,^doc/,$cached_docbase/,
2151 s,^lib/,$cached_sourcebase/,
2152 s,^m4/,$cached_m4base/,
2153 s,^tests/,$cached_testsbase/,"
2154 sed_rewrite_new_files="\
2155 s,^build-aux/,$auxdir/,
2157 s,^lib/,$sourcebase/,
2159 s,^tests/,$testsbase/,"
2161 # Create directories.
2162 { echo "$sourcebase"
2164 if test -n "$pobase"; then
2167 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2168 if test -n "$docfiles"; then
2171 if test -n "$inctests"; then
2175 for f in $files; do echo $f; done \
2176 | sed -e "$sed_rewrite_new_files" \
2177 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2180 { # Rearrange file descriptors. Needed because "while ... done < ..."
2181 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2182 exec 5<&0 < "$tmp"/dirs
2184 if test ! -d "$destdir/$d"; then
2186 echo "Creating directory $destdir/$d"
2187 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2189 echo "Create directory $destdir/$d"
2196 # func_dest_tmpfilename file
2197 # determines the name of a temporary file (file is relative to destdir).
2199 # - tmpfile absolute filename of the temporary file
2200 func_dest_tmpfilename ()
2203 # Put the new contents of $file in a file in the same directory (needed
2204 # to guarantee that an 'mv' to "$destdir/$file" works).
2205 tmpfile="$destdir/$1.tmp"
2207 # Put the new contents of $file in a file in a temporary directory
2208 # (because the directory of "$file" might not exist).
2209 tmpfile="$tmp"/`basename "$1"`.tmp
2213 # Copy files or make symbolic links. Remove obsolete files.
2217 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2218 # representing the files according to the last gnulib-tool invocation.
2219 for f in $old_files; do echo $f; done \
2220 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2223 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2224 # representing the files after this gnulib-tool invocation.
2225 for f in $new_files; do echo $f; done \
2226 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2229 # First the files that are in old-files, but not in new-files:
2230 sed_take_first_column='s,'"$delimiter"'.*,,'
2231 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2232 # Remove the file. Do nothing if the user already removed it.
2233 if test -f "$destdir/$g"; then
2235 echo "Removing file $g (backup in ${g}~)"
2236 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2238 echo "Remove file $g (backup in ${g}~)"
2240 func_append removed_files "$g$nl"
2243 # func_add_or_update handles a file that ought to be present afterwards.
2245 # - f the original file name
2246 # - g the rewritten file name
2247 # - already_present nonempty if the file already exists, empty otherwise
2248 func_add_or_update ()
2250 func_dest_tmpfilename "$g"
2251 func_lookup_file "$f"
2252 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2253 if test -n "$sed_transform_lib_file"; then
2256 sed -e "$sed_transform_lib_file" \
2257 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2261 if test -f "$destdir/$g"; then
2262 # The file already exists.
2263 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2264 : # The file has not changed.
2268 if test -n "$already_present"; then
2269 echo "Updating file $g (backup in ${g}~)"
2271 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2273 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2274 if { test -n "$symbolic" \
2275 || { test -n "$lsymbolic" \
2276 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2277 && test -z "$lookedup_tmp" \
2278 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2279 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2281 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2284 if test -n "$already_present"; then
2285 echo "Update file $g (backup in ${g}~)"
2287 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2293 # Don't protest if the file should be there but isn't: it happens
2294 # frequently that developers don't put autogenerated files into CVS.
2296 echo "Copying file $g"
2297 if { test -n "$symbolic" \
2298 || { test -n "$lsymbolic" \
2299 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2300 && test -z "$lookedup_tmp" \
2301 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2302 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2304 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2309 func_append added_files "$g$nl"
2313 # Then the files that are in new-files, but not in old-files:
2314 sed_take_last_column='s,^.*'"$delimiter"',,'
2316 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2317 | sed -e "$sed_take_last_column" \
2318 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2319 { # Rearrange file descriptors. Needed because "while ... done < ..."
2320 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2321 exec 5<&0 < "$tmp"/added-files
2327 # Then the files that are in new-files and in old-files:
2328 already_present=true
2329 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2330 | sed -e "$sed_take_last_column" \
2331 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2332 { # Rearrange file descriptors. Needed because "while ... done < ..."
2333 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2334 exec 5<&0 < "$tmp"/kept-files
2341 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2342 actioncmd="gnulib-tool --import"
2343 func_append actioncmd " --dir=$destdir"
2344 if test -n "$local_gnulib_dir"; then
2345 func_append actioncmd " --local-dir=$local_gnulib_dir"
2347 func_append actioncmd " --lib=$libname"
2348 func_append actioncmd " --source-base=$sourcebase"
2349 func_append actioncmd " --m4-base=$m4base"
2350 if test -n "$pobase"; then
2351 func_append actioncmd " --po-base=$pobase"
2353 func_append actioncmd " --doc-base=$docbase"
2354 func_append actioncmd " --aux-dir=$auxdir"
2355 if test -n "$inctests"; then
2356 func_append actioncmd " --with-tests"
2358 for module in $avoidlist; do
2359 func_append actioncmd " --avoid=$module"
2361 if test -n "$lgpl"; then
2362 func_append actioncmd " --lgpl"
2364 if test -n "$makefile_name"; then
2365 func_append actioncmd " --makefile-name=$makefile_name"
2367 if test "$libtool" = true; then
2368 func_append actioncmd " --libtool"
2370 func_append actioncmd " --no-libtool"
2372 func_append actioncmd " --macro-prefix=$macro_prefix"
2373 if test -n "$po_domain"; then
2374 func_append actioncmd " --po-domain=$po_domain"
2376 func_append actioncmd " `echo $specified_modules`"
2378 # Default the makefile name to Makefile.am.
2379 if test -n "$makefile_name"; then
2380 makefile_am=$makefile_name
2382 makefile_am=Makefile.am
2385 # Create normal Makefile.ams.
2388 # Create library makefile.
2389 func_dest_tmpfilename $sourcebase/$makefile_am
2390 func_emit_lib_Makefile_am > "$tmpfile"
2391 if test -f "$destdir"/$sourcebase/$makefile_am; then
2392 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2396 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2397 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2398 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2400 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2406 echo "Creating $sourcebase/$makefile_am"
2407 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2409 echo "Create $sourcebase/$makefile_am"
2412 func_append added_files "$sourcebase/$makefile_am$nl"
2415 # Create po/ directory.
2416 if test -n "$pobase"; then
2417 # Create po makefile and auxiliary files.
2418 for file in Makefile.in.in remove-potcdate.sin; do
2419 func_dest_tmpfilename $pobase/$file
2420 func_lookup_file build-aux/po/$file
2421 cat "$lookedup_file" > "$tmpfile"
2422 if test -f "$destdir"/$pobase/$file; then
2423 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
2427 echo "Updating $pobase/$file (backup in $pobase/$file~)"
2428 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
2429 mv -f "$tmpfile" "$destdir"/$pobase/$file
2431 echo "Update $pobase/$file (backup in $pobase/$file~)"
2437 echo "Creating $pobase/$file"
2438 mv -f "$tmpfile" "$destdir"/$pobase/$file
2440 echo "Create $pobase/$file"
2443 func_append added_files "$pobase/$file$nl"
2446 # Create po makefile parametrization, part 1.
2447 func_dest_tmpfilename $pobase/Makevars
2448 func_emit_po_Makevars > "$tmpfile"
2449 if test -f "$destdir"/$pobase/Makevars; then
2450 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
2454 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
2455 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
2456 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2458 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
2464 echo "Creating $pobase/Makevars"
2465 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2467 echo "Create $pobase/Makevars"
2470 func_append added_files "$pobase/Makevars$nl"
2472 # Create po makefile parametrization, part 2.
2473 func_dest_tmpfilename $pobase/POTFILES.in
2474 func_emit_po_POTFILES_in > "$tmpfile"
2475 if test -f "$destdir"/$pobase/POTFILES.in; then
2476 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
2480 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2481 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
2482 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2484 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2490 echo "Creating $pobase/POTFILES.in"
2491 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2493 echo "Create $pobase/POTFILES.in"
2496 func_append added_files "$pobase/POTFILES.in$nl"
2499 TP_URL="http://translationproject.org/latest/"
2501 echo "Fetching gnulib PO files from $TP_URL"
2502 (cd "$destdir"/$pobase \
2503 && wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
2506 echo "Fetch gnulib PO files from $TP_URL"
2508 # Create po/LINGUAS.
2510 func_dest_tmpfilename $pobase/LINGUAS
2511 (cd "$destdir"/$pobase \
2512 && { echo '# Set of available languages.'
2513 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
2516 if test -f "$destdir"/$pobase/LINGUAS; then
2517 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
2520 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2521 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
2522 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2525 echo "Creating $pobase/LINGUAS"
2526 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2527 func_append added_files "$pobase/LINGUAS$nl"
2530 if test -f "$destdir"/$pobase/LINGUAS; then
2531 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2533 echo "Create $pobase/LINGUAS"
2538 # Create m4/gnulib-cache.m4.
2539 func_dest_tmpfilename $m4base/gnulib-cache.m4
2541 func_emit_copyright_notice
2543 echo "# This file represents the specification of how gnulib-tool is used."
2544 echo "# It acts as a cache: It is written and read by gnulib-tool."
2545 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2546 echo "# like the configure.ac and various Makefile.am files."
2549 echo "# Specification in the form of a command-line invocation:"
2552 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2553 # Store the local_gnulib_dir relative to destdir.
2554 case "$local_gnulib_dir" in
2556 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2559 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2561 # destdir, local_gnulib_dir are both relative.
2562 func_relativize "$destdir" "$local_gnulib_dir"
2563 relative_local_gnulib_dir="$reldir" ;;
2566 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2567 echo "gl_MODULES(["`echo $specified_modules`"])"
2568 echo "gl_AVOID([$avoidlist])"
2569 echo "gl_SOURCE_BASE([$sourcebase])"
2570 echo "gl_M4_BASE([$m4base])"
2571 echo "gl_PO_BASE([$pobase])"
2572 echo "gl_DOC_BASE([$docbase])"
2573 echo "gl_TESTS_BASE([$testsbase])"
2574 test -z "$inctests" || echo "gl_WITH_TESTS"
2575 echo "gl_LIB([$libname])"
2576 test -z "$lgpl" || echo "gl_LGPL"
2577 echo "gl_MAKEFILE_NAME([$makefile_name])"
2578 if test "$libtool" = true; then
2581 echo "gl_MACRO_PREFIX([$macro_prefix])"
2582 echo "gl_PO_DOMAIN([$po_domain])"
2584 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2585 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2589 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2590 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2591 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2593 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2597 echo "# gnulib-cache.m4 ends here"
2604 echo "Creating $m4base/gnulib-cache.m4"
2605 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2607 echo "Create $m4base/gnulib-cache.m4"
2613 # Create m4/gnulib-comp.m4.
2614 func_dest_tmpfilename $m4base/gnulib-comp.m4
2616 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2617 func_emit_copyright_notice
2619 echo "# This file represents the compiled summary of the specification in"
2620 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2621 echo "# to be invoked from configure.ac."
2622 echo "# In projects using CVS, this file can be treated like other built files."
2625 echo "# This macro should be invoked from $configure_ac, in the section"
2626 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2627 echo "# any checks for libraries, header files, types and library functions."
2628 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2630 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2631 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2632 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2633 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2634 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2635 if test -n "$uses_subdirs"; then
2636 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2638 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2639 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2641 for module in $modules; do
2643 if test -n "$module"; then
2644 func_get_autoconf_early_snippet "$module"
2647 | sed -e '/^$/d;' -e 's/^/ /'
2650 echo "# This macro should be invoked from $configure_ac, in the section"
2651 echo "# \"Check for header files, types and library functions\"."
2652 echo "AC_DEFUN([${macro_prefix}_INIT],"
2654 func_emit_initmacro_start
2655 if test "$libtool" = true; then
2656 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2657 echo " gl_cond_libtool=true"
2659 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2660 echo " gl_cond_libtool=false"
2662 echo " gl_ltlibdeps="
2664 echo " gl_source_base='$sourcebase'"
2665 if test "$auxdir" != "build-aux"; then
2666 sed_replace_build_aux='
2668 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2669 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2673 sed_replace_build_aux=
2675 for module in $modules; do
2677 if test -n "$module"; then
2678 func_get_autoconf_snippet "$module" \
2679 | sed -e '/^$/d;' -e 's/^/ /' \
2680 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2681 -e "$sed_replace_build_aux"
2682 if test "$module" = 'alloca' && test "$libtool" = true; then
2683 echo 'changequote(,)dnl'
2684 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2685 echo 'changequote([, ])dnl'
2686 echo 'AC_SUBST([LTALLOCA])'
2690 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2691 # created using libtool, because libtool already handles the dependencies.
2692 if test "$libtool" != true; then
2693 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
2694 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2695 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2696 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2697 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2699 func_emit_initmacro_end
2701 func_emit_initmacro_done
2703 echo "# This macro records the list of files which have been installed by"
2704 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2705 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2706 echo "$files" | sed -e 's,^, ,'
2709 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2710 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2714 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2715 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2716 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2718 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2722 echo "# gnulib-comp.m4 ends here"
2729 echo "Creating $m4base/gnulib-comp.m4"
2730 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2732 echo "Create $m4base/gnulib-comp.m4"
2738 if test -n "$inctests"; then
2739 # Create tests makefile.
2740 func_dest_tmpfilename $testsbase/$makefile_am
2741 func_emit_tests_Makefile_am > "$tmpfile"
2742 if test -f "$destdir"/$testsbase/$makefile_am; then
2743 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2747 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2748 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2749 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2751 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2757 echo "Creating $testsbase/$makefile_am"
2758 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2760 echo "Create $testsbase/$makefile_am"
2763 func_append added_files "$testsbase/$makefile_am$nl"
2767 # Update the .cvsignore and .gitignore files.
2768 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
2769 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
2770 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
2771 { # Rearrange file descriptors. Needed because "while ... done < ..."
2772 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2773 exec 5<&0 < "$tmp"/fileset-changes
2774 func_update_ignorelist ()
2777 if test -f "$destdir/$dir$ignore"; then
2778 if test -n "$dir_added" || test -n "$dir_removed"; then
2779 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
2780 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
2781 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
2782 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
2783 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
2784 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
2786 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2787 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
2788 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
2789 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
2790 | sed -f "$tmp"/sed-ignore-removed \
2791 > "$destdir/$dir$ignore"
2793 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2798 if test -n "$dir_added"; then
2800 echo "Creating $destdir/$dir$ignore"
2802 if test "$ignore" = .cvsignore; then
2804 # Automake generates Makefile rules that create .dirstamp files.
2807 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u
2808 } > "$destdir/$dir$ignore"
2810 echo "Create $destdir/$dir$ignore"
2820 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
2821 func_update_ignorelist .cvsignore
2823 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
2824 func_update_ignorelist .gitignore
2831 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
2832 next_dir=`echo "$line" | sed -e 's,|.*,,'`
2833 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
2834 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
2835 if test "$next_dir" != "$last_dir"; then
2836 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2837 last_dir="$next_dir"
2842 A) func_append last_dir_added "$file$nl";;
2843 R) func_append last_dir_removed "$file$nl";;
2846 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2852 echo "You may need to add #include directives for the following .h files."
2853 # Intersect $specified_modules and $modules
2854 # (since $specified_modules is not necessarily of subset of $modules - some
2855 # may have been skipped through --avoid, and since the elements of $modules
2856 # but not in $specified_modules can go away without explicit notice - through
2857 # changes in the module dependencies).
2858 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2859 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2860 # First the #include <...> directives without #ifs, sorted for convenience,
2861 # then the #include "..." directives without #ifs, sorted for convenience,
2862 # then the #include directives that are surrounded by #ifs. Not sorted.
2863 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2864 include_directive=`func_get_include_directive "$module"`
2865 case "$nl$include_directive" in
2867 echo "$include_directive" 1>&5
2870 echo "$include_directive" | grep -v 'include "' 1>&6
2871 echo "$include_directive" | grep 'include "' 1>&7
2874 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2876 LC_ALL=C sort -u "$tmp"/include-angles
2877 LC_ALL=C sort -u "$tmp"/include-quotes
2878 cat "$tmp"/include-if
2879 ) | sed -e '/^$/d' -e 's/^/ /'
2880 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2882 for module in $modules; do
2883 func_get_link_directive "$module"
2885 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
2886 if test `wc -l < "$tmp"/link` != 0; then
2888 echo "You may need to use the following Makefile variables when linking."
2889 echo "Use them in <program>_LDADD when linking a program, or"
2890 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
2896 echo "Don't forget to"
2897 if test "$makefile_am" = Makefile.am; then
2898 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2900 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2902 if test -n "$pobase"; then
2903 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
2905 if test -n "$inctests"; then
2906 if test "$makefile_am" = Makefile.am; then
2907 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2909 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2912 if test "$makefile_am" = Makefile.am; then
2913 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2914 sourcebase_base=`basename "$sourcebase"`
2915 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2917 if test -n "$pobase"; then
2918 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
2919 pobase_base=`basename "$pobase"`
2920 echo " - mention \"${pobase_base}\" in SUBDIRS in ${pobase_dir}Makefile.am,"
2922 if test -n "$inctests"; then
2923 if test "$makefile_am" = Makefile.am; then
2924 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2925 testsbase_base=`basename "$testsbase"`
2926 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2929 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2930 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2931 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2934 # func_create_testdir testdir modules
2936 # - local_gnulib_dir from --local-dir
2937 # - auxdir directory relative to destdir where to place build aux files
2938 func_create_testdir ()
2942 if test -z "$modules"; then
2943 # All modules together.
2944 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2945 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2946 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2947 modules=`func_all_modules`
2948 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2950 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2952 # Check that the license of every module is consistent with the license of
2954 saved_modules="$modules"
2955 saved_inctests="$inctests"
2956 # When computing transitive closures, don't consider $module to depend on
2957 # $module-tests. Need this becauses tests are implicitly GPL and may depend
2958 # on GPL modules - therefore we don't want a warning in this case.
2960 for requested_module in $saved_modules; do
2961 requested_license=`func_get_license "$requested_module"`
2962 if test "$requested_license" != GPL; then
2963 # Here we use func_modules_transitive_closure, not just
2964 # func_get_dependencies, so that we also detect weird situations like
2965 # an LGPL module which depends on a GPLed build tool module which depends
2967 modules="$requested_module"
2968 func_modules_transitive_closure
2969 for module in $modules; do
2970 license=`func_get_license "$module"`
2972 'GPLed build tool') ;;
2973 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2975 case "$requested_license" in
2978 GPLv2+ | LGPLv2+) ;;
2979 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2985 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2991 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3000 modules="$saved_modules"
3001 inctests="$saved_inctests"
3003 # Subdirectory names.
3012 # Determine final module list.
3013 func_modules_transitive_closure
3014 echo "Module list with included dependencies:"
3015 echo "$modules" | sed -e 's/^/ /'
3017 # Add the dummy module if needed.
3018 func_modules_add_dummy
3020 # Determine final file list.
3021 func_modules_to_filelist
3023 echo "$files" | sed -e 's/^/ /'
3025 sed_rewrite_files="\
3026 s,^build-aux/,$auxdir/,
3028 s,^lib/,$sourcebase/,
3030 s,^tests/,$testsbase/,"
3032 # Create directories.
3033 for f in $files; do echo $f; done \
3034 | sed -e "$sed_rewrite_files" \
3035 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3036 | LC_ALL=C sort -u \
3038 { # Rearrange file descriptors. Needed because "while ... done < ..."
3039 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3040 exec 5<&0 < "$tmp"/dirs
3042 mkdir -p "$testdir/$d"
3047 # Copy files or make symbolic links.
3049 for f in $files; do echo $f; done \
3050 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3053 { # Rearrange file descriptors. Needed because "while ... done < ..."
3054 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3055 exec 5<&0 < "$tmp"/files
3057 func_lookup_file "$f"
3058 if test -n "$lookedup_tmp"; then
3059 cp -p "$lookedup_file" "$testdir/$g"
3061 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3062 if { test -n "$symbolic" \
3063 || { test -n "$lsymbolic" \
3064 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3065 func_ln "$lookedup_file" "$testdir/$g"
3067 cp -p "$lookedup_file" "$testdir/$g"
3074 # Create Makefile.ams that are for testing.
3077 # Create $sourcebase/Makefile.am.
3078 mkdir -p "$testdir/$sourcebase"
3079 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3081 # Create $m4base/Makefile.am.
3082 mkdir -p "$testdir/$m4base"
3083 (echo "## Process this file with automake to produce Makefile.in."
3089 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3092 ) > "$testdir/$m4base/Makefile.am"
3094 subdirs="$sourcebase $m4base"
3095 subdirs_with_configure_ac=""
3097 if false && test -f "$testdir"/$m4base/gettext.m4; then
3098 # Avoid stupid error message from automake:
3099 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3100 mkdir -p "$testdir/po"
3101 (echo "## Process this file with automake to produce Makefile.in."
3102 ) > "$testdir/po/Makefile.am"
3103 func_append subdirs " po"
3106 if test -n "$inctests"; then
3107 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3108 # Create $testsbase/Makefile.am.
3109 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3110 # Create $testsbase/configure.ac.
3111 (echo "# Process this file with autoconf to produce a configure script."
3112 echo "AC_INIT([dummy], [0])"
3113 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
3114 echo "AM_INIT_AUTOMAKE"
3116 echo "AM_CONFIG_HEADER([config.h])"
3119 echo "AC_PROG_INSTALL"
3120 echo "AC_PROG_MAKE_SET"
3121 echo "AC_PROG_RANLIB"
3123 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3124 echo "AC_GNU_SOURCE"
3127 for module in $modules; do
3129 if test -n "$module"; then
3130 func_get_autoconf_early_snippet "$module"
3133 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3134 if test "$libtool" = true; then
3135 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3136 echo "gl_cond_libtool=true"
3138 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3139 echo "gl_cond_libtool=false"
3141 echo "gl_ltlibdeps="
3143 # Wrap the set of autoconf snippets into an autoconf macro that is then
3144 # invoked. This is needed because autoconf does not support AC_REQUIRE
3146 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3147 # but we want the AC_REQUIRE to have its normal meaning (provide one
3148 # expansion of the required macro before the current point, and only one
3150 echo "AC_DEFUN([gl_INIT], ["
3151 func_emit_initmacro_start
3152 sed_replace_build_aux='
3154 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3155 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
3158 # We don't have explicit ordering constraints between the various
3159 # autoconf snippets. It's cleanest to put those of the library before
3160 # those of the tests.
3161 echo "gl_source_base='../$sourcebase'"
3162 for module in $modules; do
3163 func_verify_nontests_module
3164 if test -n "$module"; then
3165 func_get_autoconf_snippet "$module" \
3166 | sed -e "$sed_replace_build_aux"
3169 echo "gl_source_base='.'"
3170 for module in $modules; do
3171 func_verify_tests_module
3172 if test -n "$module"; then
3173 func_get_autoconf_snippet "$module" \
3174 | sed -e "$sed_replace_build_aux"
3177 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3178 # created using libtool, because libtool already handles the dependencies.
3179 if test "$libtool" != true; then
3180 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3181 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3182 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3183 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3184 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3186 func_emit_initmacro_end
3188 func_emit_initmacro_done
3192 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3193 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3194 echo "AH_TOP([#include \"../config.h\"])"
3196 echo "AC_OUTPUT([Makefile])"
3197 ) > "$testdir/$testsbase/configure.ac"
3198 func_append subdirs " $testsbase"
3199 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3202 # Create Makefile.am.
3203 (echo "## Process this file with automake to produce Makefile.in."
3205 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3207 echo "SUBDIRS = $subdirs"
3209 echo "ACLOCAL_AMFLAGS = -I $m4base"
3210 ) > "$testdir/Makefile.am"
3212 # Create configure.ac.
3213 (echo "# Process this file with autoconf to produce a configure script."
3214 echo "AC_INIT([dummy], [0])"
3215 if test "$auxdir" != "."; then
3216 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3218 echo "AM_INIT_AUTOMAKE"
3220 echo "AM_CONFIG_HEADER([config.h])"
3223 echo "AC_PROG_INSTALL"
3224 echo "AC_PROG_MAKE_SET"
3226 echo "# For autobuild."
3227 echo "AC_CANONICAL_BUILD"
3228 echo "AC_CANONICAL_HOST"
3230 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3231 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3232 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3233 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3235 echo "AC_PROG_RANLIB"
3237 if test -n "$uses_subdirs"; then
3238 echo "AM_PROG_CC_C_O"
3241 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3242 echo "AC_GNU_SOURCE"
3245 for module in $modules; do
3246 func_verify_nontests_module
3247 if test -n "$module"; then
3248 func_get_autoconf_early_snippet "$module"
3251 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3252 if test "$libtool" = true; then
3253 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3254 echo "gl_cond_libtool=true"
3256 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3257 echo "gl_cond_libtool=false"
3259 echo "gl_ltlibdeps="
3261 echo "gl_source_base='$sourcebase'"
3262 # Wrap the set of autoconf snippets into an autoconf macro that is then
3263 # invoked. This is needed because autoconf does not support AC_REQUIRE
3265 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3266 # but we want the AC_REQUIRE to have its normal meaning (provide one
3267 # expansion of the required macro before the current point, and only one
3269 echo "AC_DEFUN([gl_INIT], ["
3270 func_emit_initmacro_start
3271 if test "$auxdir" != "build-aux"; then
3272 sed_replace_build_aux='
3274 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3275 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3279 sed_replace_build_aux=
3281 for module in $modules; do
3282 func_verify_nontests_module
3283 if test -n "$module"; then
3284 func_get_autoconf_snippet "$module" \
3285 | sed -e "$sed_replace_build_aux"
3288 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3289 # created using libtool, because libtool already handles the dependencies.
3290 if test "$libtool" != true; then
3291 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3292 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3293 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3294 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3295 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3297 func_emit_initmacro_end
3299 func_emit_initmacro_done
3303 if test -n "$subdirs_with_configure_ac"; then
3304 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3306 makefiles="Makefile"
3307 for d in $subdirs; do
3308 # For subdirs that have a configure.ac by their own, it's the subdir's
3309 # configure.ac which creates the subdir's Makefile.am, not this one.
3310 case " $subdirs_with_configure_ac " in
3312 *) func_append makefiles " $d/Makefile" ;;
3315 echo "AC_OUTPUT([$makefiles])"
3316 ) > "$testdir/configure.ac"
3318 # Create autogenerated files.
3320 # Do not use "${AUTORECONF} --force --install", because it may invoke
3321 # autopoint, which brings in older versions of some of our .m4 files.
3322 if test -f $m4base/gettext.m4; then
3323 echo "executing ${AUTOPOINT} --force"
3324 ${AUTOPOINT} --force || func_exit 1
3325 for f in $m4base/*.m4~; do
3326 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3329 echo "executing ${ACLOCAL} -I $m4base"
3330 ${ACLOCAL} -I $m4base || func_exit 1
3331 if ! test -d build-aux; then
3332 echo "executing mkdir build-aux"
3333 mkdir build-aux || func_exit 1
3335 echo "executing ${AUTOCONF}"
3336 ${AUTOCONF} || func_exit 1
3337 echo "executing ${AUTOHEADER}"
3338 ${AUTOHEADER} || func_exit 1
3339 echo "executing ${AUTOMAKE} --add-missing --copy"
3340 ${AUTOMAKE} --add-missing --copy || func_exit 1
3342 if test -n "$inctests"; then
3343 # Create autogenerated files.
3344 (cd "$testdir/$testsbase" || func_exit 1
3345 # Do not use "${AUTORECONF} --force --install", because it may invoke
3346 # autopoint, which brings in older versions of some of our .m4 files.
3347 if test -f ../$m4base/gettext.m4; then
3348 echo "executing ${AUTOPOINT} --force"
3349 ${AUTOPOINT} --force || func_exit 1
3350 for f in ../$m4base/*.m4~; do
3351 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3354 echo "executing ${ACLOCAL} -I ../$m4base"
3355 ${ACLOCAL} -I ../$m4base || func_exit 1
3356 if ! test -d ../build-aux; then
3357 echo "executing mkdir ../build-aux"
3360 echo "executing ${AUTOCONF}"
3361 ${AUTOCONF} || func_exit 1
3362 echo "executing ${AUTOHEADER}"
3363 ${AUTOHEADER} || func_exit 1
3364 echo "executing ${AUTOMAKE} --add-missing --copy"
3365 ${AUTOMAKE} --add-missing --copy || func_exit 1
3368 # Need to run configure and make once, to create built files that are to be
3369 # distributed (such as getdate.c).
3370 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3371 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3372 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3373 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3374 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3375 # such $(FOO_H) because they don't refer to distributed files.
3376 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3377 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3378 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3379 | sed -e "$sed_remove_make_variables"`
3380 distributed_built_sources=`for file in $built_sources; do
3381 case "$cleaned_files" in
3386 if test -n "$distributed_built_sources"; then
3388 ./configure || func_exit 1
3390 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3391 make built_sources || func_exit 1
3393 make distclean || func_exit 1
3398 # func_create_megatestdir megatestdir allmodules
3400 # - local_gnulib_dir from --local-dir
3401 # - auxdir directory relative to destdir where to place build aux files
3402 func_create_megatestdir ()
3406 if test -z "$allmodules"; then
3407 allmodules=`func_all_modules`
3411 # First, all modules one by one.
3412 for onemodule in $allmodules; do
3413 func_create_testdir "$megatestdir/$onemodule" $onemodule
3414 func_append megasubdirs "$onemodule "
3416 # Then, all modules all together.
3417 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3418 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3419 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3420 func_create_testdir "$megatestdir/ALL" "$allmodules"
3421 func_append megasubdirs "ALL"
3424 cvsdate=`sh "$gnulib_dir/build-aux/mdate-sh" "$gnulib_dir/CVS/Entries" \
3425 | sed -e 's,January,01,' -e 's,Jan,01,' \
3426 -e 's,February,02,' -e 's,Feb,02,' \
3427 -e 's,March,03,' -e 's,Mar,03,' \
3428 -e 's,April,04,' -e 's,Apr,04,' \
3430 -e 's,June,06,' -e 's,Jun,06,' \
3431 -e 's,July,07,' -e 's,Jul,07,' \
3432 -e 's,August,08,' -e 's,Aug,08,' \
3433 -e 's,September,09,' -e 's,Sep,09,' \
3434 -e 's,October,10,' -e 's,Oct,10,' \
3435 -e 's,November,11,' -e 's,Nov,11,' \
3436 -e 's,December,12,' -e 's,Dec,12,' \
3437 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3438 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3440 echo "CVSDATE=$cvsdate"
3441 echo "test -d logs || mkdir logs"
3442 echo "for module in $megasubdirs; do"
3443 echo " echo \"Working on module \$module...\""
3444 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3445 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3448 echo " : autobuild project... \$module"
3449 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3450 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3451 echo " : autobuild hostname... \`hostname\`"
3452 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3454 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3456 ) > "$megatestdir/do-autobuild"
3457 chmod a+x "$megatestdir/do-autobuild"
3459 # Create Makefile.am.
3460 (echo "## Process this file with automake to produce Makefile.in."
3462 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3464 echo "SUBDIRS = $megasubdirs"
3466 echo "EXTRA_DIST = do-autobuild"
3467 ) > "$megatestdir/Makefile.am"
3469 # Create configure.ac.
3470 (echo "# Process this file with autoconf to produce a configure script."
3471 echo "AC_INIT([dummy], [0])"
3472 if test "$auxdir" != "."; then
3473 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3475 echo "AM_INIT_AUTOMAKE"
3477 echo "AC_PROG_MAKE_SET"
3479 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3480 echo "AC_OUTPUT([Makefile])"
3481 ) > "$megatestdir/configure.ac"
3483 # Create autogenerated files.
3485 # Do not use "${AUTORECONF} --install", because autoreconf operates
3486 # recursively, but the subdirectories are already finished, therefore
3487 # calling autoreconf here would only waste lots of CPU time.
3488 echo "executing ${ACLOCAL}"
3489 ${ACLOCAL} || func_exit 1
3490 echo "executing mkdir build-aux"
3492 echo "executing ${AUTOCONF}"
3493 ${AUTOCONF} || func_exit 1
3494 echo "executing ${AUTOMAKE} --add-missing --copy"
3495 ${AUTOMAKE} --add-missing --copy || func_exit 1
3501 func_fatal_error "no mode specified" ;;
3510 if test -z "$destdir"; then
3513 test -d "$destdir" \
3514 || func_fatal_error "destination directory does not exist: $destdir"
3516 # Prefer configure.ac to configure.in.
3517 if test -f "$destdir"/configure.ac; then
3518 configure_ac="$destdir/configure.ac"
3520 if test -f "$destdir"/configure.in; then
3521 configure_ac="$destdir/configure.in"
3523 func_fatal_error "cannot find $destdir/configure.ac"
3527 # Analyze configure.ac.
3529 guessed_libtool=false
3534 /AC_CONFIG_AUX_DIR/ {
3535 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3537 /A[CM]_PROG_LIBTOOL/ {
3538 s,^.*$,guessed_libtool=true,p
3540 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3542 if test -z "$auxdir"; then
3543 auxdir="$guessed_auxdir"
3546 # Determine where to apply func_import.
3547 if test -n "$m4base"; then
3548 # Apply func_import to a particular gnulib directory.
3549 # Any number of additional modules can be given.
3550 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3551 # First use of gnulib in the given m4base.
3552 test -n "$supplied_libname" || supplied_libname=true
3553 test -n "$sourcebase" || sourcebase="lib"
3554 test -n "$docbase" || docbase="doc"
3555 test -n "$testsbase" || testsbase="tests"
3556 test -n "$macro_prefix" || macro_prefix="gl"
3560 # Apply func_import to all gnulib directories.
3561 # To get this list of directories, look at Makefile.am. (Not at
3562 # configure, because it may be omitted from CVS. Also, don't run
3563 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3566 if test -f "$destdir"/Makefile.am; then
3567 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3569 for arg in $aclocal_amflags; do
3570 if test -n "$m4dir_is_next"; then
3571 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3575 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3576 func_append m4dirs " $arg"
3577 m4dirs_count=`expr $m4dirs_count + 1`
3583 if test "X$arg" = "X-I"; then
3591 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3592 if test -f "$destdir"/aclocal.m4; then
3593 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3594 sedexpr2='s,^[^/]*$,.,'
3595 sedexpr3='s,/[^/]*$,,'
3596 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3597 m4dirs_count=`echo "$m4dirs" | wc -l`
3600 if test $m4dirs_count = 0; then
3601 # First use of gnulib in a package.
3602 # Any number of additional modules can be given.
3603 test -n "$supplied_libname" || supplied_libname=true
3604 test -n "$sourcebase" || sourcebase="lib"
3606 test -n "$docbase" || docbase="doc"
3607 test -n "$testsbase" || testsbase="tests"
3608 test -n "$macro_prefix" || macro_prefix="gl"
3611 if test $m4dirs_count = 1; then
3612 # There's only one use of gnulib here. Assume the user means it.
3613 # Any number of additional modules can be given.
3614 for m4base in $m4dirs; do
3618 # Ambiguous - guess what the user meant.
3619 if test $# = 0; then
3620 # No further arguments. Guess the user wants to update all of them.
3621 for m4base in $m4dirs; do
3622 # Perform func_import in a subshell, so that variable values
3624 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
3625 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
3626 # libtool, macro_prefix, po_domain
3627 # don't propagate from one directory to another.
3628 (func_import) || func_exit 1
3632 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
3640 if test -z "$destdir"; then
3641 func_fatal_error "please specify --dir option"
3644 test -d "$destdir" \
3645 || func_fatal_error "could not create destination directory"
3646 test -n "$auxdir" || auxdir="build-aux"
3647 func_create_testdir "$destdir" "$*"
3650 create-megatestdir )
3651 if test -z "$destdir"; then
3652 func_fatal_error "please specify --dir option"
3654 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3655 test -n "$auxdir" || auxdir="build-aux"
3656 func_create_megatestdir "$destdir" "$*"
3660 test -n "$destdir" || destdir=testdir$$
3661 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3662 test -n "$auxdir" || auxdir="build-aux"
3663 func_create_testdir "$destdir" "$*"
3667 ../configure || func_exit 1
3669 make check || func_exit 1
3670 make distclean || func_exit 1
3671 remaining=`find . -type f -print`
3672 if test -n "$remaining"; then
3673 echo "Remaining files:" $remaining 1>&2
3674 echo "gnulib-tool: *** Stop." 1>&2
3683 test -n "$destdir" || destdir=testdir$$
3684 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3685 test -n "$auxdir" || auxdir="build-aux"
3686 func_create_megatestdir "$destdir" "$*"
3694 remaining=`find . -type f -print`
3695 if test -n "$remaining"; then
3696 echo "Remaining files:" $remaining 1>&2
3697 echo "gnulib-tool: *** Stop." 1>&2
3705 extract-description )
3709 if test -n "$module"; then
3710 func_get_description "$module"
3719 if test -n "$module"; then
3720 func_get_filelist "$module"
3725 extract-dependencies )
3729 if test -n "$module"; then
3730 func_get_dependencies "$module"
3735 extract-autoconf-snippet )
3739 if test -n "$module"; then
3740 func_get_autoconf_snippet "$module"
3745 extract-automake-snippet )
3749 if test -n "$module"; then
3750 func_get_automake_snippet "$module"
3755 extract-include-directive )
3759 if test -n "$module"; then
3760 func_get_include_directive "$module"
3765 extract-link-directive )
3769 if test -n "$module"; then
3770 func_get_link_directive "$module"
3779 if test -n "$module"; then
3780 func_get_license "$module"
3785 extract-maintainer )
3789 if test -n "$module"; then
3790 func_get_maintainer "$module"
3795 extract-tests-module )
3799 if test -n "$module"; then
3800 func_get_tests_module "$module"
3806 func_fatal_error "unknown operation mode --$mode" ;;
3810 # Undo the effect of the previous 'trap' command. Some shellology:
3811 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3812 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3813 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3814 # 128 + signal number and is set before the trap-registered command is run.
3816 trap 'func_exit $?' 1 2 3 13 15
3821 # indent-tabs-mode: nil
3822 # whitespace-check-buffer-indent: nil