3 # Copyright (C) 2002-2007 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # This program is meant for authors or maintainers which want to import
21 # modules from gnulib into their packages.
25 cvsdatestamp='$Date: 2007-09-17 10:26:33 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 # Sometimes last_checkin_date is "YYYY/MM/DD ...", sometimes "YYYY-MM-DD ...".
28 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
29 # version is in YYYY-MM-DD format.
34 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
38 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
39 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
43 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
46 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
49 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
50 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
51 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
52 AUTOCONF="${AUTOCONFPATH}autoconf"
54 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
55 AUTOHEADER="${AUTOCONFPATH}autoheader"
57 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
58 ACLOCAL="${AUTOMAKEPATH}aclocal"
60 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
61 AUTOMAKE="${AUTOMAKEPATH}automake"
63 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
64 AUTORECONF="${AUTOCONFPATH}autoreconf"
67 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
68 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
69 AUTOPOINT="${GETTEXTPATH}autopoint"
72 # When using GNU sed, turn off as many GNU extensions as possible,
73 # to minimize the risk of accidentally using non-portable features.
74 # However, do this only for gnulib-tool itself, not for the code that
75 # gnulib-tool generates, since we don't want "sed --posix" to leak
77 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
78 # Define sed as an alias.
79 # It is not always possible to use aliases. Aliases are guaranteed to work
80 # if the executing shell is bash and either it is invoked as /bin/sh or
81 # is a version >= 2.0, supporting shopt. This is the common case.
82 # Two other approaches (use of a variable $sed or of a function func_sed
83 # instead of an alias) require massive, fragile code changes.
84 # An other approach (use of function sed) requires `which sed` - but 'which'
85 # is hard to emulate, due to missing "test -x" on some platforms.
86 if test -n "$BASH_VERSION"; then
87 shopt -s expand_aliases >/dev/null 2>&1
89 alias sed='sed --posix'
93 # outputs to stdout the --help usage message.
97 Usage: gnulib-tool --list
98 gnulib-tool --import [module1 ... moduleN]
100 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
101 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
102 gnulib-tool --test --dir=directory module1 ... moduleN
103 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
104 gnulib-tool --extract-description module
105 gnulib-tool --extract-notice module
106 gnulib-tool --extract-filelist module
107 gnulib-tool --extract-dependencies module
108 gnulib-tool --extract-autoconf-snippet module
109 gnulib-tool --extract-automake-snippet module
110 gnulib-tool --extract-include-directive module
111 gnulib-tool --extract-link-directive module
112 gnulib-tool --extract-license module
113 gnulib-tool --extract-maintainer module
114 gnulib-tool --extract-tests-module module
117 --list print the available module names
118 --import import the given modules into the current package;
119 if no modules are specified, update the current
120 package from the current gnulib
121 --update update the current package, restore files omitted
123 --create-testdir create a scratch package with the given modules
124 --create-megatestdir create a mega scratch package with the given modules
125 one by one and all together
126 --test test the combination of the given modules
127 (recommended to use CC=\"gcc -Wall\" here)
128 --megatest test the given modules one by one and all together
129 (recommended to use CC=\"gcc -Wall\" here)
130 --extract-description extract the description
131 --extract-notice extract the notice or banner
132 --extract-filelist extract the list of files
133 --extract-dependencies extract the dependencies
134 --extract-autoconf-snippet extract the snippet for configure.ac
135 --extract-automake-snippet extract the snippet for library makefile
136 --extract-include-directive extract the #include directive
137 --extract-link-directive extract the linker directive
138 --extract-license report the license terms of the source files
140 --extract-maintainer report the maintainer(s) inside gnulib
141 --extract-tests-module report the unit test module, if it exists
144 --dir=DIRECTORY Specify the target directory.
145 For --import, this specifies where your
146 configure.ac can be found. Defaults to current
148 --local-dir=DIRECTORY Specify a local override directory where to look
149 up files before looking in gnulib's directory.
150 --verbose Increase verbosity. May be repeated.
151 --quiet Decrease verbosity. May be repeated.
153 Options for --import:
154 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
155 --source-base=DIRECTORY
156 Directory relative to --dir where source code is
157 placed (default \"lib\").
158 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
159 placed (default \"m4\").
160 --po-base=DIRECTORY Directory relative to --dir where *.po files are
161 placed (default \"po\").
162 --doc-base=DIRECTORY Directory relative to --dir where doc files are
163 placed (default \"doc\").
164 --tests-base=DIRECTORY
165 Directory relative to --dir where unit tests are
166 placed (default \"tests\").
167 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
168 tools are placed (default \"build-aux\").
169 --with-tests Include unit tests for the included modules.
170 --avoid=MODULE Avoid including the given MODULE. Useful if you
171 have code that provides equivalent functionality.
172 This option can be repeated.
173 --lgpl Abort if modules aren't available under the LGPL.
174 Also modify license template from GPL to LGPL.
175 --makefile-name=NAME Name of makefile in automake syntax in the
176 source-base and tests-base directories
177 (default \"Makefile.am\").
178 --libtool Use libtool rules.
179 --no-libtool Don't use libtool rules.
180 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
181 'gl_INIT'. Default is 'gl'.
182 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
183 the package name. A suffix '-gnulib' is appended.
184 --no-changelog don't update or create ChangeLog files
186 Options for --import and --update:
187 --dry-run For --import, only print what would have been done.
188 -s, --symbolic, --symlink Make symbolic links instead of copying files.
189 --local-symlink Make symbolic links instead of copying files, only
190 for files from the local override directory.
191 -S, --more-symlinks Make symbolic links instead of copying files, and
192 don't replace copyright notices.
194 Report bugs to <bug-gnulib@gnu.org>."
198 # outputs to stdout the --version message.
201 year=`echo "$version" | sed -e 's,-.*$,,'`
203 $progname (GNU $package) $version
204 Copyright (C) $year Free Software Foundation, Inc.
205 This is free software; see the source for copying conditions. There is NO
206 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
207 Written by" "Bruno Haible" "and" "Simon Josefsson"
210 # func_emit_copyright_notice
211 # outputs to stdout a header for a generated file.
212 func_emit_copyright_notice ()
214 echo "# Copyright (C) 2004-2007 Free Software Foundation, Inc."
216 echo "# This file is free software, distributed under the terms of the GNU"
217 echo "# General Public License. As a special exception to the GNU General"
218 echo "# Public License, this file may be distributed as part of a program"
219 echo "# that contains a configuration script generated by Autoconf, under"
220 echo "# the same distribution terms as the rest of that program."
222 echo "# Generated by gnulib-tool."
233 # creates a temporary directory.
235 # - tmp pathname of freshly created temporary directory
238 # Use the environment variable TMPDIR, falling back to /tmp. This allows
239 # users to specify a different temporary directory, for example, if their
240 # /tmp is filled up or too small.
243 # Use the mktemp program if available. If not available, hide the error
245 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
246 test -n "$tmp" && test -d "$tmp"
249 # Use a simple mkdir command. It is guaranteed to fail if the directory
250 # already exists. $RANDOM is bash specific and expands to empty in shells
251 # other than bash, ksh and zsh. Its use does not increase security;
252 # rather, it minimizes the probability of failure in a very cluttered /tmp
254 tmp=$TMPDIR/gl$$-$RANDOM
255 (umask 077 && mkdir "$tmp")
258 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
263 # func_append var value
264 # appends the given value to the shell variable var.
265 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
266 # Use bash's += operator. It reduces complexity of appending repeatedly to
267 # a single variable from O(n^2) to O(n).
275 eval "$1=\"\$$1\$2\""
279 # func_fatal_error message
280 # outputs to stderr a fatal error message, and terminates the program.
283 echo "gnulib-tool: *** $1" 1>&2
284 echo "gnulib-tool: *** Stop." 1>&2
288 # func_readlink SYMLINK
289 # outputs the target of the given symlink.
290 if (type -p readlink) > /dev/null 2>&1; then
293 # Use the readlink program from GNU coreutils.
299 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
300 # would do the wrong thing if the link target contains " -> ".
301 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
305 # func_relativize DIR1 DIR2
306 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
308 # - DIR1 relative pathname, relative to the current directory
309 # - DIR2 relative pathname, relative to the current directory
311 # - reldir relative pathname of DIR2, relative to DIR1
317 sed_first='s,^\([^/]*\)/.*$,\1,'
318 sed_rest='s,^[^/]*/*,,'
319 sed_last='s,^.*/\([^/]*\)$,\1,'
320 sed_butlast='s,/*[^/]*$,,'
321 while test -n "$dir1"; do
322 first=`echo "$dir1" | sed -e "$sed_first"`
323 if test "$first" != "."; then
324 if test "$first" = ".."; then
325 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
326 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
328 first2=`echo "$dir2" | sed -e "$sed_first"`
329 if test "$first2" = "$first"; then
330 dir2=`echo "$dir2" | sed -e "$sed_rest"`
334 dir0="$dir0"/"$first"
337 dir1=`echo "$dir1" | sed -e "$sed_rest"`
342 # func_relconcat DIR1 DIR2
343 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
345 # - DIR1 relative pathname, relative to the current directory
346 # - DIR2 relative pathname, relative to DIR1
348 # - relconcat DIR1/DIR2, relative to the current directory
353 sed_first='s,^\([^/]*\)/.*$,\1,'
354 sed_rest='s,^[^/]*/*,,'
355 sed_last='s,^.*/\([^/]*\)$,\1,'
356 sed_butlast='s,/*[^/]*$,,'
358 first=`echo "$dir2" | sed -e "$sed_first"`
359 if test "$first" = "."; then
360 dir2=`echo "$dir2" | sed -e "$sed_rest"`
361 if test -z "$dir2"; then
366 last=`echo "$dir1" | sed -e "$sed_last"`
367 while test "$last" = "."; do
368 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
369 last=`echo "$dir1" | sed -e "$sed_last"`
371 if test -z "$dir1"; then
375 if test "$first" = ".."; then
376 if test "$last" = ".."; then
377 relconcat="$dir1/$dir2"
380 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
381 dir2=`echo "$dir2" | sed -e "$sed_rest"`
382 if test -z "$dir1"; then
386 if test -z "$dir2"; then
391 relconcat="$dir1/$dir2"
399 # Like ln -s, except that SRC is given relative to the current directory (or
400 # absolute), not given relative to the directory of DEST.
406 *) # SRC is relative.
409 ln -s "`pwd`/$1" "$2" ;;
410 *) # DEST is relative too.
411 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
412 test -n "$ln_destdir" || ln_destdir="."
413 func_relativize "$ln_destdir" "$1"
421 # func_ln_if_changed SRC DEST
422 # Like func_ln, but avoids munging timestamps if the link is correct.
423 func_ln_if_changed ()
425 if test $# -ne 2; then
426 echo "usage: func_ln_if_changed SRC DEST" >&2
428 ln_target=`func_readlink "$2"`
429 if test -h "$2" && test "$1" = "$ln_target"; then
437 # Ensure an 'echo' command that does not interpret backslashes.
439 # echo '\n' | wc -l prints 1 when OK, 2 when KO
440 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
441 # This problem is a weird heritage from SVR4. BSD got it right (except that
442 # BSD echo interprets '-n' as an option, which is also not desirable).
443 # Nowadays the problem occurs in 4 situations:
444 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
445 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
446 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
447 # - in zsh, when sh-emulation is not set,
448 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
449 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
450 # - in Solaris /bin/sh and OSF/1 /bin/sh.
451 # We try the following workarounds:
452 # - for all: respawn using $CONFIG_SHELL if that is set and works.
453 # - for bash >= 2.04: unset the shell option xpg_echo.
454 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
455 # - for bash < 2.0: define echo to a function that uses cat of a here document.
456 # - for zsh: turn sh-emulation on.
457 # - for ksh: alias echo to 'print -r'.
458 # - for ksh: alias echo to a function that uses cat of a here document.
459 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
460 # the ksh workaround.
461 # - otherwise: respawn using /bin/sh and rely on the workarounds.
462 # When respawning, we pass --no-reexec as first argument, so as to avoid
463 # turning this script into a fork bomb in unlucky situations.
465 if echo '\t' | grep t > /dev/null; then
466 have_echo=yes # Lucky!
468 # Try the workarounds.
469 # Respawn using $CONFIG_SHELL if that is set and works.
470 if test -z "$have_echo" \
471 && test "X$1" != "X--no-reexec" \
472 && test -n "$CONFIG_SHELL" \
473 && test -f "$CONFIG_SHELL" \
474 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
475 exec $CONFIG_SHELL "$0" --no-reexec "$@"
478 # For bash >= 2.04: unset the shell option xpg_echo.
479 if test -z "$have_echo" \
480 && test -n "$BASH_VERSION" \
481 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
485 # For bash >= 2.0: define echo to a function that uses the printf built-in.
486 # For bash < 2.0: define echo to a function that uses cat of a here document.
487 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
488 if test -z "$have_echo" \
489 && test -n "$BASH_VERSION"; then \
490 if type printf 2>/dev/null | grep / > /dev/null; then
491 # 'printf' is not a shell built-in.
499 # 'printf' is a shell built-in.
505 if echo '\t' | grep t > /dev/null; then
509 # For zsh: turn sh-emulation on.
510 if test -z "$have_echo" \
511 && test -n "$ZSH_VERSION" \
512 && (emulate sh) >/dev/null 2>&1; then
515 # For ksh: alias echo to 'print -r'.
516 if test -z "$have_echo" \
517 && (type print) >/dev/null 2>&1; then
518 # A 'print' command exists.
519 if type print 2>/dev/null | grep / > /dev/null; then
522 # 'print' is a shell built-in.
523 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
524 # 'print' is the ksh shell built-in.
525 alias echo='print -r'
529 if test -z "$have_echo" \
530 && echo '\t' | grep t > /dev/null; then
533 # For ksh: alias echo to a function that uses cat of a here document.
534 # The ksh manual page says:
535 # "Aliasing is performed when scripts are read, not while they are executed.
536 # Therefore, for an alias to take effect, the alias definition command has
537 # to be executed before the command which references the alias is read."
538 # Because of this, we have to play strange tricks with have_echo, to ensure
539 # that the top-level statement containing the test starts after the 'alias'
541 if test -z "$have_echo"; then
548 alias echo=bsd_echo 2>/dev/null
550 if test -z "$have_echo" \
551 && echo '\t' | grep t > /dev/null; then
554 if test -z "$have_echo"; then
555 unalias echo 2>/dev/null
557 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
558 if test -z "$have_echo" \
559 && test "X$1" != "X--no-reexec" \
560 && test -f /bin/ksh; then
561 exec /bin/ksh "$0" --no-reexec "$@"
564 # Otherwise: respawn using /bin/sh.
565 if test -z "$have_echo" \
566 && test "X$1" != "X--no-reexec" \
567 && test -f /bin/sh; then
568 exec /bin/sh "$0" --no-reexec "$@"
571 if test -z "$have_echo"; then
572 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
574 if echo '\t' | grep t > /dev/null; then
577 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
579 if test "X$1" = "X--no-reexec"; then
583 # Command-line option processing.
584 # Removes the OPTIONS from the arguments. Sets the variables:
585 # - mode list or import or create-testdir or create-megatestdir
586 # - destdir from --dir
587 # - local_gnulib_dir from --local-dir
588 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
589 # - libname, supplied_libname from --lib
590 # - sourcebase from --source-base
591 # - m4base from --m4-base
592 # - pobase from --po-base
593 # - docbase from --doc-base
594 # - testsbase from --tests-base
595 # - auxdir from --aux-dir
596 # - inctests true if --with-tests was given, blank otherwise
597 # - avoidlist list of modules to avoid, from --avoid
598 # - lgpl true if --lgpl was given, blank otherwise
599 # - makefile_name from --makefile-name
600 # - libtool true if --libtool was given, false if --no-libtool was
601 # given, blank otherwise
602 # - macro_prefix from --macro-prefix
603 # - po_domain from --po-domain
604 # - autoconf_minversion minimum supported autoconf version
605 # - do_changelog false if --no-changelog was given, : otherwise
606 # - doit : if actions shall be executed, false if only to be printed
607 # - symbolic true if --symlink or --more-symlinks was given, blank
609 # - lsymbolic true if --local-symlink was given, blank otherwise
610 # - do_copyrights blank if --more-symlinks was given, true otherwise
639 while test $# -gt 0; do
644 --import | --impor | --impo | --imp | --im | --i )
647 --update | --updat | --upda | --upd | --up | --u )
650 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
653 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
654 mode=create-megatestdir
656 --test | --tes | --te | --t )
659 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
663 mode=`echo "X$1" | sed -e 's/^X--//'`
668 func_fatal_error "missing argument for --dir"
673 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
678 func_fatal_error "missing argument for --local-dir"
683 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
685 --verbose | --verbos | --verbo | --verb )
686 verbose=`expr $verbose + 1`
688 --quiet | --quie | --qui | --qu | --q )
689 verbose=`expr $verbose - 1`
694 func_fatal_error "missing argument for --lib"
697 supplied_libname=true
700 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
701 supplied_libname=true
706 func_fatal_error "missing argument for --source-base"
711 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
716 func_fatal_error "missing argument for --m4-base"
721 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
726 func_fatal_error "missing argument for --po-base"
731 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
736 func_fatal_error "missing argument for --doc-base"
741 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
746 func_fatal_error "missing argument for --tests-base"
751 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
756 func_fatal_error "missing argument for --aux-dir"
761 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
769 func_fatal_error "missing argument for --avoid"
771 func_append avoidlist " $1"
774 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
775 func_append avoidlist " $arg"
783 func_fatal_error "missing argument for --makefile-name"
788 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
799 func_fatal_error "missing argument for --macro-prefix"
804 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
809 func_fatal_error "missing argument for --po-domain"
814 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
816 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
822 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
825 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
828 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
832 --help | --hel | --he | --h )
835 --version | --versio | --versi | --vers )
839 # Stop option processing
843 echo "gnulib-tool: unknown option $1" 1>&2
844 echo "Try 'gnulib-tool --help' for more information." 1>&2
851 if test "$mode" = update; then
852 if test $# != 0; then
853 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
854 echo "Try 'gnulib-tool --help' for more information." 1>&2
855 echo "If you really want to modify the gnulib configuration of your project," 1>&2
856 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
859 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
860 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
861 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
862 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
863 || test -n "$makefile_name" || test -n "$macro_prefix" \
864 || test -n "$po_domain"; then
865 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
866 echo "Try 'gnulib-tool --help' for more information." 1>&2
867 echo "If you really want to modify the gnulib configuration of your project," 1>&2
868 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
873 if test -n "$pobase" && test -z "$po_domain"; then
874 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
875 echo "Try 'gnulib-tool --help' for more information." 1>&2
878 if test -z "$pobase" && test -n "$po_domain"; then
879 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
882 # Determine the minimum supported autoconf version from the project's
884 DEFAULT_AUTOCONF_MINVERSION="2.59"
887 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
888 if test -f "$destdir"/configure.ac; then
889 configure_ac="$destdir/configure.ac"
891 if test -f "$destdir"/configure.in; then
892 configure_ac="$destdir/configure.in"
896 if test -f configure.ac; then
897 configure_ac="configure.ac"
899 if test -f configure.in; then
900 configure_ac="configure.in"
904 if test -n "$configure_ac"; then
905 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
906 # because when some m4 files are omitted from a CVS repository,
907 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
908 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
909 # autom4te: m4 failed with exit status: 1
916 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
918 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
919 if test -n "$prereqs"; then
920 autoconf_minversion=`
921 for version in $prereqs; do echo $version; done |
922 LC_ALL=C sort -nru | sed 1q
926 if test -z "$autoconf_minversion"; then
927 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
929 case "$autoconf_minversion" in
930 1.* | 2.[0-4]* | 2.5[0-8]*)
931 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
934 # Remove trailing slashes from the directory names. This is necessary for
935 # m4base (to avoid an error in func_import) and optional for the others.
936 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
937 case "$local_gnulib_dir" in
938 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
940 case "$sourcebase" in
941 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
944 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
947 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
950 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
953 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
956 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
961 /*) self_abspathname="$0" ;;
962 */*) self_abspathname=`pwd`/"$0" ;;
965 # Iterate through the elements of $PATH.
966 # We use IFS=: instead of
967 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
968 # because the latter does not work when some PATH element contains spaces.
969 # We use a canonicalized $pathx instead of $PATH, because empty PATH
970 # elements are by definition equivalent to '.', however field splitting
971 # according to IFS=: loses empty fields in many shells:
972 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
973 # beginning, at the end, and in the middle),
974 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
975 # at the beginning and at the end,
976 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
977 # Solaris lose empty fields at the end.
978 # The 'case' statement is an optimization, to avoid evaluating the
979 # explicit canonicalization command when $PATH contains no empty fields.
981 if test "${PATH_SEPARATOR+set}" != set; then
983 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
984 chmod +x "$tmp"/conf.sh
985 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
992 if test "$PATH_SEPARATOR" = ";"; then
993 # On Windows, programs are searched in "." before $PATH.
996 # On Unix, we have to convert empty PATH elements to ".".
1000 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
1005 IFS="$PATH_SEPARATOR"
1009 if test -x "$d/$0" && test ! -d "$d/$0"; then
1010 self_abspathname="$d/$0"
1015 if test -z "$self_abspathname"; then
1016 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
1020 while test -h "$self_abspathname"; do
1021 # Resolve symbolic link.
1022 linkval=`func_readlink "$self_abspathname"`
1023 test -n "$linkval" || break
1025 /* ) self_abspathname="$linkval" ;;
1026 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
1029 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
1032 trap 'exit_status=$?
1033 if test "$signal" != 0; then
1034 echo "caught signal $signal" >&2
1037 exit $exit_status' 0
1038 for signal in 1 2 3 13 15; do
1039 trap '{ signal='$signal'; func_exit 1; }' $signal
1043 # func_lookup_file file
1044 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1047 # - local_gnulib_dir from --local-dir
1049 # - lookedup_file name of the merged (combined) file
1050 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1054 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1055 lookedup_file="$local_gnulib_dir/$lkfile"
1058 if test -f "$gnulib_dir/$lkfile"; then
1059 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1060 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1061 rm -f "$tmp/$lkbase"
1062 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1063 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1064 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1065 lookedup_file="$tmp/$lkbase"
1068 lookedup_file="$gnulib_dir/$lkfile"
1072 func_fatal_error "file $gnulib_dir/$lkfile not found"
1079 # - local_gnulib_dir from --local-dir
1082 # Filter out metainformation files like README, which are not modules.
1083 # Filter out unit test modules; they can be retrieved through
1084 # --extract-tests-module if desired.
1086 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1087 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1088 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1091 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1092 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1093 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1094 -e '/^README$/d' -e '/\/README$/d' \
1095 -e '/^TEMPLATE$/d' \
1096 -e '/^TEMPLATE-EXTENDED$/d' \
1097 -e '/^TEMPLATE-TESTS$/d' \
1100 | sed -e '/-tests$/d' \
1104 # func_verify_module
1105 # verifies a module name
1107 # - local_gnulib_dir from --local-dir
1108 # - module module name argument
1109 func_verify_module ()
1111 if { test -f "$gnulib_dir/modules/$module" \
1112 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1113 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1114 && test "CVS" != "$module" \
1115 && test "ChangeLog" != "$module" \
1116 && test "COPYING" != "$module" \
1117 && test "README" != "$module" \
1118 && test "TEMPLATE" != "$module" \
1119 && test "TEMPLATE-EXTENDED" != "$module" \
1120 && test "TEMPLATE-TESTS" != "$module"; then
1121 # OK, $module is a correct module name.
1122 # Verify that building the module description with 'patch' succeeds.
1123 func_lookup_file "modules/$module"
1125 echo "gnulib-tool: module $module doesn't exist" 1>&2
1130 # func_verify_nontests_module
1131 # verifies a module name, excluding tests modules
1133 # - local_gnulib_dir from --local-dir
1134 # - module module name argument
1135 func_verify_nontests_module ()
1138 *-tests ) module= ;;
1139 * ) func_verify_module ;;
1143 # func_verify_tests_module
1144 # verifies a module name, considering only tests modules
1146 # - local_gnulib_dir from --local-dir
1147 # - module module name argument
1148 func_verify_tests_module ()
1151 *-tests ) func_verify_module ;;
1156 sed_extract_prog=':[ ]*$/ {
1159 s/^Description:[ ]*$//
1162 s/^Depends-on:[ ]*$//
1163 s/^configure\.ac-early:[ ]*$//
1164 s/^configure\.ac:[ ]*$//
1165 s/^Makefile\.am:[ ]*$//
1169 s/^Maintainer:[ ]*$//
1176 # func_get_description module
1178 # - local_gnulib_dir from --local-dir
1179 func_get_description ()
1181 func_lookup_file "modules/$1"
1182 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1185 # func_get_notice module
1187 # - local_gnulib_dir from --local-dir
1190 func_lookup_file "modules/$1"
1191 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1194 # func_get_filelist module
1196 # - local_gnulib_dir from --local-dir
1197 func_get_filelist ()
1199 func_lookup_file "modules/$1"
1200 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1201 echo m4/gnulib-common.m4
1202 case "$autoconf_minversion" in
1204 #echo m4/onceonly.m4
1205 echo m4/onceonly_2_57.m4
1210 # func_get_dependencies module
1212 # - local_gnulib_dir from --local-dir
1213 func_get_dependencies ()
1215 # ${module}-tests always implicitly depends on ${module}.
1216 echo "$1" | sed -n -e 's/-tests//p'
1217 # Then the explicit dependencies listed in the module description.
1218 func_lookup_file "modules/$1"
1219 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1222 # func_get_autoconf_early_snippet module
1224 # - local_gnulib_dir from --local-dir
1225 func_get_autoconf_early_snippet ()
1227 func_lookup_file "modules/$1"
1228 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1231 # func_get_autoconf_snippet module
1233 # - local_gnulib_dir from --local-dir
1234 func_get_autoconf_snippet ()
1236 func_lookup_file "modules/$1"
1237 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1240 # func_get_automake_snippet module
1242 # - local_gnulib_dir from --local-dir
1243 func_get_automake_snippet ()
1245 func_lookup_file "modules/$1"
1246 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1249 # *-tests module live in tests/, not lib/.
1252 # Synthesize an EXTRA_DIST augmentation.
1253 sed_combine_lines='/\\$/{
1260 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1261 already_mentioned_files=` \
1262 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1263 | sed -e "$sed_combine_lines" \
1264 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1265 all_files=`func_get_filelist $1`
1266 lib_files=`for f in $all_files; do \
1270 done | sed -e 's,^lib/,,'`
1271 # Remove $already_mentioned_files from $lib_files.
1272 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1273 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1274 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1275 if test -n "$extra_files"; then
1276 echo "EXTRA_DIST +=" $extra_files
1279 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1280 # This is necessary so that automake can generate the right list of
1282 # A possible approach would be to use autom4te --trace of the redefined
1283 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1284 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1285 # inside autoconf's built-in macros are not missed).
1286 # But it's simpler and more robust to do it here, based on the file list.
1287 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1288 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1289 # automake will generate a useless dependency; this is harmless.
1291 relocatable-prog-wrapper) ;;
1293 sed_extract_c_files='/\.c$/p'
1294 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1295 if test -n "$extra_files"; then
1296 echo "EXTRA_lib_SOURCES +=" $extra_files
1301 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1302 buildaux_files=`for f in $all_files; do \
1304 build-aux/*) echo $f ;; \
1306 done | sed -e 's,^build-aux/,,'`
1307 if test -n "$buildaux_files"; then
1308 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1309 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1316 # func_get_include_directive module
1318 # - local_gnulib_dir from --local-dir
1319 func_get_include_directive ()
1321 func_lookup_file "modules/$1"
1322 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1323 sed -e 's/^\(["<]\)/#include \1/'
1326 # func_get_link_directive module
1328 # - local_gnulib_dir from --local-dir
1329 func_get_link_directive ()
1331 func_lookup_file "modules/$1"
1332 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1335 # func_get_license module
1337 # - local_gnulib_dir from --local-dir
1340 func_lookup_file "modules/$1"
1341 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1342 # The default is GPL.
1344 } | sed -e 's,^ *$,,' | sed -e 1q
1347 # func_get_maintainer module
1349 # - local_gnulib_dir from --local-dir
1350 func_get_maintainer ()
1352 func_lookup_file "modules/$1"
1353 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1356 # func_get_tests_module module
1358 # - local_gnulib_dir from --local-dir
1359 func_get_tests_module ()
1361 # The naming convention for tests modules is hardwired: ${module}-tests.
1362 if test -f "$gnulib_dir/modules/$1"-tests \
1363 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1364 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1369 # func_acceptable module
1370 # tests whether a module is acceptable.
1372 # - avoidlist list of modules to avoid
1375 for avoid in $avoidlist; do
1376 if test "$avoid" = "$1"; then
1383 # func_modules_transitive_closure
1385 # - local_gnulib_dir from --local-dir
1386 # - modules list of specified modules
1387 # - inctests true if tests should be included, blank otherwise
1388 # - avoidlist list of modules to avoid
1389 # - tmp pathname of a temporary directory
1391 # - modules list of modules, including dependencies
1392 func_modules_transitive_closure ()
1394 # In order to process every module only once (for speed), process an "input
1395 # list" of modules, producing an "output list" of modules. During each round,
1396 # more modules can be queued in the input list. Once a module on the input
1397 # list has been processed, it is added to the "handled list", so we can avoid
1398 # to process it again.
1400 inmodules="$modules"
1402 while test -n "$inmodules"; do
1403 inmodules_this_round="$inmodules"
1404 inmodules= # Accumulator, queue for next round
1405 for module in $inmodules_this_round; do
1407 if test -n "$module"; then
1408 if func_acceptable $module; then
1409 func_append outmodules " $module"
1410 deps=`func_get_dependencies $module`
1411 # Duplicate dependencies are harmless, but Jim wants a warning.
1412 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1413 if test -n "$duplicated_deps"; then
1414 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1416 func_append inmodules " $deps"
1417 if test -n "$inctests"; then
1418 testsmodule=`func_get_tests_module $module`
1419 if test -n "$testsmodule"; then
1420 func_append inmodules " $testsmodule"
1426 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1427 # Remove $handledmodules from $inmodules.
1428 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1429 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1431 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1432 rm -f "$tmp"/queued-modules
1435 # func_modules_add_dummy
1437 # - local_gnulib_dir from --local-dir
1438 # - modules list of modules, including dependencies
1440 # - modules list of modules, including 'dummy' if needed
1441 func_modules_add_dummy ()
1444 sed_remove_backslash_newline=':a
1451 for module in $modules; do
1452 func_verify_nontests_module
1453 if test -n "$module"; then
1454 # Extract the value of "lib_SOURCES += ...".
1455 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1456 # Ignore .h files since they are not compiled.
1459 *) have_lib_SOURCES=yes ;;
1464 # Add the dummy module, to make sure the library will be non-empty.
1465 if test -z "$have_lib_SOURCES"; then
1466 if func_acceptable "dummy"; then
1467 func_append modules " dummy"
1472 # func_modules_notice
1474 # - local_gnulib_dir from --local-dir
1475 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1476 # - modules list of modules, including dependencies
1477 func_modules_notice ()
1479 if test $verbose -ge -1; then
1480 for module in $modules; do
1482 if test -n "$module"; then
1483 msg=`func_get_notice $module`
1484 if test -n "$msg"; then
1485 echo "Notice from module $module:"
1486 echo "$msg" | sed -e 's/^/ /'
1493 # func_modules_to_filelist
1495 # - local_gnulib_dir from --local-dir
1496 # - modules list of modules, including dependencies
1498 # - files list of files
1499 func_modules_to_filelist ()
1502 for module in $modules; do
1504 if test -n "$module"; then
1505 fs=`func_get_filelist $module`
1506 func_append files " $fs"
1509 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1512 # func_execute_command command [args...]
1513 # Executes a command.
1514 # Uses also the variables
1515 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1516 func_execute_command ()
1518 if test $verbose -ge 0; then
1522 # Commands like automake produce output to stderr even when the succeed.
1523 # Turn this output off if the command succeeds.
1524 "$@" > "$tmp"/cmdout 2>&1
1526 if test $cmdret = 0; then
1530 cat "$tmp"/cmdout 1>&2
1537 # func_emit_lib_Makefile_am
1538 # emits the contents of library makefile to standard output.
1540 # - local_gnulib_dir from --local-dir
1541 # - modules list of modules, including dependencies
1542 # - libname library name
1543 # - pobase directory relative to destdir where to place *.po files
1544 # - auxdir directory relative to destdir where to place build aux files
1545 # - makefile_name from --makefile-name
1546 # - libtool true if libtool will be used, false or blank otherwise
1547 # - macro_prefix prefix of gl_LIBOBJS macros to use
1548 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1549 # - actioncmd (optional) command that will reproduce this invocation
1550 # - for_test true if creating a package for testing, false otherwise
1552 # - uses_subdirs nonempty if object files in subdirs exist
1553 func_emit_lib_Makefile_am ()
1555 # When creating an includable Makefile.am snippet, augment variables with
1556 # += instead of assigning them.
1557 if test -n "$makefile_name"; then
1562 if test "$libtool" = true; then
1565 sed_eliminate_LDFLAGS=
1569 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1572 # When creating a package for testing: Attempt to provoke failures,
1573 # especially link errors, already during "make" rather than during
1574 # "make check", because "make check" is not possible in a cross-compiling
1575 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1576 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1578 sed_transform_check_PROGRAMS=
1580 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1581 echo "## Process this file with automake to produce Makefile.in."
1582 func_emit_copyright_notice
1583 if test -n "$actioncmd"; then
1584 echo "# Reproduce by: $actioncmd"
1589 for module in $modules; do
1590 func_verify_nontests_module
1591 if test -n "$module"; then
1593 func_get_automake_snippet "$module" |
1594 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1595 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1596 -e "$sed_eliminate_LDFLAGS" \
1597 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1598 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1599 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1600 -e "$sed_transform_check_PROGRAMS"
1601 if test "$module" = 'alloca'; then
1602 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1603 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1606 # Skip the contents if its entirely empty.
1607 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1608 echo "## begin gnulib module $module"
1611 echo "## end gnulib module $module"
1615 # Test whether there are some source files in subdirectories.
1616 for f in `func_get_filelist "$module"`; do
1618 lib/*/*.c) uses_subdirs=yes ;;
1624 if test -z "$makefile_name"; then
1625 # If there are source files in subdirectories, prevent collision of the
1626 # object files (example: hash.c and libxml/hash.c).
1628 if test -n "$uses_subdirs"; then
1629 subdir_options=' subdir-objects'
1631 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1634 if test -z "$makefile_name"; then
1635 echo "noinst_HEADERS ="
1636 echo "noinst_LIBRARIES ="
1637 echo "noinst_LTLIBRARIES ="
1638 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1639 # if you specify pkgdata_DATA to empty. This is a workaround.
1640 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1641 echo "pkgdata_DATA ="
1644 echo "BUILT_SOURCES ="
1647 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1648 if test -z "$makefile_name"; then
1649 echo "MOSTLYCLEANDIRS ="
1651 echo "DISTCLEANFILES ="
1652 echo "MAINTAINERCLEANFILES ="
1654 echo "AM_CPPFLAGS ="
1657 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1658 # One of the snippets already specifies an installation location for the
1659 # library. Don't confuse automake by saying it should not be installed.
1662 # By default, the generated library should not be installed.
1663 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1666 echo "${libname}_${libext}_SOURCES ="
1667 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1668 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1669 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1670 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1671 echo "EXTRA_${libname}_${libext}_SOURCES ="
1672 if test "$libtool" = true; then
1673 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1676 if test -n "$pobase"; then
1677 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1680 cat allsnippets.tmp \
1681 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1683 echo "mostlyclean-local: mostlyclean-generic"
1684 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1685 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1686 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1690 rm -f allsnippets.tmp
1693 # func_emit_po_Makevars
1694 # emits the contents of po/ makefile parametrization to standard output.
1696 # - local_gnulib_dir from --local-dir
1697 # - sourcebase directory relative to destdir where to place source code
1698 # - pobase directory relative to destdir where to place *.po files
1699 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1700 func_emit_po_Makevars ()
1702 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1703 func_emit_copyright_notice
1705 echo "# Usually the message domain is the same as the package name."
1706 echo "# But here it has a '-gnulib' suffix."
1707 echo "DOMAIN = ${po_domain}-gnulib"
1709 echo "# These two variables depend on the location of this directory."
1710 echo "subdir = ${pobase}"
1711 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1714 # These options get passed to xgettext.
1715 XGETTEXT_OPTIONS = \
1716 --keyword=_ --flag=_:1:pass-c-format \
1717 --keyword=N_ --flag=N_:1:pass-c-format \
1718 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1719 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1720 --flag=error:3:c-format --flag=error_at_line:5:c-format
1722 # This is the copyright holder that gets inserted into the header of the
1723 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1724 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1726 # This is the email address or URL to which the translators shall report
1727 # bugs in the untranslated strings:
1728 # - Strings which are not entire sentences, see the maintainer guidelines
1729 # in the GNU gettext documentation, section 'Preparing Strings'.
1730 # - Strings which use unclear terms or require additional context to be
1732 # - Strings which make invalid assumptions about notation of date, time or
1734 # - Pluralisation problems.
1735 # - Incorrect English spelling.
1736 # - Incorrect formatting.
1737 # It can be your email address, or a mailing list address where translators
1738 # can write to without being subscribed, or the URL of a web page through
1739 # which the translators can contact you.
1740 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1742 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1743 # message catalogs shall be used. It is usually empty.
1744 EXTRA_LOCALE_CATEGORIES =
1746 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1747 # context. Possible values are "yes" and "no". Set this to yes if the
1748 # package uses functions taking also a message context, like pgettext(), or
1749 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1754 # func_emit_po_POTFILES_in
1755 # emits the file list to be passed to xgettext to standard output.
1757 # - local_gnulib_dir from --local-dir
1758 # - sourcebase directory relative to destdir where to place source code
1759 # - files list of new files
1760 func_emit_po_POTFILES_in ()
1762 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1763 func_emit_copyright_notice
1765 echo "# List of files which contain translatable strings."
1766 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1769 # func_emit_tests_Makefile_am
1770 # emits the contents of tests makefile to standard output.
1772 # - local_gnulib_dir from --local-dir
1773 # - modules list of modules, including dependencies
1774 # - libname library name
1775 # - makefile_name from --makefile-name
1776 # - libtool true if libtool will be used, false or blank otherwise
1777 # - sourcebase relative directory containing lib source code
1778 # - m4base relative directory containing autoconf macros
1779 # - testsbase relative directory containing unit test code
1780 # - for_test true if creating a package for testing, false otherwise
1781 func_emit_tests_Makefile_am ()
1783 if test "$libtool" = true; then
1788 if test "$libtool" = true; then
1790 sed_eliminate_LDFLAGS=
1793 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1796 # When creating a package for testing: Attempt to provoke failures,
1797 # especially link errors, already during "make" rather than during
1798 # "make check", because "make check" is not possible in a cross-compiling
1799 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1800 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1802 sed_transform_check_PROGRAMS=
1804 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1805 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1806 echo "## Process this file with automake to produce Makefile.in."
1807 func_emit_copyright_notice
1809 # Generate dependencies here, since it eases the debugging of test failures.
1810 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1812 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1815 for module in $modules; do
1816 func_verify_tests_module
1817 if test -n "$module"; then
1819 func_get_automake_snippet "$module" |
1820 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1821 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1822 -e "$sed_eliminate_LDFLAGS" \
1823 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1824 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1825 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1826 -e "$sed_transform_check_PROGRAMS"
1828 # Skip the contents if its entirely empty.
1829 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1830 echo "## begin gnulib module $module"
1833 echo "## end gnulib module $module"
1840 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1841 # variable is needed to avoid an error from automake:
1842 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1845 echo "TESTS_ENVIRONMENT ="
1846 echo "noinst_PROGRAMS ="
1847 if ! $for_test; then
1848 echo "check_PROGRAMS ="
1850 echo "noinst_HEADERS ="
1851 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1852 echo "pkgdata_DATA ="
1855 echo "BUILT_SOURCES ="
1857 echo "MOSTLYCLEANFILES = core *.stackdump"
1858 echo "MOSTLYCLEANDIRS ="
1860 echo "DISTCLEANFILES ="
1861 echo "MAINTAINERCLEANFILES ="
1863 echo "AM_CPPFLAGS = \\"
1864 echo " -I. -I\$(srcdir) \\"
1865 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1866 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1868 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1871 echo "# Clean up after Solaris cc."
1873 echo " rm -rf SunWS_cache"
1875 echo "mostlyclean-local: mostlyclean-generic"
1876 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1877 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1878 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1882 rm -f allsnippets.tmp
1885 # func_emit_initmacro_start
1886 # emits the first few statements of the gl_INIT macro to standard output.
1887 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1888 func_emit_initmacro_start ()
1890 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1891 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1892 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1893 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1895 # Furthermore it avoids an automake error like this when a Makefile.am
1896 # that uses pieces of gnulib also uses $(LIBOBJ):
1897 # automatically discovered file `error.c' should not be explicitly mentioned
1898 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1899 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1900 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1901 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1902 # automatically discovered file `error.c' should not be explicitly mentioned
1903 # We let automake know about the files to be distributed through the
1904 # EXTRA_lib_SOURCES variable.
1905 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1908 # func_emit_initmacro_end
1909 # emits the last few statements of the gl_INIT macro to standard output.
1910 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1911 func_emit_initmacro_end ()
1913 echo " m4_popdef([AC_LIBSOURCES])"
1914 echo " m4_popdef([AC_REPLACE_FUNCS])"
1915 echo " m4_popdef([AC_LIBOBJ])"
1916 echo " AC_CONFIG_COMMANDS_PRE(["
1917 echo " ${macro_prefix}_libobjs="
1918 echo " ${macro_prefix}_ltlibobjs="
1919 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1920 echo " # Remove the extension."
1921 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1922 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1923 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1924 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1927 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1928 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1932 # func_emit_initmacro_done
1933 # emits a few statements after the gl_INIT macro to standard output.
1934 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1935 # - sourcebase directory relative to destdir where to place source code
1936 func_emit_initmacro_done ()
1939 echo "# Like AC_LIBOBJ, except that the module name goes"
1940 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1941 echo "AC_DEFUN([${macro_prefix}_LIBOBJ], ["
1942 echo " AS_LITERAL_IF([\$1], [${macro_prefix}_LIBSOURCES([\$1.c])])dnl"
1943 echo " ${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\""
1946 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1947 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1948 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS], ["
1949 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
1950 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])"
1953 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
1954 echo "# expected is derived from the gnulib-tool parametrization,"
1955 echo "# and alloca is special cased (for the alloca-opt module)."
1956 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
1957 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES], ["
1958 echo " m4_foreach([_gl_NAME], [\$1], ["
1959 echo " m4_if(_gl_NAME, [alloca.c], [], ["
1960 echo " m4_syscmd([test -r $sourcebase/]_gl_NAME[ || test ! -d $sourcebase])dnl"
1961 echo " m4_if(m4_sysval, [0], [],"
1962 echo " [AC_FATAL([missing $sourcebase/]_gl_NAME)])"
1968 # func_import modules
1969 # Uses also the variables
1970 # - destdir target directory
1971 # - local_gnulib_dir from --local-dir
1972 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1973 # - libname library name
1974 # - sourcebase directory relative to destdir where to place source code
1975 # - m4base directory relative to destdir where to place *.m4 macros
1976 # - pobase directory relative to destdir where to place *.po files
1977 # - docbase directory relative to destdir where to place doc files
1978 # - testsbase directory relative to destdir where to place unit test code
1979 # - auxdir directory relative to destdir where to place build aux files
1980 # - inctests true if --with-tests was given, blank otherwise
1981 # - avoidlist list of modules to avoid, from --avoid
1982 # - lgpl true if library's license shall be LGPL, blank otherwise
1983 # - makefile_name from --makefile-name
1984 # - libtool true if --libtool was given, false if --no-libtool was
1985 # given, blank otherwise
1986 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1987 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1988 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1989 # - autoconf_minversion minimum supported autoconf version
1990 # - doit : if actions shall be executed, false if only to be printed
1991 # - symbolic true if files should be symlinked, copied otherwise
1992 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1994 # - do_copyrights true if copyright notices in files should be replaced,
1998 # Get the cached settings.
1999 cached_local_gnulib_dir=
2000 cached_specified_modules=
2010 cached_makefile_name=
2012 cached_macro_prefix=
2015 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2016 cached_libtool=false
2022 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
2025 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
2028 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
2031 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
2034 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
2037 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
2040 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
2043 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
2046 s,^.*$,cached_inctests=true,p
2049 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
2052 s,^.*$,cached_lgpl=true,p
2054 /gl_MAKEFILE_NAME(/ {
2055 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
2058 s,^.*$,cached_libtool=true,p
2060 /gl_MACRO_PREFIX(/ {
2061 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2064 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2066 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2067 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2072 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2073 s,^.*$,cached_files=",p
2085 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2089 # Merge the cached settings with the specified ones.
2090 # The m4base must be the same as expected from the pathname.
2091 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2092 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2094 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2095 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2096 if test -z "$local_gnulib_dir"; then
2097 if test -n "$cached_local_gnulib_dir"; then
2100 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2102 case "$cached_local_gnulib_dir" in
2104 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2106 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2107 local_gnulib_dir="$relconcat" ;;
2112 # Append the cached and the specified module names. So that
2113 # "gnulib-tool --import foo" means to add the module foo.
2114 specified_modules="$cached_specified_modules $1"
2115 # Append the cached and the specified avoidlist. This is probably better
2116 # than dropping the cached one when --avoid is specified at least once.
2117 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2118 avoidlist=`echo $avoidlist`
2120 # The sourcebase defaults to the cached one.
2121 if test -z "$sourcebase"; then
2122 sourcebase="$cached_sourcebase"
2123 if test -z "$sourcebase"; then
2124 func_fatal_error "missing --source-base option"
2127 # The pobase defaults to the cached one.
2128 if test -z "$pobase"; then
2129 pobase="$cached_pobase"
2131 # The docbase defaults to the cached one.
2132 if test -z "$docbase"; then
2133 docbase="$cached_docbase"
2134 if test -z "$docbase"; then
2135 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."
2138 # The testsbase defaults to the cached one.
2139 if test -z "$testsbase"; then
2140 testsbase="$cached_testsbase"
2141 if test -z "$testsbase"; then
2142 func_fatal_error "missing --tests-base option"
2145 # Require the tests if specified either way.
2146 if test -z "$inctests"; then
2147 inctests="$cached_inctests"
2149 # The libname defaults to the cached one.
2150 if test -z "$supplied_libname"; then
2151 libname="$cached_libname"
2152 if test -z "$libname"; then
2153 func_fatal_error "missing --lib option"
2156 # Require LGPL if specified either way.
2157 if test -z "$lgpl"; then
2160 # The makefile_name defaults to the cached one.
2161 if test -z "$makefile_name"; then
2162 makefile_name="$cached_makefile_name"
2164 # Use libtool if specified either way, or if guessed.
2165 if test -z "$libtool"; then
2166 if test -n "$cached_m4base"; then
2167 libtool="$cached_libtool"
2169 libtool="$guessed_libtool"
2172 # The macro_prefix defaults to the cached one.
2173 if test -z "$macro_prefix"; then
2174 macro_prefix="$cached_macro_prefix"
2175 if test -z "$macro_prefix"; then
2176 func_fatal_error "missing --macro-prefix option"
2179 # The po_domain defaults to the cached one.
2180 if test -z "$po_domain"; then
2181 po_domain="$cached_po_domain"
2184 # Canonicalize the list of specified modules.
2185 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2187 # Determine final module list.
2188 modules="$specified_modules"
2189 func_modules_transitive_closure
2190 if test $verbose -ge 0; then
2191 echo "Module list with included dependencies:"
2192 echo "$modules" | sed -e 's/^/ /'
2195 # Add the dummy module if needed.
2196 func_modules_add_dummy
2198 # If --lgpl, verify that the licenses of modules are compatible.
2199 if test -n "$lgpl"; then
2200 for module in $modules; do
2201 license=`func_get_license $module`
2203 LGPL | LGPLv2+ | 'GPLed build tool') ;;
2204 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2205 *) func_fatal_error "incompatible license on module $module: $license" ;;
2210 # Show banner notice of every module.
2213 # Determine script to apply to imported library files.
2214 sed_transform_lib_file=
2215 for module in $modules; do
2216 if test $module = config-h; then
2217 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2218 sed_transform_lib_file=$sed_transform_lib_file'
2219 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2224 if test -n "$do_copyrights"; then
2225 if test -n "$lgpl"; then
2227 sed_transform_lib_file=$sed_transform_lib_file'
2228 s/GNU General/GNU Lesser General/g
2229 s/version 2\([ ,]\)/version 2.1\1/g
2234 # Determine final file list.
2235 func_modules_to_filelist
2236 if test $verbose -ge 0; then
2238 echo "$files" | sed -e 's/^/ /'
2242 || func_fatal_error "refusing to do nothing"
2244 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2245 new_files="$files m4/gnulib-tool.m4"
2246 old_files="$cached_files"
2247 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2248 func_append old_files " m4/gnulib-tool.m4"
2251 sed_rewrite_old_files="\
2252 s,^build-aux/,$auxdir/,
2253 s,^doc/,$cached_docbase/,
2254 s,^lib/,$cached_sourcebase/,
2255 s,^m4/,$cached_m4base/,
2256 s,^tests/,$cached_testsbase/,"
2257 sed_rewrite_new_files="\
2258 s,^build-aux/,$auxdir/,
2260 s,^lib/,$sourcebase/,
2262 s,^tests/,$testsbase/,"
2264 # Create directories.
2265 { echo "$sourcebase"
2267 if test -n "$pobase"; then
2270 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2271 if test -n "$docfiles"; then
2274 if test -n "$inctests"; then
2278 for f in $files; do echo $f; done \
2279 | sed -e "$sed_rewrite_new_files" \
2280 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2283 { # Rearrange file descriptors. Needed because "while ... done < ..."
2284 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2285 exec 5<&0 < "$tmp"/dirs
2287 if test ! -d "$destdir/$d"; then
2289 echo "Creating directory $destdir/$d"
2290 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2292 echo "Create directory $destdir/$d"
2299 # func_dest_tmpfilename file
2300 # determines the name of a temporary file (file is relative to destdir).
2302 # - tmpfile absolute filename of the temporary file
2303 func_dest_tmpfilename ()
2306 # Put the new contents of $file in a file in the same directory (needed
2307 # to guarantee that an 'mv' to "$destdir/$file" works).
2308 tmpfile="$destdir/$1.tmp"
2310 # Put the new contents of $file in a file in a temporary directory
2311 # (because the directory of "$file" might not exist).
2312 tmpfile="$tmp"/`basename "$1"`.tmp
2316 # Copy files or make symbolic links. Remove obsolete files.
2320 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2321 # representing the files according to the last gnulib-tool invocation.
2322 for f in $old_files; do echo $f; done \
2323 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2326 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2327 # representing the files after this gnulib-tool invocation.
2328 for f in $new_files; do echo $f; done \
2329 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2332 # First the files that are in old-files, but not in new-files:
2333 sed_take_first_column='s,'"$delimiter"'.*,,'
2334 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2335 # Remove the file. Do nothing if the user already removed it.
2336 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2338 echo "Removing file $g (backup in ${g}~)"
2339 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2341 echo "Remove file $g (backup in ${g}~)"
2343 func_append removed_files "$g$nl"
2346 # func_add_or_update handles a file that ought to be present afterwards.
2348 # - f the original file name
2349 # - g the rewritten file name
2350 # - already_present nonempty if the file already exists, empty otherwise
2351 func_add_or_update ()
2353 func_dest_tmpfilename "$g"
2354 func_lookup_file "$f"
2355 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2356 if test -n "$sed_transform_lib_file"; then
2359 sed -e "$sed_transform_lib_file" \
2360 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2364 if test -f "$destdir/$g"; then
2365 # The file already exists.
2366 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2367 : # The file has not changed.
2371 if test -n "$already_present"; then
2372 echo "Updating file $g (backup in ${g}~)"
2374 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2376 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2377 if { test -n "$symbolic" \
2378 || { test -n "$lsymbolic" \
2379 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2380 && test -z "$lookedup_tmp" \
2381 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2382 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2384 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2387 if test -n "$already_present"; then
2388 echo "Update file $g (backup in ${g}~)"
2390 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2396 # Don't protest if the file should be there but isn't: it happens
2397 # frequently that developers don't put autogenerated files into CVS.
2399 echo "Copying file $g"
2400 if { test -n "$symbolic" \
2401 || { test -n "$lsymbolic" \
2402 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2403 && test -z "$lookedup_tmp" \
2404 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2405 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2407 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2412 func_append added_files "$g$nl"
2416 # Then the files that are in new-files, but not in old-files:
2417 sed_take_last_column='s,^.*'"$delimiter"',,'
2419 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2420 | sed -e "$sed_take_last_column" \
2421 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2422 { # Rearrange file descriptors. Needed because "while ... done < ..."
2423 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2424 exec 5<&0 < "$tmp"/added-files
2430 # Then the files that are in new-files and in old-files:
2431 already_present=true
2432 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2433 | sed -e "$sed_take_last_column" \
2434 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2435 { # Rearrange file descriptors. Needed because "while ... done < ..."
2436 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2437 exec 5<&0 < "$tmp"/kept-files
2444 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2445 actioncmd="gnulib-tool --import"
2446 func_append actioncmd " --dir=$destdir"
2447 if test -n "$local_gnulib_dir"; then
2448 func_append actioncmd " --local-dir=$local_gnulib_dir"
2450 func_append actioncmd " --lib=$libname"
2451 func_append actioncmd " --source-base=$sourcebase"
2452 func_append actioncmd " --m4-base=$m4base"
2453 if test -n "$pobase"; then
2454 func_append actioncmd " --po-base=$pobase"
2456 func_append actioncmd " --doc-base=$docbase"
2457 func_append actioncmd " --aux-dir=$auxdir"
2458 if test -n "$inctests"; then
2459 func_append actioncmd " --with-tests"
2461 for module in $avoidlist; do
2462 func_append actioncmd " --avoid=$module"
2464 if test -n "$lgpl"; then
2465 func_append actioncmd " --lgpl"
2467 if test -n "$makefile_name"; then
2468 func_append actioncmd " --makefile-name=$makefile_name"
2470 if test "$libtool" = true; then
2471 func_append actioncmd " --libtool"
2473 func_append actioncmd " --no-libtool"
2475 func_append actioncmd " --macro-prefix=$macro_prefix"
2476 if test -n "$po_domain"; then
2477 func_append actioncmd " --po-domain=$po_domain"
2479 func_append actioncmd " `echo $specified_modules`"
2481 # Default the makefile name to Makefile.am.
2482 if test -n "$makefile_name"; then
2483 makefile_am=$makefile_name
2485 makefile_am=Makefile.am
2488 # Create normal Makefile.ams.
2491 # Create library makefile.
2492 func_dest_tmpfilename $sourcebase/$makefile_am
2493 func_emit_lib_Makefile_am > "$tmpfile"
2494 if test -f "$destdir"/$sourcebase/$makefile_am; then
2495 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2499 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2500 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2501 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2503 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2509 echo "Creating $sourcebase/$makefile_am"
2510 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2512 echo "Create $sourcebase/$makefile_am"
2515 func_append added_files "$sourcebase/$makefile_am$nl"
2518 # Create po/ directory.
2519 if test -n "$pobase"; then
2520 # Create po makefile and auxiliary files.
2521 for file in Makefile.in.in remove-potcdate.sin; do
2522 func_dest_tmpfilename $pobase/$file
2523 func_lookup_file build-aux/po/$file
2524 cat "$lookedup_file" > "$tmpfile"
2525 if test -f "$destdir"/$pobase/$file; then
2526 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
2530 echo "Updating $pobase/$file (backup in $pobase/$file~)"
2531 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
2532 mv -f "$tmpfile" "$destdir"/$pobase/$file
2534 echo "Update $pobase/$file (backup in $pobase/$file~)"
2540 echo "Creating $pobase/$file"
2541 mv -f "$tmpfile" "$destdir"/$pobase/$file
2543 echo "Create $pobase/$file"
2546 func_append added_files "$pobase/$file$nl"
2549 # Create po makefile parametrization, part 1.
2550 func_dest_tmpfilename $pobase/Makevars
2551 func_emit_po_Makevars > "$tmpfile"
2552 if test -f "$destdir"/$pobase/Makevars; then
2553 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
2557 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
2558 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
2559 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2561 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
2567 echo "Creating $pobase/Makevars"
2568 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2570 echo "Create $pobase/Makevars"
2573 func_append added_files "$pobase/Makevars$nl"
2575 # Create po makefile parametrization, part 2.
2576 func_dest_tmpfilename $pobase/POTFILES.in
2577 func_emit_po_POTFILES_in > "$tmpfile"
2578 if test -f "$destdir"/$pobase/POTFILES.in; then
2579 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
2583 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2584 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
2585 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2587 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2593 echo "Creating $pobase/POTFILES.in"
2594 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2596 echo "Create $pobase/POTFILES.in"
2599 func_append added_files "$pobase/POTFILES.in$nl"
2602 TP_URL="http://translationproject.org/latest/"
2603 TP_RSYNC_URI="translationproject.org::tp/latest/"
2605 echo "Fetching gnulib PO files from $TP_URL"
2606 (cd "$destdir"/$pobase \
2607 && { # Prefer rsync over wget if it is available, since it consumes
2608 # less network bandwidth, due to compression.
2609 if type rsync 2>/dev/null | grep / > /dev/null; then
2610 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
2612 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
2617 echo "Fetch gnulib PO files from $TP_URL"
2619 # Create po/LINGUAS.
2621 func_dest_tmpfilename $pobase/LINGUAS
2622 (cd "$destdir"/$pobase \
2623 && { echo '# Set of available languages.'
2624 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
2627 if test -f "$destdir"/$pobase/LINGUAS; then
2628 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
2631 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2632 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
2633 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2636 echo "Creating $pobase/LINGUAS"
2637 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2638 func_append added_files "$pobase/LINGUAS$nl"
2641 if test -f "$destdir"/$pobase/LINGUAS; then
2642 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2644 echo "Create $pobase/LINGUAS"
2649 # Create m4/gnulib-cache.m4.
2650 func_dest_tmpfilename $m4base/gnulib-cache.m4
2652 func_emit_copyright_notice
2654 echo "# This file represents the specification of how gnulib-tool is used."
2655 echo "# It acts as a cache: It is written and read by gnulib-tool."
2656 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2657 echo "# like the configure.ac and various Makefile.am files."
2660 echo "# Specification in the form of a command-line invocation:"
2663 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2664 # Store the local_gnulib_dir relative to destdir.
2665 case "$local_gnulib_dir" in
2667 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2670 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2672 # destdir, local_gnulib_dir are both relative.
2673 func_relativize "$destdir" "$local_gnulib_dir"
2674 relative_local_gnulib_dir="$reldir" ;;
2677 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2678 echo "gl_MODULES(["`echo $specified_modules`"])"
2679 echo "gl_AVOID([$avoidlist])"
2680 echo "gl_SOURCE_BASE([$sourcebase])"
2681 echo "gl_M4_BASE([$m4base])"
2682 echo "gl_PO_BASE([$pobase])"
2683 echo "gl_DOC_BASE([$docbase])"
2684 echo "gl_TESTS_BASE([$testsbase])"
2685 test -z "$inctests" || echo "gl_WITH_TESTS"
2686 echo "gl_LIB([$libname])"
2687 test -z "$lgpl" || echo "gl_LGPL"
2688 echo "gl_MAKEFILE_NAME([$makefile_name])"
2689 if test "$libtool" = true; then
2692 echo "gl_MACRO_PREFIX([$macro_prefix])"
2693 echo "gl_PO_DOMAIN([$po_domain])"
2695 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2696 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2700 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2701 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2702 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2704 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2708 echo "# gnulib-cache.m4 ends here"
2715 echo "Creating $m4base/gnulib-cache.m4"
2716 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2718 echo "Create $m4base/gnulib-cache.m4"
2724 # Create m4/gnulib-comp.m4.
2725 func_dest_tmpfilename $m4base/gnulib-comp.m4
2727 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2728 func_emit_copyright_notice
2730 echo "# This file represents the compiled summary of the specification in"
2731 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2732 echo "# to be invoked from configure.ac."
2733 echo "# In projects using CVS, this file can be treated like other built files."
2736 echo "# This macro should be invoked from $configure_ac, in the section"
2737 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2738 echo "# any checks for libraries, header files, types and library functions."
2739 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2741 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2742 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2743 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2744 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2745 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2746 if test -n "$uses_subdirs"; then
2747 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2749 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2750 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2752 for module in $modules; do
2754 if test -n "$module"; then
2755 func_get_autoconf_early_snippet "$module"
2758 | sed -e '/^$/d;' -e 's/^/ /'
2761 echo "# This macro should be invoked from $configure_ac, in the section"
2762 echo "# \"Check for header files, types and library functions\"."
2763 echo "AC_DEFUN([${macro_prefix}_INIT],"
2765 func_emit_initmacro_start
2766 if test "$libtool" = true; then
2767 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2768 echo " gl_cond_libtool=true"
2770 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2771 echo " gl_cond_libtool=false"
2773 echo " gl_ltlibdeps="
2775 echo " gl_source_base='$sourcebase'"
2776 if test "$auxdir" != "build-aux"; then
2777 sed_replace_build_aux='
2779 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2780 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2784 sed_replace_build_aux=
2786 for module in $modules; do
2788 if test -n "$module"; then
2789 func_get_autoconf_snippet "$module" \
2790 | sed -e '/^$/d;' -e 's/^/ /' \
2791 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2792 -e "$sed_replace_build_aux"
2793 if test "$module" = 'alloca' && test "$libtool" = true; then
2794 echo 'changequote(,)dnl'
2795 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2796 echo 'changequote([, ])dnl'
2797 echo 'AC_SUBST([LTALLOCA])'
2801 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2802 # created using libtool, because libtool already handles the dependencies.
2803 if test "$libtool" != true; then
2804 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
2805 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2806 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2807 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2808 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2810 func_emit_initmacro_end
2812 func_emit_initmacro_done
2814 echo "# This macro records the list of files which have been installed by"
2815 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2816 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2817 echo "$files" | sed -e 's,^, ,'
2820 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2821 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2825 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2826 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2827 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2829 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2833 echo "# gnulib-comp.m4 ends here"
2840 echo "Creating $m4base/gnulib-comp.m4"
2841 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2843 echo "Create $m4base/gnulib-comp.m4"
2849 if test -n "$inctests"; then
2850 # Create tests makefile.
2851 func_dest_tmpfilename $testsbase/$makefile_am
2852 func_emit_tests_Makefile_am > "$tmpfile"
2853 if test -f "$destdir"/$testsbase/$makefile_am; then
2854 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2858 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2859 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2860 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2862 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2868 echo "Creating $testsbase/$makefile_am"
2869 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2871 echo "Create $testsbase/$makefile_am"
2874 func_append added_files "$testsbase/$makefile_am$nl"
2878 # Update the .cvsignore and .gitignore files.
2879 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
2880 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
2881 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
2882 { # Rearrange file descriptors. Needed because "while ... done < ..."
2883 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2884 exec 5<&0 < "$tmp"/fileset-changes
2885 func_update_ignorelist ()
2888 if test -f "$destdir/$dir$ignore"; then
2889 if test -n "$dir_added" || test -n "$dir_removed"; then
2890 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
2891 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
2892 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
2893 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
2894 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
2895 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
2897 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2898 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
2899 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
2900 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
2901 | sed -f "$tmp"/sed-ignore-removed \
2902 > "$destdir/$dir$ignore"
2904 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2909 if test -n "$dir_added"; then
2911 echo "Creating $destdir/$dir$ignore"
2913 if test "$ignore" = .cvsignore; then
2915 # Automake generates Makefile rules that create .dirstamp files.
2918 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u
2919 } > "$destdir/$dir$ignore"
2921 echo "Create $destdir/$dir$ignore"
2931 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
2932 func_update_ignorelist .cvsignore
2934 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
2935 func_update_ignorelist .gitignore
2942 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
2943 next_dir=`echo "$line" | sed -e 's,|.*,,'`
2944 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
2945 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
2946 if test "$next_dir" != "$last_dir"; then
2947 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2948 last_dir="$next_dir"
2953 A) func_append last_dir_added "$file$nl";;
2954 R) func_append last_dir_removed "$file$nl";;
2957 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2963 echo "You may need to add #include directives for the following .h files."
2964 # Intersect $specified_modules and $modules
2965 # (since $specified_modules is not necessarily of subset of $modules - some
2966 # may have been skipped through --avoid, and since the elements of $modules
2967 # but not in $specified_modules can go away without explicit notice - through
2968 # changes in the module dependencies).
2969 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2970 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2971 # First the #include <...> directives without #ifs, sorted for convenience,
2972 # then the #include "..." directives without #ifs, sorted for convenience,
2973 # then the #include directives that are surrounded by #ifs. Not sorted.
2974 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2975 include_directive=`func_get_include_directive "$module"`
2976 case "$nl$include_directive" in
2978 echo "$include_directive" 1>&5
2981 echo "$include_directive" | grep -v 'include "' 1>&6
2982 echo "$include_directive" | grep 'include "' 1>&7
2985 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2987 LC_ALL=C sort -u "$tmp"/include-angles
2988 LC_ALL=C sort -u "$tmp"/include-quotes
2989 cat "$tmp"/include-if
2990 ) | sed -e '/^$/d' -e 's/^/ /'
2991 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2993 for module in $modules; do
2994 func_get_link_directive "$module"
2996 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
2997 if test `wc -l < "$tmp"/link` != 0; then
2999 echo "You may need to use the following Makefile variables when linking."
3000 echo "Use them in <program>_LDADD when linking a program, or"
3001 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3007 echo "Don't forget to"
3008 if test "$makefile_am" = Makefile.am; then
3009 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3011 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3013 if test -n "$pobase"; then
3014 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3016 if test -n "$inctests"; then
3017 if test "$makefile_am" = Makefile.am; then
3018 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3020 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3023 if test "$makefile_am" = Makefile.am; then
3024 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3025 sourcebase_base=`basename "$sourcebase"`
3026 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
3028 if test -n "$pobase"; then
3029 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3030 pobase_base=`basename "$pobase"`
3031 echo " - mention \"${pobase_base}\" in SUBDIRS in ${pobase_dir}Makefile.am,"
3033 if test -n "$inctests"; then
3034 if test "$makefile_am" = Makefile.am; then
3035 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3036 testsbase_base=`basename "$testsbase"`
3037 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
3040 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
3041 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3042 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3045 # func_create_testdir testdir modules
3047 # - local_gnulib_dir from --local-dir
3048 # - auxdir directory relative to destdir where to place build aux files
3049 func_create_testdir ()
3053 if test -z "$modules"; then
3054 # All modules together.
3055 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3056 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3057 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3058 modules=`func_all_modules`
3059 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3061 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3063 # Check that the license of every module is consistent with the license of
3065 saved_modules="$modules"
3066 saved_inctests="$inctests"
3067 # When computing transitive closures, don't consider $module to depend on
3068 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3069 # on GPL modules - therefore we don't want a warning in this case.
3071 for requested_module in $saved_modules; do
3072 requested_license=`func_get_license "$requested_module"`
3073 if test "$requested_license" != GPL; then
3074 # Here we use func_modules_transitive_closure, not just
3075 # func_get_dependencies, so that we also detect weird situations like
3076 # an LGPL module which depends on a GPLed build tool module which depends
3078 modules="$requested_module"
3079 func_modules_transitive_closure
3080 for module in $modules; do
3081 license=`func_get_license "$module"`
3083 'GPLed build tool') ;;
3084 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3086 case "$requested_license" in
3089 GPLv2+ | LGPLv2+) ;;
3090 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3096 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3102 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3111 modules="$saved_modules"
3112 inctests="$saved_inctests"
3114 # Subdirectory names.
3123 # Determine final module list.
3124 func_modules_transitive_closure
3125 if test $verbose -ge 0; then
3126 echo "Module list with included dependencies:"
3127 echo "$modules" | sed -e 's/^/ /'
3130 # Add the dummy module if needed.
3131 func_modules_add_dummy
3133 # Show banner notice of every module.
3136 # Determine final file list.
3137 func_modules_to_filelist
3138 if test $verbose -ge 0; then
3140 echo "$files" | sed -e 's/^/ /'
3143 sed_rewrite_files="\
3144 s,^build-aux/,$auxdir/,
3146 s,^lib/,$sourcebase/,
3148 s,^tests/,$testsbase/,"
3150 # Create directories.
3151 for f in $files; do echo $f; done \
3152 | sed -e "$sed_rewrite_files" \
3153 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3154 | LC_ALL=C sort -u \
3156 { # Rearrange file descriptors. Needed because "while ... done < ..."
3157 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3158 exec 5<&0 < "$tmp"/dirs
3160 mkdir -p "$testdir/$d"
3165 # Copy files or make symbolic links.
3167 for f in $files; do echo $f; done \
3168 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3171 { # Rearrange file descriptors. Needed because "while ... done < ..."
3172 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3173 exec 5<&0 < "$tmp"/files
3175 func_lookup_file "$f"
3176 if test -n "$lookedup_tmp"; then
3177 cp -p "$lookedup_file" "$testdir/$g"
3179 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3180 if { test -n "$symbolic" \
3181 || { test -n "$lsymbolic" \
3182 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3183 func_ln "$lookedup_file" "$testdir/$g"
3185 cp -p "$lookedup_file" "$testdir/$g"
3192 # Create Makefile.ams that are for testing.
3195 # Create $sourcebase/Makefile.am.
3196 mkdir -p "$testdir/$sourcebase"
3197 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3199 # Create $m4base/Makefile.am.
3200 mkdir -p "$testdir/$m4base"
3201 (echo "## Process this file with automake to produce Makefile.in."
3207 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3210 ) > "$testdir/$m4base/Makefile.am"
3212 subdirs="$sourcebase $m4base"
3213 subdirs_with_configure_ac=""
3215 if false && test -f "$testdir"/$m4base/gettext.m4; then
3216 # Avoid stupid error message from automake:
3217 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3218 mkdir -p "$testdir/po"
3219 (echo "## Process this file with automake to produce Makefile.in."
3220 ) > "$testdir/po/Makefile.am"
3221 func_append subdirs " po"
3224 if test -n "$inctests"; then
3225 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3226 # Create $testsbase/Makefile.am.
3227 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3228 # Create $testsbase/configure.ac.
3229 (echo "# Process this file with autoconf to produce a configure script."
3230 echo "AC_INIT([dummy], [0])"
3231 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
3232 echo "AM_INIT_AUTOMAKE"
3234 echo "AM_CONFIG_HEADER([config.h])"
3237 echo "AC_PROG_INSTALL"
3238 echo "AC_PROG_MAKE_SET"
3239 echo "AC_PROG_RANLIB"
3241 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3242 echo "AC_GNU_SOURCE"
3245 for module in $modules; do
3247 if test -n "$module"; then
3248 func_get_autoconf_early_snippet "$module"
3251 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3252 if test "$libtool" = true; then
3253 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3254 echo "gl_cond_libtool=true"
3256 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3257 echo "gl_cond_libtool=false"
3259 echo "gl_ltlibdeps="
3261 # 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 sed_replace_build_aux='
3272 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3273 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
3276 # We don't have explicit ordering constraints between the various
3277 # autoconf snippets. It's cleanest to put those of the library before
3278 # those of the tests.
3279 echo "gl_source_base='../$sourcebase'"
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 echo "gl_source_base='.'"
3288 for module in $modules; do
3289 func_verify_tests_module
3290 if test -n "$module"; then
3291 func_get_autoconf_snippet "$module" \
3292 | sed -e "$sed_replace_build_aux"
3295 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3296 # created using libtool, because libtool already handles the dependencies.
3297 if test "$libtool" != true; then
3298 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3299 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3300 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3301 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3302 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3304 func_emit_initmacro_end
3306 func_emit_initmacro_done
3310 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3311 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3312 echo "AH_TOP([#include \"../config.h\"])"
3314 echo "AC_OUTPUT([Makefile])"
3315 ) > "$testdir/$testsbase/configure.ac"
3316 func_append subdirs " $testsbase"
3317 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3320 # Create Makefile.am.
3321 (echo "## Process this file with automake to produce Makefile.in."
3323 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3325 echo "SUBDIRS = $subdirs"
3327 echo "ACLOCAL_AMFLAGS = -I $m4base"
3328 ) > "$testdir/Makefile.am"
3330 # Create configure.ac.
3331 (echo "# Process this file with autoconf to produce a configure script."
3332 echo "AC_INIT([dummy], [0])"
3333 if test "$auxdir" != "."; then
3334 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3336 echo "AM_INIT_AUTOMAKE"
3338 echo "AM_CONFIG_HEADER([config.h])"
3341 echo "AC_PROG_INSTALL"
3342 echo "AC_PROG_MAKE_SET"
3344 echo "# For autobuild."
3345 echo "AC_CANONICAL_BUILD"
3346 echo "AC_CANONICAL_HOST"
3348 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3349 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3350 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3351 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3353 echo "AC_PROG_RANLIB"
3355 if test -n "$uses_subdirs"; then
3356 echo "AM_PROG_CC_C_O"
3359 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3360 echo "AC_GNU_SOURCE"
3363 for module in $modules; do
3364 func_verify_nontests_module
3365 if test -n "$module"; then
3366 func_get_autoconf_early_snippet "$module"
3369 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3370 if test "$libtool" = true; then
3371 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3372 echo "gl_cond_libtool=true"
3374 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3375 echo "gl_cond_libtool=false"
3377 echo "gl_ltlibdeps="
3379 echo "gl_source_base='$sourcebase'"
3380 # Wrap the set of autoconf snippets into an autoconf macro that is then
3381 # invoked. This is needed because autoconf does not support AC_REQUIRE
3383 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3384 # but we want the AC_REQUIRE to have its normal meaning (provide one
3385 # expansion of the required macro before the current point, and only one
3387 echo "AC_DEFUN([gl_INIT], ["
3388 func_emit_initmacro_start
3389 if test "$auxdir" != "build-aux"; then
3390 sed_replace_build_aux='
3392 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3393 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3397 sed_replace_build_aux=
3399 for module in $modules; do
3400 func_verify_nontests_module
3401 if test -n "$module"; then
3402 func_get_autoconf_snippet "$module" \
3403 | sed -e "$sed_replace_build_aux"
3406 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3407 # created using libtool, because libtool already handles the dependencies.
3408 if test "$libtool" != true; then
3409 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3410 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3411 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3412 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3413 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3415 func_emit_initmacro_end
3417 func_emit_initmacro_done
3421 if test -n "$subdirs_with_configure_ac"; then
3422 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3424 makefiles="Makefile"
3425 for d in $subdirs; do
3426 # For subdirs that have a configure.ac by their own, it's the subdir's
3427 # configure.ac which creates the subdir's Makefile.am, not this one.
3428 case " $subdirs_with_configure_ac " in
3430 *) func_append makefiles " $d/Makefile" ;;
3433 echo "AC_OUTPUT([$makefiles])"
3434 ) > "$testdir/configure.ac"
3436 # Create autogenerated files.
3438 # Do not use "${AUTORECONF} --force --install", because it may invoke
3439 # autopoint, which brings in older versions of some of our .m4 files.
3440 if test -f $m4base/gettext.m4; then
3441 func_execute_command ${AUTOPOINT} --force || func_exit 1
3442 for f in $m4base/*.m4~; do
3443 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3446 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
3447 if ! test -d build-aux; then
3448 func_execute_command mkdir build-aux || func_exit 1
3450 func_execute_command ${AUTOCONF} || func_exit 1
3451 func_execute_command ${AUTOHEADER} || func_exit 1
3452 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3454 if test -n "$inctests"; then
3455 # Create autogenerated files.
3456 (cd "$testdir/$testsbase" || func_exit 1
3457 # Do not use "${AUTORECONF} --force --install", because it may invoke
3458 # autopoint, which brings in older versions of some of our .m4 files.
3459 if test -f ../$m4base/gettext.m4; then
3460 func_execute_command ${AUTOPOINT} --force || func_exit 1
3461 for f in ../$m4base/*.m4~; do
3462 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3465 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
3466 if ! test -d ../build-aux; then
3467 func_execute_command mkdir ../build-aux
3469 func_execute_command ${AUTOCONF} || func_exit 1
3470 func_execute_command ${AUTOHEADER} || func_exit 1
3471 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3474 # Need to run configure and make once, to create built files that are to be
3475 # distributed (such as getdate.c).
3476 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3477 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3478 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3479 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3480 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3481 # such $(FOO_H) because they don't refer to distributed files.
3482 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3483 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3484 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3485 | sed -e "$sed_remove_make_variables"`
3486 distributed_built_sources=`for file in $built_sources; do
3487 case "$cleaned_files" in
3492 if test -n "$distributed_built_sources"; then
3494 ./configure || func_exit 1
3496 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3497 make built_sources || func_exit 1
3499 make distclean || func_exit 1
3504 # func_create_megatestdir megatestdir allmodules
3506 # - local_gnulib_dir from --local-dir
3507 # - auxdir directory relative to destdir where to place build aux files
3508 func_create_megatestdir ()
3512 if test -z "$allmodules"; then
3513 allmodules=`func_all_modules`
3517 # First, all modules one by one.
3518 for onemodule in $allmodules; do
3519 func_create_testdir "$megatestdir/$onemodule" $onemodule
3520 func_append megasubdirs "$onemodule "
3522 # Then, all modules all together.
3523 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3524 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3525 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3526 func_create_testdir "$megatestdir/ALL" "$allmodules"
3527 func_append megasubdirs "ALL"
3530 cvsdate=`sh "$gnulib_dir/build-aux/mdate-sh" "$gnulib_dir/CVS/Entries" \
3531 | sed -e 's,January,01,' -e 's,Jan,01,' \
3532 -e 's,February,02,' -e 's,Feb,02,' \
3533 -e 's,March,03,' -e 's,Mar,03,' \
3534 -e 's,April,04,' -e 's,Apr,04,' \
3536 -e 's,June,06,' -e 's,Jun,06,' \
3537 -e 's,July,07,' -e 's,Jul,07,' \
3538 -e 's,August,08,' -e 's,Aug,08,' \
3539 -e 's,September,09,' -e 's,Sep,09,' \
3540 -e 's,October,10,' -e 's,Oct,10,' \
3541 -e 's,November,11,' -e 's,Nov,11,' \
3542 -e 's,December,12,' -e 's,Dec,12,' \
3543 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3544 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3546 echo "CVSDATE=$cvsdate"
3547 echo "test -d logs || mkdir logs"
3548 echo "for module in $megasubdirs; do"
3549 echo " echo \"Working on module \$module...\""
3550 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3551 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3554 echo " : autobuild project... \$module"
3555 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3556 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3557 echo " : autobuild hostname... \`hostname\`"
3558 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3560 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3562 ) > "$megatestdir/do-autobuild"
3563 chmod a+x "$megatestdir/do-autobuild"
3565 # Create Makefile.am.
3566 (echo "## Process this file with automake to produce Makefile.in."
3568 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3570 echo "SUBDIRS = $megasubdirs"
3572 echo "EXTRA_DIST = do-autobuild"
3573 ) > "$megatestdir/Makefile.am"
3575 # Create configure.ac.
3576 (echo "# Process this file with autoconf to produce a configure script."
3577 echo "AC_INIT([dummy], [0])"
3578 if test "$auxdir" != "."; then
3579 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3581 echo "AM_INIT_AUTOMAKE"
3583 echo "AC_PROG_MAKE_SET"
3585 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3586 echo "AC_OUTPUT([Makefile])"
3587 ) > "$megatestdir/configure.ac"
3589 # Create autogenerated files.
3591 # Do not use "${AUTORECONF} --install", because autoreconf operates
3592 # recursively, but the subdirectories are already finished, therefore
3593 # calling autoreconf here would only waste lots of CPU time.
3594 func_execute_command ${ACLOCAL} || func_exit 1
3595 func_execute_command mkdir build-aux
3596 func_execute_command ${AUTOCONF} || func_exit 1
3597 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3603 func_fatal_error "no mode specified" ;;
3612 if test -z "$destdir"; then
3615 test -d "$destdir" \
3616 || func_fatal_error "destination directory does not exist: $destdir"
3618 # Prefer configure.ac to configure.in.
3619 if test -f "$destdir"/configure.ac; then
3620 configure_ac="$destdir/configure.ac"
3622 if test -f "$destdir"/configure.in; then
3623 configure_ac="$destdir/configure.in"
3625 func_fatal_error "cannot find $destdir/configure.ac"
3629 # Analyze configure.ac.
3631 guessed_libtool=false
3636 /AC_CONFIG_AUX_DIR/ {
3637 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3639 /A[CM]_PROG_LIBTOOL/ {
3640 s,^.*$,guessed_libtool=true,p
3642 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3644 if test -z "$auxdir"; then
3645 auxdir="$guessed_auxdir"
3648 # Determine where to apply func_import.
3649 if test -n "$m4base"; then
3650 # Apply func_import to a particular gnulib directory.
3651 # Any number of additional modules can be given.
3652 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3653 # First use of gnulib in the given m4base.
3654 test -n "$supplied_libname" || supplied_libname=true
3655 test -n "$sourcebase" || sourcebase="lib"
3656 test -n "$docbase" || docbase="doc"
3657 test -n "$testsbase" || testsbase="tests"
3658 test -n "$macro_prefix" || macro_prefix="gl"
3662 # Apply func_import to all gnulib directories.
3663 # To get this list of directories, look at Makefile.am. (Not at
3664 # configure, because it may be omitted from CVS. Also, don't run
3665 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3668 if test -f "$destdir"/Makefile.am; then
3669 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3671 for arg in $aclocal_amflags; do
3672 if test -n "$m4dir_is_next"; then
3673 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3677 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3678 func_append m4dirs " $arg"
3679 m4dirs_count=`expr $m4dirs_count + 1`
3685 if test "X$arg" = "X-I"; then
3693 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3694 if test -f "$destdir"/aclocal.m4; then
3695 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3696 sedexpr2='s,^[^/]*$,.,'
3697 sedexpr3='s,/[^/]*$,,'
3698 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3699 m4dirs_count=`echo "$m4dirs" | wc -l`
3702 if test $m4dirs_count = 0; then
3703 # First use of gnulib in a package.
3704 # Any number of additional modules can be given.
3705 test -n "$supplied_libname" || supplied_libname=true
3706 test -n "$sourcebase" || sourcebase="lib"
3708 test -n "$docbase" || docbase="doc"
3709 test -n "$testsbase" || testsbase="tests"
3710 test -n "$macro_prefix" || macro_prefix="gl"
3713 if test $m4dirs_count = 1; then
3714 # There's only one use of gnulib here. Assume the user means it.
3715 # Any number of additional modules can be given.
3716 for m4base in $m4dirs; do
3720 # Ambiguous - guess what the user meant.
3721 if test $# = 0; then
3722 # No further arguments. Guess the user wants to update all of them.
3723 for m4base in $m4dirs; do
3724 # Perform func_import in a subshell, so that variable values
3726 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
3727 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
3728 # libtool, macro_prefix, po_domain
3729 # don't propagate from one directory to another.
3730 (func_import) || func_exit 1
3734 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
3742 if test -z "$destdir"; then
3743 func_fatal_error "please specify --dir option"
3746 test -d "$destdir" \
3747 || func_fatal_error "could not create destination directory"
3748 test -n "$auxdir" || auxdir="build-aux"
3749 func_create_testdir "$destdir" "$*"
3752 create-megatestdir )
3753 if test -z "$destdir"; then
3754 func_fatal_error "please specify --dir option"
3756 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3757 test -n "$auxdir" || auxdir="build-aux"
3758 func_create_megatestdir "$destdir" "$*"
3762 test -n "$destdir" || destdir=testdir$$
3763 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3764 test -n "$auxdir" || auxdir="build-aux"
3765 func_create_testdir "$destdir" "$*"
3769 ../configure || func_exit 1
3771 make check || func_exit 1
3772 make distclean || func_exit 1
3773 remaining=`find . -type f -print`
3774 if test -n "$remaining"; then
3775 echo "Remaining files:" $remaining 1>&2
3776 echo "gnulib-tool: *** Stop." 1>&2
3785 test -n "$destdir" || destdir=testdir$$
3786 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3787 test -n "$auxdir" || auxdir="build-aux"
3788 func_create_megatestdir "$destdir" "$*"
3796 remaining=`find . -type f -print`
3797 if test -n "$remaining"; then
3798 echo "Remaining files:" $remaining 1>&2
3799 echo "gnulib-tool: *** Stop." 1>&2
3807 extract-description )
3811 if test -n "$module"; then
3812 func_get_description "$module"
3821 if test -n "$module"; then
3822 func_get_notice "$module"
3831 if test -n "$module"; then
3832 func_get_filelist "$module"
3837 extract-dependencies )
3841 if test -n "$module"; then
3842 func_get_dependencies "$module"
3847 extract-autoconf-snippet )
3851 if test -n "$module"; then
3852 func_get_autoconf_snippet "$module"
3857 extract-automake-snippet )
3861 if test -n "$module"; then
3862 func_get_automake_snippet "$module"
3867 extract-include-directive )
3871 if test -n "$module"; then
3872 func_get_include_directive "$module"
3877 extract-link-directive )
3881 if test -n "$module"; then
3882 func_get_link_directive "$module"
3891 if test -n "$module"; then
3892 func_get_license "$module"
3897 extract-maintainer )
3901 if test -n "$module"; then
3902 func_get_maintainer "$module"
3907 extract-tests-module )
3911 if test -n "$module"; then
3912 func_get_tests_module "$module"
3918 func_fatal_error "unknown operation mode --$mode" ;;
3922 # Undo the effect of the previous 'trap' command. Some shellology:
3923 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3924 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3925 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3926 # 128 + signal number and is set before the trap-registered command is run.
3928 trap 'func_exit $?' 1 2 3 13 15
3933 # indent-tabs-mode: nil
3934 # whitespace-check-buffer-indent: nil