3 # Copyright (C) 2002-2007 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # This program is meant for authors or maintainers which want to import
21 # modules from gnulib into their packages.
25 cvsdatestamp='$Date: 2007-06-23 02:02:46 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
31 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
35 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
36 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
40 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
43 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # When using GNU sed, turn off as many GNU extensions as possible,
70 # to minimize the risk of accidentally using non-portable features.
71 # However, do this only for gnulib-tool itself, not for the code that
72 # gnulib-tool generates, since we don't want "sed --posix" to leak
74 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
75 alias sed='sed --posix'
79 # outputs to stdout the --help usage message.
83 Usage: gnulib-tool --list
84 gnulib-tool --import [module1 ... moduleN]
86 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
87 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
88 gnulib-tool --test --dir=directory module1 ... moduleN
89 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
90 gnulib-tool --extract-description module
91 gnulib-tool --extract-filelist module
92 gnulib-tool --extract-dependencies module
93 gnulib-tool --extract-autoconf-snippet module
94 gnulib-tool --extract-automake-snippet module
95 gnulib-tool --extract-include-directive module
96 gnulib-tool --extract-link-directive module
97 gnulib-tool --extract-license module
98 gnulib-tool --extract-maintainer module
99 gnulib-tool --extract-tests-module module
102 --list print the available module names
103 --import import the given modules into the current package;
104 if no modules are specified, update the current
105 package from the current gnulib
106 --update update the current package, restore files omitted
108 --create-testdir create a scratch package with the given modules
109 --create-megatestdir create a mega scratch package with the given modules
110 one by one and all together
111 --test test the combination of the given modules
112 (recommended to use CC=\"gcc -Wall\" here)
113 --megatest test the given modules one by one and all together
114 (recommended to use CC=\"gcc -Wall\" here)
115 --extract-description extract the description
116 --extract-filelist extract the list of files
117 --extract-dependencies extract the dependencies
118 --extract-autoconf-snippet extract the snippet for configure.ac
119 --extract-automake-snippet extract the snippet for library makefile
120 --extract-include-directive extract the #include directive
121 --extract-link-directive extract the linker directive
122 --extract-license report the license terms of the source files
124 --extract-maintainer report the maintainer(s) inside gnulib
125 --extract-tests-module report the unit test module, if it exists
128 --dir=DIRECTORY Specify the target directory.
129 For --import, this specifies where your
130 configure.ac can be found. Defaults to current
132 --local-dir=DIRECTORY Specify a local override directory where to look
133 up files before looking in gnulib's directory.
135 Options for --import:
136 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
137 --source-base=DIRECTORY
138 Directory relative to --dir where source code is
139 placed (default \"lib\").
140 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
141 placed (default \"m4\").
142 --doc-base=DIRECTORY Directory relative to --dir where doc files are
143 placed (default \"doc\").
144 --tests-base=DIRECTORY
145 Directory relative to --dir where unit tests are
146 placed (default \"tests\").
147 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
148 tools are placed (default \"build-aux\").
149 --with-tests Include unit tests for the included modules.
150 --avoid=MODULE Avoid including the given MODULE. Useful if you
151 have code that provides equivalent functionality.
152 This option can be repeated.
153 --lgpl Abort if modules aren't available under the LGPL.
154 Also modify license template from GPL to LGPL.
155 --makefile-name=NAME Name of makefile in automake syntax in the
156 source-base and tests-base directories
157 (default \"Makefile.am\").
158 --libtool Use libtool rules.
159 --no-libtool Don't use libtool rules.
160 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
161 'gl_INIT'. Default is 'gl'.
162 --no-changelog don't update or create ChangeLog files
164 Options for --import and --update:
165 --dry-run For --import, only print what would have been done.
166 -s, --symbolic, --symlink Make symbolic links instead of copying files.
167 --local-symlink Make symbolic links instead of copying files, only
168 for files from the local override directory.
170 Report bugs to <bug-gnulib@gnu.org>."
174 # outputs to stdout the --version message.
177 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
179 $progname (GNU $package) $version
180 Copyright (C) $year Free Software Foundation, Inc.
181 This is free software; see the source for copying conditions. There is NO
182 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
183 Written by" "Bruno Haible" "and" "Simon Josefsson"
186 # func_emit_copyright_notice
187 # outputs to stdout a header for a generated file.
188 func_emit_copyright_notice ()
190 echo "# Copyright (C) 2004-2007 Free Software Foundation, Inc."
192 echo "# This file is free software, distributed under the terms of the GNU"
193 echo "# General Public License. As a special exception to the GNU General"
194 echo "# Public License, this file may be distributed as part of a program"
195 echo "# that contains a configuration script generated by Autoconf, under"
196 echo "# the same distribution terms as the rest of that program."
198 echo "# Generated by gnulib-tool."
209 # creates a temporary directory.
211 # - tmp pathname of freshly created temporary directory
214 # Use the environment variable TMPDIR, falling back to /tmp. This allows
215 # users to specify a different temporary directory, for example, if their
216 # /tmp is filled up or too small.
219 # Use the mktemp program if available. If not available, hide the error
221 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
222 test -n "$tmp" && test -d "$tmp"
225 # Use a simple mkdir command. It is guaranteed to fail if the directory
226 # already exists. $RANDOM is bash specific and expands to empty in shells
227 # other than bash, ksh and zsh. Its use does not increase security;
228 # rather, it minimizes the probability of failure in a very cluttered /tmp
230 tmp=$TMPDIR/gl$$-$RANDOM
231 (umask 077 && mkdir "$tmp")
234 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
239 # func_append var value
240 # appends the given value to the shell variable var.
241 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
242 # Use bash's += operator. It reduces complexity of appending repeatedly to
243 # a single variable from O(n^2) to O(n).
251 eval "$1=\"\$$1\$2\""
255 # func_fatal_error message
256 # outputs to stderr a fatal error message, and terminates the program.
259 echo "gnulib-tool: *** $1" 1>&2
260 echo "gnulib-tool: *** Stop." 1>&2
264 # func_readlink SYMLINK
265 # outputs the target of the given symlink.
266 if (type -p readlink) > /dev/null 2>&1; then
269 # Use the readlink program from GNU coreutils.
275 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
276 # would do the wrong thing if the link target contains " -> ".
277 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
281 # func_relativize DIR1 DIR2
282 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
284 # - DIR1 relative pathname, relative to the current directory
285 # - DIR2 relative pathname, relative to the current directory
287 # - reldir relative pathname of DIR2, relative to DIR1
293 sed_first='s,^\([^/]*\)/.*$,\1,'
294 sed_rest='s,^[^/]*/*,,'
295 sed_last='s,^.*/\([^/]*\)$,\1,'
296 sed_butlast='s,/*[^/]*$,,'
297 while test -n "$dir1"; do
298 first=`echo "$dir1" | sed -e "$sed_first"`
299 if test "$first" != "."; then
300 if test "$first" = ".."; then
301 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
302 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
304 first2=`echo "$dir2" | sed -e "$sed_first"`
305 if test "$first2" = "$first"; then
306 dir2=`echo "$dir2" | sed -e "$sed_rest"`
310 dir0="$dir0"/"$first"
313 dir1=`echo "$dir1" | sed -e "$sed_rest"`
318 # func_relconcat DIR1 DIR2
319 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
321 # - DIR1 relative pathname, relative to the current directory
322 # - DIR2 relative pathname, relative to DIR1
324 # - relconcat DIR1/DIR2, relative to the current directory
329 sed_first='s,^\([^/]*\)/.*$,\1,'
330 sed_rest='s,^[^/]*/*,,'
331 sed_last='s,^.*/\([^/]*\)$,\1,'
332 sed_butlast='s,/*[^/]*$,,'
334 first=`echo "$dir2" | sed -e "$sed_first"`
335 if test "$first" = "."; then
336 dir2=`echo "$dir2" | sed -e "$sed_rest"`
337 if test -z "$dir2"; then
342 last=`echo "$dir1" | sed -e "$sed_last"`
343 while test "$last" = "."; do
344 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
345 last=`echo "$dir1" | sed -e "$sed_last"`
347 if test -z "$dir1"; then
351 if test "$first" = ".."; then
352 if test "$last" = ".."; then
353 relconcat="$dir1/$dir2"
356 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
357 dir2=`echo "$dir2" | sed -e "$sed_rest"`
358 if test -z "$dir1"; then
362 if test -z "$dir2"; then
367 relconcat="$dir1/$dir2"
375 # Like ln -s, except that SRC is given relative to the current directory (or
376 # absolute), not given relative to the directory of DEST.
382 *) # SRC is relative.
385 ln -s "`pwd`/$1" "$2" ;;
386 *) # DEST is relative too.
387 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
388 test -n "$ln_destdir" || ln_destdir="."
389 func_relativize "$ln_destdir" "$1"
397 # func_ln_if_changed SRC DEST
398 # Like func_ln, but avoids munging timestamps if the link is correct.
399 func_ln_if_changed ()
401 if test $# -ne 2; then
402 echo "usage: func_ln_if_changed SRC DEST" >&2
404 ln_target=`func_readlink "$2"`
405 if test -L "$2" && test "$1" = "$ln_target"; then
413 # Ensure an 'echo' command that does not interpret backslashes.
415 # echo '\n' | wc -l prints 1 when OK, 2 when KO
416 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
417 # This problem is a weird heritage from SVR4. BSD got it right.
418 # Nowadays the problem occurs in 4 situations:
419 # - in bash, when the shell option xpg_echo is set,
420 # - in zsh, when sh-emulation is not set,
421 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
422 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
423 # - in Solaris /bin/sh and OSF/1 /bin/sh.
424 # We try the following workarounds:
425 # - for all: respawn using $CONFIG_SHELL if that is set and works.
426 # - for bash: unset the shell option xpg_echo.
427 # - for zsh: turn sh-emulation on.
428 # - for ksh: alias echo to a function that uses cat of a here document.
429 # - for Solaris /bin/sh: respawn using /bin/ksh and rely on the ksh workaround.
430 # - otherwise: respawn using /bin/sh and rely on the workarounds.
431 # When respawning, we pass --no-reexec as first argument, so as to avoid
432 # turning this script into a fork bomb in unlucky situations.
434 if echo '\t' | grep t > /dev/null; then
435 have_echo=yes # Lucky!
437 # Try the workarounds.
438 # Respawn using $CONFIG_SHELL if that is set and works.
439 if test -z "$have_echo" \
440 && test "X$1" != "X--no-reexec" \
441 && test -n "$CONFIG_SHELL" \
442 && test -f "$CONFIG_SHELL" \
443 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
444 exec $CONFIG_SHELL "$0" --no-reexec "$@"
447 # For bash: unset the shell option xpg_echo.
448 if test -z "$have_echo" \
449 && test -n "$BASH_VERSION" \
450 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
454 # For zsh: turn sh-emulation on.
455 if test -z "$have_echo" \
456 && test -n "$ZSH_VERSION" \
457 && (emulate sh) >/dev/null 2>&1; then
460 # For ksh: alias echo to a function that uses cat of a here document.
461 # The ksh manual page says:
462 # "Aliasing is performed when scripts are read, not while they are executed.
463 # Therefore, for an alias to take effect, the alias definition command has
464 # to be executed before the command which references the alias is read."
465 # Because of this, we have to play strange tricks with have_echo, to ensure
466 # that the top-level statement containing the test start after the 'alias'
468 if test -z "$have_echo"; then
475 alias echo=bsd_echo 2>/dev/null
477 if test -z "$have_echo" \
478 && echo '\t' | grep t > /dev/null; then
481 if test -z "$have_echo"; then
482 unalias echo 2>/dev/null
484 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
485 if test -z "$have_echo" \
486 && test "X$1" != "X--no-reexec" \
487 && test -f /bin/ksh; then
488 exec /bin/ksh "$0" --no-reexec "$@"
491 # Otherwise: respawn using /bin/sh.
492 if test -z "$have_echo" \
493 && test "X$1" != "X--no-reexec" \
494 && test -f /bin/sh; then
495 exec /bin/sh "$0" --no-reexec "$@"
498 if test -z "$have_echo"; then
499 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
501 if echo '\t' | grep t > /dev/null; then
504 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
506 if test "X$1" = "X--no-reexec"; then
510 # Command-line option processing.
511 # Removes the OPTIONS from the arguments. Sets the variables:
512 # - mode list or import or create-testdir or create-megatestdir
513 # - destdir from --dir
514 # - local_gnulib_dir from --local-dir
515 # - libname, supplied_libname from --lib
516 # - sourcebase from --source-base
517 # - m4base from --m4-base
518 # - docbase from --doc-base
519 # - testsbase from --tests-base
520 # - auxdir from --aux-dir
521 # - inctests true if --with-tests was given, blank otherwise
522 # - avoidlist list of modules to avoid, from --avoid
523 # - lgpl true if --lgpl was given, blank otherwise
524 # - makefile_name from --makefile-name
525 # - libtool true if --libtool was given, false if --no-libtool was
526 # given, blank otherwise
527 # - macro_prefix from --macro-prefix
528 # - autoconf_minversion minimum supported autoconf version
529 # - do_changelog false if --no-changelog was given, : otherwise
530 # - doit : if actions shall be executed, false if only to be printed
531 # - symbolic true if --symlink was given, blank otherwise
532 # - lsymbolic true if --local-symlink was given, blank otherwise
557 while test $# -gt 0; do
562 --import | --impor | --impo | --imp | --im | --i )
565 --update | --updat | --upda | --upd | --up | --u )
568 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
571 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
572 mode=create-megatestdir
574 --test | --tes | --te | --t )
577 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
581 mode=`echo "X$1" | sed -e 's/^X--//'`
586 func_fatal_error "missing argument for --dir"
591 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
596 func_fatal_error "missing argument for --local-dir"
601 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
606 func_fatal_error "missing argument for --lib"
609 supplied_libname=true
612 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
613 supplied_libname=true
618 func_fatal_error "missing argument for --source-base"
623 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
628 func_fatal_error "missing argument for --m4-base"
633 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
638 func_fatal_error "missing argument for --doc-base"
643 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
648 func_fatal_error "missing argument for --tests-base"
653 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
658 func_fatal_error "missing argument for --aux-dir"
663 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
671 func_fatal_error "missing argument for --avoid"
673 func_append avoidlist " $1"
676 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
677 func_append avoidlist " $arg"
685 func_fatal_error "missing argument for --makefile-name"
690 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
701 func_fatal_error "missing argument for --macro-prefix"
706 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
708 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
714 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
717 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
720 --help | --hel | --he | --h )
723 --version | --versio | --versi | --vers | --ver | --ve | --v )
727 # Stop option processing
731 echo "gnulib-tool: unknown option $1" 1>&2
732 echo "Try 'gnulib-tool --help' for more information." 1>&2
739 if test "$mode" = update; then
740 if test $# != 0; then
741 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
742 echo "Try 'gnulib-tool --help' for more information." 1>&2
743 echo "If you really want to modify the gnulib configuration of your project," 1>&2
744 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
747 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
748 || test -n "$sourcebase" || test -n "$m4base" \
749 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
750 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
751 || test -n "$makefile_name" || test -n "$macro_prefix"; then
752 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
753 echo "Try 'gnulib-tool --help' for more information." 1>&2
754 echo "If you really want to modify the gnulib configuration of your project," 1>&2
755 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
761 # Determine the minimum supported autoconf version from the project's
763 DEFAULT_AUTOCONF_MINVERSION="2.59"
766 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
767 if test -f "$destdir"/configure.ac; then
768 configure_ac="$destdir/configure.ac"
770 if test -f "$destdir"/configure.in; then
771 configure_ac="$destdir/configure.in"
775 if test -f configure.ac; then
776 configure_ac="configure.ac"
778 if test -f configure.in; then
779 configure_ac="configure.in"
783 if test -n "$configure_ac"; then
784 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
785 # because when some m4 files are omitted from a CVS repository,
786 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
787 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
788 # autom4te: m4 failed with exit status: 1
795 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
797 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
798 if test -n "$prereqs"; then
799 autoconf_minversion=`
800 for version in $prereqs; do echo $version; done |
801 LC_ALL=C sort -nru | sed 1q
805 if test -z "$autoconf_minversion"; then
806 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
808 case "$autoconf_minversion" in
809 1.* | 2.[0-4]* | 2.5[0-8]*)
810 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
813 # Remove trailing slashes from the directory names. This is necessary for
814 # m4base (to avoid an error in func_import) and optional for the others.
815 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
816 case "$local_gnulib_dir" in
817 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
819 case "$sourcebase" in
820 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
823 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
826 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
829 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
832 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
837 /*) self_abspathname="$0" ;;
838 */*) self_abspathname=`pwd`/"$0" ;;
839 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
840 if test -x "$d/$0" && test ! -d "$d/$0"; then
841 self_abspathname="$d/$0"
845 if test -z "$self_abspathname"; then
846 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
850 while test -h "$self_abspathname"; do
851 # Resolve symbolic link.
852 linkval=`func_readlink "$self_abspathname"`
853 test -n "$linkval" || break
855 /* ) self_abspathname="$linkval" ;;
856 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
859 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
863 if test "$signal" != 0; then
864 echo "caught signal $signal" >&2
868 for signal in 1 2 3 13 15; do
869 trap '{ signal='$signal'; func_exit 1; }' $signal
873 # func_lookup_file file
874 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
877 # - local_gnulib_dir from --local-dir
879 # - lookedup_file name of the merged (combined) file
880 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
884 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
885 lookedup_file="$local_gnulib_dir/$lkfile"
888 if test -f "$gnulib_dir/$lkfile"; then
889 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
890 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
892 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
893 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
894 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
895 lookedup_file="$tmp/$lkbase"
898 lookedup_file="$gnulib_dir/$lkfile"
902 func_fatal_error "file $gnulib_dir/$lkfile not found"
909 # - local_gnulib_dir from --local-dir
912 # Filter out metainformation files like README, which are not modules.
913 # Filter out unit test modules; they can be retrieved through
914 # --extract-tests-module if desired.
916 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
917 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
918 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
921 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
922 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
923 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
924 -e '/^README$/d' -e '/\/README$/d' \
926 -e '/^TEMPLATE-EXTENDED$/d' \
927 -e '/^TEMPLATE-TESTS$/d' \
930 | sed -e '/-tests$/d' \
935 # verifies a module name
937 # - local_gnulib_dir from --local-dir
938 # - module module name argument
939 func_verify_module ()
941 if { test -f "$gnulib_dir/modules/$module" \
942 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
943 && test -f "$local_gnulib_dir/modules/$module"; }; } \
944 && test "CVS" != "$module" \
945 && test "ChangeLog" != "$module" \
946 && test "COPYING" != "$module" \
947 && test "README" != "$module" \
948 && test "TEMPLATE" != "$module" \
949 && test "TEMPLATE-EXTENDED" != "$module" \
950 && test "TEMPLATE-TESTS" != "$module"; then
951 # OK, $module is a correct module name.
952 # Verify that building the module description with 'patch' succeeds.
953 func_lookup_file "modules/$module"
955 echo "gnulib-tool: module $module doesn't exist" 1>&2
960 # func_verify_nontests_module
961 # verifies a module name, excluding tests modules
963 # - local_gnulib_dir from --local-dir
964 # - module module name argument
965 func_verify_nontests_module ()
969 * ) func_verify_module ;;
973 # func_verify_tests_module
974 # verifies a module name, considering only tests modules
976 # - local_gnulib_dir from --local-dir
977 # - module module name argument
978 func_verify_tests_module ()
981 *-tests ) func_verify_module ;;
986 sed_extract_prog=':[ ]*$/ {
989 s/^Description:[ ]*$//
991 s/^Depends-on:[ ]*$//
992 s/^configure\.ac-early:[ ]*$//
993 s/^configure\.ac:[ ]*$//
994 s/^Makefile\.am:[ ]*$//
998 s/^Maintainer:[ ]*$//
1005 # func_get_description module
1007 # - local_gnulib_dir from --local-dir
1008 func_get_description ()
1010 func_lookup_file "modules/$1"
1011 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1014 # func_get_filelist module
1016 # - local_gnulib_dir from --local-dir
1017 func_get_filelist ()
1019 func_lookup_file "modules/$1"
1020 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1021 echo m4/gnulib-common.m4
1022 case "$autoconf_minversion" in
1024 #echo m4/onceonly.m4
1025 echo m4/onceonly_2_57.m4
1030 # func_get_dependencies module
1032 # - local_gnulib_dir from --local-dir
1033 func_get_dependencies ()
1035 # ${module}-tests always implicitly depends on ${module}.
1036 echo "$1" | sed -n -e 's/-tests//p'
1037 # Then the explicit dependencies listed in the module description.
1038 func_lookup_file "modules/$1"
1039 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1042 # func_get_autoconf_early_snippet module
1044 # - local_gnulib_dir from --local-dir
1045 func_get_autoconf_early_snippet ()
1047 func_lookup_file "modules/$1"
1048 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1051 # func_get_autoconf_snippet module
1053 # - local_gnulib_dir from --local-dir
1054 func_get_autoconf_snippet ()
1056 func_lookup_file "modules/$1"
1057 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1060 # func_get_automake_snippet module
1062 # - local_gnulib_dir from --local-dir
1063 func_get_automake_snippet ()
1065 func_lookup_file "modules/$1"
1066 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1069 # *-tests module live in tests/, not lib/.
1072 # Synthesize an EXTRA_DIST augmentation.
1073 sed_combine_lines='/\\$/{
1080 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1081 already_mentioned_files=` \
1082 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1083 | sed -e "$sed_combine_lines" \
1084 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1085 all_files=`func_get_filelist $1`
1086 lib_files=`for f in $all_files; do \
1090 done | sed -e 's,^lib/,,'`
1091 # Remove $already_mentioned_files from $lib_files.
1092 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1093 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1094 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1095 if test -n "$extra_files"; then
1096 echo "EXTRA_DIST +=" $extra_files
1099 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1100 # This is necessary so that automake can generate the right list of
1102 # A possible approach would be to use autom4te --trace of the redefined
1103 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1104 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1105 # inside autoconf's built-in macros are not missed).
1106 # But it's simpler and more robust to do it here, based on the file list.
1107 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1108 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1109 # automake will generate a useless dependency; this is harmless.
1111 relocatable-prog-wrapper) ;;
1113 sed_extract_c_files='/\.c$/p'
1114 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1115 if test -n "$extra_files"; then
1116 echo "EXTRA_lib_SOURCES +=" $extra_files
1125 # func_get_include_directive module
1127 # - local_gnulib_dir from --local-dir
1128 func_get_include_directive ()
1130 func_lookup_file "modules/$1"
1131 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1132 sed -e 's/^\(["<]\)/#include \1/'
1135 # func_get_link_directive module
1137 # - local_gnulib_dir from --local-dir
1138 func_get_link_directive ()
1140 func_lookup_file "modules/$1"
1141 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1144 # func_get_license module
1146 # - local_gnulib_dir from --local-dir
1149 func_lookup_file "modules/$1"
1150 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1151 # The default is GPL.
1153 } | sed -e 's,^ *$,,' | sed -e 1q
1156 # func_get_maintainer module
1158 # - local_gnulib_dir from --local-dir
1159 func_get_maintainer ()
1161 func_lookup_file "modules/$1"
1162 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1165 # func_get_tests_module module
1167 # - local_gnulib_dir from --local-dir
1168 func_get_tests_module ()
1170 # The naming convention for tests modules is hardwired: ${module}-tests.
1171 if test -f "$gnulib_dir/modules/$1"-tests \
1172 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1173 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1178 # func_acceptable module
1179 # tests whether a module is acceptable.
1181 # - avoidlist list of modules to avoid
1184 for avoid in $avoidlist; do
1185 if test "$avoid" = "$1"; then
1192 # func_modules_transitive_closure
1194 # - local_gnulib_dir from --local-dir
1195 # - modules list of specified modules
1196 # - inctests true if tests should be included, blank otherwise
1197 # - avoidlist list of modules to avoid
1198 # - tmp pathname of a temporary directory
1200 # - modules list of modules, including dependencies
1201 func_modules_transitive_closure ()
1203 # In order to process every module only once (for speed), process an "input
1204 # list" of modules, producing an "output list" of modules. During each round,
1205 # more modules can be queued in the input list. Once a module on the input
1206 # list has been processed, it is added to the "handled list", so we can avoid
1207 # to process it again.
1209 inmodules="$modules"
1211 while test -n "$inmodules"; do
1212 inmodules_this_round="$inmodules"
1213 inmodules= # Accumulator, queue for next round
1214 for module in $inmodules_this_round; do
1216 if test -n "$module"; then
1217 if func_acceptable $module; then
1218 func_append outmodules " $module"
1219 deps=`func_get_dependencies $module`
1220 # Duplicate dependencies are harmless, but Jim wants a warning.
1221 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1222 if test -n "$duplicated_deps"; then
1223 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1225 func_append inmodules " $deps"
1226 if test -n "$inctests"; then
1227 testsmodule=`func_get_tests_module $module`
1228 if test -n "$testsmodule"; then
1229 func_append inmodules " $testsmodule"
1235 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1236 # Remove $handledmodules from $inmodules.
1237 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1238 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1240 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1241 rm -f "$tmp"/queued-modules
1244 # func_modules_add_dummy
1246 # - local_gnulib_dir from --local-dir
1247 # - modules list of modules, including dependencies
1249 # - modules list of modules, including 'dummy' if needed
1250 func_modules_add_dummy ()
1253 sed_remove_backslash_newline=':a
1260 for module in $modules; do
1261 func_verify_nontests_module
1262 if test -n "$module"; then
1263 # Extract the value of "lib_SOURCES += ...".
1264 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1265 # Ignore .h files since they are not compiled.
1268 *) have_lib_SOURCES=yes ;;
1273 # Add the dummy module, to make sure the library will be non-empty.
1274 if test -z "$have_lib_SOURCES"; then
1275 if func_acceptable "dummy"; then
1276 func_append modules " dummy"
1281 # func_modules_to_filelist
1283 # - local_gnulib_dir from --local-dir
1284 # - modules list of modules, including dependencies
1286 # - files list of files
1287 func_modules_to_filelist ()
1290 for module in $modules; do
1292 if test -n "$module"; then
1293 fs=`func_get_filelist $module`
1294 func_append files " $fs"
1297 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1300 # func_emit_lib_Makefile_am
1301 # emits the contents of library makefile to standard output.
1303 # - local_gnulib_dir from --local-dir
1304 # - modules list of modules, including dependencies
1305 # - libname library name
1306 # - auxdir directory relative to destdir where to place build aux files
1307 # - makefile_name from --makefile-name
1308 # - libtool true if libtool will be used, false or blank otherwise
1309 # - macro_prefix prefix of gl_LIBOBJS macros to use
1310 # - actioncmd (optional) command that will reproduce this invocation
1311 # - for_test true if creating a package for testing, false otherwise
1313 # - uses_subdirs nonempty if object files in subdirs exist
1314 func_emit_lib_Makefile_am ()
1316 # When creating an includable Makefile.am snippet, augment variables with
1317 # += instead of assigning them.
1318 if test -n "$makefile_name"; then
1323 if test "$libtool" = true; then
1326 sed_eliminate_LDFLAGS=
1330 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1333 # When creating a package for testing: Attempt to provoke failures,
1334 # especially link errors, already during "make" rather than during
1335 # "make check", because "make check" is not possible in a cross-compiling
1336 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1337 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1339 sed_transform_check_PROGRAMS=
1341 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1342 echo "## Process this file with automake to produce Makefile.in."
1343 func_emit_copyright_notice
1344 if test -n "$actioncmd"; then
1345 echo "# Reproduce by: $actioncmd"
1350 for module in $modules; do
1351 func_verify_nontests_module
1352 if test -n "$module"; then
1354 func_get_automake_snippet "$module" |
1355 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1356 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1357 sed -e "$sed_eliminate_LDFLAGS" |
1358 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1359 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1360 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' |
1361 sed -e "$sed_transform_check_PROGRAMS"
1362 if test "$module" = 'alloca'; then
1363 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1364 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1367 # Skip the contents if its entirely empty.
1368 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1369 echo "## begin gnulib module $module"
1372 echo "## end gnulib module $module"
1376 # Test whether there are some source files in subdirectories.
1377 for f in `func_get_filelist "$module"`; do
1379 lib/*/*.c) uses_subdirs=yes ;;
1385 if test -z "$makefile_name"; then
1386 # If there are source files in subdirectories, prevent collision of the
1387 # object files (example: hash.c and libxml/hash.c).
1389 if test -n "$uses_subdirs"; then
1390 subdir_options=' subdir-objects'
1392 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1395 if test -z "$makefile_name"; then
1396 echo "noinst_HEADERS ="
1397 echo "noinst_LIBRARIES ="
1398 echo "noinst_LTLIBRARIES ="
1399 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1400 # if you specify pkgdata_DATA to empty. This is a workaround.
1401 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1402 echo "pkgdata_DATA ="
1405 echo "BUILT_SOURCES ="
1408 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1409 if test -z "$makefile_name"; then
1410 echo "MOSTLYCLEANDIRS ="
1412 echo "DISTCLEANFILES ="
1413 echo "MAINTAINERCLEANFILES ="
1415 echo "AM_CPPFLAGS ="
1418 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1419 # One of the snippets already specifies an installation location for the
1420 # library. Don't confuse automake by saying it should not be installed.
1423 # By default, the generated library should not be installed.
1424 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1427 echo "${libname}_${libext}_SOURCES ="
1428 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1429 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1430 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1431 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1432 echo "EXTRA_${libname}_${libext}_SOURCES ="
1433 if test "$libtool" = true; then
1434 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1437 cat allsnippets.tmp \
1438 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1440 echo "mostlyclean-local: mostlyclean-generic"
1441 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1442 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1443 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1446 rm -f allsnippets.tmp
1449 # func_emit_tests_Makefile_am
1450 # emits the contents of tests makefile to standard output.
1452 # - local_gnulib_dir from --local-dir
1453 # - modules list of modules, including dependencies
1454 # - libname library name
1455 # - makefile_name from --makefile-name
1456 # - libtool true if libtool will be used, false or blank otherwise
1457 # - sourcebase relative directory containing lib source code
1458 # - m4base relative directory containing autoconf macros
1459 # - testsbase relative directory containing unit test code
1460 # - for_test true if creating a package for testing, false otherwise
1461 func_emit_tests_Makefile_am ()
1463 if test "$libtool" = true; then
1468 if test "$libtool" = true; then
1470 sed_eliminate_LDFLAGS=
1473 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1476 # When creating a package for testing: Attempt to provoke failures,
1477 # especially link errors, already during "make" rather than during
1478 # "make check", because "make check" is not possible in a cross-compiling
1479 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1480 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1482 sed_transform_check_PROGRAMS=
1484 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1485 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1486 echo "## Process this file with automake to produce Makefile.in."
1487 func_emit_copyright_notice
1489 # Generate dependencies here, since it eases the debugging of test failures.
1490 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1492 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1495 for module in $modules; do
1496 func_verify_tests_module
1497 if test -n "$module"; then
1499 func_get_automake_snippet "$module" |
1500 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1501 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1502 sed -e "$sed_eliminate_LDFLAGS" |
1503 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1504 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1505 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' |
1506 sed -e "$sed_transform_check_PROGRAMS"
1508 # Skip the contents if its entirely empty.
1509 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1510 echo "## begin gnulib module $module"
1513 echo "## end gnulib module $module"
1520 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1521 # variable is needed to avoid an error from automake:
1522 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1525 echo "TESTS_ENVIRONMENT ="
1526 echo "noinst_PROGRAMS ="
1527 if ! $for_test; then
1528 echo "check_PROGRAMS ="
1530 echo "noinst_HEADERS ="
1531 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1532 echo "pkgdata_DATA ="
1535 echo "BUILT_SOURCES ="
1537 echo "MOSTLYCLEANFILES = core *.stackdump"
1538 echo "MOSTLYCLEANDIRS ="
1540 echo "DISTCLEANFILES ="
1541 echo "MAINTAINERCLEANFILES ="
1543 echo "AM_CPPFLAGS = \\"
1544 echo " -I. -I\$(srcdir) \\"
1545 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1546 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1548 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1551 echo "# Clean up after Solaris cc."
1553 echo " rm -rf SunWS_cache"
1555 echo "mostlyclean-local: mostlyclean-generic"
1556 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1557 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1558 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1561 rm -f allsnippets.tmp
1564 # func_emit_initmacro_start
1565 # emits the first few statements of the gl_INIT macro to standard output.
1566 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1567 func_emit_initmacro_start ()
1569 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1570 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1571 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1572 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1574 # Furthermore it avoids an automake error like this when a Makefile.am
1575 # that uses pieces of gnulib also uses $(LIBOBJ):
1576 # automatically discovered file `error.c' should not be explicitly mentioned
1577 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1578 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1579 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1580 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1581 # automatically discovered file `error.c' should not be explicitly mentioned
1582 # We let automake know about the files to be distributed through the
1583 # EXTRA_lib_SOURCES variable.
1584 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1587 # func_emit_initmacro_end
1588 # emits the last few statements of the gl_INIT macro to standard output.
1589 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1590 func_emit_initmacro_end ()
1592 echo " m4_popdef([AC_LIBSOURCES])"
1593 echo " m4_popdef([AC_REPLACE_FUNCS])"
1594 echo " m4_popdef([AC_LIBOBJ])"
1595 echo " AC_CONFIG_COMMANDS_PRE(["
1596 echo " ${macro_prefix}_libobjs="
1597 echo " ${macro_prefix}_ltlibobjs="
1598 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1599 echo " # Remove the extension."
1600 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1601 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1602 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1603 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1606 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1607 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1611 # func_emit_initmacro_done
1612 # emits a few statements after the gl_INIT macro to standard output.
1613 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1614 func_emit_initmacro_done ()
1617 echo "# Like AC_LIBOBJ, except that the module name goes"
1618 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1619 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1620 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1622 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1623 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1624 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1625 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1627 echo "# Like AC_LIBSOURCES, except that it does nothing."
1628 echo "# We rely on EXTRA_lib..._SOURCES instead."
1629 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1633 # func_import modules
1634 # Uses also the variables
1635 # - destdir target directory
1636 # - local_gnulib_dir from --local-dir
1637 # - libname library name
1638 # - sourcebase directory relative to destdir where to place source code
1639 # - m4base directory relative to destdir where to place *.m4 macros
1640 # - docbase directory relative to destdir where to place doc files
1641 # - testsbase directory relative to destdir where to place unit test code
1642 # - auxdir directory relative to destdir where to place build aux files
1643 # - inctests true if --with-tests was given, blank otherwise
1644 # - avoidlist list of modules to avoid, from --avoid
1645 # - lgpl true if library's license shall be LGPL, blank otherwise
1646 # - makefile_name from --makefile-name
1647 # - libtool true if --libtool was given, false if --no-libtool was
1648 # given, blank otherwise
1649 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1650 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1651 # - autoconf_minversion minimum supported autoconf version
1652 # - doit : if actions shall be executed, false if only to be printed
1653 # - symbolic true if files should be symlinked, copied otherwise
1654 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1658 # Get the cached settings.
1659 cached_local_gnulib_dir=
1660 cached_specified_modules=
1669 cached_makefile_name=
1671 cached_macro_prefix=
1673 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1674 cached_libtool=false
1680 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1683 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1686 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1689 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1692 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1695 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1698 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1701 s,^.*$,cached_inctests=true,p
1704 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1707 s,^.*$,cached_lgpl=true,p
1709 /gl_MAKEFILE_NAME(/ {
1710 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1713 s,^.*$,cached_libtool=true,p
1715 /gl_MACRO_PREFIX(/ {
1716 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1718 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1719 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1724 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1725 s,^.*$,cached_files=",p
1737 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1741 # Merge the cached settings with the specified ones.
1742 # The m4base must be the same as expected from the pathname.
1743 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1744 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1746 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1747 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1748 if test -z "$local_gnulib_dir"; then
1749 if test -n "$cached_local_gnulib_dir"; then
1752 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1754 case "$cached_local_gnulib_dir" in
1756 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1758 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1759 local_gnulib_dir="$relconcat" ;;
1764 # Append the cached and the specified module names. So that
1765 # "gnulib-tool --import foo" means to add the module foo.
1766 specified_modules="$cached_specified_modules $1"
1767 # Append the cached and the specified avoidlist. This is probably better
1768 # than dropping the cached one when --avoid is specified at least once.
1769 avoidlist=`echo $cached_avoidlist $avoidlist`
1770 # The sourcebase defaults to the cached one.
1771 if test -z "$sourcebase"; then
1772 sourcebase="$cached_sourcebase"
1773 if test -z "$sourcebase"; then
1774 func_fatal_error "missing --source-base option"
1777 # The docbase defaults to the cached one.
1778 if test -z "$docbase"; then
1779 docbase="$cached_docbase"
1780 if test -z "$docbase"; then
1781 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."
1784 # The testsbase defaults to the cached one.
1785 if test -z "$testsbase"; then
1786 testsbase="$cached_testsbase"
1787 if test -z "$testsbase"; then
1788 func_fatal_error "missing --tests-base option"
1791 # Require the tests if specified either way.
1792 if test -z "$inctests"; then
1793 inctests="$cached_inctests"
1795 # The libname defaults to the cached one.
1796 if test -z "$supplied_libname"; then
1797 libname="$cached_libname"
1798 if test -z "$libname"; then
1799 func_fatal_error "missing --lib option"
1802 # Require LGPL if specified either way.
1803 if test -z "$lgpl"; then
1806 # The makefile_name defaults to the cached one.
1807 if test -z "$makefile_name"; then
1808 makefile_name="$cached_makefile_name"
1810 # Use libtool if specified either way, or if guessed.
1811 if test -z "$libtool"; then
1812 if test -n "$cached_m4base"; then
1813 libtool="$cached_libtool"
1815 libtool="$guessed_libtool"
1818 # The macro_prefix defaults to the cached one.
1819 if test -z "$macro_prefix"; then
1820 macro_prefix="$cached_macro_prefix"
1821 if test -z "$macro_prefix"; then
1822 func_fatal_error "missing --macro-prefix option"
1826 # Canonicalize the list of specified modules.
1827 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1829 # Determine final module list.
1830 modules="$specified_modules"
1831 func_modules_transitive_closure
1832 echo "Module list with included dependencies:"
1833 echo "$modules" | sed -e 's/^/ /'
1835 # Add the dummy module if needed.
1836 func_modules_add_dummy
1838 # If --lgpl, verify that the licenses of modules are compatible.
1839 if test -n "$lgpl"; then
1840 for module in $modules; do
1841 license=`func_get_license $module`
1843 LGPL | 'GPLed build tool') ;;
1844 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1845 *) func_fatal_error "incompatible license on module $module: $license" ;;
1850 # Determine script to apply to imported library files.
1851 sed_transform_lib_file=
1852 for module in $modules; do
1853 if test $module = config-h; then
1854 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1855 sed_transform_lib_file=$sed_transform_lib_file'
1856 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1861 if test -n "$lgpl"; then
1863 sed_transform_lib_file=$sed_transform_lib_file'
1864 s/GNU General/GNU Lesser General/g
1865 s/version 2\([ ,]\)/version 2.1\1/g
1869 # Determine final file list.
1870 func_modules_to_filelist
1872 echo "$files" | sed -e 's/^/ /'
1875 || func_fatal_error "refusing to do nothing"
1877 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1878 new_files="$files m4/gnulib-tool.m4"
1879 old_files="$cached_files"
1880 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1881 func_append old_files " m4/gnulib-tool.m4"
1884 sed_rewrite_old_files="\
1885 s,^build-aux/,$auxdir/,
1886 s,^doc/,$cached_docbase/,
1887 s,^lib/,$cached_sourcebase/,
1888 s,^m4/,$cached_m4base/,
1889 s,^tests/,$cached_testsbase/,"
1890 sed_rewrite_new_files="\
1891 s,^build-aux/,$auxdir/,
1893 s,^lib/,$sourcebase/,
1895 s,^tests/,$testsbase/,"
1897 # Create directories.
1898 { echo "$sourcebase"
1900 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1901 if test -n "$docfiles"; then
1904 if test -n "$inctests"; then
1908 for f in $files; do echo $f; done \
1909 | sed -e "$sed_rewrite_new_files" \
1910 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
1913 { # Rearrange file descriptors. Needed because "while ... done < ..."
1914 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1915 exec 5<&0 < "$tmp"/dirs
1917 if test ! -d "$destdir/$d"; then
1919 echo "Creating directory $destdir/$d"
1920 mkdir -p "$destdir/$d" || func_fatal_error "failed"
1922 echo "Create directory $destdir/$d"
1929 # func_dest_tmpfilename file
1930 # determines the name of a temporary file (file is relative to destdir).
1932 # - tmpfile absolute filename of the temporary file
1933 func_dest_tmpfilename ()
1936 # Put the new contents of $file in a file in the same directory (needed
1937 # to guarantee that an 'mv' to "$destdir/$file" works).
1938 tmpfile="$destdir/$1.tmp"
1940 # Put the new contents of $file in a file in a temporary directory
1941 # (because the directory of "$file" might not exist).
1942 tmpfile="$tmp"/`basename "$1"`.tmp
1946 # Copy files or make symbolic links. Remove obsolete files.
1950 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1951 # representing the files according to the last gnulib-tool invocation.
1952 for f in $old_files; do echo $f; done \
1953 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
1956 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1957 # representing the files after this gnulib-tool invocation.
1958 for f in $new_files; do echo $f; done \
1959 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
1962 # First the files that are in old-files, but not in new-files:
1963 sed_take_first_column='s,'"$delimiter"'.*,,'
1964 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1965 # Remove the file. Do nothing if the user already removed it.
1966 if test -f "$destdir/$g"; then
1968 echo "Removing file $g (backup in ${g}~)"
1969 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1971 echo "Remove file $g (backup in ${g}~)"
1973 func_append removed_files "$g$nl"
1976 # func_add_or_update handles a file that ought to be present afterwards.
1978 # - f the original file name
1979 # - g the rewritten file name
1980 # - already_present nonempty if the file already exists, empty otherwise
1981 func_add_or_update ()
1983 func_dest_tmpfilename "$g"
1984 func_lookup_file "$f"
1985 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1986 if test -n "$sed_transform_lib_file"; then
1989 sed -e "$sed_transform_lib_file" \
1990 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1994 if test -f "$destdir/$g"; then
1995 # The file already exists.
1996 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1997 : # The file has not changed.
2001 if test -n "$already_present"; then
2002 echo "Updating file $g (backup in ${g}~)"
2004 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2006 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2007 if { test -n "$symbolic" \
2008 || { test -n "$lsymbolic" \
2009 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2010 && test -z "$lookedup_tmp" \
2011 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2012 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2014 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2017 if test -n "$already_present"; then
2018 echo "Update file $g (backup in ${g}~)"
2020 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2026 # Don't protest if the file should be there but isn't: it happens
2027 # frequently that developers don't put autogenerated files into CVS.
2029 echo "Copying file $g"
2030 if { test -n "$symbolic" \
2031 || { test -n "$lsymbolic" \
2032 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2033 && test -z "$lookedup_tmp" \
2034 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2035 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2037 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2042 func_append added_files "$g$nl"
2046 # Then the files that are in new-files, but not in old-files:
2047 sed_take_last_column='s,^.*'"$delimiter"',,'
2049 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2050 | sed -e "$sed_take_last_column" \
2051 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2052 { # Rearrange file descriptors. Needed because "while ... done < ..."
2053 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2054 exec 5<&0 < "$tmp"/added-files
2060 # Then the files that are in new-files and in old-files:
2061 already_present=true
2062 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2063 | sed -e "$sed_take_last_column" \
2064 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2065 { # Rearrange file descriptors. Needed because "while ... done < ..."
2066 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2067 exec 5<&0 < "$tmp"/kept-files
2074 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2075 actioncmd="gnulib-tool --import"
2076 func_append actioncmd " --dir=$destdir"
2077 if test -n "$local_gnulib_dir"; then
2078 func_append actioncmd " --local-dir=$local_gnulib_dir"
2080 func_append actioncmd " --lib=$libname"
2081 func_append actioncmd " --source-base=$sourcebase"
2082 func_append actioncmd " --m4-base=$m4base"
2083 func_append actioncmd " --doc-base=$docbase"
2084 func_append actioncmd " --aux-dir=$auxdir"
2085 if test -n "$inctests"; then
2086 func_append actioncmd " --with-tests"
2088 for module in $avoidlist; do
2089 func_append actioncmd " --avoid=$module"
2091 if test -n "$lgpl"; then
2092 func_append actioncmd " --lgpl"
2094 if test -n "$makefile_name"; then
2095 func_append actioncmd " --makefile-name=$makefile_name"
2097 if test "$libtool" = true; then
2098 func_append actioncmd " --libtool"
2100 func_append actioncmd " --no-libtool"
2102 func_append actioncmd " --macro-prefix=$macro_prefix"
2103 func_append actioncmd " `echo $specified_modules`"
2105 # Default the makefile name to Makefile.am.
2106 if test -n "$makefile_name"; then
2107 makefile_am=$makefile_name
2109 makefile_am=Makefile.am
2112 # Create normal Makefile.ams.
2115 # Create library makefile.
2116 func_dest_tmpfilename $sourcebase/$makefile_am
2117 func_emit_lib_Makefile_am > "$tmpfile"
2118 if test -f "$destdir"/$sourcebase/$makefile_am; then
2119 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2123 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2124 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2125 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2127 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2133 echo "Creating $sourcebase/$makefile_am"
2134 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2136 echo "Create $sourcebase/$makefile_am"
2139 func_append added_files "$sourcebase/$makefile_am$nl"
2142 # Create m4/gnulib-cache.m4.
2143 func_dest_tmpfilename $m4base/gnulib-cache.m4
2145 func_emit_copyright_notice
2147 echo "# This file represents the specification of how gnulib-tool is used."
2148 echo "# It acts as a cache: It is written and read by gnulib-tool."
2149 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2150 echo "# like the configure.ac and various Makefile.am files."
2153 echo "# Specification in the form of a command-line invocation:"
2156 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2157 # Store the local_gnulib_dir relative to destdir.
2158 case "$local_gnulib_dir" in
2160 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2163 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2165 # destdir, local_gnulib_dir are both relative.
2166 func_relativize "$destdir" "$local_gnulib_dir"
2167 relative_local_gnulib_dir="$reldir" ;;
2170 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2171 echo "gl_MODULES(["`echo $specified_modules`"])"
2172 echo "gl_AVOID([$avoidlist])"
2173 echo "gl_SOURCE_BASE([$sourcebase])"
2174 echo "gl_M4_BASE([$m4base])"
2175 echo "gl_DOC_BASE([$docbase])"
2176 echo "gl_TESTS_BASE([$testsbase])"
2177 test -z "$inctests" || echo "gl_WITH_TESTS"
2178 echo "gl_LIB([$libname])"
2179 test -z "$lgpl" || echo "gl_LGPL"
2180 echo "gl_MAKEFILE_NAME([$makefile_name])"
2181 if test "$libtool" = true; then
2184 echo "gl_MACRO_PREFIX([$macro_prefix])"
2186 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2187 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2191 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2192 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2193 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2195 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2199 echo "# gnulib-cache.m4 ends here"
2206 echo "Creating $m4base/gnulib-cache.m4"
2207 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2209 echo "Create $m4base/gnulib-cache.m4"
2215 # Create m4/gnulib-comp.m4.
2216 func_dest_tmpfilename $m4base/gnulib-comp.m4
2218 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2219 func_emit_copyright_notice
2221 echo "# This file represents the compiled summary of the specification in"
2222 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2223 echo "# to be invoked from configure.ac."
2224 echo "# In projects using CVS, this file can be treated like other built files."
2227 echo "# This macro should be invoked from $configure_ac, in the section"
2228 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2229 echo "# any checks for libraries, header files, types and library functions."
2230 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2232 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2233 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2234 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2235 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2236 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2237 if test -n "$uses_subdirs"; then
2238 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2240 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2241 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2243 for module in $modules; do
2245 if test -n "$module"; then
2246 func_get_autoconf_early_snippet "$module"
2249 | sed -e '/^$/d;' -e 's/^/ /'
2252 echo "# This macro should be invoked from $configure_ac, in the section"
2253 echo "# \"Check for header files, types and library functions\"."
2254 echo "AC_DEFUN([${macro_prefix}_INIT],"
2256 func_emit_initmacro_start
2257 if test "$libtool" = true; then
2258 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2259 echo " gl_cond_libtool=true"
2261 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2262 echo " gl_cond_libtool=false"
2264 echo " gl_ltlibdeps="
2266 echo " gl_source_base='$sourcebase'"
2267 if test "$auxdir" != "build-aux"; then
2268 sed_replace_build_aux='
2270 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2271 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2275 sed_replace_build_aux=
2277 for module in $modules; do
2279 if test -n "$module"; then
2280 func_get_autoconf_snippet "$module" \
2281 | sed -e '/^$/d;' -e 's/^/ /' \
2282 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2283 -e "$sed_replace_build_aux"
2284 if test "$module" = 'alloca' && test "$libtool" = true; then
2285 echo 'changequote(,)dnl'
2286 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2287 echo 'changequote([, ])dnl'
2288 echo 'AC_SUBST([LTALLOCA])'
2292 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2293 # created using libtool, because libtool already handles the dependencies.
2294 if test "$libtool" != true; then
2295 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2296 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2297 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2298 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2299 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2301 func_emit_initmacro_end
2303 func_emit_initmacro_done
2305 echo "# This macro records the list of files which have been installed by"
2306 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2307 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2308 echo "$files" | sed -e 's,^, ,'
2311 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2312 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2316 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2317 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2318 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2320 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2324 echo "# gnulib-comp.m4 ends here"
2331 echo "Creating $m4base/gnulib-comp.m4"
2332 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2334 echo "Create $m4base/gnulib-comp.m4"
2340 if test -n "$inctests"; then
2341 # Create tests makefile.
2342 func_dest_tmpfilename $testsbase/$makefile_am
2343 func_emit_tests_Makefile_am > "$tmpfile"
2344 if test -f "$destdir"/$testsbase/$makefile_am; then
2345 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2349 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2350 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2351 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2353 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2359 echo "Creating $testsbase/$makefile_am"
2360 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2362 echo "Create $testsbase/$makefile_am"
2365 func_append added_files "$testsbase/$makefile_am$nl"
2369 # Update the .cvsignore and .gitignore files.
2370 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
2371 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
2372 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
2373 { # Rearrange file descriptors. Needed because "while ... done < ..."
2374 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2375 exec 5<&0 < "$tmp"/fileset-changes
2376 func_update_ignorelist ()
2379 if test -f "$destdir/$dir$ignore"; then
2380 if test -n "$dir_added" || test -n "$dir_removed"; then
2381 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
2382 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
2383 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
2384 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
2385 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
2386 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
2388 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2389 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
2390 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
2391 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
2392 | sed -f "$tmp"/sed-ignore-removed \
2393 > "$destdir/$dir$ignore"
2395 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2400 if test -n "$dir_added"; then
2402 echo "Creating $destdir/$dir$ignore"
2403 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u > "$destdir/$dir$ignore"
2405 echo "Create $destdir/$dir$ignore"
2415 if test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
2416 func_update_ignorelist .cvsignore
2418 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
2419 func_update_ignorelist .gitignore
2426 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
2427 next_dir=`echo "$line" | sed -e 's,|.*,,'`
2428 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
2429 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
2430 if test "$next_dir" != "$last_dir"; then
2431 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2432 last_dir="$next_dir"
2437 A) func_append last_dir_added "$file$nl";;
2438 R) func_append last_dir_removed "$file$nl";;
2441 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2447 echo "You may need to add #include directives for the following .h files."
2448 # Intersect $specified_modules and $modules
2449 # (since $specified_modules is not necessarily of subset of $modules - some
2450 # may have been skipped through --avoid, and since the elements of $modules
2451 # but not in $specified_modules can go away without explicit notice - through
2452 # changes in the module dependencies).
2453 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2454 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2455 # First the #include <...> directives without #ifs, sorted for convenience,
2456 # then the #include "..." directives without #ifs, sorted for convenience,
2457 # then the #include directives that are surrounded by #ifs. Not sorted.
2458 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2459 include_directive=`func_get_include_directive "$module"`
2460 case "$nl$include_directive" in
2462 echo "$include_directive" 1>&5
2465 echo "$include_directive" | grep -v 'include "' 1>&6
2466 echo "$include_directive" | grep 'include "' 1>&7
2469 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2471 LC_ALL=C sort -u "$tmp"/include-angles
2472 LC_ALL=C sort -u "$tmp"/include-quotes
2473 cat "$tmp"/include-if
2474 ) | sed -e '/^$/d' -e 's/^/ /'
2475 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2477 for module in $modules; do
2478 func_get_link_directive "$module"
2480 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
2481 if test `wc -l < "$tmp"/link` != 0; then
2483 echo "You may need to use the following Makefile variables when linking."
2484 echo "Use them in <program>_LDADD when linking a program, or"
2485 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
2491 echo "Don't forget to"
2492 if test "$makefile_am" = Makefile.am; then
2493 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2495 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2497 if test -n "$inctests"; then
2498 if test "$makefile_am" = Makefile.am; then
2499 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2501 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2504 if test "$makefile_am" = Makefile.am; then
2505 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2506 sourcebase_base=`basename "$sourcebase"`
2507 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2509 if test -n "$inctests"; then
2510 if test "$makefile_am" = Makefile.am; then
2511 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2512 testsbase_base=`basename "$testsbase"`
2513 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2516 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2517 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2518 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2521 # func_create_testdir testdir modules
2523 # - local_gnulib_dir from --local-dir
2524 # - auxdir directory relative to destdir where to place build aux files
2525 func_create_testdir ()
2529 if test -z "$modules"; then
2530 # All modules together.
2531 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2532 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2533 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2534 modules=`func_all_modules`
2535 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2537 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2539 # Check that the license of every module is consistent with the license of
2541 saved_modules="$modules"
2542 saved_inctests="$inctests"
2543 # When computing transitive closures, don't consider $module to depend on
2544 # $module-tests. Need this becauses tests are implicitly GPL and may depend
2545 # on GPL modules - therefore we don't want a warning in this case.
2547 for requested_module in $saved_modules; do
2548 requested_license=`func_get_license "$requested_module"`
2549 if test "$requested_license" != GPL; then
2550 # Here we use func_modules_transitive_closure, not just
2551 # func_get_dependencies, so that we also detect weird situations like
2552 # an LGPL module which depends on a GPLed build tool module which depends
2554 modules="$requested_module"
2555 func_modules_transitive_closure
2556 for module in $modules; do
2557 license=`func_get_license "$module"`
2559 LGPL | 'GPLed build tool') ;;
2560 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2561 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2566 modules="$saved_modules"
2567 inctests="$saved_inctests"
2569 # Subdirectory names.
2576 # Determine final module list.
2577 func_modules_transitive_closure
2578 echo "Module list with included dependencies:"
2579 echo "$modules" | sed -e 's/^/ /'
2581 # Add the dummy module if needed.
2582 func_modules_add_dummy
2584 # Determine final file list.
2585 func_modules_to_filelist
2587 echo "$files" | sed -e 's/^/ /'
2589 sed_rewrite_files="\
2590 s,^build-aux/,$auxdir/,
2592 s,^lib/,$sourcebase/,
2594 s,^tests/,$testsbase/,"
2596 # Create directories.
2597 for f in $files; do echo $f; done \
2598 | sed -e "$sed_rewrite_files" \
2599 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2600 | LC_ALL=C sort -u \
2602 { # Rearrange file descriptors. Needed because "while ... done < ..."
2603 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2604 exec 5<&0 < "$tmp"/dirs
2606 mkdir -p "$testdir/$d"
2611 # Copy files or make symbolic links.
2613 for f in $files; do echo $f; done \
2614 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2617 { # Rearrange file descriptors. Needed because "while ... done < ..."
2618 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2619 exec 5<&0 < "$tmp"/files
2621 func_lookup_file "$f"
2622 if test -n "$lookedup_tmp"; then
2623 cp -p "$lookedup_file" "$testdir/$g"
2625 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2626 if { test -n "$symbolic" \
2627 || { test -n "$lsymbolic" \
2628 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
2629 func_ln "$lookedup_file" "$testdir/$g"
2631 cp -p "$lookedup_file" "$testdir/$g"
2638 # Create Makefile.ams that are for testing.
2641 # Create $sourcebase/Makefile.am.
2642 mkdir -p "$testdir/$sourcebase"
2643 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2645 # Create $m4base/Makefile.am.
2646 mkdir -p "$testdir/$m4base"
2647 (echo "## Process this file with automake to produce Makefile.in."
2653 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2656 ) > "$testdir/$m4base/Makefile.am"
2658 subdirs="$sourcebase $m4base"
2659 subdirs_with_configure_ac=""
2661 if false && test -f "$testdir"/$m4base/gettext.m4; then
2662 # Avoid stupid error message from automake:
2663 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2664 mkdir -p "$testdir/po"
2665 (echo "## Process this file with automake to produce Makefile.in."
2666 ) > "$testdir/po/Makefile.am"
2667 func_append subdirs " po"
2670 if test -n "$inctests"; then
2671 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2672 # Create $testsbase/Makefile.am.
2673 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2674 # Create $testsbase/configure.ac.
2675 (echo "# Process this file with autoconf to produce a configure script."
2676 echo "AC_INIT([dummy], [0])"
2677 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2678 echo "AM_INIT_AUTOMAKE"
2680 echo "AM_CONFIG_HEADER([config.h])"
2683 echo "AC_PROG_INSTALL"
2684 echo "AC_PROG_MAKE_SET"
2685 echo "AC_PROG_RANLIB"
2687 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2688 echo "AC_GNU_SOURCE"
2691 for module in $modules; do
2693 if test -n "$module"; then
2694 func_get_autoconf_early_snippet "$module"
2697 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
2698 if test "$libtool" = true; then
2699 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2700 echo "gl_cond_libtool=true"
2702 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2703 echo "gl_cond_libtool=false"
2705 echo "gl_ltlibdeps="
2707 # Wrap the set of autoconf snippets into an autoconf macro that is then
2708 # invoked. This is needed because autoconf does not support AC_REQUIRE
2710 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2711 # but we want the AC_REQUIRE to have its normal meaning (provide one
2712 # expansion of the required macro before the current point, and only one
2714 echo "AC_DEFUN([gl_INIT], ["
2715 func_emit_initmacro_start
2716 sed_replace_build_aux='
2718 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2719 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2722 # We don't have explicit ordering constraints between the various
2723 # autoconf snippets. It's cleanest to put those of the library before
2724 # those of the tests.
2725 echo "gl_source_base='../$sourcebase'"
2726 for module in $modules; do
2727 func_verify_nontests_module
2728 if test -n "$module"; then
2729 func_get_autoconf_snippet "$module" \
2730 | sed -e "$sed_replace_build_aux"
2733 echo "gl_source_base='.'"
2734 for module in $modules; do
2735 func_verify_tests_module
2736 if test -n "$module"; then
2737 func_get_autoconf_snippet "$module" \
2738 | sed -e "$sed_replace_build_aux"
2741 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2742 # created using libtool, because libtool already handles the dependencies.
2743 if test "$libtool" != true; then
2744 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2745 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2746 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2747 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2748 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2750 func_emit_initmacro_end
2752 func_emit_initmacro_done
2756 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2757 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2758 echo "AH_TOP([#include \"../config.h\"])"
2760 echo "AC_OUTPUT([Makefile])"
2761 ) > "$testdir/$testsbase/configure.ac"
2762 func_append subdirs " $testsbase"
2763 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2766 # Create Makefile.am.
2767 (echo "## Process this file with automake to produce Makefile.in."
2769 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2771 echo "SUBDIRS = $subdirs"
2773 echo "ACLOCAL_AMFLAGS = -I $m4base"
2774 ) > "$testdir/Makefile.am"
2776 # Create configure.ac.
2777 (echo "# Process this file with autoconf to produce a configure script."
2778 echo "AC_INIT([dummy], [0])"
2779 if test "$auxdir" != "."; then
2780 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2782 echo "AM_INIT_AUTOMAKE"
2784 echo "AM_CONFIG_HEADER([config.h])"
2787 echo "AC_PROG_INSTALL"
2788 echo "AC_PROG_MAKE_SET"
2790 echo "# For autobuild."
2791 echo "AC_CANONICAL_BUILD"
2792 echo "AC_CANONICAL_HOST"
2794 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2795 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2796 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2797 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2799 echo "AC_PROG_RANLIB"
2801 if test -n "$uses_subdirs"; then
2802 echo "AM_PROG_CC_C_O"
2805 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2806 echo "AC_GNU_SOURCE"
2809 for module in $modules; do
2810 func_verify_nontests_module
2811 if test -n "$module"; then
2812 func_get_autoconf_early_snippet "$module"
2815 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
2816 if test "$libtool" = true; then
2817 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2818 echo "gl_cond_libtool=true"
2820 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2821 echo "gl_cond_libtool=false"
2823 echo "gl_ltlibdeps="
2825 echo "gl_source_base='$sourcebase'"
2826 # Wrap the set of autoconf snippets into an autoconf macro that is then
2827 # invoked. This is needed because autoconf does not support AC_REQUIRE
2829 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2830 # but we want the AC_REQUIRE to have its normal meaning (provide one
2831 # expansion of the required macro before the current point, and only one
2833 echo "AC_DEFUN([gl_INIT], ["
2834 func_emit_initmacro_start
2835 if test "$auxdir" != "build-aux"; then
2836 sed_replace_build_aux='
2838 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2839 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2843 sed_replace_build_aux=
2845 for module in $modules; do
2846 func_verify_nontests_module
2847 if test -n "$module"; then
2848 func_get_autoconf_snippet "$module" \
2849 | sed -e "$sed_replace_build_aux"
2852 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2853 # created using libtool, because libtool already handles the dependencies.
2854 if test "$libtool" != true; then
2855 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2856 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2857 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2858 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2859 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2861 func_emit_initmacro_end
2863 func_emit_initmacro_done
2867 if test -n "$subdirs_with_configure_ac"; then
2868 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2870 makefiles="Makefile"
2871 for d in $subdirs; do
2872 # For subdirs that have a configure.ac by their own, it's the subdir's
2873 # configure.ac which creates the subdir's Makefile.am, not this one.
2874 case " $subdirs_with_configure_ac " in
2876 *) func_append makefiles " $d/Makefile" ;;
2879 echo "AC_OUTPUT([$makefiles])"
2880 ) > "$testdir/configure.ac"
2882 # Create autogenerated files.
2884 # Do not use "${AUTORECONF} --force --install", because it may invoke
2885 # autopoint, which brings in older versions of some of our .m4 files.
2886 if test -f $m4base/gettext.m4; then
2887 echo "executing ${AUTOPOINT} --force"
2888 ${AUTOPOINT} --force || func_exit 1
2889 for f in $m4base/*.m4~; do
2890 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2893 echo "executing ${ACLOCAL} -I $m4base"
2894 ${ACLOCAL} -I $m4base || func_exit 1
2895 if ! test -d build-aux; then
2896 echo "executing mkdir build-aux"
2897 mkdir build-aux || func_exit 1
2899 echo "executing ${AUTOCONF}"
2900 ${AUTOCONF} || func_exit 1
2901 echo "executing ${AUTOHEADER}"
2902 ${AUTOHEADER} || func_exit 1
2903 echo "executing ${AUTOMAKE} --add-missing --copy"
2904 ${AUTOMAKE} --add-missing --copy || func_exit 1
2906 if test -n "$inctests"; then
2907 # Create autogenerated files.
2908 (cd "$testdir/$testsbase" || func_exit 1
2909 # Do not use "${AUTORECONF} --force --install", because it may invoke
2910 # autopoint, which brings in older versions of some of our .m4 files.
2911 if test -f ../$m4base/gettext.m4; then
2912 echo "executing ${AUTOPOINT} --force"
2913 ${AUTOPOINT} --force || func_exit 1
2914 for f in ../$m4base/*.m4~; do
2915 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2918 echo "executing ${ACLOCAL} -I ../$m4base"
2919 ${ACLOCAL} -I ../$m4base || func_exit 1
2920 if ! test -d ../build-aux; then
2921 echo "executing mkdir ../build-aux"
2924 echo "executing ${AUTOCONF}"
2925 ${AUTOCONF} || func_exit 1
2926 echo "executing ${AUTOHEADER}"
2927 ${AUTOHEADER} || func_exit 1
2928 echo "executing ${AUTOMAKE} --add-missing --copy"
2929 ${AUTOMAKE} --add-missing --copy || func_exit 1
2932 # Need to run configure and make once, to create built files that are to be
2933 # distributed (such as getdate.c).
2934 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
2935 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
2936 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
2937 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
2938 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
2939 # such $(FOO_H) because they don't refer to distributed files.
2940 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
2941 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
2942 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
2943 | sed -e "$sed_remove_make_variables"`
2944 distributed_built_sources=`for file in $built_sources; do
2945 case "$cleaned_files" in
2950 if test -n "$distributed_built_sources"; then
2952 ./configure || func_exit 1
2954 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2955 make built_sources || func_exit 1
2957 make distclean || func_exit 1
2962 # func_create_megatestdir megatestdir allmodules
2964 # - local_gnulib_dir from --local-dir
2965 # - auxdir directory relative to destdir where to place build aux files
2966 func_create_megatestdir ()
2970 if test -z "$allmodules"; then
2971 allmodules=`func_all_modules`
2975 # First, all modules one by one.
2976 for onemodule in $allmodules; do
2977 func_create_testdir "$megatestdir/$onemodule" $onemodule
2978 func_append megasubdirs "$onemodule "
2980 # Then, all modules all together.
2981 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2982 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2983 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
2984 func_create_testdir "$megatestdir/ALL" "$allmodules"
2985 func_append megasubdirs "ALL"
2988 cvsdate=`sh "$gnulib_dir/build-aux/mdate-sh" "$gnulib_dir/CVS/Entries" \
2989 | sed -e 's,January,01,' -e 's,Jan,01,' \
2990 -e 's,February,02,' -e 's,Feb,02,' \
2991 -e 's,March,03,' -e 's,Mar,03,' \
2992 -e 's,April,04,' -e 's,Apr,04,' \
2994 -e 's,June,06,' -e 's,Jun,06,' \
2995 -e 's,July,07,' -e 's,Jul,07,' \
2996 -e 's,August,08,' -e 's,Aug,08,' \
2997 -e 's,September,09,' -e 's,Sep,09,' \
2998 -e 's,October,10,' -e 's,Oct,10,' \
2999 -e 's,November,11,' -e 's,Nov,11,' \
3000 -e 's,December,12,' -e 's,Dec,12,' \
3001 | sed -e 's,^,00,' | sed -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3002 | sed -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3004 echo "CVSDATE=$cvsdate"
3005 echo "test -d logs || mkdir logs"
3006 echo "for module in $megasubdirs; do"
3007 echo " echo \"Working on module \$module...\""
3008 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3009 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3012 echo " : autobuild project... \$module"
3013 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3014 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3015 echo " : autobuild hostname... \`hostname\`"
3016 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3018 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3020 ) > "$megatestdir/do-autobuild"
3021 chmod a+x "$megatestdir/do-autobuild"
3023 # Create Makefile.am.
3024 (echo "## Process this file with automake to produce Makefile.in."
3026 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3028 echo "SUBDIRS = $megasubdirs"
3030 echo "EXTRA_DIST = do-autobuild"
3031 ) > "$megatestdir/Makefile.am"
3033 # Create configure.ac.
3034 (echo "# Process this file with autoconf to produce a configure script."
3035 echo "AC_INIT([dummy], [0])"
3036 if test "$auxdir" != "."; then
3037 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3039 echo "AM_INIT_AUTOMAKE"
3041 echo "AC_PROG_MAKE_SET"
3043 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3044 echo "AC_OUTPUT([Makefile])"
3045 ) > "$megatestdir/configure.ac"
3047 # Create autogenerated files.
3049 # Do not use "${AUTORECONF} --install", because autoreconf operates
3050 # recursively, but the subdirectories are already finished, therefore
3051 # calling autoreconf here would only waste lots of CPU time.
3052 echo "executing ${ACLOCAL}"
3053 ${ACLOCAL} || func_exit 1
3054 echo "executing mkdir build-aux"
3056 echo "executing ${AUTOCONF}"
3057 ${AUTOCONF} || func_exit 1
3058 echo "executing ${AUTOMAKE} --add-missing --copy"
3059 ${AUTOMAKE} --add-missing --copy || func_exit 1
3065 func_fatal_error "no mode specified" ;;
3074 if test -z "$destdir"; then
3077 test -d "$destdir" \
3078 || func_fatal_error "destination directory does not exist: $destdir"
3080 # Prefer configure.ac to configure.in.
3081 if test -f "$destdir"/configure.ac; then
3082 configure_ac="$destdir/configure.ac"
3084 if test -f "$destdir"/configure.in; then
3085 configure_ac="$destdir/configure.in"
3087 func_fatal_error "cannot find $destdir/configure.ac"
3091 # Analyze configure.ac.
3093 guessed_libtool=false
3098 /AC_CONFIG_AUX_DIR/ {
3099 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3101 /A[CM]_PROG_LIBTOOL/ {
3102 s,^.*$,guessed_libtool=true,p
3104 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3106 if test -z "$auxdir"; then
3107 auxdir="$guessed_auxdir"
3110 # Determine where to apply func_import.
3111 if test -n "$m4base"; then
3112 # Apply func_import to a particular gnulib directory.
3113 # Any number of additional modules can be given.
3114 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3115 # First use of gnulib in the given m4base.
3116 test -n "$supplied_libname" || supplied_libname=true
3117 test -n "$sourcebase" || sourcebase="lib"
3118 test -n "$docbase" || docbase="doc"
3119 test -n "$testsbase" || testsbase="tests"
3120 test -n "$macro_prefix" || macro_prefix="gl"
3124 # Apply func_import to all gnulib directories.
3125 # To get this list of directories, look at Makefile.am. (Not at
3126 # configure, because it may be omitted from CVS. Also, don't run
3127 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3130 if test -f "$destdir"/Makefile.am; then
3131 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3133 for arg in $aclocal_amflags; do
3134 if test -n "$m4dir_is_next"; then
3135 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3139 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3140 func_append m4dirs " $arg"
3141 m4dirs_count=`expr $m4dirs_count + 1`
3147 if test "X$arg" = "X-I"; then
3155 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3156 if test -f "$destdir"/aclocal.m4; then
3157 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3158 sedexpr2='s,^[^/]*$,.,'
3159 sedexpr3='s,/[^/]*$,,'
3160 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3161 m4dirs_count=`echo "$m4dirs" | wc -l`
3164 if test $m4dirs_count = 0; then
3165 # First use of gnulib in a package.
3166 # Any number of additional modules can be given.
3167 test -n "$supplied_libname" || supplied_libname=true
3168 test -n "$sourcebase" || sourcebase="lib"
3170 test -n "$docbase" || docbase="doc"
3171 test -n "$testsbase" || testsbase="tests"
3172 test -n "$macro_prefix" || macro_prefix="gl"
3175 if test $m4dirs_count = 1; then
3176 # There's only one use of gnulib here. Assume the user means it.
3177 # Any number of additional modules can be given.
3178 for m4base in $m4dirs; do
3182 # Ambiguous - guess what the user meant.
3183 if test $# = 0; then
3184 # No further arguments. Guess the user wants to update all of them.
3185 for m4base in $m4dirs; do
3186 # Perform func_import in a subshell, so that variable values
3188 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
3189 # testsbase, inctests, libname, lgpl, makefile_name, libtool,
3191 # don't propagate from one directory to another.
3192 (func_import) || func_exit 1
3196 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
3204 if test -z "$destdir"; then
3205 func_fatal_error "please specify --dir option"
3208 test -d "$destdir" \
3209 || func_fatal_error "could not create destination directory"
3210 test -n "$auxdir" || auxdir="build-aux"
3211 func_create_testdir "$destdir" "$*"
3214 create-megatestdir )
3215 if test -z "$destdir"; then
3216 func_fatal_error "please specify --dir option"
3218 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3219 test -n "$auxdir" || auxdir="build-aux"
3220 func_create_megatestdir "$destdir" "$*"
3224 test -n "$destdir" || destdir=testdir$$
3225 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3226 test -n "$auxdir" || auxdir="build-aux"
3227 func_create_testdir "$destdir" "$*"
3231 ../configure || func_exit 1
3233 make check || func_exit 1
3234 make distclean || func_exit 1
3235 remaining=`find . -type f -print`
3236 if test -n "$remaining"; then
3237 echo "Remaining files:" $remaining 1>&2
3238 echo "gnulib-tool: *** Stop." 1>&2
3247 test -n "$destdir" || destdir=testdir$$
3248 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3249 test -n "$auxdir" || auxdir="build-aux"
3250 func_create_megatestdir "$destdir" "$*"
3258 remaining=`find . -type f -print`
3259 if test -n "$remaining"; then
3260 echo "Remaining files:" $remaining 1>&2
3261 echo "gnulib-tool: *** Stop." 1>&2
3269 extract-description )
3273 if test -n "$module"; then
3274 func_get_description "$module"
3283 if test -n "$module"; then
3284 func_get_filelist "$module"
3289 extract-dependencies )
3293 if test -n "$module"; then
3294 func_get_dependencies "$module"
3299 extract-autoconf-snippet )
3303 if test -n "$module"; then
3304 func_get_autoconf_snippet "$module"
3309 extract-automake-snippet )
3313 if test -n "$module"; then
3314 func_get_automake_snippet "$module"
3319 extract-include-directive )
3323 if test -n "$module"; then
3324 func_get_include_directive "$module"
3329 extract-link-directive )
3333 if test -n "$module"; then
3334 func_get_link_directive "$module"
3343 if test -n "$module"; then
3344 func_get_license "$module"
3349 extract-maintainer )
3353 if test -n "$module"; then
3354 func_get_maintainer "$module"
3359 extract-tests-module )
3363 if test -n "$module"; then
3364 func_get_tests_module "$module"
3370 func_fatal_error "unknown operation mode --$mode" ;;
3374 # Undo the effect of the previous 'trap' command. Some shellology:
3375 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3376 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3377 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3378 # 128 + signal number and is set before the trap-registered command is run.
3380 trap 'func_exit $?' 1 2 3 13 15
3385 # indent-tabs-mode: nil
3386 # whitespace-check-buffer-indent: nil