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 3 of the License, or
8 # (at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
24 cvsdatestamp='$Date: 2007-09-17 10:26:33 $'
25 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
26 # Sometimes last_checkin_date is "YYYY/MM/DD ...", sometimes "YYYY-MM-DD ...".
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
28 # version is in YYYY-MM-DD format.
33 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
37 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
38 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
42 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
45 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
48 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
49 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
50 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
51 AUTOCONF="${AUTOCONFPATH}autoconf"
53 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
54 AUTOHEADER="${AUTOCONFPATH}autoheader"
56 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
57 ACLOCAL="${AUTOMAKEPATH}aclocal"
59 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
60 AUTOMAKE="${AUTOMAKEPATH}automake"
62 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
63 AUTORECONF="${AUTOCONFPATH}autoreconf"
66 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
67 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
68 AUTOPOINT="${GETTEXTPATH}autopoint"
71 # When using GNU sed, turn off as many GNU extensions as possible,
72 # to minimize the risk of accidentally using non-portable features.
73 # However, do this only for gnulib-tool itself, not for the code that
74 # gnulib-tool generates, since we don't want "sed --posix" to leak
76 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
77 # Define sed as an alias.
78 # It is not always possible to use aliases. Aliases are guaranteed to work
79 # if the executing shell is bash and either it is invoked as /bin/sh or
80 # is a version >= 2.0, supporting shopt. This is the common case.
81 # Two other approaches (use of a variable $sed or of a function func_sed
82 # instead of an alias) require massive, fragile code changes.
83 # An other approach (use of function sed) requires `which sed` - but 'which'
84 # is hard to emulate, due to missing "test -x" on some platforms.
85 if test -n "$BASH_VERSION"; then
86 shopt -s expand_aliases >/dev/null 2>&1
88 alias sed='sed --posix'
92 # outputs to stdout the --help usage message.
96 Usage: gnulib-tool --list
97 gnulib-tool --import [module1 ... moduleN]
99 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
100 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
101 gnulib-tool --test --dir=directory module1 ... moduleN
102 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
103 gnulib-tool --extract-description module
104 gnulib-tool --extract-notice module
105 gnulib-tool --extract-filelist module
106 gnulib-tool --extract-dependencies module
107 gnulib-tool --extract-autoconf-snippet module
108 gnulib-tool --extract-automake-snippet module
109 gnulib-tool --extract-include-directive module
110 gnulib-tool --extract-link-directive module
111 gnulib-tool --extract-license module
112 gnulib-tool --extract-maintainer module
113 gnulib-tool --extract-tests-module module
116 --list print the available module names
117 --import import the given modules into the current package;
118 if no modules are specified, update the current
119 package from the current gnulib
120 --update update the current package, restore files omitted
122 --create-testdir create a scratch package with the given modules
123 --create-megatestdir create a mega scratch package with the given modules
124 one by one and all together
125 --test test the combination of the given modules
126 (recommended to use CC=\"gcc -Wall\" here)
127 --megatest test the given modules one by one and all together
128 (recommended to use CC=\"gcc -Wall\" here)
129 --extract-description extract the description
130 --extract-notice extract the notice or banner
131 --extract-filelist extract the list of files
132 --extract-dependencies extract the dependencies
133 --extract-autoconf-snippet extract the snippet for configure.ac
134 --extract-automake-snippet extract the snippet for library makefile
135 --extract-include-directive extract the #include directive
136 --extract-link-directive extract the linker directive
137 --extract-license report the license terms of the source files
139 --extract-maintainer report the maintainer(s) inside gnulib
140 --extract-tests-module report the unit test module, if it exists
143 --dir=DIRECTORY Specify the target directory.
144 For --import, this specifies where your
145 configure.ac can be found. Defaults to current
147 --local-dir=DIRECTORY Specify a local override directory where to look
148 up files before looking in gnulib's directory.
149 --verbose Increase verbosity. May be repeated.
150 --quiet Decrease verbosity. May be repeated.
152 Options for --import:
153 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
154 --source-base=DIRECTORY
155 Directory relative to --dir where source code is
156 placed (default \"lib\").
157 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
158 placed (default \"m4\").
159 --po-base=DIRECTORY Directory relative to --dir where *.po files are
160 placed (default \"po\").
161 --doc-base=DIRECTORY Directory relative to --dir where doc files are
162 placed (default \"doc\").
163 --tests-base=DIRECTORY
164 Directory relative to --dir where unit tests are
165 placed (default \"tests\").
166 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
167 tools are placed (default \"build-aux\").
168 --with-tests Include unit tests for the included modules.
169 --avoid=MODULE Avoid including the given MODULE. Useful if you
170 have code that provides equivalent functionality.
171 This option can be repeated.
172 --lgpl Abort if modules aren't available under the LGPL.
173 Also modify license template from GPL to LGPL.
174 --makefile-name=NAME Name of makefile in automake syntax in the
175 source-base and tests-base directories
176 (default \"Makefile.am\").
177 --libtool Use libtool rules.
178 --no-libtool Don't use libtool rules.
179 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
180 'gl_INIT'. Default is 'gl'.
181 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
182 the package name. A suffix '-gnulib' is appended.
183 --no-changelog don't update or create ChangeLog files
185 Options for --import and --update:
186 --dry-run For --import, only print what would have been done.
187 -s, --symbolic, --symlink Make symbolic links instead of copying files.
188 --local-symlink Make symbolic links instead of copying files, only
189 for files from the local override directory.
190 -S, --more-symlinks Make symbolic links instead of copying files, and
191 don't replace copyright notices.
193 Report bugs to <bug-gnulib@gnu.org>."
197 # outputs to stdout the --version message.
200 year=`echo "$version" | sed -e 's,-.*$,,'`
202 $progname (GNU $package) $version
203 Copyright (C) $year Free Software Foundation, Inc.
204 This is free software; see the source for copying conditions. There is NO
205 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
206 Written by" "Bruno Haible" "and" "Simon Josefsson"
209 # func_emit_copyright_notice
210 # outputs to stdout a header for a generated file.
211 func_emit_copyright_notice ()
213 echo "# Copyright (C) 2004-2007 Free Software Foundation, Inc."
215 echo "# This file is free software, distributed under the terms of the GNU"
216 echo "# General Public License. As a special exception to the GNU General"
217 echo "# Public License, this file may be distributed as part of a program"
218 echo "# that contains a configuration script generated by Autoconf, under"
219 echo "# the same distribution terms as the rest of that program."
221 echo "# Generated by gnulib-tool."
232 # creates a temporary directory.
234 # - tmp pathname of freshly created temporary directory
237 # Use the environment variable TMPDIR, falling back to /tmp. This allows
238 # users to specify a different temporary directory, for example, if their
239 # /tmp is filled up or too small.
242 # Use the mktemp program if available. If not available, hide the error
244 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
245 test -n "$tmp" && test -d "$tmp"
248 # Use a simple mkdir command. It is guaranteed to fail if the directory
249 # already exists. $RANDOM is bash specific and expands to empty in shells
250 # other than bash, ksh and zsh. Its use does not increase security;
251 # rather, it minimizes the probability of failure in a very cluttered /tmp
253 tmp=$TMPDIR/gl$$-$RANDOM
254 (umask 077 && mkdir "$tmp")
257 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
262 # func_append var value
263 # appends the given value to the shell variable var.
264 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
265 # Use bash's += operator. It reduces complexity of appending repeatedly to
266 # a single variable from O(n^2) to O(n).
274 eval "$1=\"\$$1\$2\""
278 # func_fatal_error message
279 # outputs to stderr a fatal error message, and terminates the program.
282 echo "gnulib-tool: *** $1" 1>&2
283 echo "gnulib-tool: *** Stop." 1>&2
287 # func_readlink SYMLINK
288 # outputs the target of the given symlink.
289 if (type -p readlink) > /dev/null 2>&1; then
292 # Use the readlink program from GNU coreutils.
298 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
299 # would do the wrong thing if the link target contains " -> ".
300 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
304 # func_relativize DIR1 DIR2
305 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
307 # - DIR1 relative pathname, relative to the current directory
308 # - DIR2 relative pathname, relative to the current directory
310 # - reldir relative pathname of DIR2, relative to DIR1
316 sed_first='s,^\([^/]*\)/.*$,\1,'
317 sed_rest='s,^[^/]*/*,,'
318 sed_last='s,^.*/\([^/]*\)$,\1,'
319 sed_butlast='s,/*[^/]*$,,'
320 while test -n "$dir1"; do
321 first=`echo "$dir1" | sed -e "$sed_first"`
322 if test "$first" != "."; then
323 if test "$first" = ".."; then
324 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
325 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
327 first2=`echo "$dir2" | sed -e "$sed_first"`
328 if test "$first2" = "$first"; then
329 dir2=`echo "$dir2" | sed -e "$sed_rest"`
333 dir0="$dir0"/"$first"
336 dir1=`echo "$dir1" | sed -e "$sed_rest"`
341 # func_relconcat DIR1 DIR2
342 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
344 # - DIR1 relative pathname, relative to the current directory
345 # - DIR2 relative pathname, relative to DIR1
347 # - relconcat DIR1/DIR2, relative to the current directory
352 sed_first='s,^\([^/]*\)/.*$,\1,'
353 sed_rest='s,^[^/]*/*,,'
354 sed_last='s,^.*/\([^/]*\)$,\1,'
355 sed_butlast='s,/*[^/]*$,,'
357 first=`echo "$dir2" | sed -e "$sed_first"`
358 if test "$first" = "."; then
359 dir2=`echo "$dir2" | sed -e "$sed_rest"`
360 if test -z "$dir2"; then
365 last=`echo "$dir1" | sed -e "$sed_last"`
366 while test "$last" = "."; do
367 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
368 last=`echo "$dir1" | sed -e "$sed_last"`
370 if test -z "$dir1"; then
374 if test "$first" = ".."; then
375 if test "$last" = ".."; then
376 relconcat="$dir1/$dir2"
379 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
380 dir2=`echo "$dir2" | sed -e "$sed_rest"`
381 if test -z "$dir1"; then
385 if test -z "$dir2"; then
390 relconcat="$dir1/$dir2"
398 # Like ln -s, except that SRC is given relative to the current directory (or
399 # absolute), not given relative to the directory of DEST.
405 *) # SRC is relative.
408 ln -s "`pwd`/$1" "$2" ;;
409 *) # DEST is relative too.
410 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
411 test -n "$ln_destdir" || ln_destdir="."
412 func_relativize "$ln_destdir" "$1"
420 # func_ln_if_changed SRC DEST
421 # Like func_ln, but avoids munging timestamps if the link is correct.
422 func_ln_if_changed ()
424 if test $# -ne 2; then
425 echo "usage: func_ln_if_changed SRC DEST" >&2
427 ln_target=`func_readlink "$2"`
428 if test -h "$2" && test "$1" = "$ln_target"; then
436 # Ensure an 'echo' command that does not interpret backslashes.
438 # echo '\n' | wc -l prints 1 when OK, 2 when KO
439 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
440 # This problem is a weird heritage from SVR4. BSD got it right (except that
441 # BSD echo interprets '-n' as an option, which is also not desirable).
442 # Nowadays the problem occurs in 4 situations:
443 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
444 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
445 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
446 # - in zsh, when sh-emulation is not set,
447 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
448 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
449 # - in Solaris /bin/sh and OSF/1 /bin/sh.
450 # We try the following workarounds:
451 # - for all: respawn using $CONFIG_SHELL if that is set and works.
452 # - for bash >= 2.04: unset the shell option xpg_echo.
453 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
454 # - for bash < 2.0: define echo to a function that uses cat of a here document.
455 # - for zsh: turn sh-emulation on.
456 # - for ksh: alias echo to 'print -r'.
457 # - for ksh: alias echo to a function that uses cat of a here document.
458 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
459 # the ksh workaround.
460 # - otherwise: respawn using /bin/sh and rely on the workarounds.
461 # When respawning, we pass --no-reexec as first argument, so as to avoid
462 # turning this script into a fork bomb in unlucky situations.
464 if echo '\t' | grep t > /dev/null; then
465 have_echo=yes # Lucky!
467 # Try the workarounds.
468 # Respawn using $CONFIG_SHELL if that is set and works.
469 if test -z "$have_echo" \
470 && test "X$1" != "X--no-reexec" \
471 && test -n "$CONFIG_SHELL" \
472 && test -f "$CONFIG_SHELL" \
473 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
474 exec $CONFIG_SHELL "$0" --no-reexec "$@"
477 # For bash >= 2.04: unset the shell option xpg_echo.
478 if test -z "$have_echo" \
479 && test -n "$BASH_VERSION" \
480 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
484 # For bash >= 2.0: define echo to a function that uses the printf built-in.
485 # For bash < 2.0: define echo to a function that uses cat of a here document.
486 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
487 if test -z "$have_echo" \
488 && test -n "$BASH_VERSION"; then \
489 if type printf 2>/dev/null | grep / > /dev/null; then
490 # 'printf' is not a shell built-in.
498 # 'printf' is a shell built-in.
504 if echo '\t' | grep t > /dev/null; then
508 # For zsh: turn sh-emulation on.
509 if test -z "$have_echo" \
510 && test -n "$ZSH_VERSION" \
511 && (emulate sh) >/dev/null 2>&1; then
514 # For ksh: alias echo to 'print -r'.
515 if test -z "$have_echo" \
516 && (type print) >/dev/null 2>&1; then
517 # A 'print' command exists.
518 if type print 2>/dev/null | grep / > /dev/null; then
521 # 'print' is a shell built-in.
522 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
523 # 'print' is the ksh shell built-in.
524 alias echo='print -r'
528 if test -z "$have_echo" \
529 && echo '\t' | grep t > /dev/null; then
532 # For ksh: alias echo to a function that uses cat of a here document.
533 # The ksh manual page says:
534 # "Aliasing is performed when scripts are read, not while they are executed.
535 # Therefore, for an alias to take effect, the alias definition command has
536 # to be executed before the command which references the alias is read."
537 # Because of this, we have to play strange tricks with have_echo, to ensure
538 # that the top-level statement containing the test starts after the 'alias'
540 if test -z "$have_echo"; then
547 alias echo=bsd_echo 2>/dev/null
549 if test -z "$have_echo" \
550 && echo '\t' | grep t > /dev/null; then
553 if test -z "$have_echo"; then
554 unalias echo 2>/dev/null
556 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
557 if test -z "$have_echo" \
558 && test "X$1" != "X--no-reexec" \
559 && test -f /bin/ksh; then
560 exec /bin/ksh "$0" --no-reexec "$@"
563 # Otherwise: respawn using /bin/sh.
564 if test -z "$have_echo" \
565 && test "X$1" != "X--no-reexec" \
566 && test -f /bin/sh; then
567 exec /bin/sh "$0" --no-reexec "$@"
570 if test -z "$have_echo"; then
571 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
573 if echo '\t' | grep t > /dev/null; then
576 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
578 if test "X$1" = "X--no-reexec"; then
582 # Command-line option processing.
583 # Removes the OPTIONS from the arguments. Sets the variables:
584 # - mode list or import or create-testdir or create-megatestdir
585 # - destdir from --dir
586 # - local_gnulib_dir from --local-dir
587 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
588 # - libname, supplied_libname from --lib
589 # - sourcebase from --source-base
590 # - m4base from --m4-base
591 # - pobase from --po-base
592 # - docbase from --doc-base
593 # - testsbase from --tests-base
594 # - auxdir from --aux-dir
595 # - inctests true if --with-tests was given, blank otherwise
596 # - avoidlist list of modules to avoid, from --avoid
597 # - lgpl true if --lgpl was given, blank otherwise
598 # - makefile_name from --makefile-name
599 # - libtool true if --libtool was given, false if --no-libtool was
600 # given, blank otherwise
601 # - macro_prefix from --macro-prefix
602 # - po_domain from --po-domain
603 # - autoconf_minversion minimum supported autoconf version
604 # - do_changelog false if --no-changelog was given, : otherwise
605 # - doit : if actions shall be executed, false if only to be printed
606 # - symbolic true if --symlink or --more-symlinks was given, blank
608 # - lsymbolic true if --local-symlink was given, blank otherwise
609 # - do_copyrights blank if --more-symlinks was given, true otherwise
638 while test $# -gt 0; do
643 --import | --impor | --impo | --imp | --im | --i )
646 --update | --updat | --upda | --upd | --up | --u )
649 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
652 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
653 mode=create-megatestdir
655 --test | --tes | --te | --t )
658 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
662 mode=`echo "X$1" | sed -e 's/^X--//'`
667 func_fatal_error "missing argument for --dir"
672 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
677 func_fatal_error "missing argument for --local-dir"
682 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
684 --verbose | --verbos | --verbo | --verb )
685 verbose=`expr $verbose + 1`
687 --quiet | --quie | --qui | --qu | --q )
688 verbose=`expr $verbose - 1`
693 func_fatal_error "missing argument for --lib"
696 supplied_libname=true
699 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
700 supplied_libname=true
705 func_fatal_error "missing argument for --source-base"
710 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
715 func_fatal_error "missing argument for --m4-base"
720 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
725 func_fatal_error "missing argument for --po-base"
730 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
735 func_fatal_error "missing argument for --doc-base"
740 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
745 func_fatal_error "missing argument for --tests-base"
750 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
755 func_fatal_error "missing argument for --aux-dir"
760 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
768 func_fatal_error "missing argument for --avoid"
770 func_append avoidlist " $1"
773 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
774 func_append avoidlist " $arg"
782 func_fatal_error "missing argument for --makefile-name"
787 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
798 func_fatal_error "missing argument for --macro-prefix"
803 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
808 func_fatal_error "missing argument for --po-domain"
813 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
815 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
821 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
824 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
827 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
831 --help | --hel | --he | --h )
834 --version | --versio | --versi | --vers )
838 # Stop option processing
842 echo "gnulib-tool: unknown option $1" 1>&2
843 echo "Try 'gnulib-tool --help' for more information." 1>&2
850 if test "$mode" = update; then
851 if test $# != 0; then
852 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
853 echo "Try 'gnulib-tool --help' for more information." 1>&2
854 echo "If you really want to modify the gnulib configuration of your project," 1>&2
855 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
858 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
859 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
860 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
861 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
862 || test -n "$makefile_name" || test -n "$macro_prefix" \
863 || test -n "$po_domain"; then
864 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
865 echo "Try 'gnulib-tool --help' for more information." 1>&2
866 echo "If you really want to modify the gnulib configuration of your project," 1>&2
867 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
872 if test -n "$pobase" && test -z "$po_domain"; then
873 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
874 echo "Try 'gnulib-tool --help' for more information." 1>&2
877 if test -z "$pobase" && test -n "$po_domain"; then
878 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
881 # Determine the minimum supported autoconf version from the project's
883 DEFAULT_AUTOCONF_MINVERSION="2.59"
886 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
887 if test -f "$destdir"/configure.ac; then
888 configure_ac="$destdir/configure.ac"
890 if test -f "$destdir"/configure.in; then
891 configure_ac="$destdir/configure.in"
895 if test -f configure.ac; then
896 configure_ac="configure.ac"
898 if test -f configure.in; then
899 configure_ac="configure.in"
903 if test -n "$configure_ac"; then
904 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
905 # because when some m4 files are omitted from a CVS repository,
906 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
907 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
908 # autom4te: m4 failed with exit status: 1
915 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
917 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
918 if test -n "$prereqs"; then
919 autoconf_minversion=`
920 for version in $prereqs; do echo $version; done |
921 LC_ALL=C sort -nru | sed 1q
925 if test -z "$autoconf_minversion"; then
926 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
928 case "$autoconf_minversion" in
929 1.* | 2.[0-4]* | 2.5[0-8]*)
930 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
933 # Remove trailing slashes from the directory names. This is necessary for
934 # m4base (to avoid an error in func_import) and optional for the others.
935 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
936 case "$local_gnulib_dir" in
937 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
939 case "$sourcebase" in
940 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
943 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
946 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
949 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
952 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
955 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
960 /*) self_abspathname="$0" ;;
961 */*) self_abspathname=`pwd`/"$0" ;;
964 # Iterate through the elements of $PATH.
965 # We use IFS=: instead of
966 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
967 # because the latter does not work when some PATH element contains spaces.
968 # We use a canonicalized $pathx instead of $PATH, because empty PATH
969 # elements are by definition equivalent to '.', however field splitting
970 # according to IFS=: loses empty fields in many shells:
971 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
972 # beginning, at the end, and in the middle),
973 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
974 # at the beginning and at the end,
975 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
976 # Solaris lose empty fields at the end.
977 # The 'case' statement is an optimization, to avoid evaluating the
978 # explicit canonicalization command when $PATH contains no empty fields.
980 if test "${PATH_SEPARATOR+set}" != set; then
982 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
983 chmod +x "$tmp"/conf.sh
984 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
991 if test "$PATH_SEPARATOR" = ";"; then
992 # On Windows, programs are searched in "." before $PATH.
995 # On Unix, we have to convert empty PATH elements to ".".
999 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
1004 IFS="$PATH_SEPARATOR"
1008 if test -x "$d/$0" && test ! -d "$d/$0"; then
1009 self_abspathname="$d/$0"
1014 if test -z "$self_abspathname"; then
1015 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
1019 while test -h "$self_abspathname"; do
1020 # Resolve symbolic link.
1021 linkval=`func_readlink "$self_abspathname"`
1022 test -n "$linkval" || break
1024 /* ) self_abspathname="$linkval" ;;
1025 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
1028 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
1031 trap 'exit_status=$?
1032 if test "$signal" != 0; then
1033 echo "caught signal $signal" >&2
1036 exit $exit_status' 0
1037 for signal in 1 2 3 13 15; do
1038 trap '{ signal='$signal'; func_exit 1; }' $signal
1042 # func_lookup_file file
1043 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1046 # - local_gnulib_dir from --local-dir
1048 # - lookedup_file name of the merged (combined) file
1049 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1053 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1054 lookedup_file="$local_gnulib_dir/$lkfile"
1057 if test -f "$gnulib_dir/$lkfile"; then
1058 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1059 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1060 rm -f "$tmp/$lkbase"
1061 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1062 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1063 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1064 lookedup_file="$tmp/$lkbase"
1067 lookedup_file="$gnulib_dir/$lkfile"
1071 func_fatal_error "file $gnulib_dir/$lkfile not found"
1078 # - local_gnulib_dir from --local-dir
1081 # Filter out metainformation files like README, which are not modules.
1082 # Filter out unit test modules; they can be retrieved through
1083 # --extract-tests-module if desired.
1085 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1086 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1087 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1090 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1091 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1092 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1093 -e '/^README$/d' -e '/\/README$/d' \
1094 -e '/^TEMPLATE$/d' \
1095 -e '/^TEMPLATE-EXTENDED$/d' \
1096 -e '/^TEMPLATE-TESTS$/d' \
1099 | sed -e '/-tests$/d' \
1103 # func_verify_module
1104 # verifies a module name
1106 # - local_gnulib_dir from --local-dir
1107 # - module module name argument
1108 func_verify_module ()
1110 if { test -f "$gnulib_dir/modules/$module" \
1111 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1112 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1113 && test "CVS" != "$module" \
1114 && test "ChangeLog" != "$module" \
1115 && test "COPYING" != "$module" \
1116 && test "README" != "$module" \
1117 && test "TEMPLATE" != "$module" \
1118 && test "TEMPLATE-EXTENDED" != "$module" \
1119 && test "TEMPLATE-TESTS" != "$module"; then
1120 # OK, $module is a correct module name.
1121 # Verify that building the module description with 'patch' succeeds.
1122 func_lookup_file "modules/$module"
1124 echo "gnulib-tool: module $module doesn't exist" 1>&2
1129 # func_verify_nontests_module
1130 # verifies a module name, excluding tests modules
1132 # - local_gnulib_dir from --local-dir
1133 # - module module name argument
1134 func_verify_nontests_module ()
1137 *-tests ) module= ;;
1138 * ) func_verify_module ;;
1142 # func_verify_tests_module
1143 # verifies a module name, considering only tests modules
1145 # - local_gnulib_dir from --local-dir
1146 # - module module name argument
1147 func_verify_tests_module ()
1150 *-tests ) func_verify_module ;;
1155 sed_extract_prog=':[ ]*$/ {
1158 s/^Description:[ ]*$//
1161 s/^Depends-on:[ ]*$//
1162 s/^configure\.ac-early:[ ]*$//
1163 s/^configure\.ac:[ ]*$//
1164 s/^Makefile\.am:[ ]*$//
1168 s/^Maintainer:[ ]*$//
1175 # func_get_description module
1177 # - local_gnulib_dir from --local-dir
1178 func_get_description ()
1180 func_lookup_file "modules/$1"
1181 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1184 # func_get_notice module
1186 # - local_gnulib_dir from --local-dir
1189 func_lookup_file "modules/$1"
1190 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1193 # func_get_filelist module
1195 # - local_gnulib_dir from --local-dir
1196 func_get_filelist ()
1198 func_lookup_file "modules/$1"
1199 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1200 echo m4/gnulib-common.m4
1201 case "$autoconf_minversion" in
1203 #echo m4/onceonly.m4
1204 echo m4/onceonly_2_57.m4
1209 # func_get_dependencies module
1211 # - local_gnulib_dir from --local-dir
1212 func_get_dependencies ()
1214 # ${module}-tests always implicitly depends on ${module}.
1215 echo "$1" | sed -n -e 's/-tests$//p'
1216 # Then the explicit dependencies listed in the module description.
1217 func_lookup_file "modules/$1"
1218 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1221 # func_get_autoconf_early_snippet module
1223 # - local_gnulib_dir from --local-dir
1224 func_get_autoconf_early_snippet ()
1226 func_lookup_file "modules/$1"
1227 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1230 # func_get_autoconf_snippet module
1232 # - local_gnulib_dir from --local-dir
1233 func_get_autoconf_snippet ()
1235 func_lookup_file "modules/$1"
1236 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1239 # func_get_automake_snippet module
1241 # - local_gnulib_dir from --local-dir
1242 func_get_automake_snippet ()
1244 func_lookup_file "modules/$1"
1245 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1248 # *-tests module live in tests/, not lib/.
1249 # Synthesize an EXTRA_DIST augmentation.
1250 all_files=`func_get_filelist $1`
1251 tests_files=`for f in $all_files; do \
1253 tests/*) echo $f ;; \
1255 done | sed -e 's,^tests/,,'`
1256 extra_files="$tests_files"
1257 if test -n "$extra_files"; then
1258 echo "EXTRA_DIST +=" $extra_files
1263 # Synthesize an EXTRA_DIST augmentation.
1264 sed_combine_lines='/\\$/{
1271 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1272 already_mentioned_files=` \
1273 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1274 | sed -e "$sed_combine_lines" \
1275 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1276 all_files=`func_get_filelist $1`
1277 lib_files=`for f in $all_files; do \
1281 done | sed -e 's,^lib/,,'`
1282 # Remove $already_mentioned_files from $lib_files.
1283 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1284 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1285 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1286 if test -n "$extra_files"; then
1287 echo "EXTRA_DIST +=" $extra_files
1290 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1291 # This is necessary so that automake can generate the right list of
1293 # A possible approach would be to use autom4te --trace of the redefined
1294 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1295 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1296 # inside autoconf's built-in macros are not missed).
1297 # But it's simpler and more robust to do it here, based on the file list.
1298 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1299 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1300 # automake will generate a useless dependency; this is harmless.
1302 relocatable-prog-wrapper) ;;
1304 sed_extract_c_files='/\.c$/p'
1305 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1306 if test -n "$extra_files"; then
1307 echo "EXTRA_lib_SOURCES +=" $extra_files
1312 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1313 buildaux_files=`for f in $all_files; do \
1315 build-aux/*) echo $f ;; \
1317 done | sed -e 's,^build-aux/,,'`
1318 if test -n "$buildaux_files"; then
1319 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1320 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1327 # func_get_include_directive module
1329 # - local_gnulib_dir from --local-dir
1330 func_get_include_directive ()
1332 func_lookup_file "modules/$1"
1333 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1334 sed -e 's/^\(["<]\)/#include \1/'
1337 # func_get_link_directive module
1339 # - local_gnulib_dir from --local-dir
1340 func_get_link_directive ()
1342 func_lookup_file "modules/$1"
1343 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1346 # func_get_license module
1348 # - local_gnulib_dir from --local-dir
1351 func_lookup_file "modules/$1"
1352 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1353 # The default is GPL.
1355 } | sed -e 's,^ *$,,' | sed -e 1q
1358 # func_get_maintainer module
1360 # - local_gnulib_dir from --local-dir
1361 func_get_maintainer ()
1363 func_lookup_file "modules/$1"
1364 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1367 # func_get_tests_module module
1369 # - local_gnulib_dir from --local-dir
1370 func_get_tests_module ()
1372 # The naming convention for tests modules is hardwired: ${module}-tests.
1373 if test -f "$gnulib_dir/modules/$1"-tests \
1374 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1375 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1380 # func_acceptable module
1381 # tests whether a module is acceptable.
1383 # - avoidlist list of modules to avoid
1386 for avoid in $avoidlist; do
1387 if test "$avoid" = "$1"; then
1394 # func_modules_transitive_closure
1396 # - local_gnulib_dir from --local-dir
1397 # - modules list of specified modules
1398 # - inctests true if tests should be included, blank otherwise
1399 # - avoidlist list of modules to avoid
1400 # - tmp pathname of a temporary directory
1402 # - modules list of modules, including dependencies
1403 func_modules_transitive_closure ()
1405 # In order to process every module only once (for speed), process an "input
1406 # list" of modules, producing an "output list" of modules. During each round,
1407 # more modules can be queued in the input list. Once a module on the input
1408 # list has been processed, it is added to the "handled list", so we can avoid
1409 # to process it again.
1411 inmodules="$modules"
1413 while test -n "$inmodules"; do
1414 inmodules_this_round="$inmodules"
1415 inmodules= # Accumulator, queue for next round
1416 for module in $inmodules_this_round; do
1418 if test -n "$module"; then
1419 if func_acceptable $module; then
1420 func_append outmodules " $module"
1421 deps=`func_get_dependencies $module`
1422 # Duplicate dependencies are harmless, but Jim wants a warning.
1423 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1424 if test -n "$duplicated_deps"; then
1425 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1427 func_append inmodules " $deps"
1428 if test -n "$inctests"; then
1429 testsmodule=`func_get_tests_module $module`
1430 if test -n "$testsmodule"; then
1431 func_append inmodules " $testsmodule"
1437 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1438 # Remove $handledmodules from $inmodules.
1439 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1440 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1442 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1443 rm -f "$tmp"/queued-modules
1446 # func_modules_add_dummy
1448 # - local_gnulib_dir from --local-dir
1449 # - modules list of modules, including dependencies
1451 # - modules list of modules, including 'dummy' if needed
1452 func_modules_add_dummy ()
1455 sed_remove_backslash_newline=':a
1462 for module in $modules; do
1463 func_verify_nontests_module
1464 if test -n "$module"; then
1465 # Extract the value of "lib_SOURCES += ...".
1466 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1467 # Ignore .h files since they are not compiled.
1470 *) have_lib_SOURCES=yes ;;
1475 # Add the dummy module, to make sure the library will be non-empty.
1476 if test -z "$have_lib_SOURCES"; then
1477 if func_acceptable "dummy"; then
1478 func_append modules " dummy"
1483 # func_modules_notice
1485 # - local_gnulib_dir from --local-dir
1486 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1487 # - modules list of modules, including dependencies
1488 func_modules_notice ()
1490 if test $verbose -ge -1; then
1491 for module in $modules; do
1493 if test -n "$module"; then
1494 msg=`func_get_notice $module`
1495 if test -n "$msg"; then
1496 echo "Notice from module $module:"
1497 echo "$msg" | sed -e 's/^/ /'
1504 # func_modules_to_filelist
1506 # - local_gnulib_dir from --local-dir
1507 # - modules list of modules, including dependencies
1509 # - files list of files
1510 func_modules_to_filelist ()
1513 for module in $modules; do
1515 if test -n "$module"; then
1516 fs=`func_get_filelist $module`
1517 func_append files " $fs"
1520 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1523 # func_execute_command command [args...]
1524 # Executes a command.
1525 # Uses also the variables
1526 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1527 func_execute_command ()
1529 if test $verbose -ge 0; then
1533 # Commands like automake produce output to stderr even when the succeed.
1534 # Turn this output off if the command succeeds.
1535 "$@" > "$tmp"/cmdout 2>&1
1537 if test $cmdret = 0; then
1541 cat "$tmp"/cmdout 1>&2
1548 # func_emit_lib_Makefile_am
1549 # emits the contents of library makefile to standard output.
1551 # - local_gnulib_dir from --local-dir
1552 # - modules list of modules, including dependencies
1553 # - libname library name
1554 # - pobase directory relative to destdir where to place *.po files
1555 # - auxdir directory relative to destdir where to place build aux files
1556 # - makefile_name from --makefile-name
1557 # - libtool true if libtool will be used, false or blank otherwise
1558 # - macro_prefix prefix of gl_LIBOBJS macros to use
1559 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1560 # - actioncmd (optional) command that will reproduce this invocation
1561 # - for_test true if creating a package for testing, false otherwise
1563 # - uses_subdirs nonempty if object files in subdirs exist
1564 func_emit_lib_Makefile_am ()
1566 # When creating an includable Makefile.am snippet, augment variables with
1567 # += instead of assigning them.
1568 if test -n "$makefile_name"; then
1573 if test "$libtool" = true; then
1576 sed_eliminate_LDFLAGS=
1580 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1583 # When creating a package for testing: Attempt to provoke failures,
1584 # especially link errors, already during "make" rather than during
1585 # "make check", because "make check" is not possible in a cross-compiling
1586 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1587 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1589 sed_transform_check_PROGRAMS=
1591 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1592 echo "## Process this file with automake to produce Makefile.in."
1593 func_emit_copyright_notice
1594 if test -n "$actioncmd"; then
1595 echo "# Reproduce by: $actioncmd"
1600 for module in $modules; do
1601 func_verify_nontests_module
1602 if test -n "$module"; then
1604 func_get_automake_snippet "$module" |
1605 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1606 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1607 -e "$sed_eliminate_LDFLAGS" \
1608 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1609 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1610 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1611 -e "$sed_transform_check_PROGRAMS"
1612 if test "$module" = 'alloca'; then
1613 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1614 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1617 # Skip the contents if its entirely empty.
1618 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1619 echo "## begin gnulib module $module"
1622 echo "## end gnulib module $module"
1626 # Test whether there are some source files in subdirectories.
1627 for f in `func_get_filelist "$module"`; do
1629 lib/*/*.c) uses_subdirs=yes ;;
1635 if test -z "$makefile_name"; then
1636 # If there are source files in subdirectories, prevent collision of the
1637 # object files (example: hash.c and libxml/hash.c).
1639 if test -n "$uses_subdirs"; then
1640 subdir_options=' subdir-objects'
1642 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1645 if test -z "$makefile_name"; then
1646 echo "noinst_HEADERS ="
1647 echo "noinst_LIBRARIES ="
1648 echo "noinst_LTLIBRARIES ="
1649 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1650 # if you specify pkgdata_DATA to empty. This is a workaround.
1651 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1652 echo "pkgdata_DATA ="
1655 echo "BUILT_SOURCES ="
1658 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1659 if test -z "$makefile_name"; then
1660 echo "MOSTLYCLEANDIRS ="
1662 echo "DISTCLEANFILES ="
1663 echo "MAINTAINERCLEANFILES ="
1665 echo "AM_CPPFLAGS ="
1668 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1669 # One of the snippets already specifies an installation location for the
1670 # library. Don't confuse automake by saying it should not be installed.
1673 # By default, the generated library should not be installed.
1674 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1677 echo "${libname}_${libext}_SOURCES ="
1678 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1679 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1680 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1681 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1682 echo "EXTRA_${libname}_${libext}_SOURCES ="
1683 if test "$libtool" = true; then
1684 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1687 if test -n "$pobase"; then
1688 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1691 cat allsnippets.tmp \
1692 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1694 echo "mostlyclean-local: mostlyclean-generic"
1695 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1696 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1697 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1701 rm -f allsnippets.tmp
1704 # func_emit_po_Makevars
1705 # emits the contents of po/ makefile parametrization to standard output.
1707 # - local_gnulib_dir from --local-dir
1708 # - sourcebase directory relative to destdir where to place source code
1709 # - pobase directory relative to destdir where to place *.po files
1710 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1711 func_emit_po_Makevars ()
1713 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1714 func_emit_copyright_notice
1716 echo "# Usually the message domain is the same as the package name."
1717 echo "# But here it has a '-gnulib' suffix."
1718 echo "DOMAIN = ${po_domain}-gnulib"
1720 echo "# These two variables depend on the location of this directory."
1721 echo "subdir = ${pobase}"
1722 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1725 # These options get passed to xgettext.
1726 XGETTEXT_OPTIONS = \
1727 --keyword=_ --flag=_:1:pass-c-format \
1728 --keyword=N_ --flag=N_:1:pass-c-format \
1729 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1730 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1731 --flag=error:3:c-format --flag=error_at_line:5:c-format
1733 # This is the copyright holder that gets inserted into the header of the
1734 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1735 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1737 # This is the email address or URL to which the translators shall report
1738 # bugs in the untranslated strings:
1739 # - Strings which are not entire sentences, see the maintainer guidelines
1740 # in the GNU gettext documentation, section 'Preparing Strings'.
1741 # - Strings which use unclear terms or require additional context to be
1743 # - Strings which make invalid assumptions about notation of date, time or
1745 # - Pluralisation problems.
1746 # - Incorrect English spelling.
1747 # - Incorrect formatting.
1748 # It can be your email address, or a mailing list address where translators
1749 # can write to without being subscribed, or the URL of a web page through
1750 # which the translators can contact you.
1751 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1753 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1754 # message catalogs shall be used. It is usually empty.
1755 EXTRA_LOCALE_CATEGORIES =
1757 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1758 # context. Possible values are "yes" and "no". Set this to yes if the
1759 # package uses functions taking also a message context, like pgettext(), or
1760 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1765 # func_emit_po_POTFILES_in
1766 # emits the file list to be passed to xgettext to standard output.
1768 # - local_gnulib_dir from --local-dir
1769 # - sourcebase directory relative to destdir where to place source code
1770 # - files list of new files
1771 func_emit_po_POTFILES_in ()
1773 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1774 func_emit_copyright_notice
1776 echo "# List of files which contain translatable strings."
1777 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1780 # func_emit_tests_Makefile_am
1781 # emits the contents of tests makefile to standard output.
1783 # - local_gnulib_dir from --local-dir
1784 # - modules list of modules, including dependencies
1785 # - libname library name
1786 # - makefile_name from --makefile-name
1787 # - libtool true if libtool will be used, false or blank otherwise
1788 # - sourcebase relative directory containing lib source code
1789 # - m4base relative directory containing autoconf macros
1790 # - testsbase relative directory containing unit test code
1791 # - for_test true if creating a package for testing, false otherwise
1792 func_emit_tests_Makefile_am ()
1794 if test "$libtool" = true; then
1799 if test "$libtool" = true; then
1801 sed_eliminate_LDFLAGS=
1804 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1807 # When creating a package for testing: Attempt to provoke failures,
1808 # especially link errors, already during "make" rather than during
1809 # "make check", because "make check" is not possible in a cross-compiling
1810 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1811 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1813 sed_transform_check_PROGRAMS=
1815 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1816 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1817 echo "## Process this file with automake to produce Makefile.in."
1818 func_emit_copyright_notice
1820 # Generate dependencies here, since it eases the debugging of test failures.
1821 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1823 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1826 for module in $modules; do
1827 func_verify_tests_module
1828 if test -n "$module"; then
1830 func_get_automake_snippet "$module" |
1831 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1832 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1833 -e "$sed_eliminate_LDFLAGS" \
1834 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1835 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1836 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1837 -e "$sed_transform_check_PROGRAMS"
1839 # Skip the contents if its entirely empty.
1840 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1841 echo "## begin gnulib module $module"
1844 echo "## end gnulib module $module"
1851 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1852 # variable is needed to avoid an error from automake:
1853 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1856 echo "TESTS_ENVIRONMENT ="
1857 echo "noinst_PROGRAMS ="
1858 if ! $for_test; then
1859 echo "check_PROGRAMS ="
1861 echo "noinst_HEADERS ="
1862 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1863 echo "pkgdata_DATA ="
1866 echo "BUILT_SOURCES ="
1868 echo "MOSTLYCLEANFILES = core *.stackdump"
1869 echo "MOSTLYCLEANDIRS ="
1871 echo "DISTCLEANFILES ="
1872 echo "MAINTAINERCLEANFILES ="
1874 echo "AM_CPPFLAGS = \\"
1875 echo " -I. -I\$(srcdir) \\"
1876 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1877 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1879 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1882 echo "# Clean up after Solaris cc."
1884 echo " rm -rf SunWS_cache"
1886 echo "mostlyclean-local: mostlyclean-generic"
1887 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1888 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1889 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1893 rm -f allsnippets.tmp
1896 # func_emit_initmacro_start
1897 # emits the first few statements of the gl_INIT macro to standard output.
1898 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1899 func_emit_initmacro_start ()
1901 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1902 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1903 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1904 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1906 # Furthermore it avoids an automake error like this when a Makefile.am
1907 # that uses pieces of gnulib also uses $(LIBOBJ):
1908 # automatically discovered file `error.c' should not be explicitly mentioned
1909 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1910 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1911 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1912 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1913 # automatically discovered file `error.c' should not be explicitly mentioned
1914 # We let automake know about the files to be distributed through the
1915 # EXTRA_lib_SOURCES variable.
1916 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1919 # func_emit_initmacro_end
1920 # emits the last few statements of the gl_INIT macro to standard output.
1921 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1922 func_emit_initmacro_end ()
1924 echo " m4_popdef([AC_LIBSOURCES])"
1925 echo " m4_popdef([AC_REPLACE_FUNCS])"
1926 echo " m4_popdef([AC_LIBOBJ])"
1927 echo " AC_CONFIG_COMMANDS_PRE(["
1928 echo " ${macro_prefix}_libobjs="
1929 echo " ${macro_prefix}_ltlibobjs="
1930 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1931 echo " # Remove the extension."
1932 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1933 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1934 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1935 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1938 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1939 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1943 # func_emit_initmacro_done
1944 # emits a few statements after the gl_INIT macro to standard output.
1945 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1946 # - sourcebase directory relative to destdir where to place source code
1947 func_emit_initmacro_done ()
1950 echo "# Like AC_LIBOBJ, except that the module name goes"
1951 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1952 echo "AC_DEFUN([${macro_prefix}_LIBOBJ], ["
1953 echo " AS_LITERAL_IF([\$1], [${macro_prefix}_LIBSOURCES([\$1.c])])dnl"
1954 echo " ${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\""
1957 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1958 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1959 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS], ["
1960 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
1961 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])"
1964 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
1965 echo "# expected is derived from the gnulib-tool parametrization,"
1966 echo "# and alloca is special cased (for the alloca-opt module)."
1967 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
1968 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES], ["
1969 echo " m4_foreach([_gl_NAME], [\$1], ["
1970 echo " m4_if(_gl_NAME, [alloca.c], [], ["
1971 echo " m4_syscmd([test -r $sourcebase/]_gl_NAME[ || test ! -d $sourcebase])dnl"
1972 echo " m4_if(m4_sysval, [0], [],"
1973 echo " [AC_FATAL([missing $sourcebase/]_gl_NAME)])"
1979 # func_import modules
1980 # Uses also the variables
1981 # - destdir target directory
1982 # - local_gnulib_dir from --local-dir
1983 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1984 # - libname library name
1985 # - sourcebase directory relative to destdir where to place source code
1986 # - m4base directory relative to destdir where to place *.m4 macros
1987 # - pobase directory relative to destdir where to place *.po files
1988 # - docbase directory relative to destdir where to place doc files
1989 # - testsbase directory relative to destdir where to place unit test code
1990 # - auxdir directory relative to destdir where to place build aux files
1991 # - inctests true if --with-tests was given, blank otherwise
1992 # - avoidlist list of modules to avoid, from --avoid
1993 # - lgpl true if library's license shall be LGPL, blank otherwise
1994 # - makefile_name from --makefile-name
1995 # - libtool true if --libtool was given, false if --no-libtool was
1996 # given, blank otherwise
1997 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1998 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1999 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2000 # - autoconf_minversion minimum supported autoconf version
2001 # - doit : if actions shall be executed, false if only to be printed
2002 # - symbolic true if files should be symlinked, copied otherwise
2003 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2005 # - do_copyrights true if copyright notices in files should be replaced,
2009 # Get the cached settings.
2010 cached_local_gnulib_dir=
2011 cached_specified_modules=
2021 cached_makefile_name=
2023 cached_macro_prefix=
2026 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2027 cached_libtool=false
2033 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
2036 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
2039 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
2042 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
2045 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
2048 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
2051 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
2054 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
2057 s,^.*$,cached_inctests=true,p
2060 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
2063 s,^.*$,cached_lgpl=true,p
2065 /gl_MAKEFILE_NAME(/ {
2066 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
2069 s,^.*$,cached_libtool=true,p
2071 /gl_MACRO_PREFIX(/ {
2072 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2075 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2077 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2078 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2083 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2084 s,^.*$,cached_files=",p
2096 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2100 # Merge the cached settings with the specified ones.
2101 # The m4base must be the same as expected from the pathname.
2102 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2103 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2105 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2106 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2107 if test -z "$local_gnulib_dir"; then
2108 if test -n "$cached_local_gnulib_dir"; then
2111 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2113 case "$cached_local_gnulib_dir" in
2115 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2117 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2118 local_gnulib_dir="$relconcat" ;;
2123 # Append the cached and the specified module names. So that
2124 # "gnulib-tool --import foo" means to add the module foo.
2125 specified_modules="$cached_specified_modules $1"
2126 # Append the cached and the specified avoidlist. This is probably better
2127 # than dropping the cached one when --avoid is specified at least once.
2128 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2129 avoidlist=`echo $avoidlist`
2131 # The sourcebase defaults to the cached one.
2132 if test -z "$sourcebase"; then
2133 sourcebase="$cached_sourcebase"
2134 if test -z "$sourcebase"; then
2135 func_fatal_error "missing --source-base option"
2138 # The pobase defaults to the cached one.
2139 if test -z "$pobase"; then
2140 pobase="$cached_pobase"
2142 # The docbase defaults to the cached one.
2143 if test -z "$docbase"; then
2144 docbase="$cached_docbase"
2145 if test -z "$docbase"; then
2146 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."
2149 # The testsbase defaults to the cached one.
2150 if test -z "$testsbase"; then
2151 testsbase="$cached_testsbase"
2152 if test -z "$testsbase"; then
2153 func_fatal_error "missing --tests-base option"
2156 # Require the tests if specified either way.
2157 if test -z "$inctests"; then
2158 inctests="$cached_inctests"
2160 # The libname defaults to the cached one.
2161 if test -z "$supplied_libname"; then
2162 libname="$cached_libname"
2163 if test -z "$libname"; then
2164 func_fatal_error "missing --lib option"
2167 # Require LGPL if specified either way.
2168 if test -z "$lgpl"; then
2171 # The makefile_name defaults to the cached one.
2172 if test -z "$makefile_name"; then
2173 makefile_name="$cached_makefile_name"
2175 # Use libtool if specified either way, or if guessed.
2176 if test -z "$libtool"; then
2177 if test -n "$cached_m4base"; then
2178 libtool="$cached_libtool"
2180 libtool="$guessed_libtool"
2183 # The macro_prefix defaults to the cached one.
2184 if test -z "$macro_prefix"; then
2185 macro_prefix="$cached_macro_prefix"
2186 if test -z "$macro_prefix"; then
2187 func_fatal_error "missing --macro-prefix option"
2190 # The po_domain defaults to the cached one.
2191 if test -z "$po_domain"; then
2192 po_domain="$cached_po_domain"
2195 # Canonicalize the list of specified modules.
2196 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2198 # Determine final module list.
2199 modules="$specified_modules"
2200 func_modules_transitive_closure
2201 if test $verbose -ge 0; then
2202 echo "Module list with included dependencies:"
2203 echo "$modules" | sed -e 's/^/ /'
2206 # Add the dummy module if needed.
2207 func_modules_add_dummy
2209 # If --lgpl, verify that the licenses of modules are compatible.
2210 if test -n "$lgpl"; then
2211 for module in $modules; do
2212 license=`func_get_license $module`
2214 LGPL | LGPLv2+ | 'GPLed build tool') ;;
2215 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2216 *) func_fatal_error "incompatible license on module $module: $license" ;;
2221 # Show banner notice of every module.
2224 # Determine script to apply to imported library files.
2225 sed_transform_lib_file=
2226 for module in $modules; do
2227 if test $module = config-h; then
2228 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2229 sed_transform_lib_file=$sed_transform_lib_file'
2230 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2235 if test -n "$do_copyrights"; then
2236 if test -n "$lgpl"; then
2238 sed_transform_lib_file=$sed_transform_lib_file'
2239 s/GNU General/GNU Lesser General/g
2240 s/version 2\([ ,]\)/version 2.1\1/g
2245 # Determine final file list.
2246 func_modules_to_filelist
2247 if test $verbose -ge 0; then
2249 echo "$files" | sed -e 's/^/ /'
2253 || func_fatal_error "refusing to do nothing"
2255 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2256 new_files="$files m4/gnulib-tool.m4"
2257 old_files="$cached_files"
2258 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2259 func_append old_files " m4/gnulib-tool.m4"
2262 sed_rewrite_old_files="\
2263 s,^build-aux/,$auxdir/,
2264 s,^doc/,$cached_docbase/,
2265 s,^lib/,$cached_sourcebase/,
2266 s,^m4/,$cached_m4base/,
2267 s,^tests/,$cached_testsbase/,"
2268 sed_rewrite_new_files="\
2269 s,^build-aux/,$auxdir/,
2271 s,^lib/,$sourcebase/,
2273 s,^tests/,$testsbase/,"
2275 # Create directories.
2276 { echo "$sourcebase"
2278 if test -n "$pobase"; then
2281 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2282 if test -n "$docfiles"; then
2285 if test -n "$inctests"; then
2289 for f in $files; do echo $f; done \
2290 | sed -e "$sed_rewrite_new_files" \
2291 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2294 { # Rearrange file descriptors. Needed because "while ... done < ..."
2295 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2296 exec 5<&0 < "$tmp"/dirs
2298 if test ! -d "$destdir/$d"; then
2300 echo "Creating directory $destdir/$d"
2301 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2303 echo "Create directory $destdir/$d"
2310 # func_dest_tmpfilename file
2311 # determines the name of a temporary file (file is relative to destdir).
2313 # - tmpfile absolute filename of the temporary file
2314 func_dest_tmpfilename ()
2317 # Put the new contents of $file in a file in the same directory (needed
2318 # to guarantee that an 'mv' to "$destdir/$file" works).
2319 tmpfile="$destdir/$1.tmp"
2321 # Put the new contents of $file in a file in a temporary directory
2322 # (because the directory of "$file" might not exist).
2323 tmpfile="$tmp"/`basename "$1"`.tmp
2327 # Copy files or make symbolic links. Remove obsolete files.
2331 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2332 # representing the files according to the last gnulib-tool invocation.
2333 for f in $old_files; do echo $f; done \
2334 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2337 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2338 # representing the files after this gnulib-tool invocation.
2339 for f in $new_files; do echo $f; done \
2340 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2343 # First the files that are in old-files, but not in new-files:
2344 sed_take_first_column='s,'"$delimiter"'.*,,'
2345 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2346 # Remove the file. Do nothing if the user already removed it.
2347 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2349 echo "Removing file $g (backup in ${g}~)"
2350 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2352 echo "Remove file $g (backup in ${g}~)"
2354 func_append removed_files "$g$nl"
2357 # func_add_or_update handles a file that ought to be present afterwards.
2359 # - f the original file name
2360 # - g the rewritten file name
2361 # - already_present nonempty if the file already exists, empty otherwise
2362 func_add_or_update ()
2364 func_dest_tmpfilename "$g"
2365 func_lookup_file "$f"
2366 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2367 if test -n "$sed_transform_lib_file"; then
2370 sed -e "$sed_transform_lib_file" \
2371 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2375 if test -f "$destdir/$g"; then
2376 # The file already exists.
2377 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2378 : # The file has not changed.
2382 if test -n "$already_present"; then
2383 echo "Updating file $g (backup in ${g}~)"
2385 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2387 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2388 if { test -n "$symbolic" \
2389 || { test -n "$lsymbolic" \
2390 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2391 && test -z "$lookedup_tmp" \
2392 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2393 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2395 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2398 if test -n "$already_present"; then
2399 echo "Update file $g (backup in ${g}~)"
2401 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2407 # Don't protest if the file should be there but isn't: it happens
2408 # frequently that developers don't put autogenerated files into CVS.
2410 echo "Copying file $g"
2411 if { test -n "$symbolic" \
2412 || { test -n "$lsymbolic" \
2413 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2414 && test -z "$lookedup_tmp" \
2415 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2416 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2418 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2423 func_append added_files "$g$nl"
2427 # Then the files that are in new-files, but not in old-files:
2428 sed_take_last_column='s,^.*'"$delimiter"',,'
2430 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2431 | sed -e "$sed_take_last_column" \
2432 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2433 { # Rearrange file descriptors. Needed because "while ... done < ..."
2434 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2435 exec 5<&0 < "$tmp"/added-files
2441 # Then the files that are in new-files and in old-files:
2442 already_present=true
2443 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2444 | sed -e "$sed_take_last_column" \
2445 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2446 { # Rearrange file descriptors. Needed because "while ... done < ..."
2447 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2448 exec 5<&0 < "$tmp"/kept-files
2455 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2456 actioncmd="gnulib-tool --import"
2457 func_append actioncmd " --dir=$destdir"
2458 if test -n "$local_gnulib_dir"; then
2459 func_append actioncmd " --local-dir=$local_gnulib_dir"
2461 func_append actioncmd " --lib=$libname"
2462 func_append actioncmd " --source-base=$sourcebase"
2463 func_append actioncmd " --m4-base=$m4base"
2464 if test -n "$pobase"; then
2465 func_append actioncmd " --po-base=$pobase"
2467 func_append actioncmd " --doc-base=$docbase"
2468 func_append actioncmd " --aux-dir=$auxdir"
2469 if test -n "$inctests"; then
2470 func_append actioncmd " --with-tests"
2472 for module in $avoidlist; do
2473 func_append actioncmd " --avoid=$module"
2475 if test -n "$lgpl"; then
2476 func_append actioncmd " --lgpl"
2478 if test -n "$makefile_name"; then
2479 func_append actioncmd " --makefile-name=$makefile_name"
2481 if test "$libtool" = true; then
2482 func_append actioncmd " --libtool"
2484 func_append actioncmd " --no-libtool"
2486 func_append actioncmd " --macro-prefix=$macro_prefix"
2487 if test -n "$po_domain"; then
2488 func_append actioncmd " --po-domain=$po_domain"
2490 func_append actioncmd " `echo $specified_modules`"
2492 # Default the makefile name to Makefile.am.
2493 if test -n "$makefile_name"; then
2494 makefile_am=$makefile_name
2496 makefile_am=Makefile.am
2499 # Create normal Makefile.ams.
2502 # Create library makefile.
2503 func_dest_tmpfilename $sourcebase/$makefile_am
2504 func_emit_lib_Makefile_am > "$tmpfile"
2505 if test -f "$destdir"/$sourcebase/$makefile_am; then
2506 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2510 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2511 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2512 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2514 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2520 echo "Creating $sourcebase/$makefile_am"
2521 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2523 echo "Create $sourcebase/$makefile_am"
2526 func_append added_files "$sourcebase/$makefile_am$nl"
2529 # Create po/ directory.
2530 if test -n "$pobase"; then
2531 # Create po makefile and auxiliary files.
2532 for file in Makefile.in.in remove-potcdate.sin; do
2533 func_dest_tmpfilename $pobase/$file
2534 func_lookup_file build-aux/po/$file
2535 cat "$lookedup_file" > "$tmpfile"
2536 if test -f "$destdir"/$pobase/$file; then
2537 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
2541 echo "Updating $pobase/$file (backup in $pobase/$file~)"
2542 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
2543 mv -f "$tmpfile" "$destdir"/$pobase/$file
2545 echo "Update $pobase/$file (backup in $pobase/$file~)"
2551 echo "Creating $pobase/$file"
2552 mv -f "$tmpfile" "$destdir"/$pobase/$file
2554 echo "Create $pobase/$file"
2557 func_append added_files "$pobase/$file$nl"
2560 # Create po makefile parametrization, part 1.
2561 func_dest_tmpfilename $pobase/Makevars
2562 func_emit_po_Makevars > "$tmpfile"
2563 if test -f "$destdir"/$pobase/Makevars; then
2564 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
2568 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
2569 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
2570 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2572 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
2578 echo "Creating $pobase/Makevars"
2579 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2581 echo "Create $pobase/Makevars"
2584 func_append added_files "$pobase/Makevars$nl"
2586 # Create po makefile parametrization, part 2.
2587 func_dest_tmpfilename $pobase/POTFILES.in
2588 func_emit_po_POTFILES_in > "$tmpfile"
2589 if test -f "$destdir"/$pobase/POTFILES.in; then
2590 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
2594 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2595 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
2596 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2598 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2604 echo "Creating $pobase/POTFILES.in"
2605 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2607 echo "Create $pobase/POTFILES.in"
2610 func_append added_files "$pobase/POTFILES.in$nl"
2613 TP_URL="http://translationproject.org/latest/"
2614 TP_RSYNC_URI="translationproject.org::tp/latest/"
2616 echo "Fetching gnulib PO files from $TP_URL"
2617 (cd "$destdir"/$pobase \
2618 && { # Prefer rsync over wget if it is available, since it consumes
2619 # less network bandwidth, due to compression.
2620 if type rsync 2>/dev/null | grep / > /dev/null; then
2621 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
2623 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
2628 echo "Fetch gnulib PO files from $TP_URL"
2630 # Create po/LINGUAS.
2632 func_dest_tmpfilename $pobase/LINGUAS
2633 (cd "$destdir"/$pobase \
2634 && { echo '# Set of available languages.'
2635 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
2638 if test -f "$destdir"/$pobase/LINGUAS; then
2639 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
2642 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2643 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
2644 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2647 echo "Creating $pobase/LINGUAS"
2648 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2649 func_append added_files "$pobase/LINGUAS$nl"
2652 if test -f "$destdir"/$pobase/LINGUAS; then
2653 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2655 echo "Create $pobase/LINGUAS"
2660 # Create m4/gnulib-cache.m4.
2661 func_dest_tmpfilename $m4base/gnulib-cache.m4
2663 func_emit_copyright_notice
2665 echo "# This file represents the specification of how gnulib-tool is used."
2666 echo "# It acts as a cache: It is written and read by gnulib-tool."
2667 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2668 echo "# like the configure.ac and various Makefile.am files."
2671 echo "# Specification in the form of a command-line invocation:"
2674 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2675 # Store the local_gnulib_dir relative to destdir.
2676 case "$local_gnulib_dir" in
2678 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2681 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2683 # destdir, local_gnulib_dir are both relative.
2684 func_relativize "$destdir" "$local_gnulib_dir"
2685 relative_local_gnulib_dir="$reldir" ;;
2688 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2689 echo "gl_MODULES(["`echo $specified_modules`"])"
2690 echo "gl_AVOID([$avoidlist])"
2691 echo "gl_SOURCE_BASE([$sourcebase])"
2692 echo "gl_M4_BASE([$m4base])"
2693 echo "gl_PO_BASE([$pobase])"
2694 echo "gl_DOC_BASE([$docbase])"
2695 echo "gl_TESTS_BASE([$testsbase])"
2696 test -z "$inctests" || echo "gl_WITH_TESTS"
2697 echo "gl_LIB([$libname])"
2698 test -z "$lgpl" || echo "gl_LGPL"
2699 echo "gl_MAKEFILE_NAME([$makefile_name])"
2700 if test "$libtool" = true; then
2703 echo "gl_MACRO_PREFIX([$macro_prefix])"
2704 echo "gl_PO_DOMAIN([$po_domain])"
2706 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2707 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2711 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2712 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2713 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2715 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2719 echo "# gnulib-cache.m4 ends here"
2726 echo "Creating $m4base/gnulib-cache.m4"
2727 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2729 echo "Create $m4base/gnulib-cache.m4"
2735 # Create m4/gnulib-comp.m4.
2736 func_dest_tmpfilename $m4base/gnulib-comp.m4
2738 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2739 func_emit_copyright_notice
2741 echo "# This file represents the compiled summary of the specification in"
2742 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2743 echo "# to be invoked from configure.ac."
2744 echo "# In projects using CVS, this file can be treated like other built files."
2747 echo "# This macro should be invoked from $configure_ac, in the section"
2748 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2749 echo "# any checks for libraries, header files, types and library functions."
2750 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2752 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2753 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2754 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2755 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2756 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2757 if test -n "$uses_subdirs"; then
2758 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2760 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2761 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2763 for module in $modules; do
2765 if test -n "$module"; then
2766 func_get_autoconf_early_snippet "$module"
2769 | sed -e '/^$/d;' -e 's/^/ /'
2772 echo "# This macro should be invoked from $configure_ac, in the section"
2773 echo "# \"Check for header files, types and library functions\"."
2774 echo "AC_DEFUN([${macro_prefix}_INIT],"
2776 func_emit_initmacro_start
2777 if test "$libtool" = true; then
2778 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2779 echo " gl_cond_libtool=true"
2781 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2782 echo " gl_cond_libtool=false"
2784 echo " gl_ltlibdeps="
2786 echo " gl_source_base='$sourcebase'"
2787 if test "$auxdir" != "build-aux"; then
2788 sed_replace_build_aux='
2790 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2791 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2795 sed_replace_build_aux=
2797 for module in $modules; do
2799 if test -n "$module"; then
2800 func_get_autoconf_snippet "$module" \
2801 | sed -e '/^$/d;' -e 's/^/ /' \
2802 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2803 -e "$sed_replace_build_aux"
2804 if test "$module" = 'alloca' && test "$libtool" = true; then
2805 echo 'changequote(,)dnl'
2806 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2807 echo 'changequote([, ])dnl'
2808 echo 'AC_SUBST([LTALLOCA])'
2812 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2813 # created using libtool, because libtool already handles the dependencies.
2814 if test "$libtool" != true; then
2815 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
2816 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2817 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2818 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2819 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2821 func_emit_initmacro_end
2823 func_emit_initmacro_done
2825 echo "# This macro records the list of files which have been installed by"
2826 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2827 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2828 echo "$files" | sed -e 's,^, ,'
2831 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2832 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2836 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2837 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2838 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2840 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2844 echo "# gnulib-comp.m4 ends here"
2851 echo "Creating $m4base/gnulib-comp.m4"
2852 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2854 echo "Create $m4base/gnulib-comp.m4"
2860 if test -n "$inctests"; then
2861 # Create tests makefile.
2862 func_dest_tmpfilename $testsbase/$makefile_am
2863 func_emit_tests_Makefile_am > "$tmpfile"
2864 if test -f "$destdir"/$testsbase/$makefile_am; then
2865 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2869 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2870 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2871 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2873 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2879 echo "Creating $testsbase/$makefile_am"
2880 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2882 echo "Create $testsbase/$makefile_am"
2885 func_append added_files "$testsbase/$makefile_am$nl"
2889 # Update the .cvsignore and .gitignore files.
2890 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
2891 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
2892 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
2893 { # Rearrange file descriptors. Needed because "while ... done < ..."
2894 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2895 exec 5<&0 < "$tmp"/fileset-changes
2896 func_update_ignorelist ()
2899 if test -f "$destdir/$dir$ignore"; then
2900 if test -n "$dir_added" || test -n "$dir_removed"; then
2901 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
2902 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
2903 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
2904 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
2905 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
2906 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
2908 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2909 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
2910 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
2911 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
2912 | sed -f "$tmp"/sed-ignore-removed \
2913 > "$destdir/$dir$ignore"
2915 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2920 if test -n "$dir_added"; then
2922 echo "Creating $destdir/$dir$ignore"
2924 if test "$ignore" = .cvsignore; then
2926 # Automake generates Makefile rules that create .dirstamp files.
2929 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u
2930 } > "$destdir/$dir$ignore"
2932 echo "Create $destdir/$dir$ignore"
2942 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
2943 func_update_ignorelist .cvsignore
2945 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
2946 func_update_ignorelist .gitignore
2953 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
2954 next_dir=`echo "$line" | sed -e 's,|.*,,'`
2955 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
2956 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
2957 if test "$next_dir" != "$last_dir"; then
2958 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2959 last_dir="$next_dir"
2964 A) func_append last_dir_added "$file$nl";;
2965 R) func_append last_dir_removed "$file$nl";;
2968 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2974 echo "You may need to add #include directives for the following .h files."
2975 # Intersect $specified_modules and $modules
2976 # (since $specified_modules is not necessarily of subset of $modules - some
2977 # may have been skipped through --avoid, and since the elements of $modules
2978 # but not in $specified_modules can go away without explicit notice - through
2979 # changes in the module dependencies).
2980 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2981 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2982 # First the #include <...> directives without #ifs, sorted for convenience,
2983 # then the #include "..." directives without #ifs, sorted for convenience,
2984 # then the #include directives that are surrounded by #ifs. Not sorted.
2985 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2986 include_directive=`func_get_include_directive "$module"`
2987 case "$nl$include_directive" in
2989 echo "$include_directive" 1>&5
2992 echo "$include_directive" | grep -v 'include "' 1>&6
2993 echo "$include_directive" | grep 'include "' 1>&7
2996 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2998 LC_ALL=C sort -u "$tmp"/include-angles
2999 LC_ALL=C sort -u "$tmp"/include-quotes
3000 cat "$tmp"/include-if
3001 ) | sed -e '/^$/d' -e 's/^/ /'
3002 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3004 for module in $modules; do
3005 func_get_link_directive "$module"
3007 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3008 if test `wc -l < "$tmp"/link` != 0; then
3010 echo "You may need to use the following Makefile variables when linking."
3011 echo "Use them in <program>_LDADD when linking a program, or"
3012 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3018 echo "Don't forget to"
3019 if test "$makefile_am" = Makefile.am; then
3020 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3022 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3024 if test -n "$pobase"; then
3025 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3027 if test -n "$inctests"; then
3028 if test "$makefile_am" = Makefile.am; then
3029 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3031 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3034 if test "$makefile_am" = Makefile.am; then
3035 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3036 sourcebase_base=`basename "$sourcebase"`
3037 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
3039 if test -n "$pobase"; then
3040 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3041 pobase_base=`basename "$pobase"`
3042 echo " - mention \"${pobase_base}\" in SUBDIRS in ${pobase_dir}Makefile.am,"
3044 if test -n "$inctests"; then
3045 if test "$makefile_am" = Makefile.am; then
3046 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3047 testsbase_base=`basename "$testsbase"`
3048 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
3051 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
3052 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3053 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3056 # func_create_testdir testdir modules
3058 # - local_gnulib_dir from --local-dir
3059 # - auxdir directory relative to destdir where to place build aux files
3060 func_create_testdir ()
3064 if test -z "$modules"; then
3065 # All modules together.
3066 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3067 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3068 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3069 modules=`func_all_modules`
3070 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3072 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3074 # Check that the license of every module is consistent with the license of
3076 saved_modules="$modules"
3077 saved_inctests="$inctests"
3078 # When computing transitive closures, don't consider $module to depend on
3079 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3080 # on GPL modules - therefore we don't want a warning in this case.
3082 for requested_module in $saved_modules; do
3083 requested_license=`func_get_license "$requested_module"`
3084 if test "$requested_license" != GPL; then
3085 # Here we use func_modules_transitive_closure, not just
3086 # func_get_dependencies, so that we also detect weird situations like
3087 # an LGPL module which depends on a GPLed build tool module which depends
3089 modules="$requested_module"
3090 func_modules_transitive_closure
3091 for module in $modules; do
3092 license=`func_get_license "$module"`
3094 'GPLed build tool') ;;
3095 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3097 case "$requested_license" in
3100 GPLv2+ | LGPLv2+) ;;
3101 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3107 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3113 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3122 modules="$saved_modules"
3123 inctests="$saved_inctests"
3125 # Subdirectory names.
3134 # Determine final module list.
3135 func_modules_transitive_closure
3136 if test $verbose -ge 0; then
3137 echo "Module list with included dependencies:"
3138 echo "$modules" | sed -e 's/^/ /'
3141 # Add the dummy module if needed.
3142 func_modules_add_dummy
3144 # Show banner notice of every module.
3147 # Determine final file list.
3148 func_modules_to_filelist
3149 if test $verbose -ge 0; then
3151 echo "$files" | sed -e 's/^/ /'
3154 sed_rewrite_files="\
3155 s,^build-aux/,$auxdir/,
3157 s,^lib/,$sourcebase/,
3159 s,^tests/,$testsbase/,"
3161 # Create directories.
3162 for f in $files; do echo $f; done \
3163 | sed -e "$sed_rewrite_files" \
3164 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3165 | LC_ALL=C sort -u \
3167 { # Rearrange file descriptors. Needed because "while ... done < ..."
3168 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3169 exec 5<&0 < "$tmp"/dirs
3171 mkdir -p "$testdir/$d"
3176 # Copy files or make symbolic links.
3178 for f in $files; do echo $f; done \
3179 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3182 { # Rearrange file descriptors. Needed because "while ... done < ..."
3183 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3184 exec 5<&0 < "$tmp"/files
3186 func_lookup_file "$f"
3187 if test -n "$lookedup_tmp"; then
3188 cp -p "$lookedup_file" "$testdir/$g"
3190 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3191 if { test -n "$symbolic" \
3192 || { test -n "$lsymbolic" \
3193 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3194 func_ln "$lookedup_file" "$testdir/$g"
3196 cp -p "$lookedup_file" "$testdir/$g"
3203 # Create Makefile.ams that are for testing.
3206 # Create $sourcebase/Makefile.am.
3207 mkdir -p "$testdir/$sourcebase"
3208 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3210 # Create $m4base/Makefile.am.
3211 mkdir -p "$testdir/$m4base"
3212 (echo "## Process this file with automake to produce Makefile.in."
3218 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3221 ) > "$testdir/$m4base/Makefile.am"
3223 subdirs="$sourcebase $m4base"
3224 subdirs_with_configure_ac=""
3226 if false && test -f "$testdir"/$m4base/gettext.m4; then
3227 # Avoid stupid error message from automake:
3228 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3229 mkdir -p "$testdir/po"
3230 (echo "## Process this file with automake to produce Makefile.in."
3231 ) > "$testdir/po/Makefile.am"
3232 func_append subdirs " po"
3235 if test -n "$inctests"; then
3236 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3237 # Create $testsbase/Makefile.am.
3238 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3239 # Create $testsbase/configure.ac.
3240 (echo "# Process this file with autoconf to produce a configure script."
3241 echo "AC_INIT([dummy], [0])"
3242 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
3243 echo "AM_INIT_AUTOMAKE"
3245 echo "AM_CONFIG_HEADER([config.h])"
3248 echo "AC_PROG_INSTALL"
3249 echo "AC_PROG_MAKE_SET"
3250 echo "AC_PROG_RANLIB"
3252 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3253 echo "AC_GNU_SOURCE"
3256 for module in $modules; do
3258 if test -n "$module"; then
3259 func_get_autoconf_early_snippet "$module"
3262 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3263 if test "$libtool" = true; then
3264 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3265 echo "gl_cond_libtool=true"
3267 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3268 echo "gl_cond_libtool=false"
3270 echo "gl_ltlibdeps="
3272 # Wrap the set of autoconf snippets into an autoconf macro that is then
3273 # invoked. This is needed because autoconf does not support AC_REQUIRE
3275 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3276 # but we want the AC_REQUIRE to have its normal meaning (provide one
3277 # expansion of the required macro before the current point, and only one
3279 echo "AC_DEFUN([gl_INIT], ["
3280 func_emit_initmacro_start
3281 sed_replace_build_aux='
3283 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3284 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
3287 # We don't have explicit ordering constraints between the various
3288 # autoconf snippets. It's cleanest to put those of the library before
3289 # those of the tests.
3290 echo "gl_source_base='../$sourcebase'"
3291 for module in $modules; do
3292 func_verify_nontests_module
3293 if test -n "$module"; then
3294 func_get_autoconf_snippet "$module" \
3295 | sed -e "$sed_replace_build_aux"
3298 echo "gl_source_base='.'"
3299 for module in $modules; do
3300 func_verify_tests_module
3301 if test -n "$module"; then
3302 func_get_autoconf_snippet "$module" \
3303 | sed -e "$sed_replace_build_aux"
3306 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3307 # created using libtool, because libtool already handles the dependencies.
3308 if test "$libtool" != true; then
3309 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3310 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3311 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3312 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3313 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3315 func_emit_initmacro_end
3317 func_emit_initmacro_done
3321 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3322 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3323 echo "AH_TOP([#include \"../config.h\"])"
3325 echo "AC_OUTPUT([Makefile])"
3326 ) > "$testdir/$testsbase/configure.ac"
3327 func_append subdirs " $testsbase"
3328 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3331 # Create Makefile.am.
3332 (echo "## Process this file with automake to produce Makefile.in."
3334 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3336 echo "SUBDIRS = $subdirs"
3338 echo "ACLOCAL_AMFLAGS = -I $m4base"
3339 ) > "$testdir/Makefile.am"
3341 # Create configure.ac.
3342 (echo "# Process this file with autoconf to produce a configure script."
3343 echo "AC_INIT([dummy], [0])"
3344 if test "$auxdir" != "."; then
3345 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3347 echo "AM_INIT_AUTOMAKE"
3349 echo "AM_CONFIG_HEADER([config.h])"
3352 echo "AC_PROG_INSTALL"
3353 echo "AC_PROG_MAKE_SET"
3355 echo "# For autobuild."
3356 echo "AC_CANONICAL_BUILD"
3357 echo "AC_CANONICAL_HOST"
3359 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3360 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3361 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3362 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3364 echo "AC_PROG_RANLIB"
3366 if test -n "$uses_subdirs"; then
3367 echo "AM_PROG_CC_C_O"
3370 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3371 echo "AC_GNU_SOURCE"
3374 for module in $modules; do
3375 func_verify_nontests_module
3376 if test -n "$module"; then
3377 func_get_autoconf_early_snippet "$module"
3380 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3381 if test "$libtool" = true; then
3382 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3383 echo "gl_cond_libtool=true"
3385 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3386 echo "gl_cond_libtool=false"
3388 echo "gl_ltlibdeps="
3390 echo "gl_source_base='$sourcebase'"
3391 # Wrap the set of autoconf snippets into an autoconf macro that is then
3392 # invoked. This is needed because autoconf does not support AC_REQUIRE
3394 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3395 # but we want the AC_REQUIRE to have its normal meaning (provide one
3396 # expansion of the required macro before the current point, and only one
3398 echo "AC_DEFUN([gl_INIT], ["
3399 func_emit_initmacro_start
3400 if test "$auxdir" != "build-aux"; then
3401 sed_replace_build_aux='
3403 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3404 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3408 sed_replace_build_aux=
3410 for module in $modules; do
3411 func_verify_nontests_module
3412 if test -n "$module"; then
3413 func_get_autoconf_snippet "$module" \
3414 | sed -e "$sed_replace_build_aux"
3417 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3418 # created using libtool, because libtool already handles the dependencies.
3419 if test "$libtool" != true; then
3420 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3421 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3422 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3423 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3424 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3426 func_emit_initmacro_end
3428 func_emit_initmacro_done
3432 if test -n "$subdirs_with_configure_ac"; then
3433 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3435 makefiles="Makefile"
3436 for d in $subdirs; do
3437 # For subdirs that have a configure.ac by their own, it's the subdir's
3438 # configure.ac which creates the subdir's Makefile.am, not this one.
3439 case " $subdirs_with_configure_ac " in
3441 *) func_append makefiles " $d/Makefile" ;;
3444 echo "AC_OUTPUT([$makefiles])"
3445 ) > "$testdir/configure.ac"
3447 # Create autogenerated files.
3449 # Do not use "${AUTORECONF} --force --install", because it may invoke
3450 # autopoint, which brings in older versions of some of our .m4 files.
3451 if test -f $m4base/gettext.m4; then
3452 func_execute_command ${AUTOPOINT} --force || func_exit 1
3453 for f in $m4base/*.m4~; do
3454 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3457 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
3458 if ! test -d build-aux; then
3459 func_execute_command mkdir build-aux || func_exit 1
3461 func_execute_command ${AUTOCONF} || func_exit 1
3462 func_execute_command ${AUTOHEADER} || func_exit 1
3463 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3465 if test -n "$inctests"; then
3466 # Create autogenerated files.
3467 (cd "$testdir/$testsbase" || func_exit 1
3468 # Do not use "${AUTORECONF} --force --install", because it may invoke
3469 # autopoint, which brings in older versions of some of our .m4 files.
3470 if test -f ../$m4base/gettext.m4; then
3471 func_execute_command ${AUTOPOINT} --force || func_exit 1
3472 for f in ../$m4base/*.m4~; do
3473 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3476 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
3477 if ! test -d ../build-aux; then
3478 func_execute_command mkdir ../build-aux
3480 func_execute_command ${AUTOCONF} || func_exit 1
3481 func_execute_command ${AUTOHEADER} || func_exit 1
3482 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3485 # Need to run configure and make once, to create built files that are to be
3486 # distributed (such as getdate.c).
3487 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3488 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3489 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3490 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3491 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3492 # such $(FOO_H) because they don't refer to distributed files.
3493 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3494 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3495 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3496 | sed -e "$sed_remove_make_variables"`
3497 distributed_built_sources=`for file in $built_sources; do
3498 case "$cleaned_files" in
3503 if test -n "$distributed_built_sources"; then
3505 ./configure || func_exit 1
3507 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3508 make built_sources || func_exit 1
3510 make distclean || func_exit 1
3515 # func_create_megatestdir megatestdir allmodules
3517 # - local_gnulib_dir from --local-dir
3518 # - auxdir directory relative to destdir where to place build aux files
3519 func_create_megatestdir ()
3523 if test -z "$allmodules"; then
3524 allmodules=`func_all_modules`
3528 # First, all modules one by one.
3529 for onemodule in $allmodules; do
3530 func_create_testdir "$megatestdir/$onemodule" $onemodule
3531 func_append megasubdirs "$onemodule "
3533 # Then, all modules all together.
3534 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3535 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3536 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3537 func_create_testdir "$megatestdir/ALL" "$allmodules"
3538 func_append megasubdirs "ALL"
3541 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
3542 vc_witness="$gnulib_dir/CVS/Entries"; \
3544 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
3546 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
3547 | sed -e 's,January,01,' -e 's,Jan,01,' \
3548 -e 's,February,02,' -e 's,Feb,02,' \
3549 -e 's,March,03,' -e 's,Mar,03,' \
3550 -e 's,April,04,' -e 's,Apr,04,' \
3552 -e 's,June,06,' -e 's,Jun,06,' \
3553 -e 's,July,07,' -e 's,Jul,07,' \
3554 -e 's,August,08,' -e 's,Aug,08,' \
3555 -e 's,September,09,' -e 's,Sep,09,' \
3556 -e 's,October,10,' -e 's,Oct,10,' \
3557 -e 's,November,11,' -e 's,Nov,11,' \
3558 -e 's,December,12,' -e 's,Dec,12,' \
3559 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3560 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3562 echo "CVSDATE=$cvsdate"
3563 echo "test -d logs || mkdir logs"
3564 echo "for module in $megasubdirs; do"
3565 echo " echo \"Working on module \$module...\""
3566 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3567 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3570 echo " : autobuild project... \$module"
3571 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3572 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3573 echo " : autobuild hostname... \`hostname\`"
3574 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3576 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3578 ) > "$megatestdir/do-autobuild"
3579 chmod a+x "$megatestdir/do-autobuild"
3581 # Create Makefile.am.
3582 (echo "## Process this file with automake to produce Makefile.in."
3584 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3586 echo "SUBDIRS = $megasubdirs"
3588 echo "EXTRA_DIST = do-autobuild"
3589 ) > "$megatestdir/Makefile.am"
3591 # Create configure.ac.
3592 (echo "# Process this file with autoconf to produce a configure script."
3593 echo "AC_INIT([dummy], [0])"
3594 if test "$auxdir" != "."; then
3595 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3597 echo "AM_INIT_AUTOMAKE"
3599 echo "AC_PROG_MAKE_SET"
3601 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3602 echo "AC_OUTPUT([Makefile])"
3603 ) > "$megatestdir/configure.ac"
3605 # Create autogenerated files.
3607 # Do not use "${AUTORECONF} --install", because autoreconf operates
3608 # recursively, but the subdirectories are already finished, therefore
3609 # calling autoreconf here would only waste lots of CPU time.
3610 func_execute_command ${ACLOCAL} || func_exit 1
3611 func_execute_command mkdir build-aux
3612 func_execute_command ${AUTOCONF} || func_exit 1
3613 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3619 func_fatal_error "no mode specified" ;;
3628 if test -z "$destdir"; then
3631 test -d "$destdir" \
3632 || func_fatal_error "destination directory does not exist: $destdir"
3634 # Prefer configure.ac to configure.in.
3635 if test -f "$destdir"/configure.ac; then
3636 configure_ac="$destdir/configure.ac"
3638 if test -f "$destdir"/configure.in; then
3639 configure_ac="$destdir/configure.in"
3641 func_fatal_error "cannot find $destdir/configure.ac"
3645 # Analyze configure.ac.
3647 guessed_libtool=false
3652 /AC_CONFIG_AUX_DIR/ {
3653 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3655 /A[CM]_PROG_LIBTOOL/ {
3656 s,^.*$,guessed_libtool=true,p
3658 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3660 if test -z "$auxdir"; then
3661 auxdir="$guessed_auxdir"
3664 # Determine where to apply func_import.
3665 if test -n "$m4base"; then
3666 # Apply func_import to a particular gnulib directory.
3667 # Any number of additional modules can be given.
3668 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3669 # First use of gnulib in the given m4base.
3670 test -n "$supplied_libname" || supplied_libname=true
3671 test -n "$sourcebase" || sourcebase="lib"
3672 test -n "$docbase" || docbase="doc"
3673 test -n "$testsbase" || testsbase="tests"
3674 test -n "$macro_prefix" || macro_prefix="gl"
3678 # Apply func_import to all gnulib directories.
3679 # To get this list of directories, look at Makefile.am. (Not at
3680 # configure, because it may be omitted from CVS. Also, don't run
3681 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3684 if test -f "$destdir"/Makefile.am; then
3685 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3687 for arg in $aclocal_amflags; do
3688 if test -n "$m4dir_is_next"; then
3689 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3693 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3694 func_append m4dirs " $arg"
3695 m4dirs_count=`expr $m4dirs_count + 1`
3701 if test "X$arg" = "X-I"; then
3709 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3710 if test -f "$destdir"/aclocal.m4; then
3711 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3712 sedexpr2='s,^[^/]*$,.,'
3713 sedexpr3='s,/[^/]*$,,'
3714 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3715 m4dirs_count=`echo "$m4dirs" | wc -l`
3718 if test $m4dirs_count = 0; then
3719 # First use of gnulib in a package.
3720 # Any number of additional modules can be given.
3721 test -n "$supplied_libname" || supplied_libname=true
3722 test -n "$sourcebase" || sourcebase="lib"
3724 test -n "$docbase" || docbase="doc"
3725 test -n "$testsbase" || testsbase="tests"
3726 test -n "$macro_prefix" || macro_prefix="gl"
3729 if test $m4dirs_count = 1; then
3730 # There's only one use of gnulib here. Assume the user means it.
3731 # Any number of additional modules can be given.
3732 for m4base in $m4dirs; do
3736 # Ambiguous - guess what the user meant.
3737 if test $# = 0; then
3738 # No further arguments. Guess the user wants to update all of them.
3739 for m4base in $m4dirs; do
3740 # Perform func_import in a subshell, so that variable values
3742 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
3743 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
3744 # libtool, macro_prefix, po_domain
3745 # don't propagate from one directory to another.
3746 (func_import) || func_exit 1
3750 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
3758 if test -z "$destdir"; then
3759 func_fatal_error "please specify --dir option"
3762 test -d "$destdir" \
3763 || func_fatal_error "could not create destination directory"
3764 test -n "$auxdir" || auxdir="build-aux"
3765 func_create_testdir "$destdir" "$*"
3768 create-megatestdir )
3769 if test -z "$destdir"; then
3770 func_fatal_error "please specify --dir option"
3772 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3773 test -n "$auxdir" || auxdir="build-aux"
3774 func_create_megatestdir "$destdir" "$*"
3778 test -n "$destdir" || destdir=testdir$$
3779 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3780 test -n "$auxdir" || auxdir="build-aux"
3781 func_create_testdir "$destdir" "$*"
3785 ../configure || func_exit 1
3787 make check || func_exit 1
3788 make distclean || func_exit 1
3789 remaining=`find . -type f -print`
3790 if test -n "$remaining"; then
3791 echo "Remaining files:" $remaining 1>&2
3792 echo "gnulib-tool: *** Stop." 1>&2
3801 test -n "$destdir" || destdir=testdir$$
3802 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3803 test -n "$auxdir" || auxdir="build-aux"
3804 func_create_megatestdir "$destdir" "$*"
3812 remaining=`find . -type f -print`
3813 if test -n "$remaining"; then
3814 echo "Remaining files:" $remaining 1>&2
3815 echo "gnulib-tool: *** Stop." 1>&2
3823 extract-description )
3827 if test -n "$module"; then
3828 func_get_description "$module"
3837 if test -n "$module"; then
3838 func_get_notice "$module"
3847 if test -n "$module"; then
3848 func_get_filelist "$module"
3853 extract-dependencies )
3857 if test -n "$module"; then
3858 func_get_dependencies "$module"
3863 extract-autoconf-snippet )
3867 if test -n "$module"; then
3868 func_get_autoconf_snippet "$module"
3873 extract-automake-snippet )
3877 if test -n "$module"; then
3878 func_get_automake_snippet "$module"
3883 extract-include-directive )
3887 if test -n "$module"; then
3888 func_get_include_directive "$module"
3893 extract-link-directive )
3897 if test -n "$module"; then
3898 func_get_link_directive "$module"
3907 if test -n "$module"; then
3908 func_get_license "$module"
3913 extract-maintainer )
3917 if test -n "$module"; then
3918 func_get_maintainer "$module"
3923 extract-tests-module )
3927 if test -n "$module"; then
3928 func_get_tests_module "$module"
3934 func_fatal_error "unknown operation mode --$mode" ;;
3938 # Undo the effect of the previous 'trap' command. Some shellology:
3939 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3940 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3941 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3942 # 128 + signal number and is set before the trap-registered command is run.
3944 trap 'func_exit $?' 1 2 3 13 15
3949 # indent-tabs-mode: nil
3950 # whitespace-check-buffer-indent: nil