3 # Copyright (C) 2002-2007 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # This program is meant for authors or maintainers which want to import
21 # modules from gnulib into their packages.
25 cvsdatestamp='$Date: 2007-07-18 23:45:37 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
32 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
36 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
37 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
41 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
44 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
47 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
48 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
49 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
50 AUTOCONF="${AUTOCONFPATH}autoconf"
52 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
53 AUTOHEADER="${AUTOCONFPATH}autoheader"
55 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
56 ACLOCAL="${AUTOMAKEPATH}aclocal"
58 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
59 AUTOMAKE="${AUTOMAKEPATH}automake"
61 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
62 AUTORECONF="${AUTOCONFPATH}autoreconf"
65 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
66 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
67 AUTOPOINT="${GETTEXTPATH}autopoint"
70 # When using GNU sed, turn off as many GNU extensions as possible,
71 # to minimize the risk of accidentally using non-portable features.
72 # However, do this only for gnulib-tool itself, not for the code that
73 # gnulib-tool generates, since we don't want "sed --posix" to leak
75 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
76 alias sed='sed --posix'
80 # outputs to stdout the --help usage message.
84 Usage: gnulib-tool --list
85 gnulib-tool --import [module1 ... moduleN]
87 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
88 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
89 gnulib-tool --test --dir=directory module1 ... moduleN
90 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
91 gnulib-tool --extract-description module
92 gnulib-tool --extract-filelist module
93 gnulib-tool --extract-dependencies module
94 gnulib-tool --extract-autoconf-snippet module
95 gnulib-tool --extract-automake-snippet module
96 gnulib-tool --extract-include-directive module
97 gnulib-tool --extract-link-directive module
98 gnulib-tool --extract-license module
99 gnulib-tool --extract-maintainer module
100 gnulib-tool --extract-tests-module module
103 --list print the available module names
104 --import import the given modules into the current package;
105 if no modules are specified, update the current
106 package from the current gnulib
107 --update update the current package, restore files omitted
109 --create-testdir create a scratch package with the given modules
110 --create-megatestdir create a mega scratch package with the given modules
111 one by one and all together
112 --test test the combination of the given modules
113 (recommended to use CC=\"gcc -Wall\" here)
114 --megatest test the given modules one by one and all together
115 (recommended to use CC=\"gcc -Wall\" here)
116 --extract-description extract the description
117 --extract-filelist extract the list of files
118 --extract-dependencies extract the dependencies
119 --extract-autoconf-snippet extract the snippet for configure.ac
120 --extract-automake-snippet extract the snippet for library makefile
121 --extract-include-directive extract the #include directive
122 --extract-link-directive extract the linker directive
123 --extract-license report the license terms of the source files
125 --extract-maintainer report the maintainer(s) inside gnulib
126 --extract-tests-module report the unit test module, if it exists
129 --dir=DIRECTORY Specify the target directory.
130 For --import, this specifies where your
131 configure.ac can be found. Defaults to current
133 --local-dir=DIRECTORY Specify a local override directory where to look
134 up files before looking in gnulib's directory.
136 Options for --import:
137 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
138 --source-base=DIRECTORY
139 Directory relative to --dir where source code is
140 placed (default \"lib\").
141 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
142 placed (default \"m4\").
143 --doc-base=DIRECTORY Directory relative to --dir where doc files are
144 placed (default \"doc\").
145 --tests-base=DIRECTORY
146 Directory relative to --dir where unit tests are
147 placed (default \"tests\").
148 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
149 tools are placed (default \"build-aux\").
150 --with-tests Include unit tests for the included modules.
151 --avoid=MODULE Avoid including the given MODULE. Useful if you
152 have code that provides equivalent functionality.
153 This option can be repeated.
154 --lgpl Abort if modules aren't available under the LGPL.
155 Also modify license template from GPL to LGPL.
156 --makefile-name=NAME Name of makefile in automake syntax in the
157 source-base and tests-base directories
158 (default \"Makefile.am\").
159 --libtool Use libtool rules.
160 --no-libtool Don't use libtool rules.
161 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
162 'gl_INIT'. Default is 'gl'.
163 --no-changelog don't update or create ChangeLog files
165 Options for --import and --update:
166 --dry-run For --import, only print what would have been done.
167 -s, --symbolic, --symlink Make symbolic links instead of copying files.
168 --local-symlink Make symbolic links instead of copying files, only
169 for files from the local override directory.
170 -S, --more-symlinks Make symbolic links instead of copying files, and
171 don't replace copyright notices.
173 Report bugs to <bug-gnulib@gnu.org>."
177 # outputs to stdout the --version message.
180 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
182 $progname (GNU $package) $version
183 Copyright (C) $year Free Software Foundation, Inc.
184 This is free software; see the source for copying conditions. There is NO
185 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
186 Written by" "Bruno Haible" "and" "Simon Josefsson"
189 # func_emit_copyright_notice
190 # outputs to stdout a header for a generated file.
191 func_emit_copyright_notice ()
193 echo "# Copyright (C) 2004-2007 Free Software Foundation, Inc."
195 echo "# This file is free software, distributed under the terms of the GNU"
196 echo "# General Public License. As a special exception to the GNU General"
197 echo "# Public License, this file may be distributed as part of a program"
198 echo "# that contains a configuration script generated by Autoconf, under"
199 echo "# the same distribution terms as the rest of that program."
201 echo "# Generated by gnulib-tool."
212 # creates a temporary directory.
214 # - tmp pathname of freshly created temporary directory
217 # Use the environment variable TMPDIR, falling back to /tmp. This allows
218 # users to specify a different temporary directory, for example, if their
219 # /tmp is filled up or too small.
222 # Use the mktemp program if available. If not available, hide the error
224 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
225 test -n "$tmp" && test -d "$tmp"
228 # Use a simple mkdir command. It is guaranteed to fail if the directory
229 # already exists. $RANDOM is bash specific and expands to empty in shells
230 # other than bash, ksh and zsh. Its use does not increase security;
231 # rather, it minimizes the probability of failure in a very cluttered /tmp
233 tmp=$TMPDIR/gl$$-$RANDOM
234 (umask 077 && mkdir "$tmp")
237 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
242 # func_append var value
243 # appends the given value to the shell variable var.
244 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
245 # Use bash's += operator. It reduces complexity of appending repeatedly to
246 # a single variable from O(n^2) to O(n).
254 eval "$1=\"\$$1\$2\""
258 # func_fatal_error message
259 # outputs to stderr a fatal error message, and terminates the program.
262 echo "gnulib-tool: *** $1" 1>&2
263 echo "gnulib-tool: *** Stop." 1>&2
267 # func_readlink SYMLINK
268 # outputs the target of the given symlink.
269 if (type -p readlink) > /dev/null 2>&1; then
272 # Use the readlink program from GNU coreutils.
278 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
279 # would do the wrong thing if the link target contains " -> ".
280 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
284 # func_relativize DIR1 DIR2
285 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
287 # - DIR1 relative pathname, relative to the current directory
288 # - DIR2 relative pathname, relative to the current directory
290 # - reldir relative pathname of DIR2, relative to DIR1
296 sed_first='s,^\([^/]*\)/.*$,\1,'
297 sed_rest='s,^[^/]*/*,,'
298 sed_last='s,^.*/\([^/]*\)$,\1,'
299 sed_butlast='s,/*[^/]*$,,'
300 while test -n "$dir1"; do
301 first=`echo "$dir1" | sed -e "$sed_first"`
302 if test "$first" != "."; then
303 if test "$first" = ".."; then
304 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
305 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
307 first2=`echo "$dir2" | sed -e "$sed_first"`
308 if test "$first2" = "$first"; then
309 dir2=`echo "$dir2" | sed -e "$sed_rest"`
313 dir0="$dir0"/"$first"
316 dir1=`echo "$dir1" | sed -e "$sed_rest"`
321 # func_relconcat DIR1 DIR2
322 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
324 # - DIR1 relative pathname, relative to the current directory
325 # - DIR2 relative pathname, relative to DIR1
327 # - relconcat DIR1/DIR2, relative to the current directory
332 sed_first='s,^\([^/]*\)/.*$,\1,'
333 sed_rest='s,^[^/]*/*,,'
334 sed_last='s,^.*/\([^/]*\)$,\1,'
335 sed_butlast='s,/*[^/]*$,,'
337 first=`echo "$dir2" | sed -e "$sed_first"`
338 if test "$first" = "."; then
339 dir2=`echo "$dir2" | sed -e "$sed_rest"`
340 if test -z "$dir2"; then
345 last=`echo "$dir1" | sed -e "$sed_last"`
346 while test "$last" = "."; do
347 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
348 last=`echo "$dir1" | sed -e "$sed_last"`
350 if test -z "$dir1"; then
354 if test "$first" = ".."; then
355 if test "$last" = ".."; then
356 relconcat="$dir1/$dir2"
359 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
360 dir2=`echo "$dir2" | sed -e "$sed_rest"`
361 if test -z "$dir1"; then
365 if test -z "$dir2"; then
370 relconcat="$dir1/$dir2"
378 # Like ln -s, except that SRC is given relative to the current directory (or
379 # absolute), not given relative to the directory of DEST.
385 *) # SRC is relative.
388 ln -s "`pwd`/$1" "$2" ;;
389 *) # DEST is relative too.
390 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
391 test -n "$ln_destdir" || ln_destdir="."
392 func_relativize "$ln_destdir" "$1"
400 # func_ln_if_changed SRC DEST
401 # Like func_ln, but avoids munging timestamps if the link is correct.
402 func_ln_if_changed ()
404 if test $# -ne 2; then
405 echo "usage: func_ln_if_changed SRC DEST" >&2
407 ln_target=`func_readlink "$2"`
408 if test -L "$2" && test "$1" = "$ln_target"; then
416 # Ensure an 'echo' command that does not interpret backslashes.
418 # echo '\n' | wc -l prints 1 when OK, 2 when KO
419 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
420 # This problem is a weird heritage from SVR4. BSD got it right (except that
421 # BSD echo interprets '-n' as an option, which is also not desirable).
422 # Nowadays the problem occurs in 4 situations:
423 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
424 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
425 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
426 # - in zsh, when sh-emulation is not set,
427 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
428 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
429 # - in Solaris /bin/sh and OSF/1 /bin/sh.
430 # We try the following workarounds:
431 # - for all: respawn using $CONFIG_SHELL if that is set and works.
432 # - for bash >= 2.04: unset the shell option xpg_echo.
433 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
434 # - for bash < 2.0: define echo to a function that uses cat of a here document.
435 # - for zsh: turn sh-emulation on.
436 # - for ksh: alias echo to 'print -r'.
437 # - for ksh: alias echo to a function that uses cat of a here document.
438 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
439 # the ksh workaround.
440 # - otherwise: respawn using /bin/sh and rely on the workarounds.
441 # When respawning, we pass --no-reexec as first argument, so as to avoid
442 # turning this script into a fork bomb in unlucky situations.
444 if echo '\t' | grep t > /dev/null; then
445 have_echo=yes # Lucky!
447 # Try the workarounds.
448 # Respawn using $CONFIG_SHELL if that is set and works.
449 if test -z "$have_echo" \
450 && test "X$1" != "X--no-reexec" \
451 && test -n "$CONFIG_SHELL" \
452 && test -f "$CONFIG_SHELL" \
453 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
454 exec $CONFIG_SHELL "$0" --no-reexec "$@"
457 # For bash >= 2.04: unset the shell option xpg_echo.
458 if test -z "$have_echo" \
459 && test -n "$BASH_VERSION" \
460 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
464 # For bash >= 2.0: define echo to a function that uses the printf built-in.
465 # For bash < 2.0: define echo to a function that uses cat of a here document.
466 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
467 if test -z "$have_echo" \
468 && test -n "$BASH_VERSION"; then \
469 if type printf 2>/dev/null | grep / > /dev/null; then
470 # 'printf' is not a shell built-in.
478 # 'printf' is a shell built-in.
484 if echo '\t' | grep t > /dev/null; then
488 # For zsh: turn sh-emulation on.
489 if test -z "$have_echo" \
490 && test -n "$ZSH_VERSION" \
491 && (emulate sh) >/dev/null 2>&1; then
494 # For ksh: alias echo to 'print -r'.
495 if test -z "$have_echo" \
496 && (type print) >/dev/null 2>&1; then
497 # A 'print' command exists.
498 if type print 2>/dev/null | grep / > /dev/null; then
501 # 'print' is a shell built-in.
502 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
503 # 'print' is the ksh shell built-in.
504 alias echo='print -r'
508 if test -z "$have_echo" \
509 && echo '\t' | grep t > /dev/null; then
512 # For ksh: alias echo to a function that uses cat of a here document.
513 # The ksh manual page says:
514 # "Aliasing is performed when scripts are read, not while they are executed.
515 # Therefore, for an alias to take effect, the alias definition command has
516 # to be executed before the command which references the alias is read."
517 # Because of this, we have to play strange tricks with have_echo, to ensure
518 # that the top-level statement containing the test starts after the 'alias'
520 if test -z "$have_echo"; then
527 alias echo=bsd_echo 2>/dev/null
529 if test -z "$have_echo" \
530 && echo '\t' | grep t > /dev/null; then
533 if test -z "$have_echo"; then
534 unalias echo 2>/dev/null
536 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
537 if test -z "$have_echo" \
538 && test "X$1" != "X--no-reexec" \
539 && test -f /bin/ksh; then
540 exec /bin/ksh "$0" --no-reexec "$@"
543 # Otherwise: respawn using /bin/sh.
544 if test -z "$have_echo" \
545 && test "X$1" != "X--no-reexec" \
546 && test -f /bin/sh; then
547 exec /bin/sh "$0" --no-reexec "$@"
550 if test -z "$have_echo"; then
551 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
553 if echo '\t' | grep t > /dev/null; then
556 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
558 if test "X$1" = "X--no-reexec"; then
562 # Command-line option processing.
563 # Removes the OPTIONS from the arguments. Sets the variables:
564 # - mode list or import or create-testdir or create-megatestdir
565 # - destdir from --dir
566 # - local_gnulib_dir from --local-dir
567 # - libname, supplied_libname from --lib
568 # - sourcebase from --source-base
569 # - m4base from --m4-base
570 # - docbase from --doc-base
571 # - testsbase from --tests-base
572 # - auxdir from --aux-dir
573 # - inctests true if --with-tests was given, blank otherwise
574 # - avoidlist list of modules to avoid, from --avoid
575 # - lgpl true if --lgpl was given, blank otherwise
576 # - makefile_name from --makefile-name
577 # - libtool true if --libtool was given, false if --no-libtool was
578 # given, blank otherwise
579 # - macro_prefix from --macro-prefix
580 # - autoconf_minversion minimum supported autoconf version
581 # - do_changelog false if --no-changelog was given, : otherwise
582 # - doit : if actions shall be executed, false if only to be printed
583 # - symbolic true if --symlink or --more-symlinks was given, blank
585 # - lsymbolic true if --local-symlink was given, blank otherwise
586 # - do_copyrights blank if --more-symlinks was given, true otherwise
612 while test $# -gt 0; do
617 --import | --impor | --impo | --imp | --im | --i )
620 --update | --updat | --upda | --upd | --up | --u )
623 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
626 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
627 mode=create-megatestdir
629 --test | --tes | --te | --t )
632 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
636 mode=`echo "X$1" | sed -e 's/^X--//'`
641 func_fatal_error "missing argument for --dir"
646 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
651 func_fatal_error "missing argument for --local-dir"
656 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
661 func_fatal_error "missing argument for --lib"
664 supplied_libname=true
667 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
668 supplied_libname=true
673 func_fatal_error "missing argument for --source-base"
678 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
683 func_fatal_error "missing argument for --m4-base"
688 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
693 func_fatal_error "missing argument for --doc-base"
698 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
703 func_fatal_error "missing argument for --tests-base"
708 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
713 func_fatal_error "missing argument for --aux-dir"
718 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
726 func_fatal_error "missing argument for --avoid"
728 func_append avoidlist " $1"
731 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
732 func_append avoidlist " $arg"
740 func_fatal_error "missing argument for --makefile-name"
745 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
756 func_fatal_error "missing argument for --macro-prefix"
761 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
763 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
769 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
772 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
775 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
779 --help | --hel | --he | --h )
782 --version | --versio | --versi | --vers | --ver | --ve | --v )
786 # Stop option processing
790 echo "gnulib-tool: unknown option $1" 1>&2
791 echo "Try 'gnulib-tool --help' for more information." 1>&2
798 if test "$mode" = update; then
799 if test $# != 0; then
800 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
801 echo "Try 'gnulib-tool --help' for more information." 1>&2
802 echo "If you really want to modify the gnulib configuration of your project," 1>&2
803 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
806 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
807 || test -n "$sourcebase" || test -n "$m4base" \
808 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
809 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
810 || test -n "$makefile_name" || test -n "$macro_prefix"; then
811 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
812 echo "Try 'gnulib-tool --help' for more information." 1>&2
813 echo "If you really want to modify the gnulib configuration of your project," 1>&2
814 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
820 # Determine the minimum supported autoconf version from the project's
822 DEFAULT_AUTOCONF_MINVERSION="2.59"
825 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
826 if test -f "$destdir"/configure.ac; then
827 configure_ac="$destdir/configure.ac"
829 if test -f "$destdir"/configure.in; then
830 configure_ac="$destdir/configure.in"
834 if test -f configure.ac; then
835 configure_ac="configure.ac"
837 if test -f configure.in; then
838 configure_ac="configure.in"
842 if test -n "$configure_ac"; then
843 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
844 # because when some m4 files are omitted from a CVS repository,
845 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
846 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
847 # autom4te: m4 failed with exit status: 1
854 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
856 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
857 if test -n "$prereqs"; then
858 autoconf_minversion=`
859 for version in $prereqs; do echo $version; done |
860 LC_ALL=C sort -nru | sed 1q
864 if test -z "$autoconf_minversion"; then
865 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
867 case "$autoconf_minversion" in
868 1.* | 2.[0-4]* | 2.5[0-8]*)
869 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
872 # Remove trailing slashes from the directory names. This is necessary for
873 # m4base (to avoid an error in func_import) and optional for the others.
874 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
875 case "$local_gnulib_dir" in
876 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
878 case "$sourcebase" in
879 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
882 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
885 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
888 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
891 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
896 /*) self_abspathname="$0" ;;
897 */*) self_abspathname=`pwd`/"$0" ;;
900 # Iterate through the elements of $PATH.
901 # We use IFS=: instead of
902 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
903 # because the latter does not work when some PATH element contains spaces.
904 # We use a canonicalized $pathx instead of $PATH, because empty PATH
905 # elements are by definition equivalent to '.', however field splitting
906 # according to IFS=: loses empty fields in many shells:
907 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
908 # beginning, at the end, and in the middle),
909 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
910 # at the beginning and at the end,
911 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
912 # Solaris lose empty fields at the end.
913 # The 'case' statement is an optimization, to avoid evaluating the
914 # explicit canonicalization command when $PATH contains no empty fields.
916 if test "${PATH_SEPARATOR+set}" != set; then
918 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
919 chmod +x "$tmp"/conf.sh
920 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
927 if test "$PATH_SEPARATOR" = ";"; then
928 # On Windows, programs are searched in "." before $PATH.
931 # On Unix, we have to convert empty PATH elements to ".".
935 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
940 IFS="$PATH_SEPARATOR"
944 if test -x "$d/$0" && test ! -d "$d/$0"; then
945 self_abspathname="$d/$0"
950 if test -z "$self_abspathname"; then
951 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
955 while test -h "$self_abspathname"; do
956 # Resolve symbolic link.
957 linkval=`func_readlink "$self_abspathname"`
958 test -n "$linkval" || break
960 /* ) self_abspathname="$linkval" ;;
961 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
964 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
968 if test "$signal" != 0; then
969 echo "caught signal $signal" >&2
973 for signal in 1 2 3 13 15; do
974 trap '{ signal='$signal'; func_exit 1; }' $signal
978 # func_lookup_file file
979 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
982 # - local_gnulib_dir from --local-dir
984 # - lookedup_file name of the merged (combined) file
985 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
989 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
990 lookedup_file="$local_gnulib_dir/$lkfile"
993 if test -f "$gnulib_dir/$lkfile"; then
994 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
995 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
997 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
998 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
999 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1000 lookedup_file="$tmp/$lkbase"
1003 lookedup_file="$gnulib_dir/$lkfile"
1007 func_fatal_error "file $gnulib_dir/$lkfile not found"
1014 # - local_gnulib_dir from --local-dir
1017 # Filter out metainformation files like README, which are not modules.
1018 # Filter out unit test modules; they can be retrieved through
1019 # --extract-tests-module if desired.
1021 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1022 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1023 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1026 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1027 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1028 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1029 -e '/^README$/d' -e '/\/README$/d' \
1030 -e '/^TEMPLATE$/d' \
1031 -e '/^TEMPLATE-EXTENDED$/d' \
1032 -e '/^TEMPLATE-TESTS$/d' \
1035 | sed -e '/-tests$/d' \
1039 # func_verify_module
1040 # verifies a module name
1042 # - local_gnulib_dir from --local-dir
1043 # - module module name argument
1044 func_verify_module ()
1046 if { test -f "$gnulib_dir/modules/$module" \
1047 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1048 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1049 && test "CVS" != "$module" \
1050 && test "ChangeLog" != "$module" \
1051 && test "COPYING" != "$module" \
1052 && test "README" != "$module" \
1053 && test "TEMPLATE" != "$module" \
1054 && test "TEMPLATE-EXTENDED" != "$module" \
1055 && test "TEMPLATE-TESTS" != "$module"; then
1056 # OK, $module is a correct module name.
1057 # Verify that building the module description with 'patch' succeeds.
1058 func_lookup_file "modules/$module"
1060 echo "gnulib-tool: module $module doesn't exist" 1>&2
1065 # func_verify_nontests_module
1066 # verifies a module name, excluding tests modules
1068 # - local_gnulib_dir from --local-dir
1069 # - module module name argument
1070 func_verify_nontests_module ()
1073 *-tests ) module= ;;
1074 * ) func_verify_module ;;
1078 # func_verify_tests_module
1079 # verifies a module name, considering only tests modules
1081 # - local_gnulib_dir from --local-dir
1082 # - module module name argument
1083 func_verify_tests_module ()
1086 *-tests ) func_verify_module ;;
1091 sed_extract_prog=':[ ]*$/ {
1094 s/^Description:[ ]*$//
1096 s/^Depends-on:[ ]*$//
1097 s/^configure\.ac-early:[ ]*$//
1098 s/^configure\.ac:[ ]*$//
1099 s/^Makefile\.am:[ ]*$//
1103 s/^Maintainer:[ ]*$//
1110 # func_get_description module
1112 # - local_gnulib_dir from --local-dir
1113 func_get_description ()
1115 func_lookup_file "modules/$1"
1116 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1119 # func_get_filelist module
1121 # - local_gnulib_dir from --local-dir
1122 func_get_filelist ()
1124 func_lookup_file "modules/$1"
1125 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1126 echo m4/gnulib-common.m4
1127 case "$autoconf_minversion" in
1129 #echo m4/onceonly.m4
1130 echo m4/onceonly_2_57.m4
1135 # func_get_dependencies module
1137 # - local_gnulib_dir from --local-dir
1138 func_get_dependencies ()
1140 # ${module}-tests always implicitly depends on ${module}.
1141 echo "$1" | sed -n -e 's/-tests//p'
1142 # Then the explicit dependencies listed in the module description.
1143 func_lookup_file "modules/$1"
1144 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1147 # func_get_autoconf_early_snippet module
1149 # - local_gnulib_dir from --local-dir
1150 func_get_autoconf_early_snippet ()
1152 func_lookup_file "modules/$1"
1153 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1156 # func_get_autoconf_snippet module
1158 # - local_gnulib_dir from --local-dir
1159 func_get_autoconf_snippet ()
1161 func_lookup_file "modules/$1"
1162 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1165 # func_get_automake_snippet module
1167 # - local_gnulib_dir from --local-dir
1168 func_get_automake_snippet ()
1170 func_lookup_file "modules/$1"
1171 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1174 # *-tests module live in tests/, not lib/.
1177 # Synthesize an EXTRA_DIST augmentation.
1178 sed_combine_lines='/\\$/{
1185 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1186 already_mentioned_files=` \
1187 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1188 | sed -e "$sed_combine_lines" \
1189 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1190 all_files=`func_get_filelist $1`
1191 lib_files=`for f in $all_files; do \
1195 done | sed -e 's,^lib/,,'`
1196 # Remove $already_mentioned_files from $lib_files.
1197 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1198 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1199 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1200 if test -n "$extra_files"; then
1201 echo "EXTRA_DIST +=" $extra_files
1204 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1205 # This is necessary so that automake can generate the right list of
1207 # A possible approach would be to use autom4te --trace of the redefined
1208 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1209 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1210 # inside autoconf's built-in macros are not missed).
1211 # But it's simpler and more robust to do it here, based on the file list.
1212 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1213 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1214 # automake will generate a useless dependency; this is harmless.
1216 relocatable-prog-wrapper) ;;
1218 sed_extract_c_files='/\.c$/p'
1219 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1220 if test -n "$extra_files"; then
1221 echo "EXTRA_lib_SOURCES +=" $extra_files
1226 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1227 buildaux_files=`for f in $all_files; do \
1229 build-aux/*) echo $f ;; \
1231 done | sed -e 's,^build-aux/,,'`
1232 if test -n "$buildaux_files"; then
1233 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1234 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1241 # func_get_include_directive module
1243 # - local_gnulib_dir from --local-dir
1244 func_get_include_directive ()
1246 func_lookup_file "modules/$1"
1247 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1248 sed -e 's/^\(["<]\)/#include \1/'
1251 # func_get_link_directive module
1253 # - local_gnulib_dir from --local-dir
1254 func_get_link_directive ()
1256 func_lookup_file "modules/$1"
1257 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1260 # func_get_license module
1262 # - local_gnulib_dir from --local-dir
1265 func_lookup_file "modules/$1"
1266 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1267 # The default is GPL.
1269 } | sed -e 's,^ *$,,' | sed -e 1q
1272 # func_get_maintainer module
1274 # - local_gnulib_dir from --local-dir
1275 func_get_maintainer ()
1277 func_lookup_file "modules/$1"
1278 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1281 # func_get_tests_module module
1283 # - local_gnulib_dir from --local-dir
1284 func_get_tests_module ()
1286 # The naming convention for tests modules is hardwired: ${module}-tests.
1287 if test -f "$gnulib_dir/modules/$1"-tests \
1288 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1289 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1294 # func_acceptable module
1295 # tests whether a module is acceptable.
1297 # - avoidlist list of modules to avoid
1300 for avoid in $avoidlist; do
1301 if test "$avoid" = "$1"; then
1308 # func_modules_transitive_closure
1310 # - local_gnulib_dir from --local-dir
1311 # - modules list of specified modules
1312 # - inctests true if tests should be included, blank otherwise
1313 # - avoidlist list of modules to avoid
1314 # - tmp pathname of a temporary directory
1316 # - modules list of modules, including dependencies
1317 func_modules_transitive_closure ()
1319 # In order to process every module only once (for speed), process an "input
1320 # list" of modules, producing an "output list" of modules. During each round,
1321 # more modules can be queued in the input list. Once a module on the input
1322 # list has been processed, it is added to the "handled list", so we can avoid
1323 # to process it again.
1325 inmodules="$modules"
1327 while test -n "$inmodules"; do
1328 inmodules_this_round="$inmodules"
1329 inmodules= # Accumulator, queue for next round
1330 for module in $inmodules_this_round; do
1332 if test -n "$module"; then
1333 if func_acceptable $module; then
1334 func_append outmodules " $module"
1335 deps=`func_get_dependencies $module`
1336 # Duplicate dependencies are harmless, but Jim wants a warning.
1337 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1338 if test -n "$duplicated_deps"; then
1339 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1341 func_append inmodules " $deps"
1342 if test -n "$inctests"; then
1343 testsmodule=`func_get_tests_module $module`
1344 if test -n "$testsmodule"; then
1345 func_append inmodules " $testsmodule"
1351 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1352 # Remove $handledmodules from $inmodules.
1353 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1354 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1356 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1357 rm -f "$tmp"/queued-modules
1360 # func_modules_add_dummy
1362 # - local_gnulib_dir from --local-dir
1363 # - modules list of modules, including dependencies
1365 # - modules list of modules, including 'dummy' if needed
1366 func_modules_add_dummy ()
1369 sed_remove_backslash_newline=':a
1376 for module in $modules; do
1377 func_verify_nontests_module
1378 if test -n "$module"; then
1379 # Extract the value of "lib_SOURCES += ...".
1380 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1381 # Ignore .h files since they are not compiled.
1384 *) have_lib_SOURCES=yes ;;
1389 # Add the dummy module, to make sure the library will be non-empty.
1390 if test -z "$have_lib_SOURCES"; then
1391 if func_acceptable "dummy"; then
1392 func_append modules " dummy"
1397 # func_modules_to_filelist
1399 # - local_gnulib_dir from --local-dir
1400 # - modules list of modules, including dependencies
1402 # - files list of files
1403 func_modules_to_filelist ()
1406 for module in $modules; do
1408 if test -n "$module"; then
1409 fs=`func_get_filelist $module`
1410 func_append files " $fs"
1413 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1416 # func_emit_lib_Makefile_am
1417 # emits the contents of library makefile to standard output.
1419 # - local_gnulib_dir from --local-dir
1420 # - modules list of modules, including dependencies
1421 # - libname library name
1422 # - auxdir directory relative to destdir where to place build aux files
1423 # - makefile_name from --makefile-name
1424 # - libtool true if libtool will be used, false or blank otherwise
1425 # - macro_prefix prefix of gl_LIBOBJS macros to use
1426 # - actioncmd (optional) command that will reproduce this invocation
1427 # - for_test true if creating a package for testing, false otherwise
1429 # - uses_subdirs nonempty if object files in subdirs exist
1430 func_emit_lib_Makefile_am ()
1432 # When creating an includable Makefile.am snippet, augment variables with
1433 # += instead of assigning them.
1434 if test -n "$makefile_name"; then
1439 if test "$libtool" = true; then
1442 sed_eliminate_LDFLAGS=
1446 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1449 # When creating a package for testing: Attempt to provoke failures,
1450 # especially link errors, already during "make" rather than during
1451 # "make check", because "make check" is not possible in a cross-compiling
1452 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1453 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1455 sed_transform_check_PROGRAMS=
1457 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1458 echo "## Process this file with automake to produce Makefile.in."
1459 func_emit_copyright_notice
1460 if test -n "$actioncmd"; then
1461 echo "# Reproduce by: $actioncmd"
1466 for module in $modules; do
1467 func_verify_nontests_module
1468 if test -n "$module"; then
1470 func_get_automake_snippet "$module" |
1471 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1472 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1473 -e "$sed_eliminate_LDFLAGS" \
1474 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1475 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1476 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1477 -e "$sed_transform_check_PROGRAMS"
1478 if test "$module" = 'alloca'; then
1479 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1480 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1483 # Skip the contents if its entirely empty.
1484 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1485 echo "## begin gnulib module $module"
1488 echo "## end gnulib module $module"
1492 # Test whether there are some source files in subdirectories.
1493 for f in `func_get_filelist "$module"`; do
1495 lib/*/*.c) uses_subdirs=yes ;;
1501 if test -z "$makefile_name"; then
1502 # If there are source files in subdirectories, prevent collision of the
1503 # object files (example: hash.c and libxml/hash.c).
1505 if test -n "$uses_subdirs"; then
1506 subdir_options=' subdir-objects'
1508 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1511 if test -z "$makefile_name"; then
1512 echo "noinst_HEADERS ="
1513 echo "noinst_LIBRARIES ="
1514 echo "noinst_LTLIBRARIES ="
1515 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1516 # if you specify pkgdata_DATA to empty. This is a workaround.
1517 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1518 echo "pkgdata_DATA ="
1521 echo "BUILT_SOURCES ="
1524 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1525 if test -z "$makefile_name"; then
1526 echo "MOSTLYCLEANDIRS ="
1528 echo "DISTCLEANFILES ="
1529 echo "MAINTAINERCLEANFILES ="
1531 echo "AM_CPPFLAGS ="
1534 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1535 # One of the snippets already specifies an installation location for the
1536 # library. Don't confuse automake by saying it should not be installed.
1539 # By default, the generated library should not be installed.
1540 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1543 echo "${libname}_${libext}_SOURCES ="
1544 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1545 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1546 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1547 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1548 echo "EXTRA_${libname}_${libext}_SOURCES ="
1549 if test "$libtool" = true; then
1550 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1553 cat allsnippets.tmp \
1554 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1556 echo "mostlyclean-local: mostlyclean-generic"
1557 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1558 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1559 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1563 rm -f allsnippets.tmp
1566 # func_emit_tests_Makefile_am
1567 # emits the contents of tests makefile to standard output.
1569 # - local_gnulib_dir from --local-dir
1570 # - modules list of modules, including dependencies
1571 # - libname library name
1572 # - makefile_name from --makefile-name
1573 # - libtool true if libtool will be used, false or blank otherwise
1574 # - sourcebase relative directory containing lib source code
1575 # - m4base relative directory containing autoconf macros
1576 # - testsbase relative directory containing unit test code
1577 # - for_test true if creating a package for testing, false otherwise
1578 func_emit_tests_Makefile_am ()
1580 if test "$libtool" = true; then
1585 if test "$libtool" = true; then
1587 sed_eliminate_LDFLAGS=
1590 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1593 # When creating a package for testing: Attempt to provoke failures,
1594 # especially link errors, already during "make" rather than during
1595 # "make check", because "make check" is not possible in a cross-compiling
1596 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1597 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1599 sed_transform_check_PROGRAMS=
1601 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1602 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1603 echo "## Process this file with automake to produce Makefile.in."
1604 func_emit_copyright_notice
1606 # Generate dependencies here, since it eases the debugging of test failures.
1607 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1609 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1612 for module in $modules; do
1613 func_verify_tests_module
1614 if test -n "$module"; then
1616 func_get_automake_snippet "$module" |
1617 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1618 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1619 -e "$sed_eliminate_LDFLAGS" \
1620 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1621 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1622 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1623 -e "$sed_transform_check_PROGRAMS"
1625 # Skip the contents if its entirely empty.
1626 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1627 echo "## begin gnulib module $module"
1630 echo "## end gnulib module $module"
1637 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1638 # variable is needed to avoid an error from automake:
1639 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1642 echo "TESTS_ENVIRONMENT ="
1643 echo "noinst_PROGRAMS ="
1644 if ! $for_test; then
1645 echo "check_PROGRAMS ="
1647 echo "noinst_HEADERS ="
1648 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1649 echo "pkgdata_DATA ="
1652 echo "BUILT_SOURCES ="
1654 echo "MOSTLYCLEANFILES = core *.stackdump"
1655 echo "MOSTLYCLEANDIRS ="
1657 echo "DISTCLEANFILES ="
1658 echo "MAINTAINERCLEANFILES ="
1660 echo "AM_CPPFLAGS = \\"
1661 echo " -I. -I\$(srcdir) \\"
1662 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1663 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1665 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1668 echo "# Clean up after Solaris cc."
1670 echo " rm -rf SunWS_cache"
1672 echo "mostlyclean-local: mostlyclean-generic"
1673 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1674 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1675 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1679 rm -f allsnippets.tmp
1682 # func_emit_initmacro_start
1683 # emits the first few statements of the gl_INIT macro to standard output.
1684 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1685 func_emit_initmacro_start ()
1687 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1688 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1689 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1690 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1692 # Furthermore it avoids an automake error like this when a Makefile.am
1693 # that uses pieces of gnulib also uses $(LIBOBJ):
1694 # automatically discovered file `error.c' should not be explicitly mentioned
1695 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1696 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1697 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1698 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1699 # automatically discovered file `error.c' should not be explicitly mentioned
1700 # We let automake know about the files to be distributed through the
1701 # EXTRA_lib_SOURCES variable.
1702 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1705 # func_emit_initmacro_end
1706 # emits the last few statements of the gl_INIT macro to standard output.
1707 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1708 func_emit_initmacro_end ()
1710 echo " m4_popdef([AC_LIBSOURCES])"
1711 echo " m4_popdef([AC_REPLACE_FUNCS])"
1712 echo " m4_popdef([AC_LIBOBJ])"
1713 echo " AC_CONFIG_COMMANDS_PRE(["
1714 echo " ${macro_prefix}_libobjs="
1715 echo " ${macro_prefix}_ltlibobjs="
1716 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1717 echo " # Remove the extension."
1718 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1719 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1720 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1721 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1724 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1725 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1729 # func_emit_initmacro_done
1730 # emits a few statements after the gl_INIT macro to standard output.
1731 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1732 func_emit_initmacro_done ()
1735 echo "# Like AC_LIBOBJ, except that the module name goes"
1736 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1737 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1738 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1740 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1741 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1742 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1743 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1745 echo "# Like AC_LIBSOURCES, except that it does nothing."
1746 echo "# We rely on EXTRA_lib..._SOURCES instead."
1747 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1751 # func_import modules
1752 # Uses also the variables
1753 # - destdir target directory
1754 # - local_gnulib_dir from --local-dir
1755 # - libname library name
1756 # - sourcebase directory relative to destdir where to place source code
1757 # - m4base directory relative to destdir where to place *.m4 macros
1758 # - docbase directory relative to destdir where to place doc files
1759 # - testsbase directory relative to destdir where to place unit test code
1760 # - auxdir directory relative to destdir where to place build aux files
1761 # - inctests true if --with-tests was given, blank otherwise
1762 # - avoidlist list of modules to avoid, from --avoid
1763 # - lgpl true if library's license shall be LGPL, blank otherwise
1764 # - makefile_name from --makefile-name
1765 # - libtool true if --libtool was given, false if --no-libtool was
1766 # given, blank otherwise
1767 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1768 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1769 # - autoconf_minversion minimum supported autoconf version
1770 # - doit : if actions shall be executed, false if only to be printed
1771 # - symbolic true if files should be symlinked, copied otherwise
1772 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1774 # - do_copyrights true if copyright notices in files should be replaced,
1778 # Get the cached settings.
1779 cached_local_gnulib_dir=
1780 cached_specified_modules=
1789 cached_makefile_name=
1791 cached_macro_prefix=
1793 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1794 cached_libtool=false
1800 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1803 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1806 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1809 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1812 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1815 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1818 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1821 s,^.*$,cached_inctests=true,p
1824 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1827 s,^.*$,cached_lgpl=true,p
1829 /gl_MAKEFILE_NAME(/ {
1830 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1833 s,^.*$,cached_libtool=true,p
1835 /gl_MACRO_PREFIX(/ {
1836 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1838 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1839 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1844 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1845 s,^.*$,cached_files=",p
1857 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1861 # Merge the cached settings with the specified ones.
1862 # The m4base must be the same as expected from the pathname.
1863 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1864 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1866 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1867 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1868 if test -z "$local_gnulib_dir"; then
1869 if test -n "$cached_local_gnulib_dir"; then
1872 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1874 case "$cached_local_gnulib_dir" in
1876 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1878 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1879 local_gnulib_dir="$relconcat" ;;
1884 # Append the cached and the specified module names. So that
1885 # "gnulib-tool --import foo" means to add the module foo.
1886 specified_modules="$cached_specified_modules $1"
1887 # Append the cached and the specified avoidlist. This is probably better
1888 # than dropping the cached one when --avoid is specified at least once.
1889 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
1890 avoidlist=`echo $avoidlist`
1892 # The sourcebase defaults to the cached one.
1893 if test -z "$sourcebase"; then
1894 sourcebase="$cached_sourcebase"
1895 if test -z "$sourcebase"; then
1896 func_fatal_error "missing --source-base option"
1899 # The docbase defaults to the cached one.
1900 if test -z "$docbase"; then
1901 docbase="$cached_docbase"
1902 if test -z "$docbase"; then
1903 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."
1906 # The testsbase defaults to the cached one.
1907 if test -z "$testsbase"; then
1908 testsbase="$cached_testsbase"
1909 if test -z "$testsbase"; then
1910 func_fatal_error "missing --tests-base option"
1913 # Require the tests if specified either way.
1914 if test -z "$inctests"; then
1915 inctests="$cached_inctests"
1917 # The libname defaults to the cached one.
1918 if test -z "$supplied_libname"; then
1919 libname="$cached_libname"
1920 if test -z "$libname"; then
1921 func_fatal_error "missing --lib option"
1924 # Require LGPL if specified either way.
1925 if test -z "$lgpl"; then
1928 # The makefile_name defaults to the cached one.
1929 if test -z "$makefile_name"; then
1930 makefile_name="$cached_makefile_name"
1932 # Use libtool if specified either way, or if guessed.
1933 if test -z "$libtool"; then
1934 if test -n "$cached_m4base"; then
1935 libtool="$cached_libtool"
1937 libtool="$guessed_libtool"
1940 # The macro_prefix defaults to the cached one.
1941 if test -z "$macro_prefix"; then
1942 macro_prefix="$cached_macro_prefix"
1943 if test -z "$macro_prefix"; then
1944 func_fatal_error "missing --macro-prefix option"
1948 # Canonicalize the list of specified modules.
1949 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1951 # Determine final module list.
1952 modules="$specified_modules"
1953 func_modules_transitive_closure
1954 echo "Module list with included dependencies:"
1955 echo "$modules" | sed -e 's/^/ /'
1957 # Add the dummy module if needed.
1958 func_modules_add_dummy
1960 # If --lgpl, verify that the licenses of modules are compatible.
1961 if test -n "$lgpl"; then
1962 for module in $modules; do
1963 license=`func_get_license $module`
1965 LGPL | LGPLv2+ | 'GPLed build tool') ;;
1966 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1967 *) func_fatal_error "incompatible license on module $module: $license" ;;
1972 # Determine script to apply to imported library files.
1973 sed_transform_lib_file=
1974 for module in $modules; do
1975 if test $module = config-h; then
1976 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1977 sed_transform_lib_file=$sed_transform_lib_file'
1978 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1983 if test -n "$do_copyrights"; then
1984 if test -n "$lgpl"; then
1986 sed_transform_lib_file=$sed_transform_lib_file'
1987 s/GNU General/GNU Lesser General/g
1988 s/version 2\([ ,]\)/version 2.1\1/g
1993 # Determine final file list.
1994 func_modules_to_filelist
1996 echo "$files" | sed -e 's/^/ /'
1999 || func_fatal_error "refusing to do nothing"
2001 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2002 new_files="$files m4/gnulib-tool.m4"
2003 old_files="$cached_files"
2004 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2005 func_append old_files " m4/gnulib-tool.m4"
2008 sed_rewrite_old_files="\
2009 s,^build-aux/,$auxdir/,
2010 s,^doc/,$cached_docbase/,
2011 s,^lib/,$cached_sourcebase/,
2012 s,^m4/,$cached_m4base/,
2013 s,^tests/,$cached_testsbase/,"
2014 sed_rewrite_new_files="\
2015 s,^build-aux/,$auxdir/,
2017 s,^lib/,$sourcebase/,
2019 s,^tests/,$testsbase/,"
2021 # Create directories.
2022 { echo "$sourcebase"
2024 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2025 if test -n "$docfiles"; then
2028 if test -n "$inctests"; then
2032 for f in $files; do echo $f; done \
2033 | sed -e "$sed_rewrite_new_files" \
2034 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2037 { # Rearrange file descriptors. Needed because "while ... done < ..."
2038 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2039 exec 5<&0 < "$tmp"/dirs
2041 if test ! -d "$destdir/$d"; then
2043 echo "Creating directory $destdir/$d"
2044 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2046 echo "Create directory $destdir/$d"
2053 # func_dest_tmpfilename file
2054 # determines the name of a temporary file (file is relative to destdir).
2056 # - tmpfile absolute filename of the temporary file
2057 func_dest_tmpfilename ()
2060 # Put the new contents of $file in a file in the same directory (needed
2061 # to guarantee that an 'mv' to "$destdir/$file" works).
2062 tmpfile="$destdir/$1.tmp"
2064 # Put the new contents of $file in a file in a temporary directory
2065 # (because the directory of "$file" might not exist).
2066 tmpfile="$tmp"/`basename "$1"`.tmp
2070 # Copy files or make symbolic links. Remove obsolete files.
2074 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2075 # representing the files according to the last gnulib-tool invocation.
2076 for f in $old_files; do echo $f; done \
2077 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2080 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2081 # representing the files after this gnulib-tool invocation.
2082 for f in $new_files; do echo $f; done \
2083 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2086 # First the files that are in old-files, but not in new-files:
2087 sed_take_first_column='s,'"$delimiter"'.*,,'
2088 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2089 # Remove the file. Do nothing if the user already removed it.
2090 if test -f "$destdir/$g"; then
2092 echo "Removing file $g (backup in ${g}~)"
2093 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2095 echo "Remove file $g (backup in ${g}~)"
2097 func_append removed_files "$g$nl"
2100 # func_add_or_update handles a file that ought to be present afterwards.
2102 # - f the original file name
2103 # - g the rewritten file name
2104 # - already_present nonempty if the file already exists, empty otherwise
2105 func_add_or_update ()
2107 func_dest_tmpfilename "$g"
2108 func_lookup_file "$f"
2109 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2110 if test -n "$sed_transform_lib_file"; then
2113 sed -e "$sed_transform_lib_file" \
2114 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2118 if test -f "$destdir/$g"; then
2119 # The file already exists.
2120 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2121 : # The file has not changed.
2125 if test -n "$already_present"; then
2126 echo "Updating file $g (backup in ${g}~)"
2128 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2130 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2131 if { test -n "$symbolic" \
2132 || { test -n "$lsymbolic" \
2133 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2134 && test -z "$lookedup_tmp" \
2135 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2136 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2138 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2141 if test -n "$already_present"; then
2142 echo "Update file $g (backup in ${g}~)"
2144 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2150 # Don't protest if the file should be there but isn't: it happens
2151 # frequently that developers don't put autogenerated files into CVS.
2153 echo "Copying file $g"
2154 if { test -n "$symbolic" \
2155 || { test -n "$lsymbolic" \
2156 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2157 && test -z "$lookedup_tmp" \
2158 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2159 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2161 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2166 func_append added_files "$g$nl"
2170 # Then the files that are in new-files, but not in old-files:
2171 sed_take_last_column='s,^.*'"$delimiter"',,'
2173 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2174 | sed -e "$sed_take_last_column" \
2175 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2176 { # Rearrange file descriptors. Needed because "while ... done < ..."
2177 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2178 exec 5<&0 < "$tmp"/added-files
2184 # Then the files that are in new-files and in old-files:
2185 already_present=true
2186 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2187 | sed -e "$sed_take_last_column" \
2188 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2189 { # Rearrange file descriptors. Needed because "while ... done < ..."
2190 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2191 exec 5<&0 < "$tmp"/kept-files
2198 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2199 actioncmd="gnulib-tool --import"
2200 func_append actioncmd " --dir=$destdir"
2201 if test -n "$local_gnulib_dir"; then
2202 func_append actioncmd " --local-dir=$local_gnulib_dir"
2204 func_append actioncmd " --lib=$libname"
2205 func_append actioncmd " --source-base=$sourcebase"
2206 func_append actioncmd " --m4-base=$m4base"
2207 func_append actioncmd " --doc-base=$docbase"
2208 func_append actioncmd " --aux-dir=$auxdir"
2209 if test -n "$inctests"; then
2210 func_append actioncmd " --with-tests"
2212 for module in $avoidlist; do
2213 func_append actioncmd " --avoid=$module"
2215 if test -n "$lgpl"; then
2216 func_append actioncmd " --lgpl"
2218 if test -n "$makefile_name"; then
2219 func_append actioncmd " --makefile-name=$makefile_name"
2221 if test "$libtool" = true; then
2222 func_append actioncmd " --libtool"
2224 func_append actioncmd " --no-libtool"
2226 func_append actioncmd " --macro-prefix=$macro_prefix"
2227 func_append actioncmd " `echo $specified_modules`"
2229 # Default the makefile name to Makefile.am.
2230 if test -n "$makefile_name"; then
2231 makefile_am=$makefile_name
2233 makefile_am=Makefile.am
2236 # Create normal Makefile.ams.
2239 # Create library makefile.
2240 func_dest_tmpfilename $sourcebase/$makefile_am
2241 func_emit_lib_Makefile_am > "$tmpfile"
2242 if test -f "$destdir"/$sourcebase/$makefile_am; then
2243 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2247 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2248 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2249 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2251 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2257 echo "Creating $sourcebase/$makefile_am"
2258 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2260 echo "Create $sourcebase/$makefile_am"
2263 func_append added_files "$sourcebase/$makefile_am$nl"
2266 # Create m4/gnulib-cache.m4.
2267 func_dest_tmpfilename $m4base/gnulib-cache.m4
2269 func_emit_copyright_notice
2271 echo "# This file represents the specification of how gnulib-tool is used."
2272 echo "# It acts as a cache: It is written and read by gnulib-tool."
2273 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2274 echo "# like the configure.ac and various Makefile.am files."
2277 echo "# Specification in the form of a command-line invocation:"
2280 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2281 # Store the local_gnulib_dir relative to destdir.
2282 case "$local_gnulib_dir" in
2284 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2287 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2289 # destdir, local_gnulib_dir are both relative.
2290 func_relativize "$destdir" "$local_gnulib_dir"
2291 relative_local_gnulib_dir="$reldir" ;;
2294 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2295 echo "gl_MODULES(["`echo $specified_modules`"])"
2296 echo "gl_AVOID([$avoidlist])"
2297 echo "gl_SOURCE_BASE([$sourcebase])"
2298 echo "gl_M4_BASE([$m4base])"
2299 echo "gl_DOC_BASE([$docbase])"
2300 echo "gl_TESTS_BASE([$testsbase])"
2301 test -z "$inctests" || echo "gl_WITH_TESTS"
2302 echo "gl_LIB([$libname])"
2303 test -z "$lgpl" || echo "gl_LGPL"
2304 echo "gl_MAKEFILE_NAME([$makefile_name])"
2305 if test "$libtool" = true; then
2308 echo "gl_MACRO_PREFIX([$macro_prefix])"
2310 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2311 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2315 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2316 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2317 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2319 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2323 echo "# gnulib-cache.m4 ends here"
2330 echo "Creating $m4base/gnulib-cache.m4"
2331 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2333 echo "Create $m4base/gnulib-cache.m4"
2339 # Create m4/gnulib-comp.m4.
2340 func_dest_tmpfilename $m4base/gnulib-comp.m4
2342 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2343 func_emit_copyright_notice
2345 echo "# This file represents the compiled summary of the specification in"
2346 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2347 echo "# to be invoked from configure.ac."
2348 echo "# In projects using CVS, this file can be treated like other built files."
2351 echo "# This macro should be invoked from $configure_ac, in the section"
2352 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2353 echo "# any checks for libraries, header files, types and library functions."
2354 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2356 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2357 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2358 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2359 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2360 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2361 if test -n "$uses_subdirs"; then
2362 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2364 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2365 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2367 for module in $modules; do
2369 if test -n "$module"; then
2370 func_get_autoconf_early_snippet "$module"
2373 | sed -e '/^$/d;' -e 's/^/ /'
2376 echo "# This macro should be invoked from $configure_ac, in the section"
2377 echo "# \"Check for header files, types and library functions\"."
2378 echo "AC_DEFUN([${macro_prefix}_INIT],"
2380 func_emit_initmacro_start
2381 if test "$libtool" = true; then
2382 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2383 echo " gl_cond_libtool=true"
2385 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2386 echo " gl_cond_libtool=false"
2388 echo " gl_ltlibdeps="
2390 echo " gl_source_base='$sourcebase'"
2391 if test "$auxdir" != "build-aux"; then
2392 sed_replace_build_aux='
2394 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2395 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2399 sed_replace_build_aux=
2401 for module in $modules; do
2403 if test -n "$module"; then
2404 func_get_autoconf_snippet "$module" \
2405 | sed -e '/^$/d;' -e 's/^/ /' \
2406 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2407 -e "$sed_replace_build_aux"
2408 if test "$module" = 'alloca' && test "$libtool" = true; then
2409 echo 'changequote(,)dnl'
2410 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2411 echo 'changequote([, ])dnl'
2412 echo 'AC_SUBST([LTALLOCA])'
2416 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2417 # created using libtool, because libtool already handles the dependencies.
2418 if test "$libtool" != true; then
2419 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
2420 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2421 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2422 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2423 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2425 func_emit_initmacro_end
2427 func_emit_initmacro_done
2429 echo "# This macro records the list of files which have been installed by"
2430 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2431 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2432 echo "$files" | sed -e 's,^, ,'
2435 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2436 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2440 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2441 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2442 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2444 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2448 echo "# gnulib-comp.m4 ends here"
2455 echo "Creating $m4base/gnulib-comp.m4"
2456 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2458 echo "Create $m4base/gnulib-comp.m4"
2464 if test -n "$inctests"; then
2465 # Create tests makefile.
2466 func_dest_tmpfilename $testsbase/$makefile_am
2467 func_emit_tests_Makefile_am > "$tmpfile"
2468 if test -f "$destdir"/$testsbase/$makefile_am; then
2469 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2473 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2474 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2475 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2477 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2483 echo "Creating $testsbase/$makefile_am"
2484 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2486 echo "Create $testsbase/$makefile_am"
2489 func_append added_files "$testsbase/$makefile_am$nl"
2493 # Update the .cvsignore and .gitignore files.
2494 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
2495 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
2496 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
2497 { # Rearrange file descriptors. Needed because "while ... done < ..."
2498 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2499 exec 5<&0 < "$tmp"/fileset-changes
2500 func_update_ignorelist ()
2503 if test -f "$destdir/$dir$ignore"; then
2504 if test -n "$dir_added" || test -n "$dir_removed"; then
2505 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
2506 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
2507 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
2508 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
2509 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
2510 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
2512 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2513 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
2514 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
2515 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
2516 | sed -f "$tmp"/sed-ignore-removed \
2517 > "$destdir/$dir$ignore"
2519 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2524 if test -n "$dir_added"; then
2526 echo "Creating $destdir/$dir$ignore"
2527 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u > "$destdir/$dir$ignore"
2529 echo "Create $destdir/$dir$ignore"
2539 if test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
2540 func_update_ignorelist .cvsignore
2542 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
2543 func_update_ignorelist .gitignore
2550 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
2551 next_dir=`echo "$line" | sed -e 's,|.*,,'`
2552 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
2553 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
2554 if test "$next_dir" != "$last_dir"; then
2555 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2556 last_dir="$next_dir"
2561 A) func_append last_dir_added "$file$nl";;
2562 R) func_append last_dir_removed "$file$nl";;
2565 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2571 echo "You may need to add #include directives for the following .h files."
2572 # Intersect $specified_modules and $modules
2573 # (since $specified_modules is not necessarily of subset of $modules - some
2574 # may have been skipped through --avoid, and since the elements of $modules
2575 # but not in $specified_modules can go away without explicit notice - through
2576 # changes in the module dependencies).
2577 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2578 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2579 # First the #include <...> directives without #ifs, sorted for convenience,
2580 # then the #include "..." directives without #ifs, sorted for convenience,
2581 # then the #include directives that are surrounded by #ifs. Not sorted.
2582 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2583 include_directive=`func_get_include_directive "$module"`
2584 case "$nl$include_directive" in
2586 echo "$include_directive" 1>&5
2589 echo "$include_directive" | grep -v 'include "' 1>&6
2590 echo "$include_directive" | grep 'include "' 1>&7
2593 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2595 LC_ALL=C sort -u "$tmp"/include-angles
2596 LC_ALL=C sort -u "$tmp"/include-quotes
2597 cat "$tmp"/include-if
2598 ) | sed -e '/^$/d' -e 's/^/ /'
2599 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2601 for module in $modules; do
2602 func_get_link_directive "$module"
2604 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
2605 if test `wc -l < "$tmp"/link` != 0; then
2607 echo "You may need to use the following Makefile variables when linking."
2608 echo "Use them in <program>_LDADD when linking a program, or"
2609 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
2615 echo "Don't forget to"
2616 if test "$makefile_am" = Makefile.am; then
2617 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2619 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2621 if test -n "$inctests"; then
2622 if test "$makefile_am" = Makefile.am; then
2623 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2625 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2628 if test "$makefile_am" = Makefile.am; then
2629 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2630 sourcebase_base=`basename "$sourcebase"`
2631 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2633 if test -n "$inctests"; then
2634 if test "$makefile_am" = Makefile.am; then
2635 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2636 testsbase_base=`basename "$testsbase"`
2637 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2640 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2641 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2642 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2645 # func_create_testdir testdir modules
2647 # - local_gnulib_dir from --local-dir
2648 # - auxdir directory relative to destdir where to place build aux files
2649 func_create_testdir ()
2653 if test -z "$modules"; then
2654 # All modules together.
2655 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2656 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2657 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2658 modules=`func_all_modules`
2659 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2661 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2663 # Check that the license of every module is consistent with the license of
2665 saved_modules="$modules"
2666 saved_inctests="$inctests"
2667 # When computing transitive closures, don't consider $module to depend on
2668 # $module-tests. Need this becauses tests are implicitly GPL and may depend
2669 # on GPL modules - therefore we don't want a warning in this case.
2671 for requested_module in $saved_modules; do
2672 requested_license=`func_get_license "$requested_module"`
2673 if test "$requested_license" != GPL; then
2674 # Here we use func_modules_transitive_closure, not just
2675 # func_get_dependencies, so that we also detect weird situations like
2676 # an LGPL module which depends on a GPLed build tool module which depends
2678 modules="$requested_module"
2679 func_modules_transitive_closure
2680 for module in $modules; do
2681 license=`func_get_license "$module"`
2683 'GPLed build tool') ;;
2684 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2686 case "$requested_license" in
2689 GPLv2+ | LGPLv2+) ;;
2690 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2696 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2702 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2711 modules="$saved_modules"
2712 inctests="$saved_inctests"
2714 # Subdirectory names.
2721 # Determine final module list.
2722 func_modules_transitive_closure
2723 echo "Module list with included dependencies:"
2724 echo "$modules" | sed -e 's/^/ /'
2726 # Add the dummy module if needed.
2727 func_modules_add_dummy
2729 # Determine final file list.
2730 func_modules_to_filelist
2732 echo "$files" | sed -e 's/^/ /'
2734 sed_rewrite_files="\
2735 s,^build-aux/,$auxdir/,
2737 s,^lib/,$sourcebase/,
2739 s,^tests/,$testsbase/,"
2741 # Create directories.
2742 for f in $files; do echo $f; done \
2743 | sed -e "$sed_rewrite_files" \
2744 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2745 | LC_ALL=C sort -u \
2747 { # Rearrange file descriptors. Needed because "while ... done < ..."
2748 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2749 exec 5<&0 < "$tmp"/dirs
2751 mkdir -p "$testdir/$d"
2756 # Copy files or make symbolic links.
2758 for f in $files; do echo $f; done \
2759 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2762 { # Rearrange file descriptors. Needed because "while ... done < ..."
2763 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2764 exec 5<&0 < "$tmp"/files
2766 func_lookup_file "$f"
2767 if test -n "$lookedup_tmp"; then
2768 cp -p "$lookedup_file" "$testdir/$g"
2770 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2771 if { test -n "$symbolic" \
2772 || { test -n "$lsymbolic" \
2773 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
2774 func_ln "$lookedup_file" "$testdir/$g"
2776 cp -p "$lookedup_file" "$testdir/$g"
2783 # Create Makefile.ams that are for testing.
2786 # Create $sourcebase/Makefile.am.
2787 mkdir -p "$testdir/$sourcebase"
2788 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2790 # Create $m4base/Makefile.am.
2791 mkdir -p "$testdir/$m4base"
2792 (echo "## Process this file with automake to produce Makefile.in."
2798 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2801 ) > "$testdir/$m4base/Makefile.am"
2803 subdirs="$sourcebase $m4base"
2804 subdirs_with_configure_ac=""
2806 if false && test -f "$testdir"/$m4base/gettext.m4; then
2807 # Avoid stupid error message from automake:
2808 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2809 mkdir -p "$testdir/po"
2810 (echo "## Process this file with automake to produce Makefile.in."
2811 ) > "$testdir/po/Makefile.am"
2812 func_append subdirs " po"
2815 if test -n "$inctests"; then
2816 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2817 # Create $testsbase/Makefile.am.
2818 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2819 # Create $testsbase/configure.ac.
2820 (echo "# Process this file with autoconf to produce a configure script."
2821 echo "AC_INIT([dummy], [0])"
2822 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2823 echo "AM_INIT_AUTOMAKE"
2825 echo "AM_CONFIG_HEADER([config.h])"
2828 echo "AC_PROG_INSTALL"
2829 echo "AC_PROG_MAKE_SET"
2830 echo "AC_PROG_RANLIB"
2832 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2833 echo "AC_GNU_SOURCE"
2836 for module in $modules; do
2838 if test -n "$module"; then
2839 func_get_autoconf_early_snippet "$module"
2842 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
2843 if test "$libtool" = true; then
2844 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2845 echo "gl_cond_libtool=true"
2847 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2848 echo "gl_cond_libtool=false"
2850 echo "gl_ltlibdeps="
2852 # Wrap the set of autoconf snippets into an autoconf macro that is then
2853 # invoked. This is needed because autoconf does not support AC_REQUIRE
2855 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2856 # but we want the AC_REQUIRE to have its normal meaning (provide one
2857 # expansion of the required macro before the current point, and only one
2859 echo "AC_DEFUN([gl_INIT], ["
2860 func_emit_initmacro_start
2861 sed_replace_build_aux='
2863 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2864 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2867 # We don't have explicit ordering constraints between the various
2868 # autoconf snippets. It's cleanest to put those of the library before
2869 # those of the tests.
2870 echo "gl_source_base='../$sourcebase'"
2871 for module in $modules; do
2872 func_verify_nontests_module
2873 if test -n "$module"; then
2874 func_get_autoconf_snippet "$module" \
2875 | sed -e "$sed_replace_build_aux"
2878 echo "gl_source_base='.'"
2879 for module in $modules; do
2880 func_verify_tests_module
2881 if test -n "$module"; then
2882 func_get_autoconf_snippet "$module" \
2883 | sed -e "$sed_replace_build_aux"
2886 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2887 # created using libtool, because libtool already handles the dependencies.
2888 if test "$libtool" != true; then
2889 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
2890 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2891 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2892 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2893 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2895 func_emit_initmacro_end
2897 func_emit_initmacro_done
2901 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2902 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2903 echo "AH_TOP([#include \"../config.h\"])"
2905 echo "AC_OUTPUT([Makefile])"
2906 ) > "$testdir/$testsbase/configure.ac"
2907 func_append subdirs " $testsbase"
2908 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2911 # Create Makefile.am.
2912 (echo "## Process this file with automake to produce Makefile.in."
2914 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2916 echo "SUBDIRS = $subdirs"
2918 echo "ACLOCAL_AMFLAGS = -I $m4base"
2919 ) > "$testdir/Makefile.am"
2921 # Create configure.ac.
2922 (echo "# Process this file with autoconf to produce a configure script."
2923 echo "AC_INIT([dummy], [0])"
2924 if test "$auxdir" != "."; then
2925 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2927 echo "AM_INIT_AUTOMAKE"
2929 echo "AM_CONFIG_HEADER([config.h])"
2932 echo "AC_PROG_INSTALL"
2933 echo "AC_PROG_MAKE_SET"
2935 echo "# For autobuild."
2936 echo "AC_CANONICAL_BUILD"
2937 echo "AC_CANONICAL_HOST"
2939 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2940 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2941 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2942 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2944 echo "AC_PROG_RANLIB"
2946 if test -n "$uses_subdirs"; then
2947 echo "AM_PROG_CC_C_O"
2950 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2951 echo "AC_GNU_SOURCE"
2954 for module in $modules; do
2955 func_verify_nontests_module
2956 if test -n "$module"; then
2957 func_get_autoconf_early_snippet "$module"
2960 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
2961 if test "$libtool" = true; then
2962 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2963 echo "gl_cond_libtool=true"
2965 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2966 echo "gl_cond_libtool=false"
2968 echo "gl_ltlibdeps="
2970 echo "gl_source_base='$sourcebase'"
2971 # Wrap the set of autoconf snippets into an autoconf macro that is then
2972 # invoked. This is needed because autoconf does not support AC_REQUIRE
2974 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2975 # but we want the AC_REQUIRE to have its normal meaning (provide one
2976 # expansion of the required macro before the current point, and only one
2978 echo "AC_DEFUN([gl_INIT], ["
2979 func_emit_initmacro_start
2980 if test "$auxdir" != "build-aux"; then
2981 sed_replace_build_aux='
2983 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2984 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2988 sed_replace_build_aux=
2990 for module in $modules; do
2991 func_verify_nontests_module
2992 if test -n "$module"; then
2993 func_get_autoconf_snippet "$module" \
2994 | sed -e "$sed_replace_build_aux"
2997 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2998 # created using libtool, because libtool already handles the dependencies.
2999 if test "$libtool" != true; then
3000 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3001 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3002 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3003 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3004 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3006 func_emit_initmacro_end
3008 func_emit_initmacro_done
3012 if test -n "$subdirs_with_configure_ac"; then
3013 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3015 makefiles="Makefile"
3016 for d in $subdirs; do
3017 # For subdirs that have a configure.ac by their own, it's the subdir's
3018 # configure.ac which creates the subdir's Makefile.am, not this one.
3019 case " $subdirs_with_configure_ac " in
3021 *) func_append makefiles " $d/Makefile" ;;
3024 echo "AC_OUTPUT([$makefiles])"
3025 ) > "$testdir/configure.ac"
3027 # Create autogenerated files.
3029 # Do not use "${AUTORECONF} --force --install", because it may invoke
3030 # autopoint, which brings in older versions of some of our .m4 files.
3031 if test -f $m4base/gettext.m4; then
3032 echo "executing ${AUTOPOINT} --force"
3033 ${AUTOPOINT} --force || func_exit 1
3034 for f in $m4base/*.m4~; do
3035 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3038 echo "executing ${ACLOCAL} -I $m4base"
3039 ${ACLOCAL} -I $m4base || func_exit 1
3040 if ! test -d build-aux; then
3041 echo "executing mkdir build-aux"
3042 mkdir build-aux || func_exit 1
3044 echo "executing ${AUTOCONF}"
3045 ${AUTOCONF} || func_exit 1
3046 echo "executing ${AUTOHEADER}"
3047 ${AUTOHEADER} || func_exit 1
3048 echo "executing ${AUTOMAKE} --add-missing --copy"
3049 ${AUTOMAKE} --add-missing --copy || func_exit 1
3051 if test -n "$inctests"; then
3052 # Create autogenerated files.
3053 (cd "$testdir/$testsbase" || func_exit 1
3054 # Do not use "${AUTORECONF} --force --install", because it may invoke
3055 # autopoint, which brings in older versions of some of our .m4 files.
3056 if test -f ../$m4base/gettext.m4; then
3057 echo "executing ${AUTOPOINT} --force"
3058 ${AUTOPOINT} --force || func_exit 1
3059 for f in ../$m4base/*.m4~; do
3060 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3063 echo "executing ${ACLOCAL} -I ../$m4base"
3064 ${ACLOCAL} -I ../$m4base || func_exit 1
3065 if ! test -d ../build-aux; then
3066 echo "executing mkdir ../build-aux"
3069 echo "executing ${AUTOCONF}"
3070 ${AUTOCONF} || func_exit 1
3071 echo "executing ${AUTOHEADER}"
3072 ${AUTOHEADER} || func_exit 1
3073 echo "executing ${AUTOMAKE} --add-missing --copy"
3074 ${AUTOMAKE} --add-missing --copy || func_exit 1
3077 # Need to run configure and make once, to create built files that are to be
3078 # distributed (such as getdate.c).
3079 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3080 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3081 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3082 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3083 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3084 # such $(FOO_H) because they don't refer to distributed files.
3085 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3086 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3087 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3088 | sed -e "$sed_remove_make_variables"`
3089 distributed_built_sources=`for file in $built_sources; do
3090 case "$cleaned_files" in
3095 if test -n "$distributed_built_sources"; then
3097 ./configure || func_exit 1
3099 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3100 make built_sources || func_exit 1
3102 make distclean || func_exit 1
3107 # func_create_megatestdir megatestdir allmodules
3109 # - local_gnulib_dir from --local-dir
3110 # - auxdir directory relative to destdir where to place build aux files
3111 func_create_megatestdir ()
3115 if test -z "$allmodules"; then
3116 allmodules=`func_all_modules`
3120 # First, all modules one by one.
3121 for onemodule in $allmodules; do
3122 func_create_testdir "$megatestdir/$onemodule" $onemodule
3123 func_append megasubdirs "$onemodule "
3125 # Then, all modules all together.
3126 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3127 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3128 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3129 func_create_testdir "$megatestdir/ALL" "$allmodules"
3130 func_append megasubdirs "ALL"
3133 cvsdate=`sh "$gnulib_dir/build-aux/mdate-sh" "$gnulib_dir/CVS/Entries" \
3134 | sed -e 's,January,01,' -e 's,Jan,01,' \
3135 -e 's,February,02,' -e 's,Feb,02,' \
3136 -e 's,March,03,' -e 's,Mar,03,' \
3137 -e 's,April,04,' -e 's,Apr,04,' \
3139 -e 's,June,06,' -e 's,Jun,06,' \
3140 -e 's,July,07,' -e 's,Jul,07,' \
3141 -e 's,August,08,' -e 's,Aug,08,' \
3142 -e 's,September,09,' -e 's,Sep,09,' \
3143 -e 's,October,10,' -e 's,Oct,10,' \
3144 -e 's,November,11,' -e 's,Nov,11,' \
3145 -e 's,December,12,' -e 's,Dec,12,' \
3146 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3147 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3149 echo "CVSDATE=$cvsdate"
3150 echo "test -d logs || mkdir logs"
3151 echo "for module in $megasubdirs; do"
3152 echo " echo \"Working on module \$module...\""
3153 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3154 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3157 echo " : autobuild project... \$module"
3158 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3159 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3160 echo " : autobuild hostname... \`hostname\`"
3161 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3163 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3165 ) > "$megatestdir/do-autobuild"
3166 chmod a+x "$megatestdir/do-autobuild"
3168 # Create Makefile.am.
3169 (echo "## Process this file with automake to produce Makefile.in."
3171 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3173 echo "SUBDIRS = $megasubdirs"
3175 echo "EXTRA_DIST = do-autobuild"
3176 ) > "$megatestdir/Makefile.am"
3178 # Create configure.ac.
3179 (echo "# Process this file with autoconf to produce a configure script."
3180 echo "AC_INIT([dummy], [0])"
3181 if test "$auxdir" != "."; then
3182 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3184 echo "AM_INIT_AUTOMAKE"
3186 echo "AC_PROG_MAKE_SET"
3188 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3189 echo "AC_OUTPUT([Makefile])"
3190 ) > "$megatestdir/configure.ac"
3192 # Create autogenerated files.
3194 # Do not use "${AUTORECONF} --install", because autoreconf operates
3195 # recursively, but the subdirectories are already finished, therefore
3196 # calling autoreconf here would only waste lots of CPU time.
3197 echo "executing ${ACLOCAL}"
3198 ${ACLOCAL} || func_exit 1
3199 echo "executing mkdir build-aux"
3201 echo "executing ${AUTOCONF}"
3202 ${AUTOCONF} || func_exit 1
3203 echo "executing ${AUTOMAKE} --add-missing --copy"
3204 ${AUTOMAKE} --add-missing --copy || func_exit 1
3210 func_fatal_error "no mode specified" ;;
3219 if test -z "$destdir"; then
3222 test -d "$destdir" \
3223 || func_fatal_error "destination directory does not exist: $destdir"
3225 # Prefer configure.ac to configure.in.
3226 if test -f "$destdir"/configure.ac; then
3227 configure_ac="$destdir/configure.ac"
3229 if test -f "$destdir"/configure.in; then
3230 configure_ac="$destdir/configure.in"
3232 func_fatal_error "cannot find $destdir/configure.ac"
3236 # Analyze configure.ac.
3238 guessed_libtool=false
3243 /AC_CONFIG_AUX_DIR/ {
3244 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3246 /A[CM]_PROG_LIBTOOL/ {
3247 s,^.*$,guessed_libtool=true,p
3249 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3251 if test -z "$auxdir"; then
3252 auxdir="$guessed_auxdir"
3255 # Determine where to apply func_import.
3256 if test -n "$m4base"; then
3257 # Apply func_import to a particular gnulib directory.
3258 # Any number of additional modules can be given.
3259 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3260 # First use of gnulib in the given m4base.
3261 test -n "$supplied_libname" || supplied_libname=true
3262 test -n "$sourcebase" || sourcebase="lib"
3263 test -n "$docbase" || docbase="doc"
3264 test -n "$testsbase" || testsbase="tests"
3265 test -n "$macro_prefix" || macro_prefix="gl"
3269 # Apply func_import to all gnulib directories.
3270 # To get this list of directories, look at Makefile.am. (Not at
3271 # configure, because it may be omitted from CVS. Also, don't run
3272 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3275 if test -f "$destdir"/Makefile.am; then
3276 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3278 for arg in $aclocal_amflags; do
3279 if test -n "$m4dir_is_next"; then
3280 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3284 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3285 func_append m4dirs " $arg"
3286 m4dirs_count=`expr $m4dirs_count + 1`
3292 if test "X$arg" = "X-I"; then
3300 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3301 if test -f "$destdir"/aclocal.m4; then
3302 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3303 sedexpr2='s,^[^/]*$,.,'
3304 sedexpr3='s,/[^/]*$,,'
3305 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3306 m4dirs_count=`echo "$m4dirs" | wc -l`
3309 if test $m4dirs_count = 0; then
3310 # First use of gnulib in a package.
3311 # Any number of additional modules can be given.
3312 test -n "$supplied_libname" || supplied_libname=true
3313 test -n "$sourcebase" || sourcebase="lib"
3315 test -n "$docbase" || docbase="doc"
3316 test -n "$testsbase" || testsbase="tests"
3317 test -n "$macro_prefix" || macro_prefix="gl"
3320 if test $m4dirs_count = 1; then
3321 # There's only one use of gnulib here. Assume the user means it.
3322 # Any number of additional modules can be given.
3323 for m4base in $m4dirs; do
3327 # Ambiguous - guess what the user meant.
3328 if test $# = 0; then
3329 # No further arguments. Guess the user wants to update all of them.
3330 for m4base in $m4dirs; do
3331 # Perform func_import in a subshell, so that variable values
3333 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
3334 # testsbase, inctests, libname, lgpl, makefile_name, libtool,
3336 # don't propagate from one directory to another.
3337 (func_import) || func_exit 1
3341 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
3349 if test -z "$destdir"; then
3350 func_fatal_error "please specify --dir option"
3353 test -d "$destdir" \
3354 || func_fatal_error "could not create destination directory"
3355 test -n "$auxdir" || auxdir="build-aux"
3356 func_create_testdir "$destdir" "$*"
3359 create-megatestdir )
3360 if test -z "$destdir"; then
3361 func_fatal_error "please specify --dir option"
3363 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3364 test -n "$auxdir" || auxdir="build-aux"
3365 func_create_megatestdir "$destdir" "$*"
3369 test -n "$destdir" || destdir=testdir$$
3370 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3371 test -n "$auxdir" || auxdir="build-aux"
3372 func_create_testdir "$destdir" "$*"
3376 ../configure || func_exit 1
3378 make check || func_exit 1
3379 make distclean || func_exit 1
3380 remaining=`find . -type f -print`
3381 if test -n "$remaining"; then
3382 echo "Remaining files:" $remaining 1>&2
3383 echo "gnulib-tool: *** Stop." 1>&2
3392 test -n "$destdir" || destdir=testdir$$
3393 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3394 test -n "$auxdir" || auxdir="build-aux"
3395 func_create_megatestdir "$destdir" "$*"
3403 remaining=`find . -type f -print`
3404 if test -n "$remaining"; then
3405 echo "Remaining files:" $remaining 1>&2
3406 echo "gnulib-tool: *** Stop." 1>&2
3414 extract-description )
3418 if test -n "$module"; then
3419 func_get_description "$module"
3428 if test -n "$module"; then
3429 func_get_filelist "$module"
3434 extract-dependencies )
3438 if test -n "$module"; then
3439 func_get_dependencies "$module"
3444 extract-autoconf-snippet )
3448 if test -n "$module"; then
3449 func_get_autoconf_snippet "$module"
3454 extract-automake-snippet )
3458 if test -n "$module"; then
3459 func_get_automake_snippet "$module"
3464 extract-include-directive )
3468 if test -n "$module"; then
3469 func_get_include_directive "$module"
3474 extract-link-directive )
3478 if test -n "$module"; then
3479 func_get_link_directive "$module"
3488 if test -n "$module"; then
3489 func_get_license "$module"
3494 extract-maintainer )
3498 if test -n "$module"; then
3499 func_get_maintainer "$module"
3504 extract-tests-module )
3508 if test -n "$module"; then
3509 func_get_tests_module "$module"
3515 func_fatal_error "unknown operation mode --$mode" ;;
3519 # Undo the effect of the previous 'trap' command. Some shellology:
3520 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3521 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3522 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3523 # 128 + signal number and is set before the trap-registered command is run.
3525 trap 'func_exit $?' 1 2 3 13 15
3530 # indent-tabs-mode: nil
3531 # whitespace-check-buffer-indent: nil