3 # Copyright (C) 2002-2007 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # This program is meant for authors or maintainers which want to import
21 # modules from gnulib into their packages.
25 cvsdatestamp='$Date: 2007-07-14 01:42:14 $'
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.
170 -S, --more-symlinks Make symbolic links instead of copying files, and
171 don't replace copyright notices.
173 Report bugs to <bug-gnulib@gnu.org>."
177 # outputs to stdout the --version message.
180 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
182 $progname (GNU $package) $version
183 Copyright (C) $year Free Software Foundation, Inc.
184 This is free software; see the source for copying conditions. There is NO
185 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
186 Written by" "Bruno Haible" "and" "Simon Josefsson"
189 # func_emit_copyright_notice
190 # outputs to stdout a header for a generated file.
191 func_emit_copyright_notice ()
193 echo "# Copyright (C) 2004-2007 Free Software Foundation, Inc."
195 echo "# This file is free software, distributed under the terms of the GNU"
196 echo "# General Public License. As a special exception to the GNU General"
197 echo "# Public License, this file may be distributed as part of a program"
198 echo "# that contains a configuration script generated by Autoconf, under"
199 echo "# the same distribution terms as the rest of that program."
201 echo "# Generated by gnulib-tool."
212 # creates a temporary directory.
214 # - tmp pathname of freshly created temporary directory
217 # Use the environment variable TMPDIR, falling back to /tmp. This allows
218 # users to specify a different temporary directory, for example, if their
219 # /tmp is filled up or too small.
222 # Use the mktemp program if available. If not available, hide the error
224 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
225 test -n "$tmp" && test -d "$tmp"
228 # Use a simple mkdir command. It is guaranteed to fail if the directory
229 # already exists. $RANDOM is bash specific and expands to empty in shells
230 # other than bash, ksh and zsh. Its use does not increase security;
231 # rather, it minimizes the probability of failure in a very cluttered /tmp
233 tmp=$TMPDIR/gl$$-$RANDOM
234 (umask 077 && mkdir "$tmp")
237 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
242 # func_append var value
243 # appends the given value to the shell variable var.
244 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
245 # Use bash's += operator. It reduces complexity of appending repeatedly to
246 # a single variable from O(n^2) to O(n).
254 eval "$1=\"\$$1\$2\""
258 # func_fatal_error message
259 # outputs to stderr a fatal error message, and terminates the program.
262 echo "gnulib-tool: *** $1" 1>&2
263 echo "gnulib-tool: *** Stop." 1>&2
267 # func_readlink SYMLINK
268 # outputs the target of the given symlink.
269 if (type -p readlink) > /dev/null 2>&1; then
272 # Use the readlink program from GNU coreutils.
278 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
279 # would do the wrong thing if the link target contains " -> ".
280 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
284 # func_relativize DIR1 DIR2
285 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
287 # - DIR1 relative pathname, relative to the current directory
288 # - DIR2 relative pathname, relative to the current directory
290 # - reldir relative pathname of DIR2, relative to DIR1
296 sed_first='s,^\([^/]*\)/.*$,\1,'
297 sed_rest='s,^[^/]*/*,,'
298 sed_last='s,^.*/\([^/]*\)$,\1,'
299 sed_butlast='s,/*[^/]*$,,'
300 while test -n "$dir1"; do
301 first=`echo "$dir1" | sed -e "$sed_first"`
302 if test "$first" != "."; then
303 if test "$first" = ".."; then
304 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
305 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
307 first2=`echo "$dir2" | sed -e "$sed_first"`
308 if test "$first2" = "$first"; then
309 dir2=`echo "$dir2" | sed -e "$sed_rest"`
313 dir0="$dir0"/"$first"
316 dir1=`echo "$dir1" | sed -e "$sed_rest"`
321 # func_relconcat DIR1 DIR2
322 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
324 # - DIR1 relative pathname, relative to the current directory
325 # - DIR2 relative pathname, relative to DIR1
327 # - relconcat DIR1/DIR2, relative to the current directory
332 sed_first='s,^\([^/]*\)/.*$,\1,'
333 sed_rest='s,^[^/]*/*,,'
334 sed_last='s,^.*/\([^/]*\)$,\1,'
335 sed_butlast='s,/*[^/]*$,,'
337 first=`echo "$dir2" | sed -e "$sed_first"`
338 if test "$first" = "."; then
339 dir2=`echo "$dir2" | sed -e "$sed_rest"`
340 if test -z "$dir2"; then
345 last=`echo "$dir1" | sed -e "$sed_last"`
346 while test "$last" = "."; do
347 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
348 last=`echo "$dir1" | sed -e "$sed_last"`
350 if test -z "$dir1"; then
354 if test "$first" = ".."; then
355 if test "$last" = ".."; then
356 relconcat="$dir1/$dir2"
359 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
360 dir2=`echo "$dir2" | sed -e "$sed_rest"`
361 if test -z "$dir1"; then
365 if test -z "$dir2"; then
370 relconcat="$dir1/$dir2"
378 # Like ln -s, except that SRC is given relative to the current directory (or
379 # absolute), not given relative to the directory of DEST.
385 *) # SRC is relative.
388 ln -s "`pwd`/$1" "$2" ;;
389 *) # DEST is relative too.
390 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
391 test -n "$ln_destdir" || ln_destdir="."
392 func_relativize "$ln_destdir" "$1"
400 # func_ln_if_changed SRC DEST
401 # Like func_ln, but avoids munging timestamps if the link is correct.
402 func_ln_if_changed ()
404 if test $# -ne 2; then
405 echo "usage: func_ln_if_changed SRC DEST" >&2
407 ln_target=`func_readlink "$2"`
408 if test -L "$2" && test "$1" = "$ln_target"; then
416 # Ensure an 'echo' command that does not interpret backslashes.
418 # echo '\n' | wc -l prints 1 when OK, 2 when KO
419 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
420 # This problem is a weird heritage from SVR4. BSD got it right (except that
421 # BSD echo interprets '-n' as an option, which is also not desirable).
422 # Nowadays the problem occurs in 4 situations:
423 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
424 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
425 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
426 # - in zsh, when sh-emulation is not set,
427 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
428 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
429 # - in Solaris /bin/sh and OSF/1 /bin/sh.
430 # We try the following workarounds:
431 # - for all: respawn using $CONFIG_SHELL if that is set and works.
432 # - for bash >= 2.04: unset the shell option xpg_echo.
433 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
434 # - for bash < 2.0: define echo to a function that uses cat of a here document.
435 # - for zsh: turn sh-emulation on.
436 # - for ksh: alias echo to 'print -r'.
437 # - for ksh: alias echo to a function that uses cat of a here document.
438 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
439 # the ksh workaround.
440 # - otherwise: respawn using /bin/sh and rely on the workarounds.
441 # When respawning, we pass --no-reexec as first argument, so as to avoid
442 # turning this script into a fork bomb in unlucky situations.
444 if echo '\t' | grep t > /dev/null; then
445 have_echo=yes # Lucky!
447 # Try the workarounds.
448 # Respawn using $CONFIG_SHELL if that is set and works.
449 if test -z "$have_echo" \
450 && test "X$1" != "X--no-reexec" \
451 && test -n "$CONFIG_SHELL" \
452 && test -f "$CONFIG_SHELL" \
453 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
454 exec $CONFIG_SHELL "$0" --no-reexec "$@"
457 # For bash >= 2.04: unset the shell option xpg_echo.
458 if test -z "$have_echo" \
459 && test -n "$BASH_VERSION" \
460 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
464 # For bash >= 2.0: define echo to a function that uses the printf built-in.
465 # For bash < 2.0: define echo to a function that uses cat of a here document.
466 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
467 if test -z "$have_echo" \
468 && test -n "$BASH_VERSION"; then \
469 if type printf 2>/dev/null | grep / > /dev/null; then
470 # 'printf' is not a shell built-in.
478 # 'printf' is a shell built-in.
484 if echo '\t' | grep t > /dev/null; then
488 # For zsh: turn sh-emulation on.
489 if test -z "$have_echo" \
490 && test -n "$ZSH_VERSION" \
491 && (emulate sh) >/dev/null 2>&1; then
494 # For ksh: alias echo to 'print -r'.
495 if test -z "$have_echo" \
496 && (type print) >/dev/null 2>&1; then
497 # A 'print' command exists.
498 if type print 2>/dev/null | grep / > /dev/null; then
501 # 'print' is a shell built-in.
502 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
503 # 'print' is the ksh shell built-in.
504 alias echo='print -r'
508 if test -z "$have_echo" \
509 && echo '\t' | grep t > /dev/null; then
512 # For ksh: alias echo to a function that uses cat of a here document.
513 # The ksh manual page says:
514 # "Aliasing is performed when scripts are read, not while they are executed.
515 # Therefore, for an alias to take effect, the alias definition command has
516 # to be executed before the command which references the alias is read."
517 # Because of this, we have to play strange tricks with have_echo, to ensure
518 # that the top-level statement containing the test starts after the 'alias'
520 if test -z "$have_echo"; then
527 alias echo=bsd_echo 2>/dev/null
529 if test -z "$have_echo" \
530 && echo '\t' | grep t > /dev/null; then
533 if test -z "$have_echo"; then
534 unalias echo 2>/dev/null
536 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
537 if test -z "$have_echo" \
538 && test "X$1" != "X--no-reexec" \
539 && test -f /bin/ksh; then
540 exec /bin/ksh "$0" --no-reexec "$@"
543 # Otherwise: respawn using /bin/sh.
544 if test -z "$have_echo" \
545 && test "X$1" != "X--no-reexec" \
546 && test -f /bin/sh; then
547 exec /bin/sh "$0" --no-reexec "$@"
550 if test -z "$have_echo"; then
551 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
553 if echo '\t' | grep t > /dev/null; then
556 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
558 if test "X$1" = "X--no-reexec"; then
562 # Command-line option processing.
563 # Removes the OPTIONS from the arguments. Sets the variables:
564 # - mode list or import or create-testdir or create-megatestdir
565 # - destdir from --dir
566 # - local_gnulib_dir from --local-dir
567 # - libname, supplied_libname from --lib
568 # - sourcebase from --source-base
569 # - m4base from --m4-base
570 # - docbase from --doc-base
571 # - testsbase from --tests-base
572 # - auxdir from --aux-dir
573 # - inctests true if --with-tests was given, blank otherwise
574 # - avoidlist list of modules to avoid, from --avoid
575 # - lgpl true if --lgpl was given, blank otherwise
576 # - makefile_name from --makefile-name
577 # - libtool true if --libtool was given, false if --no-libtool was
578 # given, blank otherwise
579 # - macro_prefix from --macro-prefix
580 # - autoconf_minversion minimum supported autoconf version
581 # - do_changelog false if --no-changelog was given, : otherwise
582 # - doit : if actions shall be executed, false if only to be printed
583 # - symbolic true if --symlink or --more-symlinks was given, blank
585 # - lsymbolic true if --local-symlink was given, blank otherwise
586 # - do_copyrights blank if --more-symlinks was given, true otherwise
612 while test $# -gt 0; do
617 --import | --impor | --impo | --imp | --im | --i )
620 --update | --updat | --upda | --upd | --up | --u )
623 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
626 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
627 mode=create-megatestdir
629 --test | --tes | --te | --t )
632 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
636 mode=`echo "X$1" | sed -e 's/^X--//'`
641 func_fatal_error "missing argument for --dir"
646 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
651 func_fatal_error "missing argument for --local-dir"
656 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
661 func_fatal_error "missing argument for --lib"
664 supplied_libname=true
667 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
668 supplied_libname=true
673 func_fatal_error "missing argument for --source-base"
678 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
683 func_fatal_error "missing argument for --m4-base"
688 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
693 func_fatal_error "missing argument for --doc-base"
698 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
703 func_fatal_error "missing argument for --tests-base"
708 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
713 func_fatal_error "missing argument for --aux-dir"
718 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
726 func_fatal_error "missing argument for --avoid"
728 func_append avoidlist " $1"
731 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
732 func_append avoidlist " $arg"
740 func_fatal_error "missing argument for --makefile-name"
745 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
756 func_fatal_error "missing argument for --macro-prefix"
761 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
763 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
769 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
772 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
775 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
779 --help | --hel | --he | --h )
782 --version | --versio | --versi | --vers | --ver | --ve | --v )
786 # Stop option processing
790 echo "gnulib-tool: unknown option $1" 1>&2
791 echo "Try 'gnulib-tool --help' for more information." 1>&2
798 if test "$mode" = update; then
799 if test $# != 0; then
800 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
801 echo "Try 'gnulib-tool --help' for more information." 1>&2
802 echo "If you really want to modify the gnulib configuration of your project," 1>&2
803 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
806 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
807 || test -n "$sourcebase" || test -n "$m4base" \
808 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
809 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
810 || test -n "$makefile_name" || test -n "$macro_prefix"; then
811 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
812 echo "Try 'gnulib-tool --help' for more information." 1>&2
813 echo "If you really want to modify the gnulib configuration of your project," 1>&2
814 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
820 # Determine the minimum supported autoconf version from the project's
822 DEFAULT_AUTOCONF_MINVERSION="2.59"
825 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
826 if test -f "$destdir"/configure.ac; then
827 configure_ac="$destdir/configure.ac"
829 if test -f "$destdir"/configure.in; then
830 configure_ac="$destdir/configure.in"
834 if test -f configure.ac; then
835 configure_ac="configure.ac"
837 if test -f configure.in; then
838 configure_ac="configure.in"
842 if test -n "$configure_ac"; then
843 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
844 # because when some m4 files are omitted from a CVS repository,
845 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
846 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
847 # autom4te: m4 failed with exit status: 1
854 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
856 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
857 if test -n "$prereqs"; then
858 autoconf_minversion=`
859 for version in $prereqs; do echo $version; done |
860 LC_ALL=C sort -nru | sed 1q
864 if test -z "$autoconf_minversion"; then
865 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
867 case "$autoconf_minversion" in
868 1.* | 2.[0-4]* | 2.5[0-8]*)
869 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
872 # Remove trailing slashes from the directory names. This is necessary for
873 # m4base (to avoid an error in func_import) and optional for the others.
874 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
875 case "$local_gnulib_dir" in
876 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
878 case "$sourcebase" in
879 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
882 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
885 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
888 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
891 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
896 /*) self_abspathname="$0" ;;
897 */*) self_abspathname=`pwd`/"$0" ;;
900 # Iterate through the elements of $PATH.
901 # We use IFS=: instead of
902 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
903 # because the latter does not work when some PATH element contains spaces.
904 # We use a canonicalized $pathx instead of $PATH, because empty PATH
905 # elements are by definition equivalent to '.', however field splitting
906 # according to IFS=: loses empty fields in many shells:
907 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
908 # beginning, at the end, and in the middle),
909 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
910 # at the beginning and at the end,
911 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
912 # Solaris lose empty fields at the end.
913 # The 'case' statement is an optimization, to avoid evaluating the
914 # explicit canonicalization command when $PATH contains no empty fields.
916 if test "${PATH_SEPARATOR+set}" != set; then
918 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
919 chmod +x "$tmp"/conf.sh
920 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
927 if test "$PATH_SEPARATOR" = ";"; then
928 # On Windows, programs are searched in "." before $PATH.
931 # On Unix, we have to convert empty PATH elements to ".".
935 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
940 IFS="$PATH_SEPARATOR"
944 if test -x "$d/$0" && test ! -d "$d/$0"; then
945 self_abspathname="$d/$0"
950 if test -z "$self_abspathname"; then
951 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
955 while test -h "$self_abspathname"; do
956 # Resolve symbolic link.
957 linkval=`func_readlink "$self_abspathname"`
958 test -n "$linkval" || break
960 /* ) self_abspathname="$linkval" ;;
961 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
964 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
968 if test "$signal" != 0; then
969 echo "caught signal $signal" >&2
973 for signal in 1 2 3 13 15; do
974 trap '{ signal='$signal'; func_exit 1; }' $signal
978 # func_lookup_file file
979 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
982 # - local_gnulib_dir from --local-dir
984 # - lookedup_file name of the merged (combined) file
985 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
989 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
990 lookedup_file="$local_gnulib_dir/$lkfile"
993 if test -f "$gnulib_dir/$lkfile"; then
994 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
995 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
997 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
998 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
999 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1000 lookedup_file="$tmp/$lkbase"
1003 lookedup_file="$gnulib_dir/$lkfile"
1007 func_fatal_error "file $gnulib_dir/$lkfile not found"
1014 # - local_gnulib_dir from --local-dir
1017 # Filter out metainformation files like README, which are not modules.
1018 # Filter out unit test modules; they can be retrieved through
1019 # --extract-tests-module if desired.
1021 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1022 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1023 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1026 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1027 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1028 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1029 -e '/^README$/d' -e '/\/README$/d' \
1030 -e '/^TEMPLATE$/d' \
1031 -e '/^TEMPLATE-EXTENDED$/d' \
1032 -e '/^TEMPLATE-TESTS$/d' \
1035 | sed -e '/-tests$/d' \
1039 # func_verify_module
1040 # verifies a module name
1042 # - local_gnulib_dir from --local-dir
1043 # - module module name argument
1044 func_verify_module ()
1046 if { test -f "$gnulib_dir/modules/$module" \
1047 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1048 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1049 && test "CVS" != "$module" \
1050 && test "ChangeLog" != "$module" \
1051 && test "COPYING" != "$module" \
1052 && test "README" != "$module" \
1053 && test "TEMPLATE" != "$module" \
1054 && test "TEMPLATE-EXTENDED" != "$module" \
1055 && test "TEMPLATE-TESTS" != "$module"; then
1056 # OK, $module is a correct module name.
1057 # Verify that building the module description with 'patch' succeeds.
1058 func_lookup_file "modules/$module"
1060 echo "gnulib-tool: module $module doesn't exist" 1>&2
1065 # func_verify_nontests_module
1066 # verifies a module name, excluding tests modules
1068 # - local_gnulib_dir from --local-dir
1069 # - module module name argument
1070 func_verify_nontests_module ()
1073 *-tests ) module= ;;
1074 * ) func_verify_module ;;
1078 # func_verify_tests_module
1079 # verifies a module name, considering only tests modules
1081 # - local_gnulib_dir from --local-dir
1082 # - module module name argument
1083 func_verify_tests_module ()
1086 *-tests ) func_verify_module ;;
1091 sed_extract_prog=':[ ]*$/ {
1094 s/^Description:[ ]*$//
1096 s/^Depends-on:[ ]*$//
1097 s/^configure\.ac-early:[ ]*$//
1098 s/^configure\.ac:[ ]*$//
1099 s/^Makefile\.am:[ ]*$//
1103 s/^Maintainer:[ ]*$//
1110 # func_get_description module
1112 # - local_gnulib_dir from --local-dir
1113 func_get_description ()
1115 func_lookup_file "modules/$1"
1116 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1119 # func_get_filelist module
1121 # - local_gnulib_dir from --local-dir
1122 func_get_filelist ()
1124 func_lookup_file "modules/$1"
1125 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1126 echo m4/gnulib-common.m4
1127 case "$autoconf_minversion" in
1129 #echo m4/onceonly.m4
1130 echo m4/onceonly_2_57.m4
1135 # func_get_dependencies module
1137 # - local_gnulib_dir from --local-dir
1138 func_get_dependencies ()
1140 # ${module}-tests always implicitly depends on ${module}.
1141 echo "$1" | sed -n -e 's/-tests//p'
1142 # Then the explicit dependencies listed in the module description.
1143 func_lookup_file "modules/$1"
1144 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1147 # func_get_autoconf_early_snippet module
1149 # - local_gnulib_dir from --local-dir
1150 func_get_autoconf_early_snippet ()
1152 func_lookup_file "modules/$1"
1153 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1156 # func_get_autoconf_snippet module
1158 # - local_gnulib_dir from --local-dir
1159 func_get_autoconf_snippet ()
1161 func_lookup_file "modules/$1"
1162 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1165 # func_get_automake_snippet module
1167 # - local_gnulib_dir from --local-dir
1168 func_get_automake_snippet ()
1170 func_lookup_file "modules/$1"
1171 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1174 # *-tests module live in tests/, not lib/.
1177 # Synthesize an EXTRA_DIST augmentation.
1178 sed_combine_lines='/\\$/{
1185 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1186 already_mentioned_files=` \
1187 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1188 | sed -e "$sed_combine_lines" \
1189 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1190 all_files=`func_get_filelist $1`
1191 lib_files=`for f in $all_files; do \
1195 done | sed -e 's,^lib/,,'`
1196 # Remove $already_mentioned_files from $lib_files.
1197 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1198 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1199 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1200 if test -n "$extra_files"; then
1201 echo "EXTRA_DIST +=" $extra_files
1204 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1205 # This is necessary so that automake can generate the right list of
1207 # A possible approach would be to use autom4te --trace of the redefined
1208 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1209 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1210 # inside autoconf's built-in macros are not missed).
1211 # But it's simpler and more robust to do it here, based on the file list.
1212 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1213 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1214 # automake will generate a useless dependency; this is harmless.
1216 relocatable-prog-wrapper) ;;
1218 sed_extract_c_files='/\.c$/p'
1219 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1220 if test -n "$extra_files"; then
1221 echo "EXTRA_lib_SOURCES +=" $extra_files
1230 # func_get_include_directive module
1232 # - local_gnulib_dir from --local-dir
1233 func_get_include_directive ()
1235 func_lookup_file "modules/$1"
1236 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1237 sed -e 's/^\(["<]\)/#include \1/'
1240 # func_get_link_directive module
1242 # - local_gnulib_dir from --local-dir
1243 func_get_link_directive ()
1245 func_lookup_file "modules/$1"
1246 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1249 # func_get_license module
1251 # - local_gnulib_dir from --local-dir
1254 func_lookup_file "modules/$1"
1255 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1256 # The default is GPL.
1258 } | sed -e 's,^ *$,,' | sed -e 1q
1261 # func_get_maintainer module
1263 # - local_gnulib_dir from --local-dir
1264 func_get_maintainer ()
1266 func_lookup_file "modules/$1"
1267 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1270 # func_get_tests_module module
1272 # - local_gnulib_dir from --local-dir
1273 func_get_tests_module ()
1275 # The naming convention for tests modules is hardwired: ${module}-tests.
1276 if test -f "$gnulib_dir/modules/$1"-tests \
1277 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1278 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1283 # func_acceptable module
1284 # tests whether a module is acceptable.
1286 # - avoidlist list of modules to avoid
1289 for avoid in $avoidlist; do
1290 if test "$avoid" = "$1"; then
1297 # func_modules_transitive_closure
1299 # - local_gnulib_dir from --local-dir
1300 # - modules list of specified modules
1301 # - inctests true if tests should be included, blank otherwise
1302 # - avoidlist list of modules to avoid
1303 # - tmp pathname of a temporary directory
1305 # - modules list of modules, including dependencies
1306 func_modules_transitive_closure ()
1308 # In order to process every module only once (for speed), process an "input
1309 # list" of modules, producing an "output list" of modules. During each round,
1310 # more modules can be queued in the input list. Once a module on the input
1311 # list has been processed, it is added to the "handled list", so we can avoid
1312 # to process it again.
1314 inmodules="$modules"
1316 while test -n "$inmodules"; do
1317 inmodules_this_round="$inmodules"
1318 inmodules= # Accumulator, queue for next round
1319 for module in $inmodules_this_round; do
1321 if test -n "$module"; then
1322 if func_acceptable $module; then
1323 func_append outmodules " $module"
1324 deps=`func_get_dependencies $module`
1325 # Duplicate dependencies are harmless, but Jim wants a warning.
1326 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1327 if test -n "$duplicated_deps"; then
1328 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1330 func_append inmodules " $deps"
1331 if test -n "$inctests"; then
1332 testsmodule=`func_get_tests_module $module`
1333 if test -n "$testsmodule"; then
1334 func_append inmodules " $testsmodule"
1340 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1341 # Remove $handledmodules from $inmodules.
1342 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1343 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1345 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1346 rm -f "$tmp"/queued-modules
1349 # func_modules_add_dummy
1351 # - local_gnulib_dir from --local-dir
1352 # - modules list of modules, including dependencies
1354 # - modules list of modules, including 'dummy' if needed
1355 func_modules_add_dummy ()
1358 sed_remove_backslash_newline=':a
1365 for module in $modules; do
1366 func_verify_nontests_module
1367 if test -n "$module"; then
1368 # Extract the value of "lib_SOURCES += ...".
1369 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1370 # Ignore .h files since they are not compiled.
1373 *) have_lib_SOURCES=yes ;;
1378 # Add the dummy module, to make sure the library will be non-empty.
1379 if test -z "$have_lib_SOURCES"; then
1380 if func_acceptable "dummy"; then
1381 func_append modules " dummy"
1386 # func_modules_to_filelist
1388 # - local_gnulib_dir from --local-dir
1389 # - modules list of modules, including dependencies
1391 # - files list of files
1392 func_modules_to_filelist ()
1395 for module in $modules; do
1397 if test -n "$module"; then
1398 fs=`func_get_filelist $module`
1399 func_append files " $fs"
1402 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1405 # func_emit_lib_Makefile_am
1406 # emits the contents of library makefile to standard output.
1408 # - local_gnulib_dir from --local-dir
1409 # - modules list of modules, including dependencies
1410 # - libname library name
1411 # - auxdir directory relative to destdir where to place build aux files
1412 # - makefile_name from --makefile-name
1413 # - libtool true if libtool will be used, false or blank otherwise
1414 # - macro_prefix prefix of gl_LIBOBJS macros to use
1415 # - actioncmd (optional) command that will reproduce this invocation
1416 # - for_test true if creating a package for testing, false otherwise
1418 # - uses_subdirs nonempty if object files in subdirs exist
1419 func_emit_lib_Makefile_am ()
1421 # When creating an includable Makefile.am snippet, augment variables with
1422 # += instead of assigning them.
1423 if test -n "$makefile_name"; then
1428 if test "$libtool" = true; then
1431 sed_eliminate_LDFLAGS=
1435 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1438 # When creating a package for testing: Attempt to provoke failures,
1439 # especially link errors, already during "make" rather than during
1440 # "make check", because "make check" is not possible in a cross-compiling
1441 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1442 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1444 sed_transform_check_PROGRAMS=
1446 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1447 echo "## Process this file with automake to produce Makefile.in."
1448 func_emit_copyright_notice
1449 if test -n "$actioncmd"; then
1450 echo "# Reproduce by: $actioncmd"
1455 for module in $modules; do
1456 func_verify_nontests_module
1457 if test -n "$module"; then
1459 func_get_automake_snippet "$module" |
1460 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1461 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1462 -e "$sed_eliminate_LDFLAGS" \
1463 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1464 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1465 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1466 -e "$sed_transform_check_PROGRAMS"
1467 if test "$module" = 'alloca'; then
1468 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1469 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1472 # Skip the contents if its entirely empty.
1473 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1474 echo "## begin gnulib module $module"
1477 echo "## end gnulib module $module"
1481 # Test whether there are some source files in subdirectories.
1482 for f in `func_get_filelist "$module"`; do
1484 lib/*/*.c) uses_subdirs=yes ;;
1490 if test -z "$makefile_name"; then
1491 # If there are source files in subdirectories, prevent collision of the
1492 # object files (example: hash.c and libxml/hash.c).
1494 if test -n "$uses_subdirs"; then
1495 subdir_options=' subdir-objects'
1497 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1500 if test -z "$makefile_name"; then
1501 echo "noinst_HEADERS ="
1502 echo "noinst_LIBRARIES ="
1503 echo "noinst_LTLIBRARIES ="
1504 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1505 # if you specify pkgdata_DATA to empty. This is a workaround.
1506 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1507 echo "pkgdata_DATA ="
1510 echo "BUILT_SOURCES ="
1513 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1514 if test -z "$makefile_name"; then
1515 echo "MOSTLYCLEANDIRS ="
1517 echo "DISTCLEANFILES ="
1518 echo "MAINTAINERCLEANFILES ="
1520 echo "AM_CPPFLAGS ="
1523 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1524 # One of the snippets already specifies an installation location for the
1525 # library. Don't confuse automake by saying it should not be installed.
1528 # By default, the generated library should not be installed.
1529 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1532 echo "${libname}_${libext}_SOURCES ="
1533 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1534 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1535 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1536 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1537 echo "EXTRA_${libname}_${libext}_SOURCES ="
1538 if test "$libtool" = true; then
1539 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1542 cat allsnippets.tmp \
1543 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1545 echo "mostlyclean-local: mostlyclean-generic"
1546 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1547 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1548 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1552 rm -f allsnippets.tmp
1555 # func_emit_tests_Makefile_am
1556 # emits the contents of tests makefile to standard output.
1558 # - local_gnulib_dir from --local-dir
1559 # - modules list of modules, including dependencies
1560 # - libname library name
1561 # - makefile_name from --makefile-name
1562 # - libtool true if libtool will be used, false or blank otherwise
1563 # - sourcebase relative directory containing lib source code
1564 # - m4base relative directory containing autoconf macros
1565 # - testsbase relative directory containing unit test code
1566 # - for_test true if creating a package for testing, false otherwise
1567 func_emit_tests_Makefile_am ()
1569 if test "$libtool" = true; then
1574 if test "$libtool" = true; then
1576 sed_eliminate_LDFLAGS=
1579 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1582 # When creating a package for testing: Attempt to provoke failures,
1583 # especially link errors, already during "make" rather than during
1584 # "make check", because "make check" is not possible in a cross-compiling
1585 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1586 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1588 sed_transform_check_PROGRAMS=
1590 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1591 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1592 echo "## Process this file with automake to produce Makefile.in."
1593 func_emit_copyright_notice
1595 # Generate dependencies here, since it eases the debugging of test failures.
1596 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1598 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1601 for module in $modules; do
1602 func_verify_tests_module
1603 if test -n "$module"; then
1605 func_get_automake_snippet "$module" |
1606 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1607 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1608 -e "$sed_eliminate_LDFLAGS" \
1609 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1610 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1611 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1612 -e "$sed_transform_check_PROGRAMS"
1614 # Skip the contents if its entirely empty.
1615 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1616 echo "## begin gnulib module $module"
1619 echo "## end gnulib module $module"
1626 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1627 # variable is needed to avoid an error from automake:
1628 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1631 echo "TESTS_ENVIRONMENT ="
1632 echo "noinst_PROGRAMS ="
1633 if ! $for_test; then
1634 echo "check_PROGRAMS ="
1636 echo "noinst_HEADERS ="
1637 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1638 echo "pkgdata_DATA ="
1641 echo "BUILT_SOURCES ="
1643 echo "MOSTLYCLEANFILES = core *.stackdump"
1644 echo "MOSTLYCLEANDIRS ="
1646 echo "DISTCLEANFILES ="
1647 echo "MAINTAINERCLEANFILES ="
1649 echo "AM_CPPFLAGS = \\"
1650 echo " -I. -I\$(srcdir) \\"
1651 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1652 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1654 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1657 echo "# Clean up after Solaris cc."
1659 echo " rm -rf SunWS_cache"
1661 echo "mostlyclean-local: mostlyclean-generic"
1662 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1663 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1664 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1668 rm -f allsnippets.tmp
1671 # func_emit_initmacro_start
1672 # emits the first few statements of the gl_INIT macro to standard output.
1673 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1674 func_emit_initmacro_start ()
1676 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1677 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1678 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1679 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1681 # Furthermore it avoids an automake error like this when a Makefile.am
1682 # that uses pieces of gnulib also uses $(LIBOBJ):
1683 # automatically discovered file `error.c' should not be explicitly mentioned
1684 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1685 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1686 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1687 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1688 # automatically discovered file `error.c' should not be explicitly mentioned
1689 # We let automake know about the files to be distributed through the
1690 # EXTRA_lib_SOURCES variable.
1691 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1694 # func_emit_initmacro_end
1695 # emits the last few statements of the gl_INIT macro to standard output.
1696 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1697 func_emit_initmacro_end ()
1699 echo " m4_popdef([AC_LIBSOURCES])"
1700 echo " m4_popdef([AC_REPLACE_FUNCS])"
1701 echo " m4_popdef([AC_LIBOBJ])"
1702 echo " AC_CONFIG_COMMANDS_PRE(["
1703 echo " ${macro_prefix}_libobjs="
1704 echo " ${macro_prefix}_ltlibobjs="
1705 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1706 echo " # Remove the extension."
1707 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1708 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1709 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1710 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1713 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1714 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1718 # func_emit_initmacro_done
1719 # emits a few statements after the gl_INIT macro to standard output.
1720 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1721 func_emit_initmacro_done ()
1724 echo "# Like AC_LIBOBJ, except that the module name goes"
1725 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1726 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1727 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1729 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1730 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1731 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1732 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1734 echo "# Like AC_LIBSOURCES, except that it does nothing."
1735 echo "# We rely on EXTRA_lib..._SOURCES instead."
1736 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1740 # func_import modules
1741 # Uses also the variables
1742 # - destdir target directory
1743 # - local_gnulib_dir from --local-dir
1744 # - libname library name
1745 # - sourcebase directory relative to destdir where to place source code
1746 # - m4base directory relative to destdir where to place *.m4 macros
1747 # - docbase directory relative to destdir where to place doc files
1748 # - testsbase directory relative to destdir where to place unit test code
1749 # - auxdir directory relative to destdir where to place build aux files
1750 # - inctests true if --with-tests was given, blank otherwise
1751 # - avoidlist list of modules to avoid, from --avoid
1752 # - lgpl true if library's license shall be LGPL, blank otherwise
1753 # - makefile_name from --makefile-name
1754 # - libtool true if --libtool was given, false if --no-libtool was
1755 # given, blank otherwise
1756 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1757 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1758 # - autoconf_minversion minimum supported autoconf version
1759 # - doit : if actions shall be executed, false if only to be printed
1760 # - symbolic true if files should be symlinked, copied otherwise
1761 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1763 # - do_copyrights true if copyright notices in files should be replaced,
1767 # Get the cached settings.
1768 cached_local_gnulib_dir=
1769 cached_specified_modules=
1778 cached_makefile_name=
1780 cached_macro_prefix=
1782 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1783 cached_libtool=false
1789 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1792 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1795 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1798 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1801 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1804 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1807 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1810 s,^.*$,cached_inctests=true,p
1813 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1816 s,^.*$,cached_lgpl=true,p
1818 /gl_MAKEFILE_NAME(/ {
1819 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1822 s,^.*$,cached_libtool=true,p
1824 /gl_MACRO_PREFIX(/ {
1825 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1827 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1828 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1833 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1834 s,^.*$,cached_files=",p
1846 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1850 # Merge the cached settings with the specified ones.
1851 # The m4base must be the same as expected from the pathname.
1852 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1853 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1855 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1856 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1857 if test -z "$local_gnulib_dir"; then
1858 if test -n "$cached_local_gnulib_dir"; then
1861 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1863 case "$cached_local_gnulib_dir" in
1865 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1867 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1868 local_gnulib_dir="$relconcat" ;;
1873 # Append the cached and the specified module names. So that
1874 # "gnulib-tool --import foo" means to add the module foo.
1875 specified_modules="$cached_specified_modules $1"
1876 # Append the cached and the specified avoidlist. This is probably better
1877 # than dropping the cached one when --avoid is specified at least once.
1878 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
1879 avoidlist=`echo $avoidlist`
1881 # The sourcebase defaults to the cached one.
1882 if test -z "$sourcebase"; then
1883 sourcebase="$cached_sourcebase"
1884 if test -z "$sourcebase"; then
1885 func_fatal_error "missing --source-base option"
1888 # The docbase defaults to the cached one.
1889 if test -z "$docbase"; then
1890 docbase="$cached_docbase"
1891 if test -z "$docbase"; then
1892 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."
1895 # The testsbase defaults to the cached one.
1896 if test -z "$testsbase"; then
1897 testsbase="$cached_testsbase"
1898 if test -z "$testsbase"; then
1899 func_fatal_error "missing --tests-base option"
1902 # Require the tests if specified either way.
1903 if test -z "$inctests"; then
1904 inctests="$cached_inctests"
1906 # The libname defaults to the cached one.
1907 if test -z "$supplied_libname"; then
1908 libname="$cached_libname"
1909 if test -z "$libname"; then
1910 func_fatal_error "missing --lib option"
1913 # Require LGPL if specified either way.
1914 if test -z "$lgpl"; then
1917 # The makefile_name defaults to the cached one.
1918 if test -z "$makefile_name"; then
1919 makefile_name="$cached_makefile_name"
1921 # Use libtool if specified either way, or if guessed.
1922 if test -z "$libtool"; then
1923 if test -n "$cached_m4base"; then
1924 libtool="$cached_libtool"
1926 libtool="$guessed_libtool"
1929 # The macro_prefix defaults to the cached one.
1930 if test -z "$macro_prefix"; then
1931 macro_prefix="$cached_macro_prefix"
1932 if test -z "$macro_prefix"; then
1933 func_fatal_error "missing --macro-prefix option"
1937 # Canonicalize the list of specified modules.
1938 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1940 # Determine final module list.
1941 modules="$specified_modules"
1942 func_modules_transitive_closure
1943 echo "Module list with included dependencies:"
1944 echo "$modules" | sed -e 's/^/ /'
1946 # Add the dummy module if needed.
1947 func_modules_add_dummy
1949 # If --lgpl, verify that the licenses of modules are compatible.
1950 if test -n "$lgpl"; then
1951 for module in $modules; do
1952 license=`func_get_license $module`
1954 LGPL | LGPLv2+ | 'GPLed build tool') ;;
1955 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1956 *) func_fatal_error "incompatible license on module $module: $license" ;;
1961 # Determine script to apply to imported library files.
1962 sed_transform_lib_file=
1963 for module in $modules; do
1964 if test $module = config-h; then
1965 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1966 sed_transform_lib_file=$sed_transform_lib_file'
1967 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1972 if test -n "$do_copyrights"; then
1973 if test -n "$lgpl"; then
1975 sed_transform_lib_file=$sed_transform_lib_file'
1976 s/GNU General/GNU Lesser General/g
1977 s/version 2\([ ,]\)/version 2.1\1/g
1982 # Determine final file list.
1983 func_modules_to_filelist
1985 echo "$files" | sed -e 's/^/ /'
1988 || func_fatal_error "refusing to do nothing"
1990 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1991 new_files="$files m4/gnulib-tool.m4"
1992 old_files="$cached_files"
1993 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1994 func_append old_files " m4/gnulib-tool.m4"
1997 sed_rewrite_old_files="\
1998 s,^build-aux/,$auxdir/,
1999 s,^doc/,$cached_docbase/,
2000 s,^lib/,$cached_sourcebase/,
2001 s,^m4/,$cached_m4base/,
2002 s,^tests/,$cached_testsbase/,"
2003 sed_rewrite_new_files="\
2004 s,^build-aux/,$auxdir/,
2006 s,^lib/,$sourcebase/,
2008 s,^tests/,$testsbase/,"
2010 # Create directories.
2011 { echo "$sourcebase"
2013 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2014 if test -n "$docfiles"; then
2017 if test -n "$inctests"; then
2021 for f in $files; do echo $f; done \
2022 | sed -e "$sed_rewrite_new_files" \
2023 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2026 { # Rearrange file descriptors. Needed because "while ... done < ..."
2027 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2028 exec 5<&0 < "$tmp"/dirs
2030 if test ! -d "$destdir/$d"; then
2032 echo "Creating directory $destdir/$d"
2033 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2035 echo "Create directory $destdir/$d"
2042 # func_dest_tmpfilename file
2043 # determines the name of a temporary file (file is relative to destdir).
2045 # - tmpfile absolute filename of the temporary file
2046 func_dest_tmpfilename ()
2049 # Put the new contents of $file in a file in the same directory (needed
2050 # to guarantee that an 'mv' to "$destdir/$file" works).
2051 tmpfile="$destdir/$1.tmp"
2053 # Put the new contents of $file in a file in a temporary directory
2054 # (because the directory of "$file" might not exist).
2055 tmpfile="$tmp"/`basename "$1"`.tmp
2059 # Copy files or make symbolic links. Remove obsolete files.
2063 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2064 # representing the files according to the last gnulib-tool invocation.
2065 for f in $old_files; do echo $f; done \
2066 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2069 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2070 # representing the files after this gnulib-tool invocation.
2071 for f in $new_files; do echo $f; done \
2072 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2075 # First the files that are in old-files, but not in new-files:
2076 sed_take_first_column='s,'"$delimiter"'.*,,'
2077 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2078 # Remove the file. Do nothing if the user already removed it.
2079 if test -f "$destdir/$g"; then
2081 echo "Removing file $g (backup in ${g}~)"
2082 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2084 echo "Remove file $g (backup in ${g}~)"
2086 func_append removed_files "$g$nl"
2089 # func_add_or_update handles a file that ought to be present afterwards.
2091 # - f the original file name
2092 # - g the rewritten file name
2093 # - already_present nonempty if the file already exists, empty otherwise
2094 func_add_or_update ()
2096 func_dest_tmpfilename "$g"
2097 func_lookup_file "$f"
2098 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2099 if test -n "$sed_transform_lib_file"; then
2102 sed -e "$sed_transform_lib_file" \
2103 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2107 if test -f "$destdir/$g"; then
2108 # The file already exists.
2109 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2110 : # The file has not changed.
2114 if test -n "$already_present"; then
2115 echo "Updating file $g (backup in ${g}~)"
2117 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2119 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2120 if { test -n "$symbolic" \
2121 || { test -n "$lsymbolic" \
2122 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2123 && test -z "$lookedup_tmp" \
2124 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2125 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2127 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2130 if test -n "$already_present"; then
2131 echo "Update file $g (backup in ${g}~)"
2133 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2139 # Don't protest if the file should be there but isn't: it happens
2140 # frequently that developers don't put autogenerated files into CVS.
2142 echo "Copying file $g"
2143 if { test -n "$symbolic" \
2144 || { test -n "$lsymbolic" \
2145 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2146 && test -z "$lookedup_tmp" \
2147 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2148 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2150 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2155 func_append added_files "$g$nl"
2159 # Then the files that are in new-files, but not in old-files:
2160 sed_take_last_column='s,^.*'"$delimiter"',,'
2162 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2163 | sed -e "$sed_take_last_column" \
2164 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2165 { # Rearrange file descriptors. Needed because "while ... done < ..."
2166 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2167 exec 5<&0 < "$tmp"/added-files
2173 # Then the files that are in new-files and in old-files:
2174 already_present=true
2175 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2176 | sed -e "$sed_take_last_column" \
2177 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2178 { # Rearrange file descriptors. Needed because "while ... done < ..."
2179 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2180 exec 5<&0 < "$tmp"/kept-files
2187 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2188 actioncmd="gnulib-tool --import"
2189 func_append actioncmd " --dir=$destdir"
2190 if test -n "$local_gnulib_dir"; then
2191 func_append actioncmd " --local-dir=$local_gnulib_dir"
2193 func_append actioncmd " --lib=$libname"
2194 func_append actioncmd " --source-base=$sourcebase"
2195 func_append actioncmd " --m4-base=$m4base"
2196 func_append actioncmd " --doc-base=$docbase"
2197 func_append actioncmd " --aux-dir=$auxdir"
2198 if test -n "$inctests"; then
2199 func_append actioncmd " --with-tests"
2201 for module in $avoidlist; do
2202 func_append actioncmd " --avoid=$module"
2204 if test -n "$lgpl"; then
2205 func_append actioncmd " --lgpl"
2207 if test -n "$makefile_name"; then
2208 func_append actioncmd " --makefile-name=$makefile_name"
2210 if test "$libtool" = true; then
2211 func_append actioncmd " --libtool"
2213 func_append actioncmd " --no-libtool"
2215 func_append actioncmd " --macro-prefix=$macro_prefix"
2216 func_append actioncmd " `echo $specified_modules`"
2218 # Default the makefile name to Makefile.am.
2219 if test -n "$makefile_name"; then
2220 makefile_am=$makefile_name
2222 makefile_am=Makefile.am
2225 # Create normal Makefile.ams.
2228 # Create library makefile.
2229 func_dest_tmpfilename $sourcebase/$makefile_am
2230 func_emit_lib_Makefile_am > "$tmpfile"
2231 if test -f "$destdir"/$sourcebase/$makefile_am; then
2232 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2236 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2237 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2238 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2240 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2246 echo "Creating $sourcebase/$makefile_am"
2247 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2249 echo "Create $sourcebase/$makefile_am"
2252 func_append added_files "$sourcebase/$makefile_am$nl"
2255 # Create m4/gnulib-cache.m4.
2256 func_dest_tmpfilename $m4base/gnulib-cache.m4
2258 func_emit_copyright_notice
2260 echo "# This file represents the specification of how gnulib-tool is used."
2261 echo "# It acts as a cache: It is written and read by gnulib-tool."
2262 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2263 echo "# like the configure.ac and various Makefile.am files."
2266 echo "# Specification in the form of a command-line invocation:"
2269 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2270 # Store the local_gnulib_dir relative to destdir.
2271 case "$local_gnulib_dir" in
2273 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2276 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2278 # destdir, local_gnulib_dir are both relative.
2279 func_relativize "$destdir" "$local_gnulib_dir"
2280 relative_local_gnulib_dir="$reldir" ;;
2283 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2284 echo "gl_MODULES(["`echo $specified_modules`"])"
2285 echo "gl_AVOID([$avoidlist])"
2286 echo "gl_SOURCE_BASE([$sourcebase])"
2287 echo "gl_M4_BASE([$m4base])"
2288 echo "gl_DOC_BASE([$docbase])"
2289 echo "gl_TESTS_BASE([$testsbase])"
2290 test -z "$inctests" || echo "gl_WITH_TESTS"
2291 echo "gl_LIB([$libname])"
2292 test -z "$lgpl" || echo "gl_LGPL"
2293 echo "gl_MAKEFILE_NAME([$makefile_name])"
2294 if test "$libtool" = true; then
2297 echo "gl_MACRO_PREFIX([$macro_prefix])"
2299 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2300 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2304 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2305 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2306 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2308 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2312 echo "# gnulib-cache.m4 ends here"
2319 echo "Creating $m4base/gnulib-cache.m4"
2320 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2322 echo "Create $m4base/gnulib-cache.m4"
2328 # Create m4/gnulib-comp.m4.
2329 func_dest_tmpfilename $m4base/gnulib-comp.m4
2331 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2332 func_emit_copyright_notice
2334 echo "# This file represents the compiled summary of the specification in"
2335 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2336 echo "# to be invoked from configure.ac."
2337 echo "# In projects using CVS, this file can be treated like other built files."
2340 echo "# This macro should be invoked from $configure_ac, in the section"
2341 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2342 echo "# any checks for libraries, header files, types and library functions."
2343 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2345 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2346 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2347 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2348 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2349 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2350 if test -n "$uses_subdirs"; then
2351 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2353 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2354 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2356 for module in $modules; do
2358 if test -n "$module"; then
2359 func_get_autoconf_early_snippet "$module"
2362 | sed -e '/^$/d;' -e 's/^/ /'
2365 echo "# This macro should be invoked from $configure_ac, in the section"
2366 echo "# \"Check for header files, types and library functions\"."
2367 echo "AC_DEFUN([${macro_prefix}_INIT],"
2369 func_emit_initmacro_start
2370 if test "$libtool" = true; then
2371 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2372 echo " gl_cond_libtool=true"
2374 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2375 echo " gl_cond_libtool=false"
2377 echo " gl_ltlibdeps="
2379 echo " gl_source_base='$sourcebase'"
2380 if test "$auxdir" != "build-aux"; then
2381 sed_replace_build_aux='
2383 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2384 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2388 sed_replace_build_aux=
2390 for module in $modules; do
2392 if test -n "$module"; then
2393 func_get_autoconf_snippet "$module" \
2394 | sed -e '/^$/d;' -e 's/^/ /' \
2395 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2396 -e "$sed_replace_build_aux"
2397 if test "$module" = 'alloca' && test "$libtool" = true; then
2398 echo 'changequote(,)dnl'
2399 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2400 echo 'changequote([, ])dnl'
2401 echo 'AC_SUBST([LTALLOCA])'
2405 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2406 # created using libtool, because libtool already handles the dependencies.
2407 if test "$libtool" != true; then
2408 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
2409 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2410 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2411 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2412 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2414 func_emit_initmacro_end
2416 func_emit_initmacro_done
2418 echo "# This macro records the list of files which have been installed by"
2419 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2420 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2421 echo "$files" | sed -e 's,^, ,'
2424 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2425 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2429 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2430 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2431 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2433 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2437 echo "# gnulib-comp.m4 ends here"
2444 echo "Creating $m4base/gnulib-comp.m4"
2445 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2447 echo "Create $m4base/gnulib-comp.m4"
2453 if test -n "$inctests"; then
2454 # Create tests makefile.
2455 func_dest_tmpfilename $testsbase/$makefile_am
2456 func_emit_tests_Makefile_am > "$tmpfile"
2457 if test -f "$destdir"/$testsbase/$makefile_am; then
2458 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2462 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2463 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2464 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2466 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2472 echo "Creating $testsbase/$makefile_am"
2473 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2475 echo "Create $testsbase/$makefile_am"
2478 func_append added_files "$testsbase/$makefile_am$nl"
2482 # Update the .cvsignore and .gitignore files.
2483 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
2484 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
2485 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
2486 { # Rearrange file descriptors. Needed because "while ... done < ..."
2487 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2488 exec 5<&0 < "$tmp"/fileset-changes
2489 func_update_ignorelist ()
2492 if test -f "$destdir/$dir$ignore"; then
2493 if test -n "$dir_added" || test -n "$dir_removed"; then
2494 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
2495 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
2496 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
2497 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
2498 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
2499 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
2501 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2502 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
2503 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
2504 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
2505 | sed -f "$tmp"/sed-ignore-removed \
2506 > "$destdir/$dir$ignore"
2508 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2513 if test -n "$dir_added"; then
2515 echo "Creating $destdir/$dir$ignore"
2516 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u > "$destdir/$dir$ignore"
2518 echo "Create $destdir/$dir$ignore"
2528 if test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
2529 func_update_ignorelist .cvsignore
2531 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
2532 func_update_ignorelist .gitignore
2539 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
2540 next_dir=`echo "$line" | sed -e 's,|.*,,'`
2541 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
2542 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
2543 if test "$next_dir" != "$last_dir"; then
2544 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2545 last_dir="$next_dir"
2550 A) func_append last_dir_added "$file$nl";;
2551 R) func_append last_dir_removed "$file$nl";;
2554 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2560 echo "You may need to add #include directives for the following .h files."
2561 # Intersect $specified_modules and $modules
2562 # (since $specified_modules is not necessarily of subset of $modules - some
2563 # may have been skipped through --avoid, and since the elements of $modules
2564 # but not in $specified_modules can go away without explicit notice - through
2565 # changes in the module dependencies).
2566 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2567 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2568 # First the #include <...> directives without #ifs, sorted for convenience,
2569 # then the #include "..." directives without #ifs, sorted for convenience,
2570 # then the #include directives that are surrounded by #ifs. Not sorted.
2571 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2572 include_directive=`func_get_include_directive "$module"`
2573 case "$nl$include_directive" in
2575 echo "$include_directive" 1>&5
2578 echo "$include_directive" | grep -v 'include "' 1>&6
2579 echo "$include_directive" | grep 'include "' 1>&7
2582 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2584 LC_ALL=C sort -u "$tmp"/include-angles
2585 LC_ALL=C sort -u "$tmp"/include-quotes
2586 cat "$tmp"/include-if
2587 ) | sed -e '/^$/d' -e 's/^/ /'
2588 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2590 for module in $modules; do
2591 func_get_link_directive "$module"
2593 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
2594 if test `wc -l < "$tmp"/link` != 0; then
2596 echo "You may need to use the following Makefile variables when linking."
2597 echo "Use them in <program>_LDADD when linking a program, or"
2598 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
2604 echo "Don't forget to"
2605 if test "$makefile_am" = Makefile.am; then
2606 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2608 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2610 if test -n "$inctests"; then
2611 if test "$makefile_am" = Makefile.am; then
2612 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2614 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2617 if test "$makefile_am" = Makefile.am; then
2618 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2619 sourcebase_base=`basename "$sourcebase"`
2620 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2622 if test -n "$inctests"; then
2623 if test "$makefile_am" = Makefile.am; then
2624 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2625 testsbase_base=`basename "$testsbase"`
2626 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2629 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2630 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2631 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2634 # func_create_testdir testdir modules
2636 # - local_gnulib_dir from --local-dir
2637 # - auxdir directory relative to destdir where to place build aux files
2638 func_create_testdir ()
2642 if test -z "$modules"; then
2643 # All modules together.
2644 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2645 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2646 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2647 modules=`func_all_modules`
2648 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2650 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2652 # Check that the license of every module is consistent with the license of
2654 saved_modules="$modules"
2655 saved_inctests="$inctests"
2656 # When computing transitive closures, don't consider $module to depend on
2657 # $module-tests. Need this becauses tests are implicitly GPL and may depend
2658 # on GPL modules - therefore we don't want a warning in this case.
2660 for requested_module in $saved_modules; do
2661 requested_license=`func_get_license "$requested_module"`
2662 if test "$requested_license" != GPL; then
2663 # Here we use func_modules_transitive_closure, not just
2664 # func_get_dependencies, so that we also detect weird situations like
2665 # an LGPL module which depends on a GPLed build tool module which depends
2667 modules="$requested_module"
2668 func_modules_transitive_closure
2669 for module in $modules; do
2670 license=`func_get_license "$module"`
2672 'GPLed build tool') ;;
2673 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2675 case "$requested_license" in
2678 GPLv2+ | LGPLv2+) ;;
2679 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2685 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2691 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2700 modules="$saved_modules"
2701 inctests="$saved_inctests"
2703 # Subdirectory names.
2710 # Determine final module list.
2711 func_modules_transitive_closure
2712 echo "Module list with included dependencies:"
2713 echo "$modules" | sed -e 's/^/ /'
2715 # Add the dummy module if needed.
2716 func_modules_add_dummy
2718 # Determine final file list.
2719 func_modules_to_filelist
2721 echo "$files" | sed -e 's/^/ /'
2723 sed_rewrite_files="\
2724 s,^build-aux/,$auxdir/,
2726 s,^lib/,$sourcebase/,
2728 s,^tests/,$testsbase/,"
2730 # Create directories.
2731 for f in $files; do echo $f; done \
2732 | sed -e "$sed_rewrite_files" \
2733 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2734 | LC_ALL=C sort -u \
2736 { # Rearrange file descriptors. Needed because "while ... done < ..."
2737 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2738 exec 5<&0 < "$tmp"/dirs
2740 mkdir -p "$testdir/$d"
2745 # Copy files or make symbolic links.
2747 for f in $files; do echo $f; done \
2748 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2751 { # Rearrange file descriptors. Needed because "while ... done < ..."
2752 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2753 exec 5<&0 < "$tmp"/files
2755 func_lookup_file "$f"
2756 if test -n "$lookedup_tmp"; then
2757 cp -p "$lookedup_file" "$testdir/$g"
2759 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2760 if { test -n "$symbolic" \
2761 || { test -n "$lsymbolic" \
2762 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
2763 func_ln "$lookedup_file" "$testdir/$g"
2765 cp -p "$lookedup_file" "$testdir/$g"
2772 # Create Makefile.ams that are for testing.
2775 # Create $sourcebase/Makefile.am.
2776 mkdir -p "$testdir/$sourcebase"
2777 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2779 # Create $m4base/Makefile.am.
2780 mkdir -p "$testdir/$m4base"
2781 (echo "## Process this file with automake to produce Makefile.in."
2787 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2790 ) > "$testdir/$m4base/Makefile.am"
2792 subdirs="$sourcebase $m4base"
2793 subdirs_with_configure_ac=""
2795 if false && test -f "$testdir"/$m4base/gettext.m4; then
2796 # Avoid stupid error message from automake:
2797 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2798 mkdir -p "$testdir/po"
2799 (echo "## Process this file with automake to produce Makefile.in."
2800 ) > "$testdir/po/Makefile.am"
2801 func_append subdirs " po"
2804 if test -n "$inctests"; then
2805 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2806 # Create $testsbase/Makefile.am.
2807 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2808 # Create $testsbase/configure.ac.
2809 (echo "# Process this file with autoconf to produce a configure script."
2810 echo "AC_INIT([dummy], [0])"
2811 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2812 echo "AM_INIT_AUTOMAKE"
2814 echo "AM_CONFIG_HEADER([config.h])"
2817 echo "AC_PROG_INSTALL"
2818 echo "AC_PROG_MAKE_SET"
2819 echo "AC_PROG_RANLIB"
2821 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2822 echo "AC_GNU_SOURCE"
2825 for module in $modules; do
2827 if test -n "$module"; then
2828 func_get_autoconf_early_snippet "$module"
2831 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
2832 if test "$libtool" = true; then
2833 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2834 echo "gl_cond_libtool=true"
2836 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2837 echo "gl_cond_libtool=false"
2839 echo "gl_ltlibdeps="
2841 # Wrap the set of autoconf snippets into an autoconf macro that is then
2842 # invoked. This is needed because autoconf does not support AC_REQUIRE
2844 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2845 # but we want the AC_REQUIRE to have its normal meaning (provide one
2846 # expansion of the required macro before the current point, and only one
2848 echo "AC_DEFUN([gl_INIT], ["
2849 func_emit_initmacro_start
2850 sed_replace_build_aux='
2852 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2853 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2856 # We don't have explicit ordering constraints between the various
2857 # autoconf snippets. It's cleanest to put those of the library before
2858 # those of the tests.
2859 echo "gl_source_base='../$sourcebase'"
2860 for module in $modules; do
2861 func_verify_nontests_module
2862 if test -n "$module"; then
2863 func_get_autoconf_snippet "$module" \
2864 | sed -e "$sed_replace_build_aux"
2867 echo "gl_source_base='.'"
2868 for module in $modules; do
2869 func_verify_tests_module
2870 if test -n "$module"; then
2871 func_get_autoconf_snippet "$module" \
2872 | sed -e "$sed_replace_build_aux"
2875 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2876 # created using libtool, because libtool already handles the dependencies.
2877 if test "$libtool" != true; then
2878 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
2879 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2880 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2881 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2882 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2884 func_emit_initmacro_end
2886 func_emit_initmacro_done
2890 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2891 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2892 echo "AH_TOP([#include \"../config.h\"])"
2894 echo "AC_OUTPUT([Makefile])"
2895 ) > "$testdir/$testsbase/configure.ac"
2896 func_append subdirs " $testsbase"
2897 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2900 # Create Makefile.am.
2901 (echo "## Process this file with automake to produce Makefile.in."
2903 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2905 echo "SUBDIRS = $subdirs"
2907 echo "ACLOCAL_AMFLAGS = -I $m4base"
2908 ) > "$testdir/Makefile.am"
2910 # Create configure.ac.
2911 (echo "# Process this file with autoconf to produce a configure script."
2912 echo "AC_INIT([dummy], [0])"
2913 if test "$auxdir" != "."; then
2914 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2916 echo "AM_INIT_AUTOMAKE"
2918 echo "AM_CONFIG_HEADER([config.h])"
2921 echo "AC_PROG_INSTALL"
2922 echo "AC_PROG_MAKE_SET"
2924 echo "# For autobuild."
2925 echo "AC_CANONICAL_BUILD"
2926 echo "AC_CANONICAL_HOST"
2928 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2929 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2930 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2931 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2933 echo "AC_PROG_RANLIB"
2935 if test -n "$uses_subdirs"; then
2936 echo "AM_PROG_CC_C_O"
2939 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2940 echo "AC_GNU_SOURCE"
2943 for module in $modules; do
2944 func_verify_nontests_module
2945 if test -n "$module"; then
2946 func_get_autoconf_early_snippet "$module"
2949 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
2950 if test "$libtool" = true; then
2951 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2952 echo "gl_cond_libtool=true"
2954 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2955 echo "gl_cond_libtool=false"
2957 echo "gl_ltlibdeps="
2959 echo "gl_source_base='$sourcebase'"
2960 # Wrap the set of autoconf snippets into an autoconf macro that is then
2961 # invoked. This is needed because autoconf does not support AC_REQUIRE
2963 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2964 # but we want the AC_REQUIRE to have its normal meaning (provide one
2965 # expansion of the required macro before the current point, and only one
2967 echo "AC_DEFUN([gl_INIT], ["
2968 func_emit_initmacro_start
2969 if test "$auxdir" != "build-aux"; then
2970 sed_replace_build_aux='
2972 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2973 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2977 sed_replace_build_aux=
2979 for module in $modules; do
2980 func_verify_nontests_module
2981 if test -n "$module"; then
2982 func_get_autoconf_snippet "$module" \
2983 | sed -e "$sed_replace_build_aux"
2986 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2987 # created using libtool, because libtool already handles the dependencies.
2988 if test "$libtool" != true; then
2989 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
2990 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2991 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2992 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2993 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2995 func_emit_initmacro_end
2997 func_emit_initmacro_done
3001 if test -n "$subdirs_with_configure_ac"; then
3002 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3004 makefiles="Makefile"
3005 for d in $subdirs; do
3006 # For subdirs that have a configure.ac by their own, it's the subdir's
3007 # configure.ac which creates the subdir's Makefile.am, not this one.
3008 case " $subdirs_with_configure_ac " in
3010 *) func_append makefiles " $d/Makefile" ;;
3013 echo "AC_OUTPUT([$makefiles])"
3014 ) > "$testdir/configure.ac"
3016 # Create autogenerated files.
3018 # Do not use "${AUTORECONF} --force --install", because it may invoke
3019 # autopoint, which brings in older versions of some of our .m4 files.
3020 if test -f $m4base/gettext.m4; then
3021 echo "executing ${AUTOPOINT} --force"
3022 ${AUTOPOINT} --force || func_exit 1
3023 for f in $m4base/*.m4~; do
3024 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3027 echo "executing ${ACLOCAL} -I $m4base"
3028 ${ACLOCAL} -I $m4base || func_exit 1
3029 if ! test -d build-aux; then
3030 echo "executing mkdir build-aux"
3031 mkdir build-aux || func_exit 1
3033 echo "executing ${AUTOCONF}"
3034 ${AUTOCONF} || func_exit 1
3035 echo "executing ${AUTOHEADER}"
3036 ${AUTOHEADER} || func_exit 1
3037 echo "executing ${AUTOMAKE} --add-missing --copy"
3038 ${AUTOMAKE} --add-missing --copy || func_exit 1
3040 if test -n "$inctests"; then
3041 # Create autogenerated files.
3042 (cd "$testdir/$testsbase" || func_exit 1
3043 # Do not use "${AUTORECONF} --force --install", because it may invoke
3044 # autopoint, which brings in older versions of some of our .m4 files.
3045 if test -f ../$m4base/gettext.m4; then
3046 echo "executing ${AUTOPOINT} --force"
3047 ${AUTOPOINT} --force || func_exit 1
3048 for f in ../$m4base/*.m4~; do
3049 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3052 echo "executing ${ACLOCAL} -I ../$m4base"
3053 ${ACLOCAL} -I ../$m4base || func_exit 1
3054 if ! test -d ../build-aux; then
3055 echo "executing mkdir ../build-aux"
3058 echo "executing ${AUTOCONF}"
3059 ${AUTOCONF} || func_exit 1
3060 echo "executing ${AUTOHEADER}"
3061 ${AUTOHEADER} || func_exit 1
3062 echo "executing ${AUTOMAKE} --add-missing --copy"
3063 ${AUTOMAKE} --add-missing --copy || func_exit 1
3066 # Need to run configure and make once, to create built files that are to be
3067 # distributed (such as getdate.c).
3068 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3069 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3070 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3071 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3072 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3073 # such $(FOO_H) because they don't refer to distributed files.
3074 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3075 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3076 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3077 | sed -e "$sed_remove_make_variables"`
3078 distributed_built_sources=`for file in $built_sources; do
3079 case "$cleaned_files" in
3084 if test -n "$distributed_built_sources"; then
3086 ./configure || func_exit 1
3088 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3089 make built_sources || func_exit 1
3091 make distclean || func_exit 1
3096 # func_create_megatestdir megatestdir allmodules
3098 # - local_gnulib_dir from --local-dir
3099 # - auxdir directory relative to destdir where to place build aux files
3100 func_create_megatestdir ()
3104 if test -z "$allmodules"; then
3105 allmodules=`func_all_modules`
3109 # First, all modules one by one.
3110 for onemodule in $allmodules; do
3111 func_create_testdir "$megatestdir/$onemodule" $onemodule
3112 func_append megasubdirs "$onemodule "
3114 # Then, all modules all together.
3115 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3116 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3117 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3118 func_create_testdir "$megatestdir/ALL" "$allmodules"
3119 func_append megasubdirs "ALL"
3122 cvsdate=`sh "$gnulib_dir/build-aux/mdate-sh" "$gnulib_dir/CVS/Entries" \
3123 | sed -e 's,January,01,' -e 's,Jan,01,' \
3124 -e 's,February,02,' -e 's,Feb,02,' \
3125 -e 's,March,03,' -e 's,Mar,03,' \
3126 -e 's,April,04,' -e 's,Apr,04,' \
3128 -e 's,June,06,' -e 's,Jun,06,' \
3129 -e 's,July,07,' -e 's,Jul,07,' \
3130 -e 's,August,08,' -e 's,Aug,08,' \
3131 -e 's,September,09,' -e 's,Sep,09,' \
3132 -e 's,October,10,' -e 's,Oct,10,' \
3133 -e 's,November,11,' -e 's,Nov,11,' \
3134 -e 's,December,12,' -e 's,Dec,12,' \
3135 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3136 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3138 echo "CVSDATE=$cvsdate"
3139 echo "test -d logs || mkdir logs"
3140 echo "for module in $megasubdirs; do"
3141 echo " echo \"Working on module \$module...\""
3142 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3143 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3146 echo " : autobuild project... \$module"
3147 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3148 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3149 echo " : autobuild hostname... \`hostname\`"
3150 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3152 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3154 ) > "$megatestdir/do-autobuild"
3155 chmod a+x "$megatestdir/do-autobuild"
3157 # Create Makefile.am.
3158 (echo "## Process this file with automake to produce Makefile.in."
3160 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3162 echo "SUBDIRS = $megasubdirs"
3164 echo "EXTRA_DIST = do-autobuild"
3165 ) > "$megatestdir/Makefile.am"
3167 # Create configure.ac.
3168 (echo "# Process this file with autoconf to produce a configure script."
3169 echo "AC_INIT([dummy], [0])"
3170 if test "$auxdir" != "."; then
3171 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3173 echo "AM_INIT_AUTOMAKE"
3175 echo "AC_PROG_MAKE_SET"
3177 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3178 echo "AC_OUTPUT([Makefile])"
3179 ) > "$megatestdir/configure.ac"
3181 # Create autogenerated files.
3183 # Do not use "${AUTORECONF} --install", because autoreconf operates
3184 # recursively, but the subdirectories are already finished, therefore
3185 # calling autoreconf here would only waste lots of CPU time.
3186 echo "executing ${ACLOCAL}"
3187 ${ACLOCAL} || func_exit 1
3188 echo "executing mkdir build-aux"
3190 echo "executing ${AUTOCONF}"
3191 ${AUTOCONF} || func_exit 1
3192 echo "executing ${AUTOMAKE} --add-missing --copy"
3193 ${AUTOMAKE} --add-missing --copy || func_exit 1
3199 func_fatal_error "no mode specified" ;;
3208 if test -z "$destdir"; then
3211 test -d "$destdir" \
3212 || func_fatal_error "destination directory does not exist: $destdir"
3214 # Prefer configure.ac to configure.in.
3215 if test -f "$destdir"/configure.ac; then
3216 configure_ac="$destdir/configure.ac"
3218 if test -f "$destdir"/configure.in; then
3219 configure_ac="$destdir/configure.in"
3221 func_fatal_error "cannot find $destdir/configure.ac"
3225 # Analyze configure.ac.
3227 guessed_libtool=false
3232 /AC_CONFIG_AUX_DIR/ {
3233 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3235 /A[CM]_PROG_LIBTOOL/ {
3236 s,^.*$,guessed_libtool=true,p
3238 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3240 if test -z "$auxdir"; then
3241 auxdir="$guessed_auxdir"
3244 # Determine where to apply func_import.
3245 if test -n "$m4base"; then
3246 # Apply func_import to a particular gnulib directory.
3247 # Any number of additional modules can be given.
3248 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3249 # First use of gnulib in the given m4base.
3250 test -n "$supplied_libname" || supplied_libname=true
3251 test -n "$sourcebase" || sourcebase="lib"
3252 test -n "$docbase" || docbase="doc"
3253 test -n "$testsbase" || testsbase="tests"
3254 test -n "$macro_prefix" || macro_prefix="gl"
3258 # Apply func_import to all gnulib directories.
3259 # To get this list of directories, look at Makefile.am. (Not at
3260 # configure, because it may be omitted from CVS. Also, don't run
3261 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3264 if test -f "$destdir"/Makefile.am; then
3265 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3267 for arg in $aclocal_amflags; do
3268 if test -n "$m4dir_is_next"; then
3269 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3273 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3274 func_append m4dirs " $arg"
3275 m4dirs_count=`expr $m4dirs_count + 1`
3281 if test "X$arg" = "X-I"; then
3289 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3290 if test -f "$destdir"/aclocal.m4; then
3291 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3292 sedexpr2='s,^[^/]*$,.,'
3293 sedexpr3='s,/[^/]*$,,'
3294 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3295 m4dirs_count=`echo "$m4dirs" | wc -l`
3298 if test $m4dirs_count = 0; then
3299 # First use of gnulib in a package.
3300 # Any number of additional modules can be given.
3301 test -n "$supplied_libname" || supplied_libname=true
3302 test -n "$sourcebase" || sourcebase="lib"
3304 test -n "$docbase" || docbase="doc"
3305 test -n "$testsbase" || testsbase="tests"
3306 test -n "$macro_prefix" || macro_prefix="gl"
3309 if test $m4dirs_count = 1; then
3310 # There's only one use of gnulib here. Assume the user means it.
3311 # Any number of additional modules can be given.
3312 for m4base in $m4dirs; do
3316 # Ambiguous - guess what the user meant.
3317 if test $# = 0; then
3318 # No further arguments. Guess the user wants to update all of them.
3319 for m4base in $m4dirs; do
3320 # Perform func_import in a subshell, so that variable values
3322 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
3323 # testsbase, inctests, libname, lgpl, makefile_name, libtool,
3325 # don't propagate from one directory to another.
3326 (func_import) || func_exit 1
3330 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
3338 if test -z "$destdir"; then
3339 func_fatal_error "please specify --dir option"
3342 test -d "$destdir" \
3343 || func_fatal_error "could not create destination directory"
3344 test -n "$auxdir" || auxdir="build-aux"
3345 func_create_testdir "$destdir" "$*"
3348 create-megatestdir )
3349 if test -z "$destdir"; then
3350 func_fatal_error "please specify --dir option"
3352 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3353 test -n "$auxdir" || auxdir="build-aux"
3354 func_create_megatestdir "$destdir" "$*"
3358 test -n "$destdir" || destdir=testdir$$
3359 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3360 test -n "$auxdir" || auxdir="build-aux"
3361 func_create_testdir "$destdir" "$*"
3365 ../configure || func_exit 1
3367 make check || func_exit 1
3368 make distclean || func_exit 1
3369 remaining=`find . -type f -print`
3370 if test -n "$remaining"; then
3371 echo "Remaining files:" $remaining 1>&2
3372 echo "gnulib-tool: *** Stop." 1>&2
3381 test -n "$destdir" || destdir=testdir$$
3382 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3383 test -n "$auxdir" || auxdir="build-aux"
3384 func_create_megatestdir "$destdir" "$*"
3392 remaining=`find . -type f -print`
3393 if test -n "$remaining"; then
3394 echo "Remaining files:" $remaining 1>&2
3395 echo "gnulib-tool: *** Stop." 1>&2
3403 extract-description )
3407 if test -n "$module"; then
3408 func_get_description "$module"
3417 if test -n "$module"; then
3418 func_get_filelist "$module"
3423 extract-dependencies )
3427 if test -n "$module"; then
3428 func_get_dependencies "$module"
3433 extract-autoconf-snippet )
3437 if test -n "$module"; then
3438 func_get_autoconf_snippet "$module"
3443 extract-automake-snippet )
3447 if test -n "$module"; then
3448 func_get_automake_snippet "$module"
3453 extract-include-directive )
3457 if test -n "$module"; then
3458 func_get_include_directive "$module"
3463 extract-link-directive )
3467 if test -n "$module"; then
3468 func_get_link_directive "$module"
3477 if test -n "$module"; then
3478 func_get_license "$module"
3483 extract-maintainer )
3487 if test -n "$module"; then
3488 func_get_maintainer "$module"
3493 extract-tests-module )
3497 if test -n "$module"; then
3498 func_get_tests_module "$module"
3504 func_fatal_error "unknown operation mode --$mode" ;;
3508 # Undo the effect of the previous 'trap' command. Some shellology:
3509 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3510 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3511 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3512 # 128 + signal number and is set before the trap-registered command is run.
3514 trap 'func_exit $?' 1 2 3 13 15
3519 # indent-tabs-mode: nil
3520 # whitespace-check-buffer-indent: nil