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-18 23:50:58 $'
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"
2034 if test -z "$pobase"; then
2035 func_fatal_error "missing --po-base option"
2038 # The docbase defaults to the cached one.
2039 if test -z "$docbase"; then
2040 docbase="$cached_docbase"
2041 if test -z "$docbase"; then
2042 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."
2045 # The testsbase defaults to the cached one.
2046 if test -z "$testsbase"; then
2047 testsbase="$cached_testsbase"
2048 if test -z "$testsbase"; then
2049 func_fatal_error "missing --tests-base option"
2052 # Require the tests if specified either way.
2053 if test -z "$inctests"; then
2054 inctests="$cached_inctests"
2056 # The libname defaults to the cached one.
2057 if test -z "$supplied_libname"; then
2058 libname="$cached_libname"
2059 if test -z "$libname"; then
2060 func_fatal_error "missing --lib option"
2063 # Require LGPL if specified either way.
2064 if test -z "$lgpl"; then
2067 # The makefile_name defaults to the cached one.
2068 if test -z "$makefile_name"; then
2069 makefile_name="$cached_makefile_name"
2071 # Use libtool if specified either way, or if guessed.
2072 if test -z "$libtool"; then
2073 if test -n "$cached_m4base"; then
2074 libtool="$cached_libtool"
2076 libtool="$guessed_libtool"
2079 # The macro_prefix defaults to the cached one.
2080 if test -z "$macro_prefix"; then
2081 macro_prefix="$cached_macro_prefix"
2082 if test -z "$macro_prefix"; then
2083 func_fatal_error "missing --macro-prefix option"
2086 # The po_domain defaults to the cached one.
2087 if test -z "$po_domain"; then
2088 po_domain="$cached_po_domain"
2089 if test -z "$po_domain"; then
2090 func_fatal_error "missing --po-domain option"
2094 # Canonicalize the list of specified modules.
2095 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2097 # Determine final module list.
2098 modules="$specified_modules"
2099 func_modules_transitive_closure
2100 echo "Module list with included dependencies:"
2101 echo "$modules" | sed -e 's/^/ /'
2103 # Add the dummy module if needed.
2104 func_modules_add_dummy
2106 # If --lgpl, verify that the licenses of modules are compatible.
2107 if test -n "$lgpl"; then
2108 for module in $modules; do
2109 license=`func_get_license $module`
2111 LGPL | LGPLv2+ | 'GPLed build tool') ;;
2112 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2113 *) func_fatal_error "incompatible license on module $module: $license" ;;
2118 # Determine script to apply to imported library files.
2119 sed_transform_lib_file=
2120 for module in $modules; do
2121 if test $module = config-h; then
2122 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2123 sed_transform_lib_file=$sed_transform_lib_file'
2124 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2129 if test -n "$do_copyrights"; then
2130 if test -n "$lgpl"; then
2132 sed_transform_lib_file=$sed_transform_lib_file'
2133 s/GNU General/GNU Lesser General/g
2134 s/version 2\([ ,]\)/version 2.1\1/g
2139 # Determine final file list.
2140 func_modules_to_filelist
2142 echo "$files" | sed -e 's/^/ /'
2145 || func_fatal_error "refusing to do nothing"
2147 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2148 new_files="$files m4/gnulib-tool.m4"
2149 old_files="$cached_files"
2150 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2151 func_append old_files " m4/gnulib-tool.m4"
2154 sed_rewrite_old_files="\
2155 s,^build-aux/,$auxdir/,
2156 s,^doc/,$cached_docbase/,
2157 s,^lib/,$cached_sourcebase/,
2158 s,^m4/,$cached_m4base/,
2159 s,^tests/,$cached_testsbase/,"
2160 sed_rewrite_new_files="\
2161 s,^build-aux/,$auxdir/,
2163 s,^lib/,$sourcebase/,
2165 s,^tests/,$testsbase/,"
2167 # Create directories.
2168 { echo "$sourcebase"
2170 if test -n "$pobase"; then
2173 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2174 if test -n "$docfiles"; then
2177 if test -n "$inctests"; then
2181 for f in $files; do echo $f; done \
2182 | sed -e "$sed_rewrite_new_files" \
2183 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2186 { # Rearrange file descriptors. Needed because "while ... done < ..."
2187 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2188 exec 5<&0 < "$tmp"/dirs
2190 if test ! -d "$destdir/$d"; then
2192 echo "Creating directory $destdir/$d"
2193 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2195 echo "Create directory $destdir/$d"
2202 # func_dest_tmpfilename file
2203 # determines the name of a temporary file (file is relative to destdir).
2205 # - tmpfile absolute filename of the temporary file
2206 func_dest_tmpfilename ()
2209 # Put the new contents of $file in a file in the same directory (needed
2210 # to guarantee that an 'mv' to "$destdir/$file" works).
2211 tmpfile="$destdir/$1.tmp"
2213 # Put the new contents of $file in a file in a temporary directory
2214 # (because the directory of "$file" might not exist).
2215 tmpfile="$tmp"/`basename "$1"`.tmp
2219 # Copy files or make symbolic links. Remove obsolete files.
2223 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2224 # representing the files according to the last gnulib-tool invocation.
2225 for f in $old_files; do echo $f; done \
2226 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2229 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2230 # representing the files after this gnulib-tool invocation.
2231 for f in $new_files; do echo $f; done \
2232 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2235 # First the files that are in old-files, but not in new-files:
2236 sed_take_first_column='s,'"$delimiter"'.*,,'
2237 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2238 # Remove the file. Do nothing if the user already removed it.
2239 if test -f "$destdir/$g"; then
2241 echo "Removing file $g (backup in ${g}~)"
2242 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2244 echo "Remove file $g (backup in ${g}~)"
2246 func_append removed_files "$g$nl"
2249 # func_add_or_update handles a file that ought to be present afterwards.
2251 # - f the original file name
2252 # - g the rewritten file name
2253 # - already_present nonempty if the file already exists, empty otherwise
2254 func_add_or_update ()
2256 func_dest_tmpfilename "$g"
2257 func_lookup_file "$f"
2258 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2259 if test -n "$sed_transform_lib_file"; then
2262 sed -e "$sed_transform_lib_file" \
2263 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2267 if test -f "$destdir/$g"; then
2268 # The file already exists.
2269 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2270 : # The file has not changed.
2274 if test -n "$already_present"; then
2275 echo "Updating file $g (backup in ${g}~)"
2277 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2279 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2280 if { test -n "$symbolic" \
2281 || { test -n "$lsymbolic" \
2282 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2283 && test -z "$lookedup_tmp" \
2284 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2285 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2287 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2290 if test -n "$already_present"; then
2291 echo "Update file $g (backup in ${g}~)"
2293 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2299 # Don't protest if the file should be there but isn't: it happens
2300 # frequently that developers don't put autogenerated files into CVS.
2302 echo "Copying file $g"
2303 if { test -n "$symbolic" \
2304 || { test -n "$lsymbolic" \
2305 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2306 && test -z "$lookedup_tmp" \
2307 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2308 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2310 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2315 func_append added_files "$g$nl"
2319 # Then the files that are in new-files, but not in old-files:
2320 sed_take_last_column='s,^.*'"$delimiter"',,'
2322 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2323 | sed -e "$sed_take_last_column" \
2324 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2325 { # Rearrange file descriptors. Needed because "while ... done < ..."
2326 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2327 exec 5<&0 < "$tmp"/added-files
2333 # Then the files that are in new-files and in old-files:
2334 already_present=true
2335 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2336 | sed -e "$sed_take_last_column" \
2337 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2338 { # Rearrange file descriptors. Needed because "while ... done < ..."
2339 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2340 exec 5<&0 < "$tmp"/kept-files
2347 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2348 actioncmd="gnulib-tool --import"
2349 func_append actioncmd " --dir=$destdir"
2350 if test -n "$local_gnulib_dir"; then
2351 func_append actioncmd " --local-dir=$local_gnulib_dir"
2353 func_append actioncmd " --lib=$libname"
2354 func_append actioncmd " --source-base=$sourcebase"
2355 func_append actioncmd " --m4-base=$m4base"
2356 if test -n "$pobase"; then
2357 func_append actioncmd " --po-base=$pobase"
2359 func_append actioncmd " --doc-base=$docbase"
2360 func_append actioncmd " --aux-dir=$auxdir"
2361 if test -n "$inctests"; then
2362 func_append actioncmd " --with-tests"
2364 for module in $avoidlist; do
2365 func_append actioncmd " --avoid=$module"
2367 if test -n "$lgpl"; then
2368 func_append actioncmd " --lgpl"
2370 if test -n "$makefile_name"; then
2371 func_append actioncmd " --makefile-name=$makefile_name"
2373 if test "$libtool" = true; then
2374 func_append actioncmd " --libtool"
2376 func_append actioncmd " --no-libtool"
2378 func_append actioncmd " --macro-prefix=$macro_prefix"
2379 if test -n "$po_domain"; then
2380 func_append actioncmd " --po-domain=$po_domain"
2382 func_append actioncmd " `echo $specified_modules`"
2384 # Default the makefile name to Makefile.am.
2385 if test -n "$makefile_name"; then
2386 makefile_am=$makefile_name
2388 makefile_am=Makefile.am
2391 # Create normal Makefile.ams.
2394 # Create library makefile.
2395 func_dest_tmpfilename $sourcebase/$makefile_am
2396 func_emit_lib_Makefile_am > "$tmpfile"
2397 if test -f "$destdir"/$sourcebase/$makefile_am; then
2398 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2402 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2403 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2404 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2406 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2412 echo "Creating $sourcebase/$makefile_am"
2413 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2415 echo "Create $sourcebase/$makefile_am"
2418 func_append added_files "$sourcebase/$makefile_am$nl"
2421 # Create po/ directory.
2422 if test -n "$pobase"; then
2423 # Create po makefile and auxiliary files.
2424 for file in Makefile.in.in remove-potcdate.sin; do
2425 func_dest_tmpfilename $pobase/$file
2426 func_lookup_file build-aux/po/$file
2427 cat "$lookedup_file" > "$tmpfile"
2428 if test -f "$destdir"/$pobase/$file; then
2429 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
2433 echo "Updating $pobase/$file (backup in $pobase/$file~)"
2434 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
2435 mv -f "$tmpfile" "$destdir"/$pobase/$file
2437 echo "Update $pobase/$file (backup in $pobase/$file~)"
2443 echo "Creating $pobase/$file"
2444 mv -f "$tmpfile" "$destdir"/$pobase/$file
2446 echo "Create $pobase/$file"
2449 func_append added_files "$pobase/$file$nl"
2452 # Create po makefile parametrization, part 1.
2453 func_dest_tmpfilename $pobase/Makevars
2454 func_emit_po_Makevars > "$tmpfile"
2455 if test -f "$destdir"/$pobase/Makevars; then
2456 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
2460 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
2461 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
2462 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2464 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
2470 echo "Creating $pobase/Makevars"
2471 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2473 echo "Create $pobase/Makevars"
2476 func_append added_files "$pobase/Makevars$nl"
2478 # Create po makefile parametrization, part 2.
2479 func_dest_tmpfilename $pobase/POTFILES.in
2480 func_emit_po_POTFILES_in > "$tmpfile"
2481 if test -f "$destdir"/$pobase/POTFILES.in; then
2482 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
2486 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2487 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
2488 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2490 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2496 echo "Creating $pobase/POTFILES.in"
2497 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2499 echo "Create $pobase/POTFILES.in"
2502 func_append added_files "$pobase/POTFILES.in$nl"
2505 TP_URL="http://translationproject.org/latest/"
2507 echo "Fetching gnulib PO files from $TP_URL"
2508 (cd "$destdir"/$pobase \
2509 && wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
2512 echo "Fetch gnulib PO files from $TP_URL"
2514 # Create po/LINGUAS.
2516 func_dest_tmpfilename $pobase/LINGUAS
2517 (cd "$destdir"/$pobase \
2518 && { echo '# Set of available languages.'
2519 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
2522 if test -f "$destdir"/$pobase/LINGUAS; then
2523 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
2526 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2527 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
2528 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2531 echo "Creating $pobase/LINGUAS"
2532 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2533 func_append added_files "$pobase/LINGUAS$nl"
2536 if test -f "$destdir"/$pobase/LINGUAS; then
2537 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2539 echo "Create $pobase/LINGUAS"
2544 # Create m4/gnulib-cache.m4.
2545 func_dest_tmpfilename $m4base/gnulib-cache.m4
2547 func_emit_copyright_notice
2549 echo "# This file represents the specification of how gnulib-tool is used."
2550 echo "# It acts as a cache: It is written and read by gnulib-tool."
2551 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2552 echo "# like the configure.ac and various Makefile.am files."
2555 echo "# Specification in the form of a command-line invocation:"
2558 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2559 # Store the local_gnulib_dir relative to destdir.
2560 case "$local_gnulib_dir" in
2562 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2565 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2567 # destdir, local_gnulib_dir are both relative.
2568 func_relativize "$destdir" "$local_gnulib_dir"
2569 relative_local_gnulib_dir="$reldir" ;;
2572 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2573 echo "gl_MODULES(["`echo $specified_modules`"])"
2574 echo "gl_AVOID([$avoidlist])"
2575 echo "gl_SOURCE_BASE([$sourcebase])"
2576 echo "gl_M4_BASE([$m4base])"
2577 echo "gl_PO_BASE([$pobase])"
2578 echo "gl_DOC_BASE([$docbase])"
2579 echo "gl_TESTS_BASE([$testsbase])"
2580 test -z "$inctests" || echo "gl_WITH_TESTS"
2581 echo "gl_LIB([$libname])"
2582 test -z "$lgpl" || echo "gl_LGPL"
2583 echo "gl_MAKEFILE_NAME([$makefile_name])"
2584 if test "$libtool" = true; then
2587 echo "gl_MACRO_PREFIX([$macro_prefix])"
2588 echo "gl_PO_DOMAIN([$po_domain])"
2590 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2591 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2595 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2596 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2597 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2599 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2603 echo "# gnulib-cache.m4 ends here"
2610 echo "Creating $m4base/gnulib-cache.m4"
2611 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2613 echo "Create $m4base/gnulib-cache.m4"
2619 # Create m4/gnulib-comp.m4.
2620 func_dest_tmpfilename $m4base/gnulib-comp.m4
2622 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2623 func_emit_copyright_notice
2625 echo "# This file represents the compiled summary of the specification in"
2626 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2627 echo "# to be invoked from configure.ac."
2628 echo "# In projects using CVS, this file can be treated like other built files."
2631 echo "# This macro should be invoked from $configure_ac, in the section"
2632 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2633 echo "# any checks for libraries, header files, types and library functions."
2634 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2636 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2637 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2638 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2639 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2640 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2641 if test -n "$uses_subdirs"; then
2642 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2644 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2645 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2647 for module in $modules; do
2649 if test -n "$module"; then
2650 func_get_autoconf_early_snippet "$module"
2653 | sed -e '/^$/d;' -e 's/^/ /'
2656 echo "# This macro should be invoked from $configure_ac, in the section"
2657 echo "# \"Check for header files, types and library functions\"."
2658 echo "AC_DEFUN([${macro_prefix}_INIT],"
2660 func_emit_initmacro_start
2661 if test "$libtool" = true; then
2662 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2663 echo " gl_cond_libtool=true"
2665 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2666 echo " gl_cond_libtool=false"
2668 echo " gl_ltlibdeps="
2670 echo " gl_source_base='$sourcebase'"
2671 if test "$auxdir" != "build-aux"; then
2672 sed_replace_build_aux='
2674 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2675 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2679 sed_replace_build_aux=
2681 for module in $modules; do
2683 if test -n "$module"; then
2684 func_get_autoconf_snippet "$module" \
2685 | sed -e '/^$/d;' -e 's/^/ /' \
2686 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2687 -e "$sed_replace_build_aux"
2688 if test "$module" = 'alloca' && test "$libtool" = true; then
2689 echo 'changequote(,)dnl'
2690 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2691 echo 'changequote([, ])dnl'
2692 echo 'AC_SUBST([LTALLOCA])'
2696 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2697 # created using libtool, because libtool already handles the dependencies.
2698 if test "$libtool" != true; then
2699 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
2700 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2701 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2702 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2703 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2705 func_emit_initmacro_end
2707 func_emit_initmacro_done
2709 echo "# This macro records the list of files which have been installed by"
2710 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2711 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2712 echo "$files" | sed -e 's,^, ,'
2715 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2716 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2720 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2721 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2722 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2724 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2728 echo "# gnulib-comp.m4 ends here"
2735 echo "Creating $m4base/gnulib-comp.m4"
2736 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2738 echo "Create $m4base/gnulib-comp.m4"
2744 if test -n "$inctests"; then
2745 # Create tests makefile.
2746 func_dest_tmpfilename $testsbase/$makefile_am
2747 func_emit_tests_Makefile_am > "$tmpfile"
2748 if test -f "$destdir"/$testsbase/$makefile_am; then
2749 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2753 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2754 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2755 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2757 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2763 echo "Creating $testsbase/$makefile_am"
2764 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2766 echo "Create $testsbase/$makefile_am"
2769 func_append added_files "$testsbase/$makefile_am$nl"
2773 # Update the .cvsignore and .gitignore files.
2774 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
2775 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
2776 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
2777 { # Rearrange file descriptors. Needed because "while ... done < ..."
2778 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2779 exec 5<&0 < "$tmp"/fileset-changes
2780 func_update_ignorelist ()
2783 if test -f "$destdir/$dir$ignore"; then
2784 if test -n "$dir_added" || test -n "$dir_removed"; then
2785 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
2786 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
2787 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
2788 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
2789 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
2790 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
2792 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2793 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
2794 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
2795 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
2796 | sed -f "$tmp"/sed-ignore-removed \
2797 > "$destdir/$dir$ignore"
2799 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2804 if test -n "$dir_added"; then
2806 echo "Creating $destdir/$dir$ignore"
2807 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u > "$destdir/$dir$ignore"
2809 echo "Create $destdir/$dir$ignore"
2819 if test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
2820 func_update_ignorelist .cvsignore
2822 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
2823 func_update_ignorelist .gitignore
2830 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
2831 next_dir=`echo "$line" | sed -e 's,|.*,,'`
2832 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
2833 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
2834 if test "$next_dir" != "$last_dir"; then
2835 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2836 last_dir="$next_dir"
2841 A) func_append last_dir_added "$file$nl";;
2842 R) func_append last_dir_removed "$file$nl";;
2845 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2851 echo "You may need to add #include directives for the following .h files."
2852 # Intersect $specified_modules and $modules
2853 # (since $specified_modules is not necessarily of subset of $modules - some
2854 # may have been skipped through --avoid, and since the elements of $modules
2855 # but not in $specified_modules can go away without explicit notice - through
2856 # changes in the module dependencies).
2857 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2858 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2859 # First the #include <...> directives without #ifs, sorted for convenience,
2860 # then the #include "..." directives without #ifs, sorted for convenience,
2861 # then the #include directives that are surrounded by #ifs. Not sorted.
2862 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2863 include_directive=`func_get_include_directive "$module"`
2864 case "$nl$include_directive" in
2866 echo "$include_directive" 1>&5
2869 echo "$include_directive" | grep -v 'include "' 1>&6
2870 echo "$include_directive" | grep 'include "' 1>&7
2873 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2875 LC_ALL=C sort -u "$tmp"/include-angles
2876 LC_ALL=C sort -u "$tmp"/include-quotes
2877 cat "$tmp"/include-if
2878 ) | sed -e '/^$/d' -e 's/^/ /'
2879 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2881 for module in $modules; do
2882 func_get_link_directive "$module"
2884 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
2885 if test `wc -l < "$tmp"/link` != 0; then
2887 echo "You may need to use the following Makefile variables when linking."
2888 echo "Use them in <program>_LDADD when linking a program, or"
2889 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
2895 echo "Don't forget to"
2896 if test "$makefile_am" = Makefile.am; then
2897 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2899 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2901 if test -n "$pobase"; then
2902 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
2904 if test -n "$inctests"; then
2905 if test "$makefile_am" = Makefile.am; then
2906 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2908 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2911 if test "$makefile_am" = Makefile.am; then
2912 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2913 sourcebase_base=`basename "$sourcebase"`
2914 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2916 if test -n "$pobase"; then
2917 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
2918 pobase_base=`basename "$pobase"`
2919 echo " - mention \"${pobase_base}\" in SUBDIRS in ${pobase_dir}Makefile.am,"
2921 if test -n "$inctests"; then
2922 if test "$makefile_am" = Makefile.am; then
2923 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2924 testsbase_base=`basename "$testsbase"`
2925 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2928 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2929 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2930 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2933 # func_create_testdir testdir modules
2935 # - local_gnulib_dir from --local-dir
2936 # - auxdir directory relative to destdir where to place build aux files
2937 func_create_testdir ()
2941 if test -z "$modules"; then
2942 # All modules together.
2943 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2944 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2945 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2946 modules=`func_all_modules`
2947 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2949 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2951 # Check that the license of every module is consistent with the license of
2953 saved_modules="$modules"
2954 saved_inctests="$inctests"
2955 # When computing transitive closures, don't consider $module to depend on
2956 # $module-tests. Need this becauses tests are implicitly GPL and may depend
2957 # on GPL modules - therefore we don't want a warning in this case.
2959 for requested_module in $saved_modules; do
2960 requested_license=`func_get_license "$requested_module"`
2961 if test "$requested_license" != GPL; then
2962 # Here we use func_modules_transitive_closure, not just
2963 # func_get_dependencies, so that we also detect weird situations like
2964 # an LGPL module which depends on a GPLed build tool module which depends
2966 modules="$requested_module"
2967 func_modules_transitive_closure
2968 for module in $modules; do
2969 license=`func_get_license "$module"`
2971 'GPLed build tool') ;;
2972 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2974 case "$requested_license" in
2977 GPLv2+ | LGPLv2+) ;;
2978 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2984 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2990 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2999 modules="$saved_modules"
3000 inctests="$saved_inctests"
3002 # Subdirectory names.
3011 # Determine final module list.
3012 func_modules_transitive_closure
3013 echo "Module list with included dependencies:"
3014 echo "$modules" | sed -e 's/^/ /'
3016 # Add the dummy module if needed.
3017 func_modules_add_dummy
3019 # Determine final file list.
3020 func_modules_to_filelist
3022 echo "$files" | sed -e 's/^/ /'
3024 sed_rewrite_files="\
3025 s,^build-aux/,$auxdir/,
3027 s,^lib/,$sourcebase/,
3029 s,^tests/,$testsbase/,"
3031 # Create directories.
3032 for f in $files; do echo $f; done \
3033 | sed -e "$sed_rewrite_files" \
3034 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3035 | LC_ALL=C sort -u \
3037 { # Rearrange file descriptors. Needed because "while ... done < ..."
3038 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3039 exec 5<&0 < "$tmp"/dirs
3041 mkdir -p "$testdir/$d"
3046 # Copy files or make symbolic links.
3048 for f in $files; do echo $f; done \
3049 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3052 { # Rearrange file descriptors. Needed because "while ... done < ..."
3053 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3054 exec 5<&0 < "$tmp"/files
3056 func_lookup_file "$f"
3057 if test -n "$lookedup_tmp"; then
3058 cp -p "$lookedup_file" "$testdir/$g"
3060 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3061 if { test -n "$symbolic" \
3062 || { test -n "$lsymbolic" \
3063 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3064 func_ln "$lookedup_file" "$testdir/$g"
3066 cp -p "$lookedup_file" "$testdir/$g"
3073 # Create Makefile.ams that are for testing.
3076 # Create $sourcebase/Makefile.am.
3077 mkdir -p "$testdir/$sourcebase"
3078 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3080 # Create $m4base/Makefile.am.
3081 mkdir -p "$testdir/$m4base"
3082 (echo "## Process this file with automake to produce Makefile.in."
3088 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3091 ) > "$testdir/$m4base/Makefile.am"
3093 subdirs="$sourcebase $m4base"
3094 subdirs_with_configure_ac=""
3096 if false && test -f "$testdir"/$m4base/gettext.m4; then
3097 # Avoid stupid error message from automake:
3098 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3099 mkdir -p "$testdir/po"
3100 (echo "## Process this file with automake to produce Makefile.in."
3101 ) > "$testdir/po/Makefile.am"
3102 func_append subdirs " po"
3105 if test -n "$inctests"; then
3106 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3107 # Create $testsbase/Makefile.am.
3108 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3109 # Create $testsbase/configure.ac.
3110 (echo "# Process this file with autoconf to produce a configure script."
3111 echo "AC_INIT([dummy], [0])"
3112 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
3113 echo "AM_INIT_AUTOMAKE"
3115 echo "AM_CONFIG_HEADER([config.h])"
3118 echo "AC_PROG_INSTALL"
3119 echo "AC_PROG_MAKE_SET"
3120 echo "AC_PROG_RANLIB"
3122 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3123 echo "AC_GNU_SOURCE"
3126 for module in $modules; do
3128 if test -n "$module"; then
3129 func_get_autoconf_early_snippet "$module"
3132 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3133 if test "$libtool" = true; then
3134 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3135 echo "gl_cond_libtool=true"
3137 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3138 echo "gl_cond_libtool=false"
3140 echo "gl_ltlibdeps="
3142 # Wrap the set of autoconf snippets into an autoconf macro that is then
3143 # invoked. This is needed because autoconf does not support AC_REQUIRE
3145 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3146 # but we want the AC_REQUIRE to have its normal meaning (provide one
3147 # expansion of the required macro before the current point, and only one
3149 echo "AC_DEFUN([gl_INIT], ["
3150 func_emit_initmacro_start
3151 sed_replace_build_aux='
3153 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3154 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
3157 # We don't have explicit ordering constraints between the various
3158 # autoconf snippets. It's cleanest to put those of the library before
3159 # those of the tests.
3160 echo "gl_source_base='../$sourcebase'"
3161 for module in $modules; do
3162 func_verify_nontests_module
3163 if test -n "$module"; then
3164 func_get_autoconf_snippet "$module" \
3165 | sed -e "$sed_replace_build_aux"
3168 echo "gl_source_base='.'"
3169 for module in $modules; do
3170 func_verify_tests_module
3171 if test -n "$module"; then
3172 func_get_autoconf_snippet "$module" \
3173 | sed -e "$sed_replace_build_aux"
3176 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3177 # created using libtool, because libtool already handles the dependencies.
3178 if test "$libtool" != true; then
3179 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3180 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3181 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3182 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3183 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3185 func_emit_initmacro_end
3187 func_emit_initmacro_done
3191 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3192 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3193 echo "AH_TOP([#include \"../config.h\"])"
3195 echo "AC_OUTPUT([Makefile])"
3196 ) > "$testdir/$testsbase/configure.ac"
3197 func_append subdirs " $testsbase"
3198 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3201 # Create Makefile.am.
3202 (echo "## Process this file with automake to produce Makefile.in."
3204 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3206 echo "SUBDIRS = $subdirs"
3208 echo "ACLOCAL_AMFLAGS = -I $m4base"
3209 ) > "$testdir/Makefile.am"
3211 # Create configure.ac.
3212 (echo "# Process this file with autoconf to produce a configure script."
3213 echo "AC_INIT([dummy], [0])"
3214 if test "$auxdir" != "."; then
3215 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3217 echo "AM_INIT_AUTOMAKE"
3219 echo "AM_CONFIG_HEADER([config.h])"
3222 echo "AC_PROG_INSTALL"
3223 echo "AC_PROG_MAKE_SET"
3225 echo "# For autobuild."
3226 echo "AC_CANONICAL_BUILD"
3227 echo "AC_CANONICAL_HOST"
3229 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3230 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3231 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3232 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3234 echo "AC_PROG_RANLIB"
3236 if test -n "$uses_subdirs"; then
3237 echo "AM_PROG_CC_C_O"
3240 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3241 echo "AC_GNU_SOURCE"
3244 for module in $modules; do
3245 func_verify_nontests_module
3246 if test -n "$module"; then
3247 func_get_autoconf_early_snippet "$module"
3250 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3251 if test "$libtool" = true; then
3252 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3253 echo "gl_cond_libtool=true"
3255 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3256 echo "gl_cond_libtool=false"
3258 echo "gl_ltlibdeps="
3260 echo "gl_source_base='$sourcebase'"
3261 # Wrap the set of autoconf snippets into an autoconf macro that is then
3262 # invoked. This is needed because autoconf does not support AC_REQUIRE
3264 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3265 # but we want the AC_REQUIRE to have its normal meaning (provide one
3266 # expansion of the required macro before the current point, and only one
3268 echo "AC_DEFUN([gl_INIT], ["
3269 func_emit_initmacro_start
3270 if test "$auxdir" != "build-aux"; then
3271 sed_replace_build_aux='
3273 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3274 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3278 sed_replace_build_aux=
3280 for module in $modules; do
3281 func_verify_nontests_module
3282 if test -n "$module"; then
3283 func_get_autoconf_snippet "$module" \
3284 | sed -e "$sed_replace_build_aux"
3287 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3288 # created using libtool, because libtool already handles the dependencies.
3289 if test "$libtool" != true; then
3290 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3291 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3292 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3293 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3294 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3296 func_emit_initmacro_end
3298 func_emit_initmacro_done
3302 if test -n "$subdirs_with_configure_ac"; then
3303 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3305 makefiles="Makefile"
3306 for d in $subdirs; do
3307 # For subdirs that have a configure.ac by their own, it's the subdir's
3308 # configure.ac which creates the subdir's Makefile.am, not this one.
3309 case " $subdirs_with_configure_ac " in
3311 *) func_append makefiles " $d/Makefile" ;;
3314 echo "AC_OUTPUT([$makefiles])"
3315 ) > "$testdir/configure.ac"
3317 # Create autogenerated files.
3319 # Do not use "${AUTORECONF} --force --install", because it may invoke
3320 # autopoint, which brings in older versions of some of our .m4 files.
3321 if test -f $m4base/gettext.m4; then
3322 echo "executing ${AUTOPOINT} --force"
3323 ${AUTOPOINT} --force || func_exit 1
3324 for f in $m4base/*.m4~; do
3325 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3328 echo "executing ${ACLOCAL} -I $m4base"
3329 ${ACLOCAL} -I $m4base || func_exit 1
3330 if ! test -d build-aux; then
3331 echo "executing mkdir build-aux"
3332 mkdir build-aux || func_exit 1
3334 echo "executing ${AUTOCONF}"
3335 ${AUTOCONF} || func_exit 1
3336 echo "executing ${AUTOHEADER}"
3337 ${AUTOHEADER} || func_exit 1
3338 echo "executing ${AUTOMAKE} --add-missing --copy"
3339 ${AUTOMAKE} --add-missing --copy || func_exit 1
3341 if test -n "$inctests"; then
3342 # Create autogenerated files.
3343 (cd "$testdir/$testsbase" || func_exit 1
3344 # Do not use "${AUTORECONF} --force --install", because it may invoke
3345 # autopoint, which brings in older versions of some of our .m4 files.
3346 if test -f ../$m4base/gettext.m4; then
3347 echo "executing ${AUTOPOINT} --force"
3348 ${AUTOPOINT} --force || func_exit 1
3349 for f in ../$m4base/*.m4~; do
3350 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3353 echo "executing ${ACLOCAL} -I ../$m4base"
3354 ${ACLOCAL} -I ../$m4base || func_exit 1
3355 if ! test -d ../build-aux; then
3356 echo "executing mkdir ../build-aux"
3359 echo "executing ${AUTOCONF}"
3360 ${AUTOCONF} || func_exit 1
3361 echo "executing ${AUTOHEADER}"
3362 ${AUTOHEADER} || func_exit 1
3363 echo "executing ${AUTOMAKE} --add-missing --copy"
3364 ${AUTOMAKE} --add-missing --copy || func_exit 1
3367 # Need to run configure and make once, to create built files that are to be
3368 # distributed (such as getdate.c).
3369 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3370 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3371 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3372 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3373 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3374 # such $(FOO_H) because they don't refer to distributed files.
3375 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3376 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3377 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3378 | sed -e "$sed_remove_make_variables"`
3379 distributed_built_sources=`for file in $built_sources; do
3380 case "$cleaned_files" in
3385 if test -n "$distributed_built_sources"; then
3387 ./configure || func_exit 1
3389 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3390 make built_sources || func_exit 1
3392 make distclean || func_exit 1
3397 # func_create_megatestdir megatestdir allmodules
3399 # - local_gnulib_dir from --local-dir
3400 # - auxdir directory relative to destdir where to place build aux files
3401 func_create_megatestdir ()
3405 if test -z "$allmodules"; then
3406 allmodules=`func_all_modules`
3410 # First, all modules one by one.
3411 for onemodule in $allmodules; do
3412 func_create_testdir "$megatestdir/$onemodule" $onemodule
3413 func_append megasubdirs "$onemodule "
3415 # Then, all modules all together.
3416 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3417 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3418 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3419 func_create_testdir "$megatestdir/ALL" "$allmodules"
3420 func_append megasubdirs "ALL"
3423 cvsdate=`sh "$gnulib_dir/build-aux/mdate-sh" "$gnulib_dir/CVS/Entries" \
3424 | sed -e 's,January,01,' -e 's,Jan,01,' \
3425 -e 's,February,02,' -e 's,Feb,02,' \
3426 -e 's,March,03,' -e 's,Mar,03,' \
3427 -e 's,April,04,' -e 's,Apr,04,' \
3429 -e 's,June,06,' -e 's,Jun,06,' \
3430 -e 's,July,07,' -e 's,Jul,07,' \
3431 -e 's,August,08,' -e 's,Aug,08,' \
3432 -e 's,September,09,' -e 's,Sep,09,' \
3433 -e 's,October,10,' -e 's,Oct,10,' \
3434 -e 's,November,11,' -e 's,Nov,11,' \
3435 -e 's,December,12,' -e 's,Dec,12,' \
3436 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3437 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3439 echo "CVSDATE=$cvsdate"
3440 echo "test -d logs || mkdir logs"
3441 echo "for module in $megasubdirs; do"
3442 echo " echo \"Working on module \$module...\""
3443 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3444 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3447 echo " : autobuild project... \$module"
3448 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3449 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3450 echo " : autobuild hostname... \`hostname\`"
3451 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3453 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3455 ) > "$megatestdir/do-autobuild"
3456 chmod a+x "$megatestdir/do-autobuild"
3458 # Create Makefile.am.
3459 (echo "## Process this file with automake to produce Makefile.in."
3461 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3463 echo "SUBDIRS = $megasubdirs"
3465 echo "EXTRA_DIST = do-autobuild"
3466 ) > "$megatestdir/Makefile.am"
3468 # Create configure.ac.
3469 (echo "# Process this file with autoconf to produce a configure script."
3470 echo "AC_INIT([dummy], [0])"
3471 if test "$auxdir" != "."; then
3472 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3474 echo "AM_INIT_AUTOMAKE"
3476 echo "AC_PROG_MAKE_SET"
3478 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3479 echo "AC_OUTPUT([Makefile])"
3480 ) > "$megatestdir/configure.ac"
3482 # Create autogenerated files.
3484 # Do not use "${AUTORECONF} --install", because autoreconf operates
3485 # recursively, but the subdirectories are already finished, therefore
3486 # calling autoreconf here would only waste lots of CPU time.
3487 echo "executing ${ACLOCAL}"
3488 ${ACLOCAL} || func_exit 1
3489 echo "executing mkdir build-aux"
3491 echo "executing ${AUTOCONF}"
3492 ${AUTOCONF} || func_exit 1
3493 echo "executing ${AUTOMAKE} --add-missing --copy"
3494 ${AUTOMAKE} --add-missing --copy || func_exit 1
3500 func_fatal_error "no mode specified" ;;
3509 if test -z "$destdir"; then
3512 test -d "$destdir" \
3513 || func_fatal_error "destination directory does not exist: $destdir"
3515 # Prefer configure.ac to configure.in.
3516 if test -f "$destdir"/configure.ac; then
3517 configure_ac="$destdir/configure.ac"
3519 if test -f "$destdir"/configure.in; then
3520 configure_ac="$destdir/configure.in"
3522 func_fatal_error "cannot find $destdir/configure.ac"
3526 # Analyze configure.ac.
3528 guessed_libtool=false
3533 /AC_CONFIG_AUX_DIR/ {
3534 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3536 /A[CM]_PROG_LIBTOOL/ {
3537 s,^.*$,guessed_libtool=true,p
3539 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3541 if test -z "$auxdir"; then
3542 auxdir="$guessed_auxdir"
3545 # Determine where to apply func_import.
3546 if test -n "$m4base"; then
3547 # Apply func_import to a particular gnulib directory.
3548 # Any number of additional modules can be given.
3549 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3550 # First use of gnulib in the given m4base.
3551 test -n "$supplied_libname" || supplied_libname=true
3552 test -n "$sourcebase" || sourcebase="lib"
3553 test -n "$docbase" || docbase="doc"
3554 test -n "$testsbase" || testsbase="tests"
3555 test -n "$macro_prefix" || macro_prefix="gl"
3559 # Apply func_import to all gnulib directories.
3560 # To get this list of directories, look at Makefile.am. (Not at
3561 # configure, because it may be omitted from CVS. Also, don't run
3562 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3565 if test -f "$destdir"/Makefile.am; then
3566 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3568 for arg in $aclocal_amflags; do
3569 if test -n "$m4dir_is_next"; then
3570 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3574 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3575 func_append m4dirs " $arg"
3576 m4dirs_count=`expr $m4dirs_count + 1`
3582 if test "X$arg" = "X-I"; then
3590 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3591 if test -f "$destdir"/aclocal.m4; then
3592 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3593 sedexpr2='s,^[^/]*$,.,'
3594 sedexpr3='s,/[^/]*$,,'
3595 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3596 m4dirs_count=`echo "$m4dirs" | wc -l`
3599 if test $m4dirs_count = 0; then
3600 # First use of gnulib in a package.
3601 # Any number of additional modules can be given.
3602 test -n "$supplied_libname" || supplied_libname=true
3603 test -n "$sourcebase" || sourcebase="lib"
3605 test -n "$docbase" || docbase="doc"
3606 test -n "$testsbase" || testsbase="tests"
3607 test -n "$macro_prefix" || macro_prefix="gl"
3610 if test $m4dirs_count = 1; then
3611 # There's only one use of gnulib here. Assume the user means it.
3612 # Any number of additional modules can be given.
3613 for m4base in $m4dirs; do
3617 # Ambiguous - guess what the user meant.
3618 if test $# = 0; then
3619 # No further arguments. Guess the user wants to update all of them.
3620 for m4base in $m4dirs; do
3621 # Perform func_import in a subshell, so that variable values
3623 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
3624 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
3625 # libtool, macro_prefix, po_domain
3626 # don't propagate from one directory to another.
3627 (func_import) || func_exit 1
3631 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
3639 if test -z "$destdir"; then
3640 func_fatal_error "please specify --dir option"
3643 test -d "$destdir" \
3644 || func_fatal_error "could not create destination directory"
3645 test -n "$auxdir" || auxdir="build-aux"
3646 func_create_testdir "$destdir" "$*"
3649 create-megatestdir )
3650 if test -z "$destdir"; then
3651 func_fatal_error "please specify --dir option"
3653 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3654 test -n "$auxdir" || auxdir="build-aux"
3655 func_create_megatestdir "$destdir" "$*"
3659 test -n "$destdir" || destdir=testdir$$
3660 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3661 test -n "$auxdir" || auxdir="build-aux"
3662 func_create_testdir "$destdir" "$*"
3666 ../configure || func_exit 1
3668 make check || func_exit 1
3669 make distclean || func_exit 1
3670 remaining=`find . -type f -print`
3671 if test -n "$remaining"; then
3672 echo "Remaining files:" $remaining 1>&2
3673 echo "gnulib-tool: *** Stop." 1>&2
3682 test -n "$destdir" || destdir=testdir$$
3683 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3684 test -n "$auxdir" || auxdir="build-aux"
3685 func_create_megatestdir "$destdir" "$*"
3693 remaining=`find . -type f -print`
3694 if test -n "$remaining"; then
3695 echo "Remaining files:" $remaining 1>&2
3696 echo "gnulib-tool: *** Stop." 1>&2
3704 extract-description )
3708 if test -n "$module"; then
3709 func_get_description "$module"
3718 if test -n "$module"; then
3719 func_get_filelist "$module"
3724 extract-dependencies )
3728 if test -n "$module"; then
3729 func_get_dependencies "$module"
3734 extract-autoconf-snippet )
3738 if test -n "$module"; then
3739 func_get_autoconf_snippet "$module"
3744 extract-automake-snippet )
3748 if test -n "$module"; then
3749 func_get_automake_snippet "$module"
3754 extract-include-directive )
3758 if test -n "$module"; then
3759 func_get_include_directive "$module"
3764 extract-link-directive )
3768 if test -n "$module"; then
3769 func_get_link_directive "$module"
3778 if test -n "$module"; then
3779 func_get_license "$module"
3784 extract-maintainer )
3788 if test -n "$module"; then
3789 func_get_maintainer "$module"
3794 extract-tests-module )
3798 if test -n "$module"; then
3799 func_get_tests_module "$module"
3805 func_fatal_error "unknown operation mode --$mode" ;;
3809 # Undo the effect of the previous 'trap' command. Some shellology:
3810 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3811 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3812 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3813 # 128 + signal number and is set before the trap-registered command is run.
3815 trap 'func_exit $?' 1 2 3 13 15
3820 # indent-tabs-mode: nil
3821 # whitespace-check-buffer-indent: nil