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 11:20:11 $'
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 'print -r'.
435 # - for ksh: alias echo to a function that uses cat of a here document.
436 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
437 # the ksh workaround.
438 # - otherwise: respawn using /bin/sh and rely on the workarounds.
439 # When respawning, we pass --no-reexec as first argument, so as to avoid
440 # turning this script into a fork bomb in unlucky situations.
442 if echo '\t' | grep t > /dev/null; then
443 have_echo=yes # Lucky!
445 # Try the workarounds.
446 # Respawn using $CONFIG_SHELL if that is set and works.
447 if test -z "$have_echo" \
448 && test "X$1" != "X--no-reexec" \
449 && test -n "$CONFIG_SHELL" \
450 && test -f "$CONFIG_SHELL" \
451 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
452 exec $CONFIG_SHELL "$0" --no-reexec "$@"
455 # For bash >= 2.04: unset the shell option xpg_echo.
456 if test -z "$have_echo" \
457 && test -n "$BASH_VERSION" \
458 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
462 # For bash >= 2.0: define echo to a function that uses the printf built-in.
463 # For bash < 2.0: define echo to a function that uses cat of a here document.
464 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
465 if test -z "$have_echo" \
466 && test -n "$BASH_VERSION"; then \
467 if type printf 2>/dev/null | grep / > /dev/null; then
468 # 'printf' is not a shell built-in.
476 # 'printf' is a shell built-in.
482 if echo '\t' | grep t > /dev/null; then
486 # For zsh: turn sh-emulation on.
487 if test -z "$have_echo" \
488 && test -n "$ZSH_VERSION" \
489 && (emulate sh) >/dev/null 2>&1; then
492 # For ksh: alias echo to 'print -r'.
493 if test -z "$have_echo" \
494 && (type print) >/dev/null 2>&1; then
495 # A 'print' command exists.
496 if type print 2>/dev/null | grep / > /dev/null; then
499 # 'print' is a shell built-in.
500 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
501 # 'print' is the ksh shell built-in.
502 alias echo='print -r'
506 if test -z "$have_echo" \
507 && echo '\t' | grep t > /dev/null; then
510 # For ksh: alias echo to a function that uses cat of a here document.
511 # The ksh manual page says:
512 # "Aliasing is performed when scripts are read, not while they are executed.
513 # Therefore, for an alias to take effect, the alias definition command has
514 # to be executed before the command which references the alias is read."
515 # Because of this, we have to play strange tricks with have_echo, to ensure
516 # that the top-level statement containing the test starts after the 'alias'
518 if test -z "$have_echo"; then
525 alias echo=bsd_echo 2>/dev/null
527 if test -z "$have_echo" \
528 && echo '\t' | grep t > /dev/null; then
531 if test -z "$have_echo"; then
532 unalias echo 2>/dev/null
534 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
535 if test -z "$have_echo" \
536 && test "X$1" != "X--no-reexec" \
537 && test -f /bin/ksh; then
538 exec /bin/ksh "$0" --no-reexec "$@"
541 # Otherwise: respawn using /bin/sh.
542 if test -z "$have_echo" \
543 && test "X$1" != "X--no-reexec" \
544 && test -f /bin/sh; then
545 exec /bin/sh "$0" --no-reexec "$@"
548 if test -z "$have_echo"; then
549 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
551 if echo '\t' | grep t > /dev/null; then
554 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
556 if test "X$1" = "X--no-reexec"; then
560 # Command-line option processing.
561 # Removes the OPTIONS from the arguments. Sets the variables:
562 # - mode list or import or create-testdir or create-megatestdir
563 # - destdir from --dir
564 # - local_gnulib_dir from --local-dir
565 # - libname, supplied_libname from --lib
566 # - sourcebase from --source-base
567 # - m4base from --m4-base
568 # - docbase from --doc-base
569 # - testsbase from --tests-base
570 # - auxdir from --aux-dir
571 # - inctests true if --with-tests was given, blank otherwise
572 # - avoidlist list of modules to avoid, from --avoid
573 # - lgpl true if --lgpl was given, blank otherwise
574 # - makefile_name from --makefile-name
575 # - libtool true if --libtool was given, false if --no-libtool was
576 # given, blank otherwise
577 # - macro_prefix from --macro-prefix
578 # - autoconf_minversion minimum supported autoconf version
579 # - do_changelog false if --no-changelog was given, : otherwise
580 # - doit : if actions shall be executed, false if only to be printed
581 # - symbolic true if --symlink was given, blank otherwise
582 # - lsymbolic true if --local-symlink was given, blank otherwise
607 while test $# -gt 0; do
612 --import | --impor | --impo | --imp | --im | --i )
615 --update | --updat | --upda | --upd | --up | --u )
618 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
621 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
622 mode=create-megatestdir
624 --test | --tes | --te | --t )
627 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
631 mode=`echo "X$1" | sed -e 's/^X--//'`
636 func_fatal_error "missing argument for --dir"
641 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
646 func_fatal_error "missing argument for --local-dir"
651 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
656 func_fatal_error "missing argument for --lib"
659 supplied_libname=true
662 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
663 supplied_libname=true
668 func_fatal_error "missing argument for --source-base"
673 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
678 func_fatal_error "missing argument for --m4-base"
683 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
688 func_fatal_error "missing argument for --doc-base"
693 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
698 func_fatal_error "missing argument for --tests-base"
703 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
708 func_fatal_error "missing argument for --aux-dir"
713 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
721 func_fatal_error "missing argument for --avoid"
723 func_append avoidlist " $1"
726 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
727 func_append avoidlist " $arg"
735 func_fatal_error "missing argument for --makefile-name"
740 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
751 func_fatal_error "missing argument for --macro-prefix"
756 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
758 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
764 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
767 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
770 --help | --hel | --he | --h )
773 --version | --versio | --versi | --vers | --ver | --ve | --v )
777 # Stop option processing
781 echo "gnulib-tool: unknown option $1" 1>&2
782 echo "Try 'gnulib-tool --help' for more information." 1>&2
789 if test "$mode" = update; then
790 if test $# != 0; then
791 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
792 echo "Try 'gnulib-tool --help' for more information." 1>&2
793 echo "If you really want to modify the gnulib configuration of your project," 1>&2
794 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
797 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
798 || test -n "$sourcebase" || test -n "$m4base" \
799 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
800 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
801 || test -n "$makefile_name" || test -n "$macro_prefix"; then
802 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
803 echo "Try 'gnulib-tool --help' for more information." 1>&2
804 echo "If you really want to modify the gnulib configuration of your project," 1>&2
805 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
811 # Determine the minimum supported autoconf version from the project's
813 DEFAULT_AUTOCONF_MINVERSION="2.59"
816 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
817 if test -f "$destdir"/configure.ac; then
818 configure_ac="$destdir/configure.ac"
820 if test -f "$destdir"/configure.in; then
821 configure_ac="$destdir/configure.in"
825 if test -f configure.ac; then
826 configure_ac="configure.ac"
828 if test -f configure.in; then
829 configure_ac="configure.in"
833 if test -n "$configure_ac"; then
834 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
835 # because when some m4 files are omitted from a CVS repository,
836 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
837 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
838 # autom4te: m4 failed with exit status: 1
845 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
847 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
848 if test -n "$prereqs"; then
849 autoconf_minversion=`
850 for version in $prereqs; do echo $version; done |
851 LC_ALL=C sort -nru | sed 1q
855 if test -z "$autoconf_minversion"; then
856 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
858 case "$autoconf_minversion" in
859 1.* | 2.[0-4]* | 2.5[0-8]*)
860 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
863 # Remove trailing slashes from the directory names. This is necessary for
864 # m4base (to avoid an error in func_import) and optional for the others.
865 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
866 case "$local_gnulib_dir" in
867 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
869 case "$sourcebase" in
870 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
873 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
876 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
879 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
882 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
887 /*) self_abspathname="$0" ;;
888 */*) self_abspathname=`pwd`/"$0" ;;
897 if test -x "$d/$0" && test ! -d "$d/$0"; then
898 self_abspathname=$d/$0
903 if test -z "$self_abspathname"; then
904 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
908 while test -h "$self_abspathname"; do
909 # Resolve symbolic link.
910 linkval=`func_readlink "$self_abspathname"`
911 test -n "$linkval" || break
913 /* ) self_abspathname="$linkval" ;;
914 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
917 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
921 if test "$signal" != 0; then
922 echo "caught signal $signal" >&2
926 for signal in 1 2 3 13 15; do
927 trap '{ signal='$signal'; func_exit 1; }' $signal
931 # func_lookup_file file
932 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
935 # - local_gnulib_dir from --local-dir
937 # - lookedup_file name of the merged (combined) file
938 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
942 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
943 lookedup_file="$local_gnulib_dir/$lkfile"
946 if test -f "$gnulib_dir/$lkfile"; then
947 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
948 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
950 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
951 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
952 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
953 lookedup_file="$tmp/$lkbase"
956 lookedup_file="$gnulib_dir/$lkfile"
960 func_fatal_error "file $gnulib_dir/$lkfile not found"
967 # - local_gnulib_dir from --local-dir
970 # Filter out metainformation files like README, which are not modules.
971 # Filter out unit test modules; they can be retrieved through
972 # --extract-tests-module if desired.
974 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
975 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
976 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
979 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
980 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
981 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
982 -e '/^README$/d' -e '/\/README$/d' \
984 -e '/^TEMPLATE-EXTENDED$/d' \
985 -e '/^TEMPLATE-TESTS$/d' \
988 | sed -e '/-tests$/d' \
993 # verifies a module name
995 # - local_gnulib_dir from --local-dir
996 # - module module name argument
997 func_verify_module ()
999 if { test -f "$gnulib_dir/modules/$module" \
1000 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1001 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1002 && test "CVS" != "$module" \
1003 && test "ChangeLog" != "$module" \
1004 && test "COPYING" != "$module" \
1005 && test "README" != "$module" \
1006 && test "TEMPLATE" != "$module" \
1007 && test "TEMPLATE-EXTENDED" != "$module" \
1008 && test "TEMPLATE-TESTS" != "$module"; then
1009 # OK, $module is a correct module name.
1010 # Verify that building the module description with 'patch' succeeds.
1011 func_lookup_file "modules/$module"
1013 echo "gnulib-tool: module $module doesn't exist" 1>&2
1018 # func_verify_nontests_module
1019 # verifies a module name, excluding tests modules
1021 # - local_gnulib_dir from --local-dir
1022 # - module module name argument
1023 func_verify_nontests_module ()
1026 *-tests ) module= ;;
1027 * ) func_verify_module ;;
1031 # func_verify_tests_module
1032 # verifies a module name, considering only tests modules
1034 # - local_gnulib_dir from --local-dir
1035 # - module module name argument
1036 func_verify_tests_module ()
1039 *-tests ) func_verify_module ;;
1044 sed_extract_prog=':[ ]*$/ {
1047 s/^Description:[ ]*$//
1049 s/^Depends-on:[ ]*$//
1050 s/^configure\.ac-early:[ ]*$//
1051 s/^configure\.ac:[ ]*$//
1052 s/^Makefile\.am:[ ]*$//
1056 s/^Maintainer:[ ]*$//
1063 # func_get_description module
1065 # - local_gnulib_dir from --local-dir
1066 func_get_description ()
1068 func_lookup_file "modules/$1"
1069 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1072 # func_get_filelist module
1074 # - local_gnulib_dir from --local-dir
1075 func_get_filelist ()
1077 func_lookup_file "modules/$1"
1078 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1079 echo m4/gnulib-common.m4
1080 case "$autoconf_minversion" in
1082 #echo m4/onceonly.m4
1083 echo m4/onceonly_2_57.m4
1088 # func_get_dependencies module
1090 # - local_gnulib_dir from --local-dir
1091 func_get_dependencies ()
1093 # ${module}-tests always implicitly depends on ${module}.
1094 echo "$1" | sed -n -e 's/-tests//p'
1095 # Then the explicit dependencies listed in the module description.
1096 func_lookup_file "modules/$1"
1097 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1100 # func_get_autoconf_early_snippet module
1102 # - local_gnulib_dir from --local-dir
1103 func_get_autoconf_early_snippet ()
1105 func_lookup_file "modules/$1"
1106 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1109 # func_get_autoconf_snippet module
1111 # - local_gnulib_dir from --local-dir
1112 func_get_autoconf_snippet ()
1114 func_lookup_file "modules/$1"
1115 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1118 # func_get_automake_snippet module
1120 # - local_gnulib_dir from --local-dir
1121 func_get_automake_snippet ()
1123 func_lookup_file "modules/$1"
1124 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1127 # *-tests module live in tests/, not lib/.
1130 # Synthesize an EXTRA_DIST augmentation.
1131 sed_combine_lines='/\\$/{
1138 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1139 already_mentioned_files=` \
1140 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1141 | sed -e "$sed_combine_lines" \
1142 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1143 all_files=`func_get_filelist $1`
1144 lib_files=`for f in $all_files; do \
1148 done | sed -e 's,^lib/,,'`
1149 # Remove $already_mentioned_files from $lib_files.
1150 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1151 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1152 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1153 if test -n "$extra_files"; then
1154 echo "EXTRA_DIST +=" $extra_files
1157 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1158 # This is necessary so that automake can generate the right list of
1160 # A possible approach would be to use autom4te --trace of the redefined
1161 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1162 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1163 # inside autoconf's built-in macros are not missed).
1164 # But it's simpler and more robust to do it here, based on the file list.
1165 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1166 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1167 # automake will generate a useless dependency; this is harmless.
1169 relocatable-prog-wrapper) ;;
1171 sed_extract_c_files='/\.c$/p'
1172 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1173 if test -n "$extra_files"; then
1174 echo "EXTRA_lib_SOURCES +=" $extra_files
1183 # func_get_include_directive module
1185 # - local_gnulib_dir from --local-dir
1186 func_get_include_directive ()
1188 func_lookup_file "modules/$1"
1189 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1190 sed -e 's/^\(["<]\)/#include \1/'
1193 # func_get_link_directive module
1195 # - local_gnulib_dir from --local-dir
1196 func_get_link_directive ()
1198 func_lookup_file "modules/$1"
1199 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1202 # func_get_license module
1204 # - local_gnulib_dir from --local-dir
1207 func_lookup_file "modules/$1"
1208 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1209 # The default is GPL.
1211 } | sed -e 's,^ *$,,' | sed -e 1q
1214 # func_get_maintainer module
1216 # - local_gnulib_dir from --local-dir
1217 func_get_maintainer ()
1219 func_lookup_file "modules/$1"
1220 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1223 # func_get_tests_module module
1225 # - local_gnulib_dir from --local-dir
1226 func_get_tests_module ()
1228 # The naming convention for tests modules is hardwired: ${module}-tests.
1229 if test -f "$gnulib_dir/modules/$1"-tests \
1230 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1231 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1236 # func_acceptable module
1237 # tests whether a module is acceptable.
1239 # - avoidlist list of modules to avoid
1242 for avoid in $avoidlist; do
1243 if test "$avoid" = "$1"; then
1250 # func_modules_transitive_closure
1252 # - local_gnulib_dir from --local-dir
1253 # - modules list of specified modules
1254 # - inctests true if tests should be included, blank otherwise
1255 # - avoidlist list of modules to avoid
1256 # - tmp pathname of a temporary directory
1258 # - modules list of modules, including dependencies
1259 func_modules_transitive_closure ()
1261 # In order to process every module only once (for speed), process an "input
1262 # list" of modules, producing an "output list" of modules. During each round,
1263 # more modules can be queued in the input list. Once a module on the input
1264 # list has been processed, it is added to the "handled list", so we can avoid
1265 # to process it again.
1267 inmodules="$modules"
1269 while test -n "$inmodules"; do
1270 inmodules_this_round="$inmodules"
1271 inmodules= # Accumulator, queue for next round
1272 for module in $inmodules_this_round; do
1274 if test -n "$module"; then
1275 if func_acceptable $module; then
1276 func_append outmodules " $module"
1277 deps=`func_get_dependencies $module`
1278 # Duplicate dependencies are harmless, but Jim wants a warning.
1279 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1280 if test -n "$duplicated_deps"; then
1281 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1283 func_append inmodules " $deps"
1284 if test -n "$inctests"; then
1285 testsmodule=`func_get_tests_module $module`
1286 if test -n "$testsmodule"; then
1287 func_append inmodules " $testsmodule"
1293 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1294 # Remove $handledmodules from $inmodules.
1295 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1296 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1298 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1299 rm -f "$tmp"/queued-modules
1302 # func_modules_add_dummy
1304 # - local_gnulib_dir from --local-dir
1305 # - modules list of modules, including dependencies
1307 # - modules list of modules, including 'dummy' if needed
1308 func_modules_add_dummy ()
1311 sed_remove_backslash_newline=':a
1318 for module in $modules; do
1319 func_verify_nontests_module
1320 if test -n "$module"; then
1321 # Extract the value of "lib_SOURCES += ...".
1322 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1323 # Ignore .h files since they are not compiled.
1326 *) have_lib_SOURCES=yes ;;
1331 # Add the dummy module, to make sure the library will be non-empty.
1332 if test -z "$have_lib_SOURCES"; then
1333 if func_acceptable "dummy"; then
1334 func_append modules " dummy"
1339 # func_modules_to_filelist
1341 # - local_gnulib_dir from --local-dir
1342 # - modules list of modules, including dependencies
1344 # - files list of files
1345 func_modules_to_filelist ()
1348 for module in $modules; do
1350 if test -n "$module"; then
1351 fs=`func_get_filelist $module`
1352 func_append files " $fs"
1355 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1358 # func_emit_lib_Makefile_am
1359 # emits the contents of library makefile to standard output.
1361 # - local_gnulib_dir from --local-dir
1362 # - modules list of modules, including dependencies
1363 # - libname library name
1364 # - auxdir directory relative to destdir where to place build aux files
1365 # - makefile_name from --makefile-name
1366 # - libtool true if libtool will be used, false or blank otherwise
1367 # - macro_prefix prefix of gl_LIBOBJS macros to use
1368 # - actioncmd (optional) command that will reproduce this invocation
1369 # - for_test true if creating a package for testing, false otherwise
1371 # - uses_subdirs nonempty if object files in subdirs exist
1372 func_emit_lib_Makefile_am ()
1374 # When creating an includable Makefile.am snippet, augment variables with
1375 # += instead of assigning them.
1376 if test -n "$makefile_name"; then
1381 if test "$libtool" = true; then
1384 sed_eliminate_LDFLAGS=
1388 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1391 # When creating a package for testing: Attempt to provoke failures,
1392 # especially link errors, already during "make" rather than during
1393 # "make check", because "make check" is not possible in a cross-compiling
1394 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1395 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1397 sed_transform_check_PROGRAMS=
1399 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1400 echo "## Process this file with automake to produce Makefile.in."
1401 func_emit_copyright_notice
1402 if test -n "$actioncmd"; then
1403 echo "# Reproduce by: $actioncmd"
1408 for module in $modules; do
1409 func_verify_nontests_module
1410 if test -n "$module"; then
1412 func_get_automake_snippet "$module" |
1413 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1414 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1415 -e "$sed_eliminate_LDFLAGS" \
1416 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1417 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1418 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1419 -e "$sed_transform_check_PROGRAMS"
1420 if test "$module" = 'alloca'; then
1421 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1422 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1425 # Skip the contents if its entirely empty.
1426 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1427 echo "## begin gnulib module $module"
1430 echo "## end gnulib module $module"
1434 # Test whether there are some source files in subdirectories.
1435 for f in `func_get_filelist "$module"`; do
1437 lib/*/*.c) uses_subdirs=yes ;;
1443 if test -z "$makefile_name"; then
1444 # If there are source files in subdirectories, prevent collision of the
1445 # object files (example: hash.c and libxml/hash.c).
1447 if test -n "$uses_subdirs"; then
1448 subdir_options=' subdir-objects'
1450 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1453 if test -z "$makefile_name"; then
1454 echo "noinst_HEADERS ="
1455 echo "noinst_LIBRARIES ="
1456 echo "noinst_LTLIBRARIES ="
1457 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1458 # if you specify pkgdata_DATA to empty. This is a workaround.
1459 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1460 echo "pkgdata_DATA ="
1463 echo "BUILT_SOURCES ="
1466 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1467 if test -z "$makefile_name"; then
1468 echo "MOSTLYCLEANDIRS ="
1470 echo "DISTCLEANFILES ="
1471 echo "MAINTAINERCLEANFILES ="
1473 echo "AM_CPPFLAGS ="
1476 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1477 # One of the snippets already specifies an installation location for the
1478 # library. Don't confuse automake by saying it should not be installed.
1481 # By default, the generated library should not be installed.
1482 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1485 echo "${libname}_${libext}_SOURCES ="
1486 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1487 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1488 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1489 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1490 echo "EXTRA_${libname}_${libext}_SOURCES ="
1491 if test "$libtool" = true; then
1492 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1495 cat allsnippets.tmp \
1496 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1498 echo "mostlyclean-local: mostlyclean-generic"
1499 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1500 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1501 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1504 rm -f allsnippets.tmp
1507 # func_emit_tests_Makefile_am
1508 # emits the contents of tests makefile to standard output.
1510 # - local_gnulib_dir from --local-dir
1511 # - modules list of modules, including dependencies
1512 # - libname library name
1513 # - makefile_name from --makefile-name
1514 # - libtool true if libtool will be used, false or blank otherwise
1515 # - sourcebase relative directory containing lib source code
1516 # - m4base relative directory containing autoconf macros
1517 # - testsbase relative directory containing unit test code
1518 # - for_test true if creating a package for testing, false otherwise
1519 func_emit_tests_Makefile_am ()
1521 if test "$libtool" = true; then
1526 if test "$libtool" = true; then
1528 sed_eliminate_LDFLAGS=
1531 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1534 # When creating a package for testing: Attempt to provoke failures,
1535 # especially link errors, already during "make" rather than during
1536 # "make check", because "make check" is not possible in a cross-compiling
1537 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1538 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1540 sed_transform_check_PROGRAMS=
1542 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1543 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1544 echo "## Process this file with automake to produce Makefile.in."
1545 func_emit_copyright_notice
1547 # Generate dependencies here, since it eases the debugging of test failures.
1548 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1550 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1553 for module in $modules; do
1554 func_verify_tests_module
1555 if test -n "$module"; then
1557 func_get_automake_snippet "$module" |
1558 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1559 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1560 -e "$sed_eliminate_LDFLAGS" \
1561 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1562 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1563 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1564 -e "$sed_transform_check_PROGRAMS"
1566 # Skip the contents if its entirely empty.
1567 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1568 echo "## begin gnulib module $module"
1571 echo "## end gnulib module $module"
1578 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1579 # variable is needed to avoid an error from automake:
1580 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1583 echo "TESTS_ENVIRONMENT ="
1584 echo "noinst_PROGRAMS ="
1585 if ! $for_test; then
1586 echo "check_PROGRAMS ="
1588 echo "noinst_HEADERS ="
1589 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1590 echo "pkgdata_DATA ="
1593 echo "BUILT_SOURCES ="
1595 echo "MOSTLYCLEANFILES = core *.stackdump"
1596 echo "MOSTLYCLEANDIRS ="
1598 echo "DISTCLEANFILES ="
1599 echo "MAINTAINERCLEANFILES ="
1601 echo "AM_CPPFLAGS = \\"
1602 echo " -I. -I\$(srcdir) \\"
1603 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1604 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1606 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1609 echo "# Clean up after Solaris cc."
1611 echo " rm -rf SunWS_cache"
1613 echo "mostlyclean-local: mostlyclean-generic"
1614 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1615 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1616 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1619 rm -f allsnippets.tmp
1622 # func_emit_initmacro_start
1623 # emits the first few statements of the gl_INIT macro to standard output.
1624 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1625 func_emit_initmacro_start ()
1627 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1628 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1629 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1630 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1632 # Furthermore it avoids an automake error like this when a Makefile.am
1633 # that uses pieces of gnulib also uses $(LIBOBJ):
1634 # automatically discovered file `error.c' should not be explicitly mentioned
1635 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1636 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1637 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1638 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1639 # automatically discovered file `error.c' should not be explicitly mentioned
1640 # We let automake know about the files to be distributed through the
1641 # EXTRA_lib_SOURCES variable.
1642 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1645 # func_emit_initmacro_end
1646 # emits the last few statements of the gl_INIT macro to standard output.
1647 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1648 func_emit_initmacro_end ()
1650 echo " m4_popdef([AC_LIBSOURCES])"
1651 echo " m4_popdef([AC_REPLACE_FUNCS])"
1652 echo " m4_popdef([AC_LIBOBJ])"
1653 echo " AC_CONFIG_COMMANDS_PRE(["
1654 echo " ${macro_prefix}_libobjs="
1655 echo " ${macro_prefix}_ltlibobjs="
1656 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1657 echo " # Remove the extension."
1658 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1659 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1660 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1661 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1664 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1665 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1669 # func_emit_initmacro_done
1670 # emits a few statements after the gl_INIT macro to standard output.
1671 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1672 func_emit_initmacro_done ()
1675 echo "# Like AC_LIBOBJ, except that the module name goes"
1676 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1677 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1678 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1680 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1681 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1682 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1683 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1685 echo "# Like AC_LIBSOURCES, except that it does nothing."
1686 echo "# We rely on EXTRA_lib..._SOURCES instead."
1687 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1691 # func_import modules
1692 # Uses also the variables
1693 # - destdir target directory
1694 # - local_gnulib_dir from --local-dir
1695 # - libname library name
1696 # - sourcebase directory relative to destdir where to place source code
1697 # - m4base directory relative to destdir where to place *.m4 macros
1698 # - docbase directory relative to destdir where to place doc files
1699 # - testsbase directory relative to destdir where to place unit test code
1700 # - auxdir directory relative to destdir where to place build aux files
1701 # - inctests true if --with-tests was given, blank otherwise
1702 # - avoidlist list of modules to avoid, from --avoid
1703 # - lgpl true if library's license shall be LGPL, blank otherwise
1704 # - makefile_name from --makefile-name
1705 # - libtool true if --libtool was given, false if --no-libtool was
1706 # given, blank otherwise
1707 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1708 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1709 # - autoconf_minversion minimum supported autoconf version
1710 # - doit : if actions shall be executed, false if only to be printed
1711 # - symbolic true if files should be symlinked, copied otherwise
1712 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1716 # Get the cached settings.
1717 cached_local_gnulib_dir=
1718 cached_specified_modules=
1727 cached_makefile_name=
1729 cached_macro_prefix=
1731 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1732 cached_libtool=false
1738 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1741 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1744 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1747 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1750 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1753 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1756 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1759 s,^.*$,cached_inctests=true,p
1762 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1765 s,^.*$,cached_lgpl=true,p
1767 /gl_MAKEFILE_NAME(/ {
1768 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1771 s,^.*$,cached_libtool=true,p
1773 /gl_MACRO_PREFIX(/ {
1774 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1776 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1777 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1782 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1783 s,^.*$,cached_files=",p
1795 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1799 # Merge the cached settings with the specified ones.
1800 # The m4base must be the same as expected from the pathname.
1801 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1802 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1804 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1805 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1806 if test -z "$local_gnulib_dir"; then
1807 if test -n "$cached_local_gnulib_dir"; then
1810 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1812 case "$cached_local_gnulib_dir" in
1814 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1816 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1817 local_gnulib_dir="$relconcat" ;;
1822 # Append the cached and the specified module names. So that
1823 # "gnulib-tool --import foo" means to add the module foo.
1824 specified_modules="$cached_specified_modules $1"
1825 # Append the cached and the specified avoidlist. This is probably better
1826 # than dropping the cached one when --avoid is specified at least once.
1827 avoidlist=`echo $cached_avoidlist $avoidlist`
1828 # The sourcebase defaults to the cached one.
1829 if test -z "$sourcebase"; then
1830 sourcebase="$cached_sourcebase"
1831 if test -z "$sourcebase"; then
1832 func_fatal_error "missing --source-base option"
1835 # The docbase defaults to the cached one.
1836 if test -z "$docbase"; then
1837 docbase="$cached_docbase"
1838 if test -z "$docbase"; then
1839 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."
1842 # The testsbase defaults to the cached one.
1843 if test -z "$testsbase"; then
1844 testsbase="$cached_testsbase"
1845 if test -z "$testsbase"; then
1846 func_fatal_error "missing --tests-base option"
1849 # Require the tests if specified either way.
1850 if test -z "$inctests"; then
1851 inctests="$cached_inctests"
1853 # The libname defaults to the cached one.
1854 if test -z "$supplied_libname"; then
1855 libname="$cached_libname"
1856 if test -z "$libname"; then
1857 func_fatal_error "missing --lib option"
1860 # Require LGPL if specified either way.
1861 if test -z "$lgpl"; then
1864 # The makefile_name defaults to the cached one.
1865 if test -z "$makefile_name"; then
1866 makefile_name="$cached_makefile_name"
1868 # Use libtool if specified either way, or if guessed.
1869 if test -z "$libtool"; then
1870 if test -n "$cached_m4base"; then
1871 libtool="$cached_libtool"
1873 libtool="$guessed_libtool"
1876 # The macro_prefix defaults to the cached one.
1877 if test -z "$macro_prefix"; then
1878 macro_prefix="$cached_macro_prefix"
1879 if test -z "$macro_prefix"; then
1880 func_fatal_error "missing --macro-prefix option"
1884 # Canonicalize the list of specified modules.
1885 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1887 # Determine final module list.
1888 modules="$specified_modules"
1889 func_modules_transitive_closure
1890 echo "Module list with included dependencies:"
1891 echo "$modules" | sed -e 's/^/ /'
1893 # Add the dummy module if needed.
1894 func_modules_add_dummy
1896 # If --lgpl, verify that the licenses of modules are compatible.
1897 if test -n "$lgpl"; then
1898 for module in $modules; do
1899 license=`func_get_license $module`
1901 LGPL | 'GPLed build tool') ;;
1902 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1903 *) func_fatal_error "incompatible license on module $module: $license" ;;
1908 # Determine script to apply to imported library files.
1909 sed_transform_lib_file=
1910 for module in $modules; do
1911 if test $module = config-h; then
1912 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1913 sed_transform_lib_file=$sed_transform_lib_file'
1914 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1919 if test -n "$lgpl"; then
1921 sed_transform_lib_file=$sed_transform_lib_file'
1922 s/GNU General/GNU Lesser General/g
1923 s/version 2\([ ,]\)/version 2.1\1/g
1927 # Determine final file list.
1928 func_modules_to_filelist
1930 echo "$files" | sed -e 's/^/ /'
1933 || func_fatal_error "refusing to do nothing"
1935 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1936 new_files="$files m4/gnulib-tool.m4"
1937 old_files="$cached_files"
1938 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1939 func_append old_files " m4/gnulib-tool.m4"
1942 sed_rewrite_old_files="\
1943 s,^build-aux/,$auxdir/,
1944 s,^doc/,$cached_docbase/,
1945 s,^lib/,$cached_sourcebase/,
1946 s,^m4/,$cached_m4base/,
1947 s,^tests/,$cached_testsbase/,"
1948 sed_rewrite_new_files="\
1949 s,^build-aux/,$auxdir/,
1951 s,^lib/,$sourcebase/,
1953 s,^tests/,$testsbase/,"
1955 # Create directories.
1956 { echo "$sourcebase"
1958 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1959 if test -n "$docfiles"; then
1962 if test -n "$inctests"; then
1966 for f in $files; do echo $f; done \
1967 | sed -e "$sed_rewrite_new_files" \
1968 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
1971 { # Rearrange file descriptors. Needed because "while ... done < ..."
1972 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1973 exec 5<&0 < "$tmp"/dirs
1975 if test ! -d "$destdir/$d"; then
1977 echo "Creating directory $destdir/$d"
1978 mkdir -p "$destdir/$d" || func_fatal_error "failed"
1980 echo "Create directory $destdir/$d"
1987 # func_dest_tmpfilename file
1988 # determines the name of a temporary file (file is relative to destdir).
1990 # - tmpfile absolute filename of the temporary file
1991 func_dest_tmpfilename ()
1994 # Put the new contents of $file in a file in the same directory (needed
1995 # to guarantee that an 'mv' to "$destdir/$file" works).
1996 tmpfile="$destdir/$1.tmp"
1998 # Put the new contents of $file in a file in a temporary directory
1999 # (because the directory of "$file" might not exist).
2000 tmpfile="$tmp"/`basename "$1"`.tmp
2004 # Copy files or make symbolic links. Remove obsolete files.
2008 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2009 # representing the files according to the last gnulib-tool invocation.
2010 for f in $old_files; do echo $f; done \
2011 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2014 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2015 # representing the files after this gnulib-tool invocation.
2016 for f in $new_files; do echo $f; done \
2017 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2020 # First the files that are in old-files, but not in new-files:
2021 sed_take_first_column='s,'"$delimiter"'.*,,'
2022 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2023 # Remove the file. Do nothing if the user already removed it.
2024 if test -f "$destdir/$g"; then
2026 echo "Removing file $g (backup in ${g}~)"
2027 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2029 echo "Remove file $g (backup in ${g}~)"
2031 func_append removed_files "$g$nl"
2034 # func_add_or_update handles a file that ought to be present afterwards.
2036 # - f the original file name
2037 # - g the rewritten file name
2038 # - already_present nonempty if the file already exists, empty otherwise
2039 func_add_or_update ()
2041 func_dest_tmpfilename "$g"
2042 func_lookup_file "$f"
2043 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2044 if test -n "$sed_transform_lib_file"; then
2047 sed -e "$sed_transform_lib_file" \
2048 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2052 if test -f "$destdir/$g"; then
2053 # The file already exists.
2054 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2055 : # The file has not changed.
2059 if test -n "$already_present"; then
2060 echo "Updating file $g (backup in ${g}~)"
2062 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2064 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2065 if { test -n "$symbolic" \
2066 || { test -n "$lsymbolic" \
2067 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2068 && test -z "$lookedup_tmp" \
2069 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2070 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2072 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2075 if test -n "$already_present"; then
2076 echo "Update file $g (backup in ${g}~)"
2078 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2084 # Don't protest if the file should be there but isn't: it happens
2085 # frequently that developers don't put autogenerated files into CVS.
2087 echo "Copying file $g"
2088 if { test -n "$symbolic" \
2089 || { test -n "$lsymbolic" \
2090 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2091 && test -z "$lookedup_tmp" \
2092 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2093 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2095 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2100 func_append added_files "$g$nl"
2104 # Then the files that are in new-files, but not in old-files:
2105 sed_take_last_column='s,^.*'"$delimiter"',,'
2107 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2108 | sed -e "$sed_take_last_column" \
2109 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2110 { # Rearrange file descriptors. Needed because "while ... done < ..."
2111 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2112 exec 5<&0 < "$tmp"/added-files
2118 # Then the files that are in new-files and in old-files:
2119 already_present=true
2120 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2121 | sed -e "$sed_take_last_column" \
2122 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2123 { # Rearrange file descriptors. Needed because "while ... done < ..."
2124 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2125 exec 5<&0 < "$tmp"/kept-files
2132 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2133 actioncmd="gnulib-tool --import"
2134 func_append actioncmd " --dir=$destdir"
2135 if test -n "$local_gnulib_dir"; then
2136 func_append actioncmd " --local-dir=$local_gnulib_dir"
2138 func_append actioncmd " --lib=$libname"
2139 func_append actioncmd " --source-base=$sourcebase"
2140 func_append actioncmd " --m4-base=$m4base"
2141 func_append actioncmd " --doc-base=$docbase"
2142 func_append actioncmd " --aux-dir=$auxdir"
2143 if test -n "$inctests"; then
2144 func_append actioncmd " --with-tests"
2146 for module in $avoidlist; do
2147 func_append actioncmd " --avoid=$module"
2149 if test -n "$lgpl"; then
2150 func_append actioncmd " --lgpl"
2152 if test -n "$makefile_name"; then
2153 func_append actioncmd " --makefile-name=$makefile_name"
2155 if test "$libtool" = true; then
2156 func_append actioncmd " --libtool"
2158 func_append actioncmd " --no-libtool"
2160 func_append actioncmd " --macro-prefix=$macro_prefix"
2161 func_append actioncmd " `echo $specified_modules`"
2163 # Default the makefile name to Makefile.am.
2164 if test -n "$makefile_name"; then
2165 makefile_am=$makefile_name
2167 makefile_am=Makefile.am
2170 # Create normal Makefile.ams.
2173 # Create library makefile.
2174 func_dest_tmpfilename $sourcebase/$makefile_am
2175 func_emit_lib_Makefile_am > "$tmpfile"
2176 if test -f "$destdir"/$sourcebase/$makefile_am; then
2177 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2181 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2182 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2183 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2185 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2191 echo "Creating $sourcebase/$makefile_am"
2192 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2194 echo "Create $sourcebase/$makefile_am"
2197 func_append added_files "$sourcebase/$makefile_am$nl"
2200 # Create m4/gnulib-cache.m4.
2201 func_dest_tmpfilename $m4base/gnulib-cache.m4
2203 func_emit_copyright_notice
2205 echo "# This file represents the specification of how gnulib-tool is used."
2206 echo "# It acts as a cache: It is written and read by gnulib-tool."
2207 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2208 echo "# like the configure.ac and various Makefile.am files."
2211 echo "# Specification in the form of a command-line invocation:"
2214 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2215 # Store the local_gnulib_dir relative to destdir.
2216 case "$local_gnulib_dir" in
2218 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2221 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2223 # destdir, local_gnulib_dir are both relative.
2224 func_relativize "$destdir" "$local_gnulib_dir"
2225 relative_local_gnulib_dir="$reldir" ;;
2228 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2229 echo "gl_MODULES(["`echo $specified_modules`"])"
2230 echo "gl_AVOID([$avoidlist])"
2231 echo "gl_SOURCE_BASE([$sourcebase])"
2232 echo "gl_M4_BASE([$m4base])"
2233 echo "gl_DOC_BASE([$docbase])"
2234 echo "gl_TESTS_BASE([$testsbase])"
2235 test -z "$inctests" || echo "gl_WITH_TESTS"
2236 echo "gl_LIB([$libname])"
2237 test -z "$lgpl" || echo "gl_LGPL"
2238 echo "gl_MAKEFILE_NAME([$makefile_name])"
2239 if test "$libtool" = true; then
2242 echo "gl_MACRO_PREFIX([$macro_prefix])"
2244 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2245 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2249 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2250 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2251 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2253 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2257 echo "# gnulib-cache.m4 ends here"
2264 echo "Creating $m4base/gnulib-cache.m4"
2265 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2267 echo "Create $m4base/gnulib-cache.m4"
2273 # Create m4/gnulib-comp.m4.
2274 func_dest_tmpfilename $m4base/gnulib-comp.m4
2276 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2277 func_emit_copyright_notice
2279 echo "# This file represents the compiled summary of the specification in"
2280 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2281 echo "# to be invoked from configure.ac."
2282 echo "# In projects using CVS, this file can be treated like other built files."
2285 echo "# This macro should be invoked from $configure_ac, in the section"
2286 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2287 echo "# any checks for libraries, header files, types and library functions."
2288 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2290 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2291 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2292 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2293 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2294 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2295 if test -n "$uses_subdirs"; then
2296 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2298 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2299 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2301 for module in $modules; do
2303 if test -n "$module"; then
2304 func_get_autoconf_early_snippet "$module"
2307 | sed -e '/^$/d;' -e 's/^/ /'
2310 echo "# This macro should be invoked from $configure_ac, in the section"
2311 echo "# \"Check for header files, types and library functions\"."
2312 echo "AC_DEFUN([${macro_prefix}_INIT],"
2314 func_emit_initmacro_start
2315 if test "$libtool" = true; then
2316 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2317 echo " gl_cond_libtool=true"
2319 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2320 echo " gl_cond_libtool=false"
2322 echo " gl_ltlibdeps="
2324 echo " gl_source_base='$sourcebase'"
2325 if test "$auxdir" != "build-aux"; then
2326 sed_replace_build_aux='
2328 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2329 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2333 sed_replace_build_aux=
2335 for module in $modules; do
2337 if test -n "$module"; then
2338 func_get_autoconf_snippet "$module" \
2339 | sed -e '/^$/d;' -e 's/^/ /' \
2340 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2341 -e "$sed_replace_build_aux"
2342 if test "$module" = 'alloca' && test "$libtool" = true; then
2343 echo 'changequote(,)dnl'
2344 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2345 echo 'changequote([, ])dnl'
2346 echo 'AC_SUBST([LTALLOCA])'
2350 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2351 # created using libtool, because libtool already handles the dependencies.
2352 if test "$libtool" != true; then
2353 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2354 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2355 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2356 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2357 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2359 func_emit_initmacro_end
2361 func_emit_initmacro_done
2363 echo "# This macro records the list of files which have been installed by"
2364 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2365 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2366 echo "$files" | sed -e 's,^, ,'
2369 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2370 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2374 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2375 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2376 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2378 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2382 echo "# gnulib-comp.m4 ends here"
2389 echo "Creating $m4base/gnulib-comp.m4"
2390 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2392 echo "Create $m4base/gnulib-comp.m4"
2398 if test -n "$inctests"; then
2399 # Create tests makefile.
2400 func_dest_tmpfilename $testsbase/$makefile_am
2401 func_emit_tests_Makefile_am > "$tmpfile"
2402 if test -f "$destdir"/$testsbase/$makefile_am; then
2403 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2407 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2408 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2409 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2411 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2417 echo "Creating $testsbase/$makefile_am"
2418 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2420 echo "Create $testsbase/$makefile_am"
2423 func_append added_files "$testsbase/$makefile_am$nl"
2427 # Update the .cvsignore and .gitignore files.
2428 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
2429 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
2430 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
2431 { # Rearrange file descriptors. Needed because "while ... done < ..."
2432 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2433 exec 5<&0 < "$tmp"/fileset-changes
2434 func_update_ignorelist ()
2437 if test -f "$destdir/$dir$ignore"; then
2438 if test -n "$dir_added" || test -n "$dir_removed"; then
2439 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
2440 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
2441 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
2442 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
2443 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
2444 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
2446 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2447 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
2448 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
2449 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
2450 | sed -f "$tmp"/sed-ignore-removed \
2451 > "$destdir/$dir$ignore"
2453 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2458 if test -n "$dir_added"; then
2460 echo "Creating $destdir/$dir$ignore"
2461 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u > "$destdir/$dir$ignore"
2463 echo "Create $destdir/$dir$ignore"
2473 if test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
2474 func_update_ignorelist .cvsignore
2476 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
2477 func_update_ignorelist .gitignore
2484 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
2485 next_dir=`echo "$line" | sed -e 's,|.*,,'`
2486 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
2487 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
2488 if test "$next_dir" != "$last_dir"; then
2489 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2490 last_dir="$next_dir"
2495 A) func_append last_dir_added "$file$nl";;
2496 R) func_append last_dir_removed "$file$nl";;
2499 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2505 echo "You may need to add #include directives for the following .h files."
2506 # Intersect $specified_modules and $modules
2507 # (since $specified_modules is not necessarily of subset of $modules - some
2508 # may have been skipped through --avoid, and since the elements of $modules
2509 # but not in $specified_modules can go away without explicit notice - through
2510 # changes in the module dependencies).
2511 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2512 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2513 # First the #include <...> directives without #ifs, sorted for convenience,
2514 # then the #include "..." directives without #ifs, sorted for convenience,
2515 # then the #include directives that are surrounded by #ifs. Not sorted.
2516 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2517 include_directive=`func_get_include_directive "$module"`
2518 case "$nl$include_directive" in
2520 echo "$include_directive" 1>&5
2523 echo "$include_directive" | grep -v 'include "' 1>&6
2524 echo "$include_directive" | grep 'include "' 1>&7
2527 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2529 LC_ALL=C sort -u "$tmp"/include-angles
2530 LC_ALL=C sort -u "$tmp"/include-quotes
2531 cat "$tmp"/include-if
2532 ) | sed -e '/^$/d' -e 's/^/ /'
2533 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2535 for module in $modules; do
2536 func_get_link_directive "$module"
2538 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
2539 if test `wc -l < "$tmp"/link` != 0; then
2541 echo "You may need to use the following Makefile variables when linking."
2542 echo "Use them in <program>_LDADD when linking a program, or"
2543 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
2549 echo "Don't forget to"
2550 if test "$makefile_am" = Makefile.am; then
2551 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2553 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2555 if test -n "$inctests"; then
2556 if test "$makefile_am" = Makefile.am; then
2557 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2559 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2562 if test "$makefile_am" = Makefile.am; then
2563 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2564 sourcebase_base=`basename "$sourcebase"`
2565 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2567 if test -n "$inctests"; then
2568 if test "$makefile_am" = Makefile.am; then
2569 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2570 testsbase_base=`basename "$testsbase"`
2571 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2574 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2575 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2576 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2579 # func_create_testdir testdir modules
2581 # - local_gnulib_dir from --local-dir
2582 # - auxdir directory relative to destdir where to place build aux files
2583 func_create_testdir ()
2587 if test -z "$modules"; then
2588 # All modules together.
2589 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2590 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2591 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2592 modules=`func_all_modules`
2593 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2595 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2597 # Check that the license of every module is consistent with the license of
2599 saved_modules="$modules"
2600 saved_inctests="$inctests"
2601 # When computing transitive closures, don't consider $module to depend on
2602 # $module-tests. Need this becauses tests are implicitly GPL and may depend
2603 # on GPL modules - therefore we don't want a warning in this case.
2605 for requested_module in $saved_modules; do
2606 requested_license=`func_get_license "$requested_module"`
2607 if test "$requested_license" != GPL; then
2608 # Here we use func_modules_transitive_closure, not just
2609 # func_get_dependencies, so that we also detect weird situations like
2610 # an LGPL module which depends on a GPLed build tool module which depends
2612 modules="$requested_module"
2613 func_modules_transitive_closure
2614 for module in $modules; do
2615 license=`func_get_license "$module"`
2617 LGPL | 'GPLed build tool') ;;
2618 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2619 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2624 modules="$saved_modules"
2625 inctests="$saved_inctests"
2627 # Subdirectory names.
2634 # Determine final module list.
2635 func_modules_transitive_closure
2636 echo "Module list with included dependencies:"
2637 echo "$modules" | sed -e 's/^/ /'
2639 # Add the dummy module if needed.
2640 func_modules_add_dummy
2642 # Determine final file list.
2643 func_modules_to_filelist
2645 echo "$files" | sed -e 's/^/ /'
2647 sed_rewrite_files="\
2648 s,^build-aux/,$auxdir/,
2650 s,^lib/,$sourcebase/,
2652 s,^tests/,$testsbase/,"
2654 # Create directories.
2655 for f in $files; do echo $f; done \
2656 | sed -e "$sed_rewrite_files" \
2657 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2658 | LC_ALL=C sort -u \
2660 { # Rearrange file descriptors. Needed because "while ... done < ..."
2661 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2662 exec 5<&0 < "$tmp"/dirs
2664 mkdir -p "$testdir/$d"
2669 # Copy files or make symbolic links.
2671 for f in $files; do echo $f; done \
2672 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2675 { # Rearrange file descriptors. Needed because "while ... done < ..."
2676 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2677 exec 5<&0 < "$tmp"/files
2679 func_lookup_file "$f"
2680 if test -n "$lookedup_tmp"; then
2681 cp -p "$lookedup_file" "$testdir/$g"
2683 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2684 if { test -n "$symbolic" \
2685 || { test -n "$lsymbolic" \
2686 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
2687 func_ln "$lookedup_file" "$testdir/$g"
2689 cp -p "$lookedup_file" "$testdir/$g"
2696 # Create Makefile.ams that are for testing.
2699 # Create $sourcebase/Makefile.am.
2700 mkdir -p "$testdir/$sourcebase"
2701 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2703 # Create $m4base/Makefile.am.
2704 mkdir -p "$testdir/$m4base"
2705 (echo "## Process this file with automake to produce Makefile.in."
2711 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2714 ) > "$testdir/$m4base/Makefile.am"
2716 subdirs="$sourcebase $m4base"
2717 subdirs_with_configure_ac=""
2719 if false && test -f "$testdir"/$m4base/gettext.m4; then
2720 # Avoid stupid error message from automake:
2721 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2722 mkdir -p "$testdir/po"
2723 (echo "## Process this file with automake to produce Makefile.in."
2724 ) > "$testdir/po/Makefile.am"
2725 func_append subdirs " po"
2728 if test -n "$inctests"; then
2729 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2730 # Create $testsbase/Makefile.am.
2731 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2732 # Create $testsbase/configure.ac.
2733 (echo "# Process this file with autoconf to produce a configure script."
2734 echo "AC_INIT([dummy], [0])"
2735 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2736 echo "AM_INIT_AUTOMAKE"
2738 echo "AM_CONFIG_HEADER([config.h])"
2741 echo "AC_PROG_INSTALL"
2742 echo "AC_PROG_MAKE_SET"
2743 echo "AC_PROG_RANLIB"
2745 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2746 echo "AC_GNU_SOURCE"
2749 for module in $modules; do
2751 if test -n "$module"; then
2752 func_get_autoconf_early_snippet "$module"
2755 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
2756 if test "$libtool" = true; then
2757 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2758 echo "gl_cond_libtool=true"
2760 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2761 echo "gl_cond_libtool=false"
2763 echo "gl_ltlibdeps="
2765 # Wrap the set of autoconf snippets into an autoconf macro that is then
2766 # invoked. This is needed because autoconf does not support AC_REQUIRE
2768 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2769 # but we want the AC_REQUIRE to have its normal meaning (provide one
2770 # expansion of the required macro before the current point, and only one
2772 echo "AC_DEFUN([gl_INIT], ["
2773 func_emit_initmacro_start
2774 sed_replace_build_aux='
2776 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2777 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2780 # We don't have explicit ordering constraints between the various
2781 # autoconf snippets. It's cleanest to put those of the library before
2782 # those of the tests.
2783 echo "gl_source_base='../$sourcebase'"
2784 for module in $modules; do
2785 func_verify_nontests_module
2786 if test -n "$module"; then
2787 func_get_autoconf_snippet "$module" \
2788 | sed -e "$sed_replace_build_aux"
2791 echo "gl_source_base='.'"
2792 for module in $modules; do
2793 func_verify_tests_module
2794 if test -n "$module"; then
2795 func_get_autoconf_snippet "$module" \
2796 | sed -e "$sed_replace_build_aux"
2799 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2800 # created using libtool, because libtool already handles the dependencies.
2801 if test "$libtool" != true; then
2802 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2803 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2804 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2805 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2806 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2808 func_emit_initmacro_end
2810 func_emit_initmacro_done
2814 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2815 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2816 echo "AH_TOP([#include \"../config.h\"])"
2818 echo "AC_OUTPUT([Makefile])"
2819 ) > "$testdir/$testsbase/configure.ac"
2820 func_append subdirs " $testsbase"
2821 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2824 # Create Makefile.am.
2825 (echo "## Process this file with automake to produce Makefile.in."
2827 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2829 echo "SUBDIRS = $subdirs"
2831 echo "ACLOCAL_AMFLAGS = -I $m4base"
2832 ) > "$testdir/Makefile.am"
2834 # Create configure.ac.
2835 (echo "# Process this file with autoconf to produce a configure script."
2836 echo "AC_INIT([dummy], [0])"
2837 if test "$auxdir" != "."; then
2838 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2840 echo "AM_INIT_AUTOMAKE"
2842 echo "AM_CONFIG_HEADER([config.h])"
2845 echo "AC_PROG_INSTALL"
2846 echo "AC_PROG_MAKE_SET"
2848 echo "# For autobuild."
2849 echo "AC_CANONICAL_BUILD"
2850 echo "AC_CANONICAL_HOST"
2852 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2853 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2854 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2855 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2857 echo "AC_PROG_RANLIB"
2859 if test -n "$uses_subdirs"; then
2860 echo "AM_PROG_CC_C_O"
2863 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2864 echo "AC_GNU_SOURCE"
2867 for module in $modules; do
2868 func_verify_nontests_module
2869 if test -n "$module"; then
2870 func_get_autoconf_early_snippet "$module"
2873 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
2874 if test "$libtool" = true; then
2875 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2876 echo "gl_cond_libtool=true"
2878 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2879 echo "gl_cond_libtool=false"
2881 echo "gl_ltlibdeps="
2883 echo "gl_source_base='$sourcebase'"
2884 # Wrap the set of autoconf snippets into an autoconf macro that is then
2885 # invoked. This is needed because autoconf does not support AC_REQUIRE
2887 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2888 # but we want the AC_REQUIRE to have its normal meaning (provide one
2889 # expansion of the required macro before the current point, and only one
2891 echo "AC_DEFUN([gl_INIT], ["
2892 func_emit_initmacro_start
2893 if test "$auxdir" != "build-aux"; then
2894 sed_replace_build_aux='
2896 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2897 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2901 sed_replace_build_aux=
2903 for module in $modules; do
2904 func_verify_nontests_module
2905 if test -n "$module"; then
2906 func_get_autoconf_snippet "$module" \
2907 | sed -e "$sed_replace_build_aux"
2910 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2911 # created using libtool, because libtool already handles the dependencies.
2912 if test "$libtool" != true; then
2913 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2914 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2915 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2916 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2917 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2919 func_emit_initmacro_end
2921 func_emit_initmacro_done
2925 if test -n "$subdirs_with_configure_ac"; then
2926 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2928 makefiles="Makefile"
2929 for d in $subdirs; do
2930 # For subdirs that have a configure.ac by their own, it's the subdir's
2931 # configure.ac which creates the subdir's Makefile.am, not this one.
2932 case " $subdirs_with_configure_ac " in
2934 *) func_append makefiles " $d/Makefile" ;;
2937 echo "AC_OUTPUT([$makefiles])"
2938 ) > "$testdir/configure.ac"
2940 # Create autogenerated files.
2942 # Do not use "${AUTORECONF} --force --install", because it may invoke
2943 # autopoint, which brings in older versions of some of our .m4 files.
2944 if test -f $m4base/gettext.m4; then
2945 echo "executing ${AUTOPOINT} --force"
2946 ${AUTOPOINT} --force || func_exit 1
2947 for f in $m4base/*.m4~; do
2948 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2951 echo "executing ${ACLOCAL} -I $m4base"
2952 ${ACLOCAL} -I $m4base || func_exit 1
2953 if ! test -d build-aux; then
2954 echo "executing mkdir build-aux"
2955 mkdir build-aux || func_exit 1
2957 echo "executing ${AUTOCONF}"
2958 ${AUTOCONF} || func_exit 1
2959 echo "executing ${AUTOHEADER}"
2960 ${AUTOHEADER} || func_exit 1
2961 echo "executing ${AUTOMAKE} --add-missing --copy"
2962 ${AUTOMAKE} --add-missing --copy || func_exit 1
2964 if test -n "$inctests"; then
2965 # Create autogenerated files.
2966 (cd "$testdir/$testsbase" || func_exit 1
2967 # Do not use "${AUTORECONF} --force --install", because it may invoke
2968 # autopoint, which brings in older versions of some of our .m4 files.
2969 if test -f ../$m4base/gettext.m4; then
2970 echo "executing ${AUTOPOINT} --force"
2971 ${AUTOPOINT} --force || func_exit 1
2972 for f in ../$m4base/*.m4~; do
2973 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2976 echo "executing ${ACLOCAL} -I ../$m4base"
2977 ${ACLOCAL} -I ../$m4base || func_exit 1
2978 if ! test -d ../build-aux; then
2979 echo "executing mkdir ../build-aux"
2982 echo "executing ${AUTOCONF}"
2983 ${AUTOCONF} || func_exit 1
2984 echo "executing ${AUTOHEADER}"
2985 ${AUTOHEADER} || func_exit 1
2986 echo "executing ${AUTOMAKE} --add-missing --copy"
2987 ${AUTOMAKE} --add-missing --copy || func_exit 1
2990 # Need to run configure and make once, to create built files that are to be
2991 # distributed (such as getdate.c).
2992 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
2993 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
2994 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
2995 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
2996 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
2997 # such $(FOO_H) because they don't refer to distributed files.
2998 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
2999 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3000 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3001 | sed -e "$sed_remove_make_variables"`
3002 distributed_built_sources=`for file in $built_sources; do
3003 case "$cleaned_files" in
3008 if test -n "$distributed_built_sources"; then
3010 ./configure || func_exit 1
3012 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3013 make built_sources || func_exit 1
3015 make distclean || func_exit 1
3020 # func_create_megatestdir megatestdir allmodules
3022 # - local_gnulib_dir from --local-dir
3023 # - auxdir directory relative to destdir where to place build aux files
3024 func_create_megatestdir ()
3028 if test -z "$allmodules"; then
3029 allmodules=`func_all_modules`
3033 # First, all modules one by one.
3034 for onemodule in $allmodules; do
3035 func_create_testdir "$megatestdir/$onemodule" $onemodule
3036 func_append megasubdirs "$onemodule "
3038 # Then, all modules all together.
3039 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3040 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3041 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3042 func_create_testdir "$megatestdir/ALL" "$allmodules"
3043 func_append megasubdirs "ALL"
3046 cvsdate=`sh "$gnulib_dir/build-aux/mdate-sh" "$gnulib_dir/CVS/Entries" \
3047 | sed -e 's,January,01,' -e 's,Jan,01,' \
3048 -e 's,February,02,' -e 's,Feb,02,' \
3049 -e 's,March,03,' -e 's,Mar,03,' \
3050 -e 's,April,04,' -e 's,Apr,04,' \
3052 -e 's,June,06,' -e 's,Jun,06,' \
3053 -e 's,July,07,' -e 's,Jul,07,' \
3054 -e 's,August,08,' -e 's,Aug,08,' \
3055 -e 's,September,09,' -e 's,Sep,09,' \
3056 -e 's,October,10,' -e 's,Oct,10,' \
3057 -e 's,November,11,' -e 's,Nov,11,' \
3058 -e 's,December,12,' -e 's,Dec,12,' \
3059 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3060 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3062 echo "CVSDATE=$cvsdate"
3063 echo "test -d logs || mkdir logs"
3064 echo "for module in $megasubdirs; do"
3065 echo " echo \"Working on module \$module...\""
3066 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3067 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3070 echo " : autobuild project... \$module"
3071 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3072 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3073 echo " : autobuild hostname... \`hostname\`"
3074 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3076 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3078 ) > "$megatestdir/do-autobuild"
3079 chmod a+x "$megatestdir/do-autobuild"
3081 # Create Makefile.am.
3082 (echo "## Process this file with automake to produce Makefile.in."
3084 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3086 echo "SUBDIRS = $megasubdirs"
3088 echo "EXTRA_DIST = do-autobuild"
3089 ) > "$megatestdir/Makefile.am"
3091 # Create configure.ac.
3092 (echo "# Process this file with autoconf to produce a configure script."
3093 echo "AC_INIT([dummy], [0])"
3094 if test "$auxdir" != "."; then
3095 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3097 echo "AM_INIT_AUTOMAKE"
3099 echo "AC_PROG_MAKE_SET"
3101 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3102 echo "AC_OUTPUT([Makefile])"
3103 ) > "$megatestdir/configure.ac"
3105 # Create autogenerated files.
3107 # Do not use "${AUTORECONF} --install", because autoreconf operates
3108 # recursively, but the subdirectories are already finished, therefore
3109 # calling autoreconf here would only waste lots of CPU time.
3110 echo "executing ${ACLOCAL}"
3111 ${ACLOCAL} || func_exit 1
3112 echo "executing mkdir build-aux"
3114 echo "executing ${AUTOCONF}"
3115 ${AUTOCONF} || func_exit 1
3116 echo "executing ${AUTOMAKE} --add-missing --copy"
3117 ${AUTOMAKE} --add-missing --copy || func_exit 1
3123 func_fatal_error "no mode specified" ;;
3132 if test -z "$destdir"; then
3135 test -d "$destdir" \
3136 || func_fatal_error "destination directory does not exist: $destdir"
3138 # Prefer configure.ac to configure.in.
3139 if test -f "$destdir"/configure.ac; then
3140 configure_ac="$destdir/configure.ac"
3142 if test -f "$destdir"/configure.in; then
3143 configure_ac="$destdir/configure.in"
3145 func_fatal_error "cannot find $destdir/configure.ac"
3149 # Analyze configure.ac.
3151 guessed_libtool=false
3156 /AC_CONFIG_AUX_DIR/ {
3157 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3159 /A[CM]_PROG_LIBTOOL/ {
3160 s,^.*$,guessed_libtool=true,p
3162 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3164 if test -z "$auxdir"; then
3165 auxdir="$guessed_auxdir"
3168 # Determine where to apply func_import.
3169 if test -n "$m4base"; then
3170 # Apply func_import to a particular gnulib directory.
3171 # Any number of additional modules can be given.
3172 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3173 # First use of gnulib in the given m4base.
3174 test -n "$supplied_libname" || supplied_libname=true
3175 test -n "$sourcebase" || sourcebase="lib"
3176 test -n "$docbase" || docbase="doc"
3177 test -n "$testsbase" || testsbase="tests"
3178 test -n "$macro_prefix" || macro_prefix="gl"
3182 # Apply func_import to all gnulib directories.
3183 # To get this list of directories, look at Makefile.am. (Not at
3184 # configure, because it may be omitted from CVS. Also, don't run
3185 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3188 if test -f "$destdir"/Makefile.am; then
3189 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3191 for arg in $aclocal_amflags; do
3192 if test -n "$m4dir_is_next"; then
3193 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3197 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3198 func_append m4dirs " $arg"
3199 m4dirs_count=`expr $m4dirs_count + 1`
3205 if test "X$arg" = "X-I"; then
3213 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3214 if test -f "$destdir"/aclocal.m4; then
3215 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3216 sedexpr2='s,^[^/]*$,.,'
3217 sedexpr3='s,/[^/]*$,,'
3218 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3219 m4dirs_count=`echo "$m4dirs" | wc -l`
3222 if test $m4dirs_count = 0; then
3223 # First use of gnulib in a package.
3224 # Any number of additional modules can be given.
3225 test -n "$supplied_libname" || supplied_libname=true
3226 test -n "$sourcebase" || sourcebase="lib"
3228 test -n "$docbase" || docbase="doc"
3229 test -n "$testsbase" || testsbase="tests"
3230 test -n "$macro_prefix" || macro_prefix="gl"
3233 if test $m4dirs_count = 1; then
3234 # There's only one use of gnulib here. Assume the user means it.
3235 # Any number of additional modules can be given.
3236 for m4base in $m4dirs; do
3240 # Ambiguous - guess what the user meant.
3241 if test $# = 0; then
3242 # No further arguments. Guess the user wants to update all of them.
3243 for m4base in $m4dirs; do
3244 # Perform func_import in a subshell, so that variable values
3246 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
3247 # testsbase, inctests, libname, lgpl, makefile_name, libtool,
3249 # don't propagate from one directory to another.
3250 (func_import) || func_exit 1
3254 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
3262 if test -z "$destdir"; then
3263 func_fatal_error "please specify --dir option"
3266 test -d "$destdir" \
3267 || func_fatal_error "could not create destination directory"
3268 test -n "$auxdir" || auxdir="build-aux"
3269 func_create_testdir "$destdir" "$*"
3272 create-megatestdir )
3273 if test -z "$destdir"; then
3274 func_fatal_error "please specify --dir option"
3276 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3277 test -n "$auxdir" || auxdir="build-aux"
3278 func_create_megatestdir "$destdir" "$*"
3282 test -n "$destdir" || destdir=testdir$$
3283 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3284 test -n "$auxdir" || auxdir="build-aux"
3285 func_create_testdir "$destdir" "$*"
3289 ../configure || func_exit 1
3291 make check || func_exit 1
3292 make distclean || func_exit 1
3293 remaining=`find . -type f -print`
3294 if test -n "$remaining"; then
3295 echo "Remaining files:" $remaining 1>&2
3296 echo "gnulib-tool: *** Stop." 1>&2
3305 test -n "$destdir" || destdir=testdir$$
3306 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3307 test -n "$auxdir" || auxdir="build-aux"
3308 func_create_megatestdir "$destdir" "$*"
3316 remaining=`find . -type f -print`
3317 if test -n "$remaining"; then
3318 echo "Remaining files:" $remaining 1>&2
3319 echo "gnulib-tool: *** Stop." 1>&2
3327 extract-description )
3331 if test -n "$module"; then
3332 func_get_description "$module"
3341 if test -n "$module"; then
3342 func_get_filelist "$module"
3347 extract-dependencies )
3351 if test -n "$module"; then
3352 func_get_dependencies "$module"
3357 extract-autoconf-snippet )
3361 if test -n "$module"; then
3362 func_get_autoconf_snippet "$module"
3367 extract-automake-snippet )
3371 if test -n "$module"; then
3372 func_get_automake_snippet "$module"
3377 extract-include-directive )
3381 if test -n "$module"; then
3382 func_get_include_directive "$module"
3387 extract-link-directive )
3391 if test -n "$module"; then
3392 func_get_link_directive "$module"
3401 if test -n "$module"; then
3402 func_get_license "$module"
3407 extract-maintainer )
3411 if test -n "$module"; then
3412 func_get_maintainer "$module"
3417 extract-tests-module )
3421 if test -n "$module"; then
3422 func_get_tests_module "$module"
3428 func_fatal_error "unknown operation mode --$mode" ;;
3432 # Undo the effect of the previous 'trap' command. Some shellology:
3433 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3434 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3435 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3436 # 128 + signal number and is set before the trap-registered command is run.
3438 trap 'func_exit $?' 1 2 3 13 15
3443 # indent-tabs-mode: nil
3444 # whitespace-check-buffer-indent: nil