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-06-23 09:52:09 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
32 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
36 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
37 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
41 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
44 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
47 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
48 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
49 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
50 AUTOCONF="${AUTOCONFPATH}autoconf"
52 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
53 AUTOHEADER="${AUTOCONFPATH}autoheader"
55 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
56 ACLOCAL="${AUTOMAKEPATH}aclocal"
58 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
59 AUTOMAKE="${AUTOMAKEPATH}automake"
61 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
62 AUTORECONF="${AUTOCONFPATH}autoreconf"
65 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
66 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
67 AUTOPOINT="${GETTEXTPATH}autopoint"
70 # When using GNU sed, turn off as many GNU extensions as possible,
71 # to minimize the risk of accidentally using non-portable features.
72 # However, do this only for gnulib-tool itself, not for the code that
73 # gnulib-tool generates, since we don't want "sed --posix" to leak
75 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
76 alias sed='sed --posix'
80 # outputs to stdout the --help usage message.
84 Usage: gnulib-tool --list
85 gnulib-tool --import [module1 ... moduleN]
87 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
88 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
89 gnulib-tool --test --dir=directory module1 ... moduleN
90 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
91 gnulib-tool --extract-description module
92 gnulib-tool --extract-filelist module
93 gnulib-tool --extract-dependencies module
94 gnulib-tool --extract-autoconf-snippet module
95 gnulib-tool --extract-automake-snippet module
96 gnulib-tool --extract-include-directive module
97 gnulib-tool --extract-link-directive module
98 gnulib-tool --extract-license module
99 gnulib-tool --extract-maintainer module
100 gnulib-tool --extract-tests-module module
103 --list print the available module names
104 --import import the given modules into the current package;
105 if no modules are specified, update the current
106 package from the current gnulib
107 --update update the current package, restore files omitted
109 --create-testdir create a scratch package with the given modules
110 --create-megatestdir create a mega scratch package with the given modules
111 one by one and all together
112 --test test the combination of the given modules
113 (recommended to use CC=\"gcc -Wall\" here)
114 --megatest test the given modules one by one and all together
115 (recommended to use CC=\"gcc -Wall\" here)
116 --extract-description extract the description
117 --extract-filelist extract the list of files
118 --extract-dependencies extract the dependencies
119 --extract-autoconf-snippet extract the snippet for configure.ac
120 --extract-automake-snippet extract the snippet for library makefile
121 --extract-include-directive extract the #include directive
122 --extract-link-directive extract the linker directive
123 --extract-license report the license terms of the source files
125 --extract-maintainer report the maintainer(s) inside gnulib
126 --extract-tests-module report the unit test module, if it exists
129 --dir=DIRECTORY Specify the target directory.
130 For --import, this specifies where your
131 configure.ac can be found. Defaults to current
133 --local-dir=DIRECTORY Specify a local override directory where to look
134 up files before looking in gnulib's directory.
136 Options for --import:
137 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
138 --source-base=DIRECTORY
139 Directory relative to --dir where source code is
140 placed (default \"lib\").
141 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
142 placed (default \"m4\").
143 --doc-base=DIRECTORY Directory relative to --dir where doc files are
144 placed (default \"doc\").
145 --tests-base=DIRECTORY
146 Directory relative to --dir where unit tests are
147 placed (default \"tests\").
148 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
149 tools are placed (default \"build-aux\").
150 --with-tests Include unit tests for the included modules.
151 --avoid=MODULE Avoid including the given MODULE. Useful if you
152 have code that provides equivalent functionality.
153 This option can be repeated.
154 --lgpl Abort if modules aren't available under the LGPL.
155 Also modify license template from GPL to LGPL.
156 --makefile-name=NAME Name of makefile in automake syntax in the
157 source-base and tests-base directories
158 (default \"Makefile.am\").
159 --libtool Use libtool rules.
160 --no-libtool Don't use libtool rules.
161 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
162 'gl_INIT'. Default is 'gl'.
163 --no-changelog don't update or create ChangeLog files
165 Options for --import and --update:
166 --dry-run For --import, only print what would have been done.
167 -s, --symbolic, --symlink Make symbolic links instead of copying files.
168 --local-symlink Make symbolic links instead of copying files, only
169 for files from the local override directory.
171 Report bugs to <bug-gnulib@gnu.org>."
175 # outputs to stdout the --version message.
178 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
180 $progname (GNU $package) $version
181 Copyright (C) $year Free Software Foundation, Inc.
182 This is free software; see the source for copying conditions. There is NO
183 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
184 Written by" "Bruno Haible" "and" "Simon Josefsson"
187 # func_emit_copyright_notice
188 # outputs to stdout a header for a generated file.
189 func_emit_copyright_notice ()
191 echo "# Copyright (C) 2004-2007 Free Software Foundation, Inc."
193 echo "# This file is free software, distributed under the terms of the GNU"
194 echo "# General Public License. As a special exception to the GNU General"
195 echo "# Public License, this file may be distributed as part of a program"
196 echo "# that contains a configuration script generated by Autoconf, under"
197 echo "# the same distribution terms as the rest of that program."
199 echo "# Generated by gnulib-tool."
210 # creates a temporary directory.
212 # - tmp pathname of freshly created temporary directory
215 # Use the environment variable TMPDIR, falling back to /tmp. This allows
216 # users to specify a different temporary directory, for example, if their
217 # /tmp is filled up or too small.
220 # Use the mktemp program if available. If not available, hide the error
222 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
223 test -n "$tmp" && test -d "$tmp"
226 # Use a simple mkdir command. It is guaranteed to fail if the directory
227 # already exists. $RANDOM is bash specific and expands to empty in shells
228 # other than bash, ksh and zsh. Its use does not increase security;
229 # rather, it minimizes the probability of failure in a very cluttered /tmp
231 tmp=$TMPDIR/gl$$-$RANDOM
232 (umask 077 && mkdir "$tmp")
235 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
240 # func_append var value
241 # appends the given value to the shell variable var.
242 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
243 # Use bash's += operator. It reduces complexity of appending repeatedly to
244 # a single variable from O(n^2) to O(n).
252 eval "$1=\"\$$1\$2\""
256 # func_fatal_error message
257 # outputs to stderr a fatal error message, and terminates the program.
260 echo "gnulib-tool: *** $1" 1>&2
261 echo "gnulib-tool: *** Stop." 1>&2
265 # func_readlink SYMLINK
266 # outputs the target of the given symlink.
267 if (type -p readlink) > /dev/null 2>&1; then
270 # Use the readlink program from GNU coreutils.
276 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
277 # would do the wrong thing if the link target contains " -> ".
278 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
282 # func_relativize DIR1 DIR2
283 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
285 # - DIR1 relative pathname, relative to the current directory
286 # - DIR2 relative pathname, relative to the current directory
288 # - reldir relative pathname of DIR2, relative to DIR1
294 sed_first='s,^\([^/]*\)/.*$,\1,'
295 sed_rest='s,^[^/]*/*,,'
296 sed_last='s,^.*/\([^/]*\)$,\1,'
297 sed_butlast='s,/*[^/]*$,,'
298 while test -n "$dir1"; do
299 first=`echo "$dir1" | sed -e "$sed_first"`
300 if test "$first" != "."; then
301 if test "$first" = ".."; then
302 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
303 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
305 first2=`echo "$dir2" | sed -e "$sed_first"`
306 if test "$first2" = "$first"; then
307 dir2=`echo "$dir2" | sed -e "$sed_rest"`
311 dir0="$dir0"/"$first"
314 dir1=`echo "$dir1" | sed -e "$sed_rest"`
319 # func_relconcat DIR1 DIR2
320 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
322 # - DIR1 relative pathname, relative to the current directory
323 # - DIR2 relative pathname, relative to DIR1
325 # - relconcat DIR1/DIR2, relative to the current directory
330 sed_first='s,^\([^/]*\)/.*$,\1,'
331 sed_rest='s,^[^/]*/*,,'
332 sed_last='s,^.*/\([^/]*\)$,\1,'
333 sed_butlast='s,/*[^/]*$,,'
335 first=`echo "$dir2" | sed -e "$sed_first"`
336 if test "$first" = "."; then
337 dir2=`echo "$dir2" | sed -e "$sed_rest"`
338 if test -z "$dir2"; then
343 last=`echo "$dir1" | sed -e "$sed_last"`
344 while test "$last" = "."; do
345 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
346 last=`echo "$dir1" | sed -e "$sed_last"`
348 if test -z "$dir1"; then
352 if test "$first" = ".."; then
353 if test "$last" = ".."; then
354 relconcat="$dir1/$dir2"
357 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
358 dir2=`echo "$dir2" | sed -e "$sed_rest"`
359 if test -z "$dir1"; then
363 if test -z "$dir2"; then
368 relconcat="$dir1/$dir2"
376 # Like ln -s, except that SRC is given relative to the current directory (or
377 # absolute), not given relative to the directory of DEST.
383 *) # SRC is relative.
386 ln -s "`pwd`/$1" "$2" ;;
387 *) # DEST is relative too.
388 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
389 test -n "$ln_destdir" || ln_destdir="."
390 func_relativize "$ln_destdir" "$1"
398 # func_ln_if_changed SRC DEST
399 # Like func_ln, but avoids munging timestamps if the link is correct.
400 func_ln_if_changed ()
402 if test $# -ne 2; then
403 echo "usage: func_ln_if_changed SRC DEST" >&2
405 ln_target=`func_readlink "$2"`
406 if test -L "$2" && test "$1" = "$ln_target"; then
414 # Ensure an 'echo' command that does not interpret backslashes.
416 # echo '\n' | wc -l prints 1 when OK, 2 when KO
417 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
418 # This problem is a weird heritage from SVR4. BSD got it right (except that
419 # BSD echo interprets '-n' as an option, which is also not desirable).
420 # Nowadays the problem occurs in 4 situations:
421 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
422 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
423 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
424 # - in zsh, when sh-emulation is not set,
425 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
426 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
427 # - in Solaris /bin/sh and OSF/1 /bin/sh.
428 # We try the following workarounds:
429 # - for all: respawn using $CONFIG_SHELL if that is set and works.
430 # - for bash >= 2.04: unset the shell option xpg_echo.
431 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
432 # - for bash < 2.0: define echo to a function that uses cat of a here document.
433 # - for zsh: turn sh-emulation on.
434 # - for ksh: alias echo to a function that uses cat of a here document.
435 # - for Solaris /bin/sh: respawn using /bin/ksh and rely on the ksh workaround.
436 # - otherwise: respawn using /bin/sh and rely on the workarounds.
437 # When respawning, we pass --no-reexec as first argument, so as to avoid
438 # turning this script into a fork bomb in unlucky situations.
440 if echo '\t' | grep t > /dev/null; then
441 have_echo=yes # Lucky!
443 # Try the workarounds.
444 # Respawn using $CONFIG_SHELL if that is set and works.
445 if test -z "$have_echo" \
446 && test "X$1" != "X--no-reexec" \
447 && test -n "$CONFIG_SHELL" \
448 && test -f "$CONFIG_SHELL" \
449 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
450 exec $CONFIG_SHELL "$0" --no-reexec "$@"
453 # For bash >= 2.04: unset the shell option xpg_echo.
454 if test -z "$have_echo" \
455 && test -n "$BASH_VERSION" \
456 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
460 # For bash >= 2.0: define echo to a function that uses the printf built-in.
461 # For bash < 2.0: define echo to a function that uses cat of a here document.
462 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
463 if test -z "$have_echo" \
464 && test -n "$BASH_VERSION"; then \
465 if type printf 2>/dev/null | grep / > /dev/null; then
466 # 'printf' is not a shell built-in.
474 # 'printf' is a shell built-in. Now it's safe to define 'echo'.
480 if echo '\t' | grep t > /dev/null; then
484 # For zsh: turn sh-emulation on.
485 if test -z "$have_echo" \
486 && test -n "$ZSH_VERSION" \
487 && (emulate sh) >/dev/null 2>&1; then
490 # For ksh: alias echo to a function that uses cat of a here document.
491 # The ksh manual page says:
492 # "Aliasing is performed when scripts are read, not while they are executed.
493 # Therefore, for an alias to take effect, the alias definition command has
494 # to be executed before the command which references the alias is read."
495 # Because of this, we have to play strange tricks with have_echo, to ensure
496 # that the top-level statement containing the test starts after the 'alias'
498 if test -z "$have_echo"; then
505 alias echo=bsd_echo 2>/dev/null
507 if test -z "$have_echo" \
508 && echo '\t' | grep t > /dev/null; then
511 if test -z "$have_echo"; then
512 unalias echo 2>/dev/null
514 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
515 if test -z "$have_echo" \
516 && test "X$1" != "X--no-reexec" \
517 && test -f /bin/ksh; then
518 exec /bin/ksh "$0" --no-reexec "$@"
521 # Otherwise: respawn using /bin/sh.
522 if test -z "$have_echo" \
523 && test "X$1" != "X--no-reexec" \
524 && test -f /bin/sh; then
525 exec /bin/sh "$0" --no-reexec "$@"
528 if test -z "$have_echo"; then
529 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
531 if echo '\t' | grep t > /dev/null; then
534 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
536 if test "X$1" = "X--no-reexec"; then
540 # Command-line option processing.
541 # Removes the OPTIONS from the arguments. Sets the variables:
542 # - mode list or import or create-testdir or create-megatestdir
543 # - destdir from --dir
544 # - local_gnulib_dir from --local-dir
545 # - libname, supplied_libname from --lib
546 # - sourcebase from --source-base
547 # - m4base from --m4-base
548 # - docbase from --doc-base
549 # - testsbase from --tests-base
550 # - auxdir from --aux-dir
551 # - inctests true if --with-tests was given, blank otherwise
552 # - avoidlist list of modules to avoid, from --avoid
553 # - lgpl true if --lgpl was given, blank otherwise
554 # - makefile_name from --makefile-name
555 # - libtool true if --libtool was given, false if --no-libtool was
556 # given, blank otherwise
557 # - macro_prefix from --macro-prefix
558 # - autoconf_minversion minimum supported autoconf version
559 # - do_changelog false if --no-changelog was given, : otherwise
560 # - doit : if actions shall be executed, false if only to be printed
561 # - symbolic true if --symlink was given, blank otherwise
562 # - lsymbolic true if --local-symlink was given, blank otherwise
587 while test $# -gt 0; do
592 --import | --impor | --impo | --imp | --im | --i )
595 --update | --updat | --upda | --upd | --up | --u )
598 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
601 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
602 mode=create-megatestdir
604 --test | --tes | --te | --t )
607 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
611 mode=`echo "X$1" | sed -e 's/^X--//'`
616 func_fatal_error "missing argument for --dir"
621 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
626 func_fatal_error "missing argument for --local-dir"
631 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
636 func_fatal_error "missing argument for --lib"
639 supplied_libname=true
642 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
643 supplied_libname=true
648 func_fatal_error "missing argument for --source-base"
653 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
658 func_fatal_error "missing argument for --m4-base"
663 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
668 func_fatal_error "missing argument for --doc-base"
673 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
678 func_fatal_error "missing argument for --tests-base"
683 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
688 func_fatal_error "missing argument for --aux-dir"
693 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
701 func_fatal_error "missing argument for --avoid"
703 func_append avoidlist " $1"
706 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
707 func_append avoidlist " $arg"
715 func_fatal_error "missing argument for --makefile-name"
720 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
731 func_fatal_error "missing argument for --macro-prefix"
736 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
738 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
744 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
747 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
750 --help | --hel | --he | --h )
753 --version | --versio | --versi | --vers | --ver | --ve | --v )
757 # Stop option processing
761 echo "gnulib-tool: unknown option $1" 1>&2
762 echo "Try 'gnulib-tool --help' for more information." 1>&2
769 if test "$mode" = update; then
770 if test $# != 0; then
771 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
772 echo "Try 'gnulib-tool --help' for more information." 1>&2
773 echo "If you really want to modify the gnulib configuration of your project," 1>&2
774 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
777 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
778 || test -n "$sourcebase" || test -n "$m4base" \
779 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
780 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
781 || test -n "$makefile_name" || test -n "$macro_prefix"; then
782 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
783 echo "Try 'gnulib-tool --help' for more information." 1>&2
784 echo "If you really want to modify the gnulib configuration of your project," 1>&2
785 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
791 # Determine the minimum supported autoconf version from the project's
793 DEFAULT_AUTOCONF_MINVERSION="2.59"
796 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
797 if test -f "$destdir"/configure.ac; then
798 configure_ac="$destdir/configure.ac"
800 if test -f "$destdir"/configure.in; then
801 configure_ac="$destdir/configure.in"
805 if test -f configure.ac; then
806 configure_ac="configure.ac"
808 if test -f configure.in; then
809 configure_ac="configure.in"
813 if test -n "$configure_ac"; then
814 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
815 # because when some m4 files are omitted from a CVS repository,
816 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
817 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
818 # autom4te: m4 failed with exit status: 1
825 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
827 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
828 if test -n "$prereqs"; then
829 autoconf_minversion=`
830 for version in $prereqs; do echo $version; done |
831 LC_ALL=C sort -nru | sed 1q
835 if test -z "$autoconf_minversion"; then
836 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
838 case "$autoconf_minversion" in
839 1.* | 2.[0-4]* | 2.5[0-8]*)
840 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
843 # Remove trailing slashes from the directory names. This is necessary for
844 # m4base (to avoid an error in func_import) and optional for the others.
845 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
846 case "$local_gnulib_dir" in
847 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
849 case "$sourcebase" in
850 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
853 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
856 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
859 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
862 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
867 /*) self_abspathname="$0" ;;
868 */*) self_abspathname=`pwd`/"$0" ;;
877 if test -x "$d/$0" && test ! -d "$d/$0"; then
878 self_abspathname=$d/$0
883 if test -z "$self_abspathname"; then
884 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
888 while test -h "$self_abspathname"; do
889 # Resolve symbolic link.
890 linkval=`func_readlink "$self_abspathname"`
891 test -n "$linkval" || break
893 /* ) self_abspathname="$linkval" ;;
894 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
897 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
901 if test "$signal" != 0; then
902 echo "caught signal $signal" >&2
906 for signal in 1 2 3 13 15; do
907 trap '{ signal='$signal'; func_exit 1; }' $signal
911 # func_lookup_file file
912 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
915 # - local_gnulib_dir from --local-dir
917 # - lookedup_file name of the merged (combined) file
918 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
922 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
923 lookedup_file="$local_gnulib_dir/$lkfile"
926 if test -f "$gnulib_dir/$lkfile"; then
927 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
928 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
930 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
931 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
932 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
933 lookedup_file="$tmp/$lkbase"
936 lookedup_file="$gnulib_dir/$lkfile"
940 func_fatal_error "file $gnulib_dir/$lkfile not found"
947 # - local_gnulib_dir from --local-dir
950 # Filter out metainformation files like README, which are not modules.
951 # Filter out unit test modules; they can be retrieved through
952 # --extract-tests-module if desired.
954 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
955 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
956 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
959 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
960 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
961 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
962 -e '/^README$/d' -e '/\/README$/d' \
964 -e '/^TEMPLATE-EXTENDED$/d' \
965 -e '/^TEMPLATE-TESTS$/d' \
968 | sed -e '/-tests$/d' \
973 # verifies a module name
975 # - local_gnulib_dir from --local-dir
976 # - module module name argument
977 func_verify_module ()
979 if { test -f "$gnulib_dir/modules/$module" \
980 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
981 && test -f "$local_gnulib_dir/modules/$module"; }; } \
982 && test "CVS" != "$module" \
983 && test "ChangeLog" != "$module" \
984 && test "COPYING" != "$module" \
985 && test "README" != "$module" \
986 && test "TEMPLATE" != "$module" \
987 && test "TEMPLATE-EXTENDED" != "$module" \
988 && test "TEMPLATE-TESTS" != "$module"; then
989 # OK, $module is a correct module name.
990 # Verify that building the module description with 'patch' succeeds.
991 func_lookup_file "modules/$module"
993 echo "gnulib-tool: module $module doesn't exist" 1>&2
998 # func_verify_nontests_module
999 # verifies a module name, excluding tests modules
1001 # - local_gnulib_dir from --local-dir
1002 # - module module name argument
1003 func_verify_nontests_module ()
1006 *-tests ) module= ;;
1007 * ) func_verify_module ;;
1011 # func_verify_tests_module
1012 # verifies a module name, considering only tests modules
1014 # - local_gnulib_dir from --local-dir
1015 # - module module name argument
1016 func_verify_tests_module ()
1019 *-tests ) func_verify_module ;;
1024 sed_extract_prog=':[ ]*$/ {
1027 s/^Description:[ ]*$//
1029 s/^Depends-on:[ ]*$//
1030 s/^configure\.ac-early:[ ]*$//
1031 s/^configure\.ac:[ ]*$//
1032 s/^Makefile\.am:[ ]*$//
1036 s/^Maintainer:[ ]*$//
1043 # func_get_description module
1045 # - local_gnulib_dir from --local-dir
1046 func_get_description ()
1048 func_lookup_file "modules/$1"
1049 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1052 # func_get_filelist module
1054 # - local_gnulib_dir from --local-dir
1055 func_get_filelist ()
1057 func_lookup_file "modules/$1"
1058 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1059 echo m4/gnulib-common.m4
1060 case "$autoconf_minversion" in
1062 #echo m4/onceonly.m4
1063 echo m4/onceonly_2_57.m4
1068 # func_get_dependencies module
1070 # - local_gnulib_dir from --local-dir
1071 func_get_dependencies ()
1073 # ${module}-tests always implicitly depends on ${module}.
1074 echo "$1" | sed -n -e 's/-tests//p'
1075 # Then the explicit dependencies listed in the module description.
1076 func_lookup_file "modules/$1"
1077 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1080 # func_get_autoconf_early_snippet module
1082 # - local_gnulib_dir from --local-dir
1083 func_get_autoconf_early_snippet ()
1085 func_lookup_file "modules/$1"
1086 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1089 # func_get_autoconf_snippet module
1091 # - local_gnulib_dir from --local-dir
1092 func_get_autoconf_snippet ()
1094 func_lookup_file "modules/$1"
1095 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1098 # func_get_automake_snippet module
1100 # - local_gnulib_dir from --local-dir
1101 func_get_automake_snippet ()
1103 func_lookup_file "modules/$1"
1104 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1107 # *-tests module live in tests/, not lib/.
1110 # Synthesize an EXTRA_DIST augmentation.
1111 sed_combine_lines='/\\$/{
1118 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1119 already_mentioned_files=` \
1120 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1121 | sed -e "$sed_combine_lines" \
1122 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1123 all_files=`func_get_filelist $1`
1124 lib_files=`for f in $all_files; do \
1128 done | sed -e 's,^lib/,,'`
1129 # Remove $already_mentioned_files from $lib_files.
1130 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1131 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1132 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1133 if test -n "$extra_files"; then
1134 echo "EXTRA_DIST +=" $extra_files
1137 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1138 # This is necessary so that automake can generate the right list of
1140 # A possible approach would be to use autom4te --trace of the redefined
1141 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1142 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1143 # inside autoconf's built-in macros are not missed).
1144 # But it's simpler and more robust to do it here, based on the file list.
1145 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1146 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1147 # automake will generate a useless dependency; this is harmless.
1149 relocatable-prog-wrapper) ;;
1151 sed_extract_c_files='/\.c$/p'
1152 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1153 if test -n "$extra_files"; then
1154 echo "EXTRA_lib_SOURCES +=" $extra_files
1163 # func_get_include_directive module
1165 # - local_gnulib_dir from --local-dir
1166 func_get_include_directive ()
1168 func_lookup_file "modules/$1"
1169 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1170 sed -e 's/^\(["<]\)/#include \1/'
1173 # func_get_link_directive module
1175 # - local_gnulib_dir from --local-dir
1176 func_get_link_directive ()
1178 func_lookup_file "modules/$1"
1179 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1182 # func_get_license module
1184 # - local_gnulib_dir from --local-dir
1187 func_lookup_file "modules/$1"
1188 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1189 # The default is GPL.
1191 } | sed -e 's,^ *$,,' | sed -e 1q
1194 # func_get_maintainer module
1196 # - local_gnulib_dir from --local-dir
1197 func_get_maintainer ()
1199 func_lookup_file "modules/$1"
1200 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1203 # func_get_tests_module module
1205 # - local_gnulib_dir from --local-dir
1206 func_get_tests_module ()
1208 # The naming convention for tests modules is hardwired: ${module}-tests.
1209 if test -f "$gnulib_dir/modules/$1"-tests \
1210 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1211 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1216 # func_acceptable module
1217 # tests whether a module is acceptable.
1219 # - avoidlist list of modules to avoid
1222 for avoid in $avoidlist; do
1223 if test "$avoid" = "$1"; then
1230 # func_modules_transitive_closure
1232 # - local_gnulib_dir from --local-dir
1233 # - modules list of specified modules
1234 # - inctests true if tests should be included, blank otherwise
1235 # - avoidlist list of modules to avoid
1236 # - tmp pathname of a temporary directory
1238 # - modules list of modules, including dependencies
1239 func_modules_transitive_closure ()
1241 # In order to process every module only once (for speed), process an "input
1242 # list" of modules, producing an "output list" of modules. During each round,
1243 # more modules can be queued in the input list. Once a module on the input
1244 # list has been processed, it is added to the "handled list", so we can avoid
1245 # to process it again.
1247 inmodules="$modules"
1249 while test -n "$inmodules"; do
1250 inmodules_this_round="$inmodules"
1251 inmodules= # Accumulator, queue for next round
1252 for module in $inmodules_this_round; do
1254 if test -n "$module"; then
1255 if func_acceptable $module; then
1256 func_append outmodules " $module"
1257 deps=`func_get_dependencies $module`
1258 # Duplicate dependencies are harmless, but Jim wants a warning.
1259 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1260 if test -n "$duplicated_deps"; then
1261 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1263 func_append inmodules " $deps"
1264 if test -n "$inctests"; then
1265 testsmodule=`func_get_tests_module $module`
1266 if test -n "$testsmodule"; then
1267 func_append inmodules " $testsmodule"
1273 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1274 # Remove $handledmodules from $inmodules.
1275 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1276 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1278 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1279 rm -f "$tmp"/queued-modules
1282 # func_modules_add_dummy
1284 # - local_gnulib_dir from --local-dir
1285 # - modules list of modules, including dependencies
1287 # - modules list of modules, including 'dummy' if needed
1288 func_modules_add_dummy ()
1291 sed_remove_backslash_newline=':a
1298 for module in $modules; do
1299 func_verify_nontests_module
1300 if test -n "$module"; then
1301 # Extract the value of "lib_SOURCES += ...".
1302 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1303 # Ignore .h files since they are not compiled.
1306 *) have_lib_SOURCES=yes ;;
1311 # Add the dummy module, to make sure the library will be non-empty.
1312 if test -z "$have_lib_SOURCES"; then
1313 if func_acceptable "dummy"; then
1314 func_append modules " dummy"
1319 # func_modules_to_filelist
1321 # - local_gnulib_dir from --local-dir
1322 # - modules list of modules, including dependencies
1324 # - files list of files
1325 func_modules_to_filelist ()
1328 for module in $modules; do
1330 if test -n "$module"; then
1331 fs=`func_get_filelist $module`
1332 func_append files " $fs"
1335 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1338 # func_emit_lib_Makefile_am
1339 # emits the contents of library makefile to standard output.
1341 # - local_gnulib_dir from --local-dir
1342 # - modules list of modules, including dependencies
1343 # - libname library name
1344 # - auxdir directory relative to destdir where to place build aux files
1345 # - makefile_name from --makefile-name
1346 # - libtool true if libtool will be used, false or blank otherwise
1347 # - macro_prefix prefix of gl_LIBOBJS macros to use
1348 # - actioncmd (optional) command that will reproduce this invocation
1349 # - for_test true if creating a package for testing, false otherwise
1351 # - uses_subdirs nonempty if object files in subdirs exist
1352 func_emit_lib_Makefile_am ()
1354 # When creating an includable Makefile.am snippet, augment variables with
1355 # += instead of assigning them.
1356 if test -n "$makefile_name"; then
1361 if test "$libtool" = true; then
1364 sed_eliminate_LDFLAGS=
1368 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1371 # When creating a package for testing: Attempt to provoke failures,
1372 # especially link errors, already during "make" rather than during
1373 # "make check", because "make check" is not possible in a cross-compiling
1374 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1375 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1377 sed_transform_check_PROGRAMS=
1379 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1380 echo "## Process this file with automake to produce Makefile.in."
1381 func_emit_copyright_notice
1382 if test -n "$actioncmd"; then
1383 echo "# Reproduce by: $actioncmd"
1388 for module in $modules; do
1389 func_verify_nontests_module
1390 if test -n "$module"; then
1392 func_get_automake_snippet "$module" |
1393 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1394 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1395 -e "$sed_eliminate_LDFLAGS" \
1396 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1397 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1398 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1399 -e "$sed_transform_check_PROGRAMS"
1400 if test "$module" = 'alloca'; then
1401 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1402 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1405 # Skip the contents if its entirely empty.
1406 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1407 echo "## begin gnulib module $module"
1410 echo "## end gnulib module $module"
1414 # Test whether there are some source files in subdirectories.
1415 for f in `func_get_filelist "$module"`; do
1417 lib/*/*.c) uses_subdirs=yes ;;
1423 if test -z "$makefile_name"; then
1424 # If there are source files in subdirectories, prevent collision of the
1425 # object files (example: hash.c and libxml/hash.c).
1427 if test -n "$uses_subdirs"; then
1428 subdir_options=' subdir-objects'
1430 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1433 if test -z "$makefile_name"; then
1434 echo "noinst_HEADERS ="
1435 echo "noinst_LIBRARIES ="
1436 echo "noinst_LTLIBRARIES ="
1437 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1438 # if you specify pkgdata_DATA to empty. This is a workaround.
1439 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1440 echo "pkgdata_DATA ="
1443 echo "BUILT_SOURCES ="
1446 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1447 if test -z "$makefile_name"; then
1448 echo "MOSTLYCLEANDIRS ="
1450 echo "DISTCLEANFILES ="
1451 echo "MAINTAINERCLEANFILES ="
1453 echo "AM_CPPFLAGS ="
1456 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1457 # One of the snippets already specifies an installation location for the
1458 # library. Don't confuse automake by saying it should not be installed.
1461 # By default, the generated library should not be installed.
1462 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1465 echo "${libname}_${libext}_SOURCES ="
1466 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1467 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1468 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1469 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1470 echo "EXTRA_${libname}_${libext}_SOURCES ="
1471 if test "$libtool" = true; then
1472 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1475 cat allsnippets.tmp \
1476 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1478 echo "mostlyclean-local: mostlyclean-generic"
1479 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1480 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1481 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1484 rm -f allsnippets.tmp
1487 # func_emit_tests_Makefile_am
1488 # emits the contents of tests makefile to standard output.
1490 # - local_gnulib_dir from --local-dir
1491 # - modules list of modules, including dependencies
1492 # - libname library name
1493 # - makefile_name from --makefile-name
1494 # - libtool true if libtool will be used, false or blank otherwise
1495 # - sourcebase relative directory containing lib source code
1496 # - m4base relative directory containing autoconf macros
1497 # - testsbase relative directory containing unit test code
1498 # - for_test true if creating a package for testing, false otherwise
1499 func_emit_tests_Makefile_am ()
1501 if test "$libtool" = true; then
1506 if test "$libtool" = true; then
1508 sed_eliminate_LDFLAGS=
1511 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1514 # When creating a package for testing: Attempt to provoke failures,
1515 # especially link errors, already during "make" rather than during
1516 # "make check", because "make check" is not possible in a cross-compiling
1517 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1518 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1520 sed_transform_check_PROGRAMS=
1522 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1523 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1524 echo "## Process this file with automake to produce Makefile.in."
1525 func_emit_copyright_notice
1527 # Generate dependencies here, since it eases the debugging of test failures.
1528 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1530 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1533 for module in $modules; do
1534 func_verify_tests_module
1535 if test -n "$module"; then
1537 func_get_automake_snippet "$module" |
1538 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1539 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1540 -e "$sed_eliminate_LDFLAGS" \
1541 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1542 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1543 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1544 -e "$sed_transform_check_PROGRAMS"
1546 # Skip the contents if its entirely empty.
1547 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1548 echo "## begin gnulib module $module"
1551 echo "## end gnulib module $module"
1558 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1559 # variable is needed to avoid an error from automake:
1560 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1563 echo "TESTS_ENVIRONMENT ="
1564 echo "noinst_PROGRAMS ="
1565 if ! $for_test; then
1566 echo "check_PROGRAMS ="
1568 echo "noinst_HEADERS ="
1569 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1570 echo "pkgdata_DATA ="
1573 echo "BUILT_SOURCES ="
1575 echo "MOSTLYCLEANFILES = core *.stackdump"
1576 echo "MOSTLYCLEANDIRS ="
1578 echo "DISTCLEANFILES ="
1579 echo "MAINTAINERCLEANFILES ="
1581 echo "AM_CPPFLAGS = \\"
1582 echo " -I. -I\$(srcdir) \\"
1583 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1584 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1586 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1589 echo "# Clean up after Solaris cc."
1591 echo " rm -rf SunWS_cache"
1593 echo "mostlyclean-local: mostlyclean-generic"
1594 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1595 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1596 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1599 rm -f allsnippets.tmp
1602 # func_emit_initmacro_start
1603 # emits the first few statements of the gl_INIT macro to standard output.
1604 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1605 func_emit_initmacro_start ()
1607 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1608 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1609 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1610 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1612 # Furthermore it avoids an automake error like this when a Makefile.am
1613 # that uses pieces of gnulib also uses $(LIBOBJ):
1614 # automatically discovered file `error.c' should not be explicitly mentioned
1615 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1616 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1617 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1618 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1619 # automatically discovered file `error.c' should not be explicitly mentioned
1620 # We let automake know about the files to be distributed through the
1621 # EXTRA_lib_SOURCES variable.
1622 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1625 # func_emit_initmacro_end
1626 # emits the last few statements of the gl_INIT macro to standard output.
1627 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1628 func_emit_initmacro_end ()
1630 echo " m4_popdef([AC_LIBSOURCES])"
1631 echo " m4_popdef([AC_REPLACE_FUNCS])"
1632 echo " m4_popdef([AC_LIBOBJ])"
1633 echo " AC_CONFIG_COMMANDS_PRE(["
1634 echo " ${macro_prefix}_libobjs="
1635 echo " ${macro_prefix}_ltlibobjs="
1636 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1637 echo " # Remove the extension."
1638 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1639 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1640 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1641 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1644 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1645 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1649 # func_emit_initmacro_done
1650 # emits a few statements after the gl_INIT macro to standard output.
1651 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1652 func_emit_initmacro_done ()
1655 echo "# Like AC_LIBOBJ, except that the module name goes"
1656 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1657 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1658 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1660 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1661 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1662 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1663 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1665 echo "# Like AC_LIBSOURCES, except that it does nothing."
1666 echo "# We rely on EXTRA_lib..._SOURCES instead."
1667 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1671 # func_import modules
1672 # Uses also the variables
1673 # - destdir target directory
1674 # - local_gnulib_dir from --local-dir
1675 # - libname library name
1676 # - sourcebase directory relative to destdir where to place source code
1677 # - m4base directory relative to destdir where to place *.m4 macros
1678 # - docbase directory relative to destdir where to place doc files
1679 # - testsbase directory relative to destdir where to place unit test code
1680 # - auxdir directory relative to destdir where to place build aux files
1681 # - inctests true if --with-tests was given, blank otherwise
1682 # - avoidlist list of modules to avoid, from --avoid
1683 # - lgpl true if library's license shall be LGPL, blank otherwise
1684 # - makefile_name from --makefile-name
1685 # - libtool true if --libtool was given, false if --no-libtool was
1686 # given, blank otherwise
1687 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1688 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1689 # - autoconf_minversion minimum supported autoconf version
1690 # - doit : if actions shall be executed, false if only to be printed
1691 # - symbolic true if files should be symlinked, copied otherwise
1692 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1696 # Get the cached settings.
1697 cached_local_gnulib_dir=
1698 cached_specified_modules=
1707 cached_makefile_name=
1709 cached_macro_prefix=
1711 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1712 cached_libtool=false
1718 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1721 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1724 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1727 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1730 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1733 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1736 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1739 s,^.*$,cached_inctests=true,p
1742 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1745 s,^.*$,cached_lgpl=true,p
1747 /gl_MAKEFILE_NAME(/ {
1748 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1751 s,^.*$,cached_libtool=true,p
1753 /gl_MACRO_PREFIX(/ {
1754 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1756 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1757 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1762 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1763 s,^.*$,cached_files=",p
1775 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1779 # Merge the cached settings with the specified ones.
1780 # The m4base must be the same as expected from the pathname.
1781 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1782 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1784 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1785 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1786 if test -z "$local_gnulib_dir"; then
1787 if test -n "$cached_local_gnulib_dir"; then
1790 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1792 case "$cached_local_gnulib_dir" in
1794 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1796 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1797 local_gnulib_dir="$relconcat" ;;
1802 # Append the cached and the specified module names. So that
1803 # "gnulib-tool --import foo" means to add the module foo.
1804 specified_modules="$cached_specified_modules $1"
1805 # Append the cached and the specified avoidlist. This is probably better
1806 # than dropping the cached one when --avoid is specified at least once.
1807 avoidlist=`echo $cached_avoidlist $avoidlist`
1808 # The sourcebase defaults to the cached one.
1809 if test -z "$sourcebase"; then
1810 sourcebase="$cached_sourcebase"
1811 if test -z "$sourcebase"; then
1812 func_fatal_error "missing --source-base option"
1815 # The docbase defaults to the cached one.
1816 if test -z "$docbase"; then
1817 docbase="$cached_docbase"
1818 if test -z "$docbase"; then
1819 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."
1822 # The testsbase defaults to the cached one.
1823 if test -z "$testsbase"; then
1824 testsbase="$cached_testsbase"
1825 if test -z "$testsbase"; then
1826 func_fatal_error "missing --tests-base option"
1829 # Require the tests if specified either way.
1830 if test -z "$inctests"; then
1831 inctests="$cached_inctests"
1833 # The libname defaults to the cached one.
1834 if test -z "$supplied_libname"; then
1835 libname="$cached_libname"
1836 if test -z "$libname"; then
1837 func_fatal_error "missing --lib option"
1840 # Require LGPL if specified either way.
1841 if test -z "$lgpl"; then
1844 # The makefile_name defaults to the cached one.
1845 if test -z "$makefile_name"; then
1846 makefile_name="$cached_makefile_name"
1848 # Use libtool if specified either way, or if guessed.
1849 if test -z "$libtool"; then
1850 if test -n "$cached_m4base"; then
1851 libtool="$cached_libtool"
1853 libtool="$guessed_libtool"
1856 # The macro_prefix defaults to the cached one.
1857 if test -z "$macro_prefix"; then
1858 macro_prefix="$cached_macro_prefix"
1859 if test -z "$macro_prefix"; then
1860 func_fatal_error "missing --macro-prefix option"
1864 # Canonicalize the list of specified modules.
1865 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1867 # Determine final module list.
1868 modules="$specified_modules"
1869 func_modules_transitive_closure
1870 echo "Module list with included dependencies:"
1871 echo "$modules" | sed -e 's/^/ /'
1873 # Add the dummy module if needed.
1874 func_modules_add_dummy
1876 # If --lgpl, verify that the licenses of modules are compatible.
1877 if test -n "$lgpl"; then
1878 for module in $modules; do
1879 license=`func_get_license $module`
1881 LGPL | 'GPLed build tool') ;;
1882 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1883 *) func_fatal_error "incompatible license on module $module: $license" ;;
1888 # Determine script to apply to imported library files.
1889 sed_transform_lib_file=
1890 for module in $modules; do
1891 if test $module = config-h; then
1892 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1893 sed_transform_lib_file=$sed_transform_lib_file'
1894 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1899 if test -n "$lgpl"; then
1901 sed_transform_lib_file=$sed_transform_lib_file'
1902 s/GNU General/GNU Lesser General/g
1903 s/version 2\([ ,]\)/version 2.1\1/g
1907 # Determine final file list.
1908 func_modules_to_filelist
1910 echo "$files" | sed -e 's/^/ /'
1913 || func_fatal_error "refusing to do nothing"
1915 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1916 new_files="$files m4/gnulib-tool.m4"
1917 old_files="$cached_files"
1918 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1919 func_append old_files " m4/gnulib-tool.m4"
1922 sed_rewrite_old_files="\
1923 s,^build-aux/,$auxdir/,
1924 s,^doc/,$cached_docbase/,
1925 s,^lib/,$cached_sourcebase/,
1926 s,^m4/,$cached_m4base/,
1927 s,^tests/,$cached_testsbase/,"
1928 sed_rewrite_new_files="\
1929 s,^build-aux/,$auxdir/,
1931 s,^lib/,$sourcebase/,
1933 s,^tests/,$testsbase/,"
1935 # Create directories.
1936 { echo "$sourcebase"
1938 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1939 if test -n "$docfiles"; then
1942 if test -n "$inctests"; then
1946 for f in $files; do echo $f; done \
1947 | sed -e "$sed_rewrite_new_files" \
1948 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
1951 { # Rearrange file descriptors. Needed because "while ... done < ..."
1952 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1953 exec 5<&0 < "$tmp"/dirs
1955 if test ! -d "$destdir/$d"; then
1957 echo "Creating directory $destdir/$d"
1958 mkdir -p "$destdir/$d" || func_fatal_error "failed"
1960 echo "Create directory $destdir/$d"
1967 # func_dest_tmpfilename file
1968 # determines the name of a temporary file (file is relative to destdir).
1970 # - tmpfile absolute filename of the temporary file
1971 func_dest_tmpfilename ()
1974 # Put the new contents of $file in a file in the same directory (needed
1975 # to guarantee that an 'mv' to "$destdir/$file" works).
1976 tmpfile="$destdir/$1.tmp"
1978 # Put the new contents of $file in a file in a temporary directory
1979 # (because the directory of "$file" might not exist).
1980 tmpfile="$tmp"/`basename "$1"`.tmp
1984 # Copy files or make symbolic links. Remove obsolete files.
1988 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1989 # representing the files according to the last gnulib-tool invocation.
1990 for f in $old_files; do echo $f; done \
1991 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
1994 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1995 # representing the files after this gnulib-tool invocation.
1996 for f in $new_files; do echo $f; done \
1997 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2000 # First the files that are in old-files, but not in new-files:
2001 sed_take_first_column='s,'"$delimiter"'.*,,'
2002 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2003 # Remove the file. Do nothing if the user already removed it.
2004 if test -f "$destdir/$g"; then
2006 echo "Removing file $g (backup in ${g}~)"
2007 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2009 echo "Remove file $g (backup in ${g}~)"
2011 func_append removed_files "$g$nl"
2014 # func_add_or_update handles a file that ought to be present afterwards.
2016 # - f the original file name
2017 # - g the rewritten file name
2018 # - already_present nonempty if the file already exists, empty otherwise
2019 func_add_or_update ()
2021 func_dest_tmpfilename "$g"
2022 func_lookup_file "$f"
2023 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2024 if test -n "$sed_transform_lib_file"; then
2027 sed -e "$sed_transform_lib_file" \
2028 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2032 if test -f "$destdir/$g"; then
2033 # The file already exists.
2034 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2035 : # The file has not changed.
2039 if test -n "$already_present"; then
2040 echo "Updating file $g (backup in ${g}~)"
2042 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2044 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2045 if { test -n "$symbolic" \
2046 || { test -n "$lsymbolic" \
2047 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2048 && test -z "$lookedup_tmp" \
2049 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2050 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2052 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2055 if test -n "$already_present"; then
2056 echo "Update file $g (backup in ${g}~)"
2058 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2064 # Don't protest if the file should be there but isn't: it happens
2065 # frequently that developers don't put autogenerated files into CVS.
2067 echo "Copying file $g"
2068 if { test -n "$symbolic" \
2069 || { test -n "$lsymbolic" \
2070 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2071 && test -z "$lookedup_tmp" \
2072 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2073 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2075 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2080 func_append added_files "$g$nl"
2084 # Then the files that are in new-files, but not in old-files:
2085 sed_take_last_column='s,^.*'"$delimiter"',,'
2087 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2088 | sed -e "$sed_take_last_column" \
2089 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2090 { # Rearrange file descriptors. Needed because "while ... done < ..."
2091 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2092 exec 5<&0 < "$tmp"/added-files
2098 # Then the files that are in new-files and in old-files:
2099 already_present=true
2100 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2101 | sed -e "$sed_take_last_column" \
2102 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2103 { # Rearrange file descriptors. Needed because "while ... done < ..."
2104 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2105 exec 5<&0 < "$tmp"/kept-files
2112 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2113 actioncmd="gnulib-tool --import"
2114 func_append actioncmd " --dir=$destdir"
2115 if test -n "$local_gnulib_dir"; then
2116 func_append actioncmd " --local-dir=$local_gnulib_dir"
2118 func_append actioncmd " --lib=$libname"
2119 func_append actioncmd " --source-base=$sourcebase"
2120 func_append actioncmd " --m4-base=$m4base"
2121 func_append actioncmd " --doc-base=$docbase"
2122 func_append actioncmd " --aux-dir=$auxdir"
2123 if test -n "$inctests"; then
2124 func_append actioncmd " --with-tests"
2126 for module in $avoidlist; do
2127 func_append actioncmd " --avoid=$module"
2129 if test -n "$lgpl"; then
2130 func_append actioncmd " --lgpl"
2132 if test -n "$makefile_name"; then
2133 func_append actioncmd " --makefile-name=$makefile_name"
2135 if test "$libtool" = true; then
2136 func_append actioncmd " --libtool"
2138 func_append actioncmd " --no-libtool"
2140 func_append actioncmd " --macro-prefix=$macro_prefix"
2141 func_append actioncmd " `echo $specified_modules`"
2143 # Default the makefile name to Makefile.am.
2144 if test -n "$makefile_name"; then
2145 makefile_am=$makefile_name
2147 makefile_am=Makefile.am
2150 # Create normal Makefile.ams.
2153 # Create library makefile.
2154 func_dest_tmpfilename $sourcebase/$makefile_am
2155 func_emit_lib_Makefile_am > "$tmpfile"
2156 if test -f "$destdir"/$sourcebase/$makefile_am; then
2157 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2161 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2162 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2163 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2165 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2171 echo "Creating $sourcebase/$makefile_am"
2172 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2174 echo "Create $sourcebase/$makefile_am"
2177 func_append added_files "$sourcebase/$makefile_am$nl"
2180 # Create m4/gnulib-cache.m4.
2181 func_dest_tmpfilename $m4base/gnulib-cache.m4
2183 func_emit_copyright_notice
2185 echo "# This file represents the specification of how gnulib-tool is used."
2186 echo "# It acts as a cache: It is written and read by gnulib-tool."
2187 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2188 echo "# like the configure.ac and various Makefile.am files."
2191 echo "# Specification in the form of a command-line invocation:"
2194 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2195 # Store the local_gnulib_dir relative to destdir.
2196 case "$local_gnulib_dir" in
2198 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2201 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2203 # destdir, local_gnulib_dir are both relative.
2204 func_relativize "$destdir" "$local_gnulib_dir"
2205 relative_local_gnulib_dir="$reldir" ;;
2208 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2209 echo "gl_MODULES(["`echo $specified_modules`"])"
2210 echo "gl_AVOID([$avoidlist])"
2211 echo "gl_SOURCE_BASE([$sourcebase])"
2212 echo "gl_M4_BASE([$m4base])"
2213 echo "gl_DOC_BASE([$docbase])"
2214 echo "gl_TESTS_BASE([$testsbase])"
2215 test -z "$inctests" || echo "gl_WITH_TESTS"
2216 echo "gl_LIB([$libname])"
2217 test -z "$lgpl" || echo "gl_LGPL"
2218 echo "gl_MAKEFILE_NAME([$makefile_name])"
2219 if test "$libtool" = true; then
2222 echo "gl_MACRO_PREFIX([$macro_prefix])"
2224 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2225 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2229 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2230 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2231 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2233 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2237 echo "# gnulib-cache.m4 ends here"
2244 echo "Creating $m4base/gnulib-cache.m4"
2245 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2247 echo "Create $m4base/gnulib-cache.m4"
2253 # Create m4/gnulib-comp.m4.
2254 func_dest_tmpfilename $m4base/gnulib-comp.m4
2256 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2257 func_emit_copyright_notice
2259 echo "# This file represents the compiled summary of the specification in"
2260 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2261 echo "# to be invoked from configure.ac."
2262 echo "# In projects using CVS, this file can be treated like other built files."
2265 echo "# This macro should be invoked from $configure_ac, in the section"
2266 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2267 echo "# any checks for libraries, header files, types and library functions."
2268 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2270 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2271 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2272 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2273 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2274 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2275 if test -n "$uses_subdirs"; then
2276 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2278 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2279 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2281 for module in $modules; do
2283 if test -n "$module"; then
2284 func_get_autoconf_early_snippet "$module"
2287 | sed -e '/^$/d;' -e 's/^/ /'
2290 echo "# This macro should be invoked from $configure_ac, in the section"
2291 echo "# \"Check for header files, types and library functions\"."
2292 echo "AC_DEFUN([${macro_prefix}_INIT],"
2294 func_emit_initmacro_start
2295 if test "$libtool" = true; then
2296 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2297 echo " gl_cond_libtool=true"
2299 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2300 echo " gl_cond_libtool=false"
2302 echo " gl_ltlibdeps="
2304 echo " gl_source_base='$sourcebase'"
2305 if test "$auxdir" != "build-aux"; then
2306 sed_replace_build_aux='
2308 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2309 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2313 sed_replace_build_aux=
2315 for module in $modules; do
2317 if test -n "$module"; then
2318 func_get_autoconf_snippet "$module" \
2319 | sed -e '/^$/d;' -e 's/^/ /' \
2320 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2321 -e "$sed_replace_build_aux"
2322 if test "$module" = 'alloca' && test "$libtool" = true; then
2323 echo 'changequote(,)dnl'
2324 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2325 echo 'changequote([, ])dnl'
2326 echo 'AC_SUBST([LTALLOCA])'
2330 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2331 # created using libtool, because libtool already handles the dependencies.
2332 if test "$libtool" != true; then
2333 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2334 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2335 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2336 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2337 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2339 func_emit_initmacro_end
2341 func_emit_initmacro_done
2343 echo "# This macro records the list of files which have been installed by"
2344 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2345 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2346 echo "$files" | sed -e 's,^, ,'
2349 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2350 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2354 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2355 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2356 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2358 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2362 echo "# gnulib-comp.m4 ends here"
2369 echo "Creating $m4base/gnulib-comp.m4"
2370 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2372 echo "Create $m4base/gnulib-comp.m4"
2378 if test -n "$inctests"; then
2379 # Create tests makefile.
2380 func_dest_tmpfilename $testsbase/$makefile_am
2381 func_emit_tests_Makefile_am > "$tmpfile"
2382 if test -f "$destdir"/$testsbase/$makefile_am; then
2383 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2387 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2388 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2389 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2391 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2397 echo "Creating $testsbase/$makefile_am"
2398 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2400 echo "Create $testsbase/$makefile_am"
2403 func_append added_files "$testsbase/$makefile_am$nl"
2407 # Update the .cvsignore and .gitignore files.
2408 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
2409 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
2410 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
2411 { # Rearrange file descriptors. Needed because "while ... done < ..."
2412 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2413 exec 5<&0 < "$tmp"/fileset-changes
2414 func_update_ignorelist ()
2417 if test -f "$destdir/$dir$ignore"; then
2418 if test -n "$dir_added" || test -n "$dir_removed"; then
2419 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
2420 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
2421 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
2422 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
2423 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
2424 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
2426 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2427 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
2428 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
2429 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
2430 | sed -f "$tmp"/sed-ignore-removed \
2431 > "$destdir/$dir$ignore"
2433 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2438 if test -n "$dir_added"; then
2440 echo "Creating $destdir/$dir$ignore"
2441 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u > "$destdir/$dir$ignore"
2443 echo "Create $destdir/$dir$ignore"
2453 if test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
2454 func_update_ignorelist .cvsignore
2456 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
2457 func_update_ignorelist .gitignore
2464 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
2465 next_dir=`echo "$line" | sed -e 's,|.*,,'`
2466 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
2467 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
2468 if test "$next_dir" != "$last_dir"; then
2469 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2470 last_dir="$next_dir"
2475 A) func_append last_dir_added "$file$nl";;
2476 R) func_append last_dir_removed "$file$nl";;
2479 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2485 echo "You may need to add #include directives for the following .h files."
2486 # Intersect $specified_modules and $modules
2487 # (since $specified_modules is not necessarily of subset of $modules - some
2488 # may have been skipped through --avoid, and since the elements of $modules
2489 # but not in $specified_modules can go away without explicit notice - through
2490 # changes in the module dependencies).
2491 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2492 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2493 # First the #include <...> directives without #ifs, sorted for convenience,
2494 # then the #include "..." directives without #ifs, sorted for convenience,
2495 # then the #include directives that are surrounded by #ifs. Not sorted.
2496 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2497 include_directive=`func_get_include_directive "$module"`
2498 case "$nl$include_directive" in
2500 echo "$include_directive" 1>&5
2503 echo "$include_directive" | grep -v 'include "' 1>&6
2504 echo "$include_directive" | grep 'include "' 1>&7
2507 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2509 LC_ALL=C sort -u "$tmp"/include-angles
2510 LC_ALL=C sort -u "$tmp"/include-quotes
2511 cat "$tmp"/include-if
2512 ) | sed -e '/^$/d' -e 's/^/ /'
2513 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2515 for module in $modules; do
2516 func_get_link_directive "$module"
2518 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
2519 if test `wc -l < "$tmp"/link` != 0; then
2521 echo "You may need to use the following Makefile variables when linking."
2522 echo "Use them in <program>_LDADD when linking a program, or"
2523 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
2529 echo "Don't forget to"
2530 if test "$makefile_am" = Makefile.am; then
2531 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2533 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2535 if test -n "$inctests"; then
2536 if test "$makefile_am" = Makefile.am; then
2537 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2539 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2542 if test "$makefile_am" = Makefile.am; then
2543 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2544 sourcebase_base=`basename "$sourcebase"`
2545 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2547 if test -n "$inctests"; then
2548 if test "$makefile_am" = Makefile.am; then
2549 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2550 testsbase_base=`basename "$testsbase"`
2551 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2554 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2555 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2556 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2559 # func_create_testdir testdir modules
2561 # - local_gnulib_dir from --local-dir
2562 # - auxdir directory relative to destdir where to place build aux files
2563 func_create_testdir ()
2567 if test -z "$modules"; then
2568 # All modules together.
2569 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2570 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2571 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2572 modules=`func_all_modules`
2573 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2575 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2577 # Check that the license of every module is consistent with the license of
2579 saved_modules="$modules"
2580 saved_inctests="$inctests"
2581 # When computing transitive closures, don't consider $module to depend on
2582 # $module-tests. Need this becauses tests are implicitly GPL and may depend
2583 # on GPL modules - therefore we don't want a warning in this case.
2585 for requested_module in $saved_modules; do
2586 requested_license=`func_get_license "$requested_module"`
2587 if test "$requested_license" != GPL; then
2588 # Here we use func_modules_transitive_closure, not just
2589 # func_get_dependencies, so that we also detect weird situations like
2590 # an LGPL module which depends on a GPLed build tool module which depends
2592 modules="$requested_module"
2593 func_modules_transitive_closure
2594 for module in $modules; do
2595 license=`func_get_license "$module"`
2597 LGPL | 'GPLed build tool') ;;
2598 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2599 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2604 modules="$saved_modules"
2605 inctests="$saved_inctests"
2607 # Subdirectory names.
2614 # Determine final module list.
2615 func_modules_transitive_closure
2616 echo "Module list with included dependencies:"
2617 echo "$modules" | sed -e 's/^/ /'
2619 # Add the dummy module if needed.
2620 func_modules_add_dummy
2622 # Determine final file list.
2623 func_modules_to_filelist
2625 echo "$files" | sed -e 's/^/ /'
2627 sed_rewrite_files="\
2628 s,^build-aux/,$auxdir/,
2630 s,^lib/,$sourcebase/,
2632 s,^tests/,$testsbase/,"
2634 # Create directories.
2635 for f in $files; do echo $f; done \
2636 | sed -e "$sed_rewrite_files" \
2637 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2638 | LC_ALL=C sort -u \
2640 { # Rearrange file descriptors. Needed because "while ... done < ..."
2641 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2642 exec 5<&0 < "$tmp"/dirs
2644 mkdir -p "$testdir/$d"
2649 # Copy files or make symbolic links.
2651 for f in $files; do echo $f; done \
2652 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2655 { # Rearrange file descriptors. Needed because "while ... done < ..."
2656 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2657 exec 5<&0 < "$tmp"/files
2659 func_lookup_file "$f"
2660 if test -n "$lookedup_tmp"; then
2661 cp -p "$lookedup_file" "$testdir/$g"
2663 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2664 if { test -n "$symbolic" \
2665 || { test -n "$lsymbolic" \
2666 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
2667 func_ln "$lookedup_file" "$testdir/$g"
2669 cp -p "$lookedup_file" "$testdir/$g"
2676 # Create Makefile.ams that are for testing.
2679 # Create $sourcebase/Makefile.am.
2680 mkdir -p "$testdir/$sourcebase"
2681 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2683 # Create $m4base/Makefile.am.
2684 mkdir -p "$testdir/$m4base"
2685 (echo "## Process this file with automake to produce Makefile.in."
2691 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2694 ) > "$testdir/$m4base/Makefile.am"
2696 subdirs="$sourcebase $m4base"
2697 subdirs_with_configure_ac=""
2699 if false && test -f "$testdir"/$m4base/gettext.m4; then
2700 # Avoid stupid error message from automake:
2701 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2702 mkdir -p "$testdir/po"
2703 (echo "## Process this file with automake to produce Makefile.in."
2704 ) > "$testdir/po/Makefile.am"
2705 func_append subdirs " po"
2708 if test -n "$inctests"; then
2709 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2710 # Create $testsbase/Makefile.am.
2711 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2712 # Create $testsbase/configure.ac.
2713 (echo "# Process this file with autoconf to produce a configure script."
2714 echo "AC_INIT([dummy], [0])"
2715 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2716 echo "AM_INIT_AUTOMAKE"
2718 echo "AM_CONFIG_HEADER([config.h])"
2721 echo "AC_PROG_INSTALL"
2722 echo "AC_PROG_MAKE_SET"
2723 echo "AC_PROG_RANLIB"
2725 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2726 echo "AC_GNU_SOURCE"
2729 for module in $modules; do
2731 if test -n "$module"; then
2732 func_get_autoconf_early_snippet "$module"
2735 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
2736 if test "$libtool" = true; then
2737 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2738 echo "gl_cond_libtool=true"
2740 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2741 echo "gl_cond_libtool=false"
2743 echo "gl_ltlibdeps="
2745 # Wrap the set of autoconf snippets into an autoconf macro that is then
2746 # invoked. This is needed because autoconf does not support AC_REQUIRE
2748 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2749 # but we want the AC_REQUIRE to have its normal meaning (provide one
2750 # expansion of the required macro before the current point, and only one
2752 echo "AC_DEFUN([gl_INIT], ["
2753 func_emit_initmacro_start
2754 sed_replace_build_aux='
2756 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2757 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2760 # We don't have explicit ordering constraints between the various
2761 # autoconf snippets. It's cleanest to put those of the library before
2762 # those of the tests.
2763 echo "gl_source_base='../$sourcebase'"
2764 for module in $modules; do
2765 func_verify_nontests_module
2766 if test -n "$module"; then
2767 func_get_autoconf_snippet "$module" \
2768 | sed -e "$sed_replace_build_aux"
2771 echo "gl_source_base='.'"
2772 for module in $modules; do
2773 func_verify_tests_module
2774 if test -n "$module"; then
2775 func_get_autoconf_snippet "$module" \
2776 | sed -e "$sed_replace_build_aux"
2779 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2780 # created using libtool, because libtool already handles the dependencies.
2781 if test "$libtool" != true; then
2782 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2783 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2784 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2785 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2786 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2788 func_emit_initmacro_end
2790 func_emit_initmacro_done
2794 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2795 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2796 echo "AH_TOP([#include \"../config.h\"])"
2798 echo "AC_OUTPUT([Makefile])"
2799 ) > "$testdir/$testsbase/configure.ac"
2800 func_append subdirs " $testsbase"
2801 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2804 # Create Makefile.am.
2805 (echo "## Process this file with automake to produce Makefile.in."
2807 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2809 echo "SUBDIRS = $subdirs"
2811 echo "ACLOCAL_AMFLAGS = -I $m4base"
2812 ) > "$testdir/Makefile.am"
2814 # Create configure.ac.
2815 (echo "# Process this file with autoconf to produce a configure script."
2816 echo "AC_INIT([dummy], [0])"
2817 if test "$auxdir" != "."; then
2818 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2820 echo "AM_INIT_AUTOMAKE"
2822 echo "AM_CONFIG_HEADER([config.h])"
2825 echo "AC_PROG_INSTALL"
2826 echo "AC_PROG_MAKE_SET"
2828 echo "# For autobuild."
2829 echo "AC_CANONICAL_BUILD"
2830 echo "AC_CANONICAL_HOST"
2832 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2833 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2834 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2835 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2837 echo "AC_PROG_RANLIB"
2839 if test -n "$uses_subdirs"; then
2840 echo "AM_PROG_CC_C_O"
2843 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2844 echo "AC_GNU_SOURCE"
2847 for module in $modules; do
2848 func_verify_nontests_module
2849 if test -n "$module"; then
2850 func_get_autoconf_early_snippet "$module"
2853 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
2854 if test "$libtool" = true; then
2855 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2856 echo "gl_cond_libtool=true"
2858 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2859 echo "gl_cond_libtool=false"
2861 echo "gl_ltlibdeps="
2863 echo "gl_source_base='$sourcebase'"
2864 # Wrap the set of autoconf snippets into an autoconf macro that is then
2865 # invoked. This is needed because autoconf does not support AC_REQUIRE
2867 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2868 # but we want the AC_REQUIRE to have its normal meaning (provide one
2869 # expansion of the required macro before the current point, and only one
2871 echo "AC_DEFUN([gl_INIT], ["
2872 func_emit_initmacro_start
2873 if test "$auxdir" != "build-aux"; then
2874 sed_replace_build_aux='
2876 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2877 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2881 sed_replace_build_aux=
2883 for module in $modules; do
2884 func_verify_nontests_module
2885 if test -n "$module"; then
2886 func_get_autoconf_snippet "$module" \
2887 | sed -e "$sed_replace_build_aux"
2890 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2891 # created using libtool, because libtool already handles the dependencies.
2892 if test "$libtool" != true; then
2893 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2894 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2895 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2896 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2897 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2899 func_emit_initmacro_end
2901 func_emit_initmacro_done
2905 if test -n "$subdirs_with_configure_ac"; then
2906 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2908 makefiles="Makefile"
2909 for d in $subdirs; do
2910 # For subdirs that have a configure.ac by their own, it's the subdir's
2911 # configure.ac which creates the subdir's Makefile.am, not this one.
2912 case " $subdirs_with_configure_ac " in
2914 *) func_append makefiles " $d/Makefile" ;;
2917 echo "AC_OUTPUT([$makefiles])"
2918 ) > "$testdir/configure.ac"
2920 # Create autogenerated files.
2922 # Do not use "${AUTORECONF} --force --install", because it may invoke
2923 # autopoint, which brings in older versions of some of our .m4 files.
2924 if test -f $m4base/gettext.m4; then
2925 echo "executing ${AUTOPOINT} --force"
2926 ${AUTOPOINT} --force || func_exit 1
2927 for f in $m4base/*.m4~; do
2928 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2931 echo "executing ${ACLOCAL} -I $m4base"
2932 ${ACLOCAL} -I $m4base || func_exit 1
2933 if ! test -d build-aux; then
2934 echo "executing mkdir build-aux"
2935 mkdir build-aux || func_exit 1
2937 echo "executing ${AUTOCONF}"
2938 ${AUTOCONF} || func_exit 1
2939 echo "executing ${AUTOHEADER}"
2940 ${AUTOHEADER} || func_exit 1
2941 echo "executing ${AUTOMAKE} --add-missing --copy"
2942 ${AUTOMAKE} --add-missing --copy || func_exit 1
2944 if test -n "$inctests"; then
2945 # Create autogenerated files.
2946 (cd "$testdir/$testsbase" || func_exit 1
2947 # Do not use "${AUTORECONF} --force --install", because it may invoke
2948 # autopoint, which brings in older versions of some of our .m4 files.
2949 if test -f ../$m4base/gettext.m4; then
2950 echo "executing ${AUTOPOINT} --force"
2951 ${AUTOPOINT} --force || func_exit 1
2952 for f in ../$m4base/*.m4~; do
2953 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2956 echo "executing ${ACLOCAL} -I ../$m4base"
2957 ${ACLOCAL} -I ../$m4base || func_exit 1
2958 if ! test -d ../build-aux; then
2959 echo "executing mkdir ../build-aux"
2962 echo "executing ${AUTOCONF}"
2963 ${AUTOCONF} || func_exit 1
2964 echo "executing ${AUTOHEADER}"
2965 ${AUTOHEADER} || func_exit 1
2966 echo "executing ${AUTOMAKE} --add-missing --copy"
2967 ${AUTOMAKE} --add-missing --copy || func_exit 1
2970 # Need to run configure and make once, to create built files that are to be
2971 # distributed (such as getdate.c).
2972 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
2973 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
2974 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
2975 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
2976 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
2977 # such $(FOO_H) because they don't refer to distributed files.
2978 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
2979 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
2980 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
2981 | sed -e "$sed_remove_make_variables"`
2982 distributed_built_sources=`for file in $built_sources; do
2983 case "$cleaned_files" in
2988 if test -n "$distributed_built_sources"; then
2990 ./configure || func_exit 1
2992 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2993 make built_sources || func_exit 1
2995 make distclean || func_exit 1
3000 # func_create_megatestdir megatestdir allmodules
3002 # - local_gnulib_dir from --local-dir
3003 # - auxdir directory relative to destdir where to place build aux files
3004 func_create_megatestdir ()
3008 if test -z "$allmodules"; then
3009 allmodules=`func_all_modules`
3013 # First, all modules one by one.
3014 for onemodule in $allmodules; do
3015 func_create_testdir "$megatestdir/$onemodule" $onemodule
3016 func_append megasubdirs "$onemodule "
3018 # Then, all modules all together.
3019 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3020 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3021 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3022 func_create_testdir "$megatestdir/ALL" "$allmodules"
3023 func_append megasubdirs "ALL"
3026 cvsdate=`sh "$gnulib_dir/build-aux/mdate-sh" "$gnulib_dir/CVS/Entries" \
3027 | sed -e 's,January,01,' -e 's,Jan,01,' \
3028 -e 's,February,02,' -e 's,Feb,02,' \
3029 -e 's,March,03,' -e 's,Mar,03,' \
3030 -e 's,April,04,' -e 's,Apr,04,' \
3032 -e 's,June,06,' -e 's,Jun,06,' \
3033 -e 's,July,07,' -e 's,Jul,07,' \
3034 -e 's,August,08,' -e 's,Aug,08,' \
3035 -e 's,September,09,' -e 's,Sep,09,' \
3036 -e 's,October,10,' -e 's,Oct,10,' \
3037 -e 's,November,11,' -e 's,Nov,11,' \
3038 -e 's,December,12,' -e 's,Dec,12,' \
3039 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3040 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3042 echo "CVSDATE=$cvsdate"
3043 echo "test -d logs || mkdir logs"
3044 echo "for module in $megasubdirs; do"
3045 echo " echo \"Working on module \$module...\""
3046 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3047 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3050 echo " : autobuild project... \$module"
3051 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3052 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3053 echo " : autobuild hostname... \`hostname\`"
3054 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3056 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3058 ) > "$megatestdir/do-autobuild"
3059 chmod a+x "$megatestdir/do-autobuild"
3061 # Create Makefile.am.
3062 (echo "## Process this file with automake to produce Makefile.in."
3064 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3066 echo "SUBDIRS = $megasubdirs"
3068 echo "EXTRA_DIST = do-autobuild"
3069 ) > "$megatestdir/Makefile.am"
3071 # Create configure.ac.
3072 (echo "# Process this file with autoconf to produce a configure script."
3073 echo "AC_INIT([dummy], [0])"
3074 if test "$auxdir" != "."; then
3075 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3077 echo "AM_INIT_AUTOMAKE"
3079 echo "AC_PROG_MAKE_SET"
3081 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3082 echo "AC_OUTPUT([Makefile])"
3083 ) > "$megatestdir/configure.ac"
3085 # Create autogenerated files.
3087 # Do not use "${AUTORECONF} --install", because autoreconf operates
3088 # recursively, but the subdirectories are already finished, therefore
3089 # calling autoreconf here would only waste lots of CPU time.
3090 echo "executing ${ACLOCAL}"
3091 ${ACLOCAL} || func_exit 1
3092 echo "executing mkdir build-aux"
3094 echo "executing ${AUTOCONF}"
3095 ${AUTOCONF} || func_exit 1
3096 echo "executing ${AUTOMAKE} --add-missing --copy"
3097 ${AUTOMAKE} --add-missing --copy || func_exit 1
3103 func_fatal_error "no mode specified" ;;
3112 if test -z "$destdir"; then
3115 test -d "$destdir" \
3116 || func_fatal_error "destination directory does not exist: $destdir"
3118 # Prefer configure.ac to configure.in.
3119 if test -f "$destdir"/configure.ac; then
3120 configure_ac="$destdir/configure.ac"
3122 if test -f "$destdir"/configure.in; then
3123 configure_ac="$destdir/configure.in"
3125 func_fatal_error "cannot find $destdir/configure.ac"
3129 # Analyze configure.ac.
3131 guessed_libtool=false
3136 /AC_CONFIG_AUX_DIR/ {
3137 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3139 /A[CM]_PROG_LIBTOOL/ {
3140 s,^.*$,guessed_libtool=true,p
3142 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3144 if test -z "$auxdir"; then
3145 auxdir="$guessed_auxdir"
3148 # Determine where to apply func_import.
3149 if test -n "$m4base"; then
3150 # Apply func_import to a particular gnulib directory.
3151 # Any number of additional modules can be given.
3152 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3153 # First use of gnulib in the given m4base.
3154 test -n "$supplied_libname" || supplied_libname=true
3155 test -n "$sourcebase" || sourcebase="lib"
3156 test -n "$docbase" || docbase="doc"
3157 test -n "$testsbase" || testsbase="tests"
3158 test -n "$macro_prefix" || macro_prefix="gl"
3162 # Apply func_import to all gnulib directories.
3163 # To get this list of directories, look at Makefile.am. (Not at
3164 # configure, because it may be omitted from CVS. Also, don't run
3165 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3168 if test -f "$destdir"/Makefile.am; then
3169 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3171 for arg in $aclocal_amflags; do
3172 if test -n "$m4dir_is_next"; then
3173 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3177 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3178 func_append m4dirs " $arg"
3179 m4dirs_count=`expr $m4dirs_count + 1`
3185 if test "X$arg" = "X-I"; then
3193 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3194 if test -f "$destdir"/aclocal.m4; then
3195 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3196 sedexpr2='s,^[^/]*$,.,'
3197 sedexpr3='s,/[^/]*$,,'
3198 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3199 m4dirs_count=`echo "$m4dirs" | wc -l`
3202 if test $m4dirs_count = 0; then
3203 # First use of gnulib in a package.
3204 # Any number of additional modules can be given.
3205 test -n "$supplied_libname" || supplied_libname=true
3206 test -n "$sourcebase" || sourcebase="lib"
3208 test -n "$docbase" || docbase="doc"
3209 test -n "$testsbase" || testsbase="tests"
3210 test -n "$macro_prefix" || macro_prefix="gl"
3213 if test $m4dirs_count = 1; then
3214 # There's only one use of gnulib here. Assume the user means it.
3215 # Any number of additional modules can be given.
3216 for m4base in $m4dirs; do
3220 # Ambiguous - guess what the user meant.
3221 if test $# = 0; then
3222 # No further arguments. Guess the user wants to update all of them.
3223 for m4base in $m4dirs; do
3224 # Perform func_import in a subshell, so that variable values
3226 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
3227 # testsbase, inctests, libname, lgpl, makefile_name, libtool,
3229 # don't propagate from one directory to another.
3230 (func_import) || func_exit 1
3234 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
3242 if test -z "$destdir"; then
3243 func_fatal_error "please specify --dir option"
3246 test -d "$destdir" \
3247 || func_fatal_error "could not create destination directory"
3248 test -n "$auxdir" || auxdir="build-aux"
3249 func_create_testdir "$destdir" "$*"
3252 create-megatestdir )
3253 if test -z "$destdir"; then
3254 func_fatal_error "please specify --dir option"
3256 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3257 test -n "$auxdir" || auxdir="build-aux"
3258 func_create_megatestdir "$destdir" "$*"
3262 test -n "$destdir" || destdir=testdir$$
3263 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3264 test -n "$auxdir" || auxdir="build-aux"
3265 func_create_testdir "$destdir" "$*"
3269 ../configure || func_exit 1
3271 make check || func_exit 1
3272 make distclean || func_exit 1
3273 remaining=`find . -type f -print`
3274 if test -n "$remaining"; then
3275 echo "Remaining files:" $remaining 1>&2
3276 echo "gnulib-tool: *** Stop." 1>&2
3285 test -n "$destdir" || destdir=testdir$$
3286 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3287 test -n "$auxdir" || auxdir="build-aux"
3288 func_create_megatestdir "$destdir" "$*"
3296 remaining=`find . -type f -print`
3297 if test -n "$remaining"; then
3298 echo "Remaining files:" $remaining 1>&2
3299 echo "gnulib-tool: *** Stop." 1>&2
3307 extract-description )
3311 if test -n "$module"; then
3312 func_get_description "$module"
3321 if test -n "$module"; then
3322 func_get_filelist "$module"
3327 extract-dependencies )
3331 if test -n "$module"; then
3332 func_get_dependencies "$module"
3337 extract-autoconf-snippet )
3341 if test -n "$module"; then
3342 func_get_autoconf_snippet "$module"
3347 extract-automake-snippet )
3351 if test -n "$module"; then
3352 func_get_automake_snippet "$module"
3357 extract-include-directive )
3361 if test -n "$module"; then
3362 func_get_include_directive "$module"
3367 extract-link-directive )
3371 if test -n "$module"; then
3372 func_get_link_directive "$module"
3381 if test -n "$module"; then
3382 func_get_license "$module"
3387 extract-maintainer )
3391 if test -n "$module"; then
3392 func_get_maintainer "$module"
3397 extract-tests-module )
3401 if test -n "$module"; then
3402 func_get_tests_module "$module"
3408 func_fatal_error "unknown operation mode --$mode" ;;
3412 # Undo the effect of the previous 'trap' command. Some shellology:
3413 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3414 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3415 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3416 # 128 + signal number and is set before the trap-registered command is run.
3418 trap 'func_exit $?' 1 2 3 13 15
3423 # indent-tabs-mode: nil
3424 # whitespace-check-buffer-indent: nil