3 # Copyright (C) 2002-2008 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.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
44 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
45 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
46 AUTOCONF="${AUTOCONFPATH}autoconf"
48 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
49 AUTOHEADER="${AUTOCONFPATH}autoheader"
51 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
52 ACLOCAL="${AUTOMAKEPATH}aclocal"
54 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
55 AUTOMAKE="${AUTOMAKEPATH}automake"
57 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
58 AUTORECONF="${AUTOCONFPATH}autoreconf"
61 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
62 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
63 AUTOPOINT="${GETTEXTPATH}autopoint"
66 # When using GNU sed, turn off as many GNU extensions as possible,
67 # to minimize the risk of accidentally using non-portable features.
68 # However, do this only for gnulib-tool itself, not for the code that
69 # gnulib-tool generates, since we don't want "sed --posix" to leak
71 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
72 # Define sed as an alias.
73 # It is not always possible to use aliases. Aliases are guaranteed to work
74 # if the executing shell is bash and either it is invoked as /bin/sh or
75 # is a version >= 2.0, supporting shopt. This is the common case.
76 # Two other approaches (use of a variable $sed or of a function func_sed
77 # instead of an alias) require massive, fragile code changes.
78 # An other approach (use of function sed) requires `which sed` - but 'which'
79 # is hard to emulate, due to missing "test -x" on some platforms.
80 if test -n "$BASH_VERSION"; then
81 shopt -s expand_aliases >/dev/null 2>&1
83 alias sed='sed --posix'
87 # outputs to stdout the --help usage message.
91 Usage: gnulib-tool --list
92 gnulib-tool --import [module1 ... moduleN]
94 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
95 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
96 gnulib-tool --test --dir=directory module1 ... moduleN
97 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
98 gnulib-tool --extract-description module
99 gnulib-tool --extract-notice module
100 gnulib-tool --extract-filelist module
101 gnulib-tool --extract-dependencies module
102 gnulib-tool --extract-autoconf-snippet module
103 gnulib-tool --extract-automake-snippet module
104 gnulib-tool --extract-include-directive module
105 gnulib-tool --extract-link-directive module
106 gnulib-tool --extract-license module
107 gnulib-tool --extract-maintainer module
108 gnulib-tool --extract-tests-module module
111 --list print the available module names
112 --import import the given modules into the current package;
113 if no modules are specified, update the current
114 package from the current gnulib
115 --update update the current package, restore files omitted
117 --create-testdir create a scratch package with the given modules
118 --create-megatestdir create a mega scratch package with the given modules
119 one by one and all together
120 --test test the combination of the given modules
121 (recommended to use CC=\"gcc -Wall\" here)
122 --megatest test the given modules one by one and all together
123 (recommended to use CC=\"gcc -Wall\" here)
124 --extract-description extract the description
125 --extract-notice extract the notice or banner
126 --extract-filelist extract the list of files
127 --extract-dependencies extract the dependencies
128 --extract-autoconf-snippet extract the snippet for configure.ac
129 --extract-automake-snippet extract the snippet for library makefile
130 --extract-include-directive extract the #include directive
131 --extract-link-directive extract the linker directive
132 --extract-license report the license terms of the source files
134 --extract-maintainer report the maintainer(s) inside gnulib
135 --extract-tests-module report the unit test module, if it exists
138 --dir=DIRECTORY Specify the target directory.
139 For --import, this specifies where your
140 configure.ac can be found. Defaults to current
142 --local-dir=DIRECTORY Specify a local override directory where to look
143 up files before looking in gnulib's directory.
144 --verbose Increase verbosity. May be repeated.
145 --quiet Decrease verbosity. May be repeated.
147 Options for --import:
148 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
149 --source-base=DIRECTORY
150 Directory relative to --dir where source code is
151 placed (default \"lib\").
152 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
153 placed (default \"m4\").
154 --po-base=DIRECTORY Directory relative to --dir where *.po files are
155 placed (default \"po\").
156 --doc-base=DIRECTORY Directory relative to --dir where doc files are
157 placed (default \"doc\").
158 --tests-base=DIRECTORY
159 Directory relative to --dir where unit tests are
160 placed (default \"tests\").
161 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
162 tools are placed (default \"build-aux\").
163 --with-tests Include unit tests for the included modules.
164 --avoid=MODULE Avoid including the given MODULE. Useful if you
165 have code that provides equivalent functionality.
166 This option can be repeated.
167 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
168 Also modify license template from GPL to LGPL.
169 The version number of the LGPL can be specified;
170 the default is currently LGPLv3.
171 --makefile-name=NAME Name of makefile in automake syntax in the
172 source-base and tests-base directories
173 (default \"Makefile.am\").
174 --libtool Use libtool rules.
175 --no-libtool Don't use libtool rules.
176 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
177 'gl_INIT'. Default is 'gl'.
178 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
179 the package name. A suffix '-gnulib' is appended.
180 --no-changelog don't update or create ChangeLog files
182 Options for --import and --update:
183 --dry-run For --import, only print what would have been done.
184 -s, --symbolic, --symlink Make symbolic links instead of copying files.
185 --local-symlink Make symbolic links instead of copying files, only
186 for files from the local override directory.
187 -S, --more-symlinks Make symbolic links instead of copying files, and
188 don't replace copyright notices.
190 Report bugs to <bug-gnulib@gnu.org>."
194 # outputs to stdout the --version message.
198 version=`"$gnulib_dir"/build-aux/git-version-gen /dev/null`
199 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
201 $progname (GNU $package) $version
202 Copyright (C) $year Free Software Foundation, Inc.
203 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
204 This is free software: you are free to change and redistribute it.
205 There is NO WARRANTY, to the extent permitted by law.
207 Written by" "Bruno Haible" "and" "Simon Josefsson"
210 # func_emit_copyright_notice
211 # outputs to stdout a header for a generated file.
212 func_emit_copyright_notice ()
214 echo "# Copyright (C) 2004-2007 Free Software Foundation, Inc."
216 echo "# This file is free software, distributed under the terms of the GNU"
217 echo "# General Public License. As a special exception to the GNU General"
218 echo "# Public License, this file may be distributed as part of a program"
219 echo "# that contains a configuration script generated by Autoconf, under"
220 echo "# the same distribution terms as the rest of that program."
222 echo "# Generated by gnulib-tool."
233 # locates the directory where the gnulib repository lives
235 # - self_abspathname absolute pathname of gnulib-tool
236 # - gnulib_dir absolute pathname of gnulib repository
240 /*) self_abspathname="$0" ;;
241 */*) self_abspathname=`pwd`/"$0" ;;
244 # Iterate through the elements of $PATH.
245 # We use IFS=: instead of
246 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
247 # because the latter does not work when some PATH element contains spaces.
248 # We use a canonicalized $pathx instead of $PATH, because empty PATH
249 # elements are by definition equivalent to '.', however field splitting
250 # according to IFS=: loses empty fields in many shells:
251 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
252 # beginning, at the end, and in the middle),
253 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
254 # at the beginning and at the end,
255 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
256 # Solaris lose empty fields at the end.
257 # The 'case' statement is an optimization, to avoid evaluating the
258 # explicit canonicalization command when $PATH contains no empty fields.
260 if test "${PATH_SEPARATOR+set}" != set; then
262 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
263 chmod +x "$tmp"/conf.sh
264 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
271 if test "$PATH_SEPARATOR" = ";"; then
272 # On Windows, programs are searched in "." before $PATH.
275 # On Unix, we have to convert empty PATH elements to ".".
279 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
284 IFS="$PATH_SEPARATOR"
288 if test -x "$d/$0" && test ! -d "$d/$0"; then
289 self_abspathname="$d/$0"
294 if test -z "$self_abspathname"; then
295 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
299 while test -h "$self_abspathname"; do
300 # Resolve symbolic link.
301 linkval=`func_readlink "$self_abspathname"`
302 test -n "$linkval" || break
304 /* ) self_abspathname="$linkval" ;;
305 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
308 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
312 # creates a temporary directory.
314 # - tmp pathname of freshly created temporary directory
317 # Use the environment variable TMPDIR, falling back to /tmp. This allows
318 # users to specify a different temporary directory, for example, if their
319 # /tmp is filled up or too small.
322 # Use the mktemp program if available. If not available, hide the error
324 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
325 test -n "$tmp" && test -d "$tmp"
328 # Use a simple mkdir command. It is guaranteed to fail if the directory
329 # already exists. $RANDOM is bash specific and expands to empty in shells
330 # other than bash, ksh and zsh. Its use does not increase security;
331 # rather, it minimizes the probability of failure in a very cluttered /tmp
333 tmp=$TMPDIR/gl$$-$RANDOM
334 (umask 077 && mkdir "$tmp")
337 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
342 # func_append var value
343 # appends the given value to the shell variable var.
344 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
345 # Use bash's += operator. It reduces complexity of appending repeatedly to
346 # a single variable from O(n^2) to O(n).
354 eval "$1=\"\$$1\$2\""
358 # func_fatal_error message
359 # outputs to stderr a fatal error message, and terminates the program.
362 echo "gnulib-tool: *** $1" 1>&2
363 echo "gnulib-tool: *** Stop." 1>&2
367 # func_readlink SYMLINK
368 # outputs the target of the given symlink.
369 if (type -p readlink) > /dev/null 2>&1; then
372 # Use the readlink program from GNU coreutils.
378 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
379 # would do the wrong thing if the link target contains " -> ".
380 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
384 # func_relativize DIR1 DIR2
385 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
387 # - DIR1 relative pathname, relative to the current directory
388 # - DIR2 relative pathname, relative to the current directory
390 # - reldir relative pathname of DIR2, relative to DIR1
396 sed_first='s,^\([^/]*\)/.*$,\1,'
397 sed_rest='s,^[^/]*/*,,'
398 sed_last='s,^.*/\([^/]*\)$,\1,'
399 sed_butlast='s,/*[^/]*$,,'
400 while test -n "$dir1"; do
401 first=`echo "$dir1" | sed -e "$sed_first"`
402 if test "$first" != "."; then
403 if test "$first" = ".."; then
404 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
405 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
407 first2=`echo "$dir2" | sed -e "$sed_first"`
408 if test "$first2" = "$first"; then
409 dir2=`echo "$dir2" | sed -e "$sed_rest"`
413 dir0="$dir0"/"$first"
416 dir1=`echo "$dir1" | sed -e "$sed_rest"`
421 # func_relconcat DIR1 DIR2
422 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
424 # - DIR1 relative pathname, relative to the current directory
425 # - DIR2 relative pathname, relative to DIR1
427 # - relconcat DIR1/DIR2, relative to the current directory
432 sed_first='s,^\([^/]*\)/.*$,\1,'
433 sed_rest='s,^[^/]*/*,,'
434 sed_last='s,^.*/\([^/]*\)$,\1,'
435 sed_butlast='s,/*[^/]*$,,'
437 first=`echo "$dir2" | sed -e "$sed_first"`
438 if test "$first" = "."; then
439 dir2=`echo "$dir2" | sed -e "$sed_rest"`
440 if test -z "$dir2"; then
445 last=`echo "$dir1" | sed -e "$sed_last"`
446 while test "$last" = "."; do
447 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
448 last=`echo "$dir1" | sed -e "$sed_last"`
450 if test -z "$dir1"; then
454 if test "$first" = ".."; then
455 if test "$last" = ".."; then
456 relconcat="$dir1/$dir2"
459 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
460 dir2=`echo "$dir2" | sed -e "$sed_rest"`
461 if test -z "$dir1"; then
465 if test -z "$dir2"; then
470 relconcat="$dir1/$dir2"
478 # Like ln -s, except that SRC is given relative to the current directory (or
479 # absolute), not given relative to the directory of DEST.
485 *) # SRC is relative.
488 ln -s "`pwd`/$1" "$2" ;;
489 *) # DEST is relative too.
490 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
491 test -n "$ln_destdir" || ln_destdir="."
492 func_relativize "$ln_destdir" "$1"
500 # func_ln_if_changed SRC DEST
501 # Like func_ln, but avoids munging timestamps if the link is correct.
502 func_ln_if_changed ()
504 if test $# -ne 2; then
505 echo "usage: func_ln_if_changed SRC DEST" >&2
507 ln_target=`func_readlink "$2"`
508 if test -h "$2" && test "$1" = "$ln_target"; then
516 # Ensure an 'echo' command that does not interpret backslashes.
518 # echo '\n' | wc -l prints 1 when OK, 2 when KO
519 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
520 # This problem is a weird heritage from SVR4. BSD got it right (except that
521 # BSD echo interprets '-n' as an option, which is also not desirable).
522 # Nowadays the problem occurs in 4 situations:
523 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
524 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
525 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
526 # - in zsh, when sh-emulation is not set,
527 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
528 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
529 # - in Solaris /bin/sh and OSF/1 /bin/sh.
530 # We try the following workarounds:
531 # - for all: respawn using $CONFIG_SHELL if that is set and works.
532 # - for bash >= 2.04: unset the shell option xpg_echo.
533 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
534 # - for bash < 2.0: define echo to a function that uses cat of a here document.
535 # - for zsh: turn sh-emulation on.
536 # - for ksh: alias echo to 'print -r'.
537 # - for ksh: alias echo to a function that uses cat of a here document.
538 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
539 # the ksh workaround.
540 # - otherwise: respawn using /bin/sh and rely on the workarounds.
541 # When respawning, we pass --no-reexec as first argument, so as to avoid
542 # turning this script into a fork bomb in unlucky situations.
544 if echo '\t' | grep t > /dev/null; then
545 have_echo=yes # Lucky!
547 # Try the workarounds.
548 # Respawn using $CONFIG_SHELL if that is set and works.
549 if test -z "$have_echo" \
550 && test "X$1" != "X--no-reexec" \
551 && test -n "$CONFIG_SHELL" \
552 && test -f "$CONFIG_SHELL" \
553 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
554 exec $CONFIG_SHELL "$0" --no-reexec "$@"
557 # For bash >= 2.04: unset the shell option xpg_echo.
558 if test -z "$have_echo" \
559 && test -n "$BASH_VERSION" \
560 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
564 # For bash >= 2.0: define echo to a function that uses the printf built-in.
565 # For bash < 2.0: define echo to a function that uses cat of a here document.
566 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
567 if test -z "$have_echo" \
568 && test -n "$BASH_VERSION"; then \
569 if type printf 2>/dev/null | grep / > /dev/null; then
570 # 'printf' is not a shell built-in.
578 # 'printf' is a shell built-in.
584 if echo '\t' | grep t > /dev/null; then
588 # For zsh: turn sh-emulation on.
589 if test -z "$have_echo" \
590 && test -n "$ZSH_VERSION" \
591 && (emulate sh) >/dev/null 2>&1; then
594 # For ksh: alias echo to 'print -r'.
595 if test -z "$have_echo" \
596 && (type print) >/dev/null 2>&1; then
597 # A 'print' command exists.
598 if type print 2>/dev/null | grep / > /dev/null; then
601 # 'print' is a shell built-in.
602 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
603 # 'print' is the ksh shell built-in.
604 alias echo='print -r'
608 if test -z "$have_echo" \
609 && echo '\t' | grep t > /dev/null; then
612 # For ksh: alias echo to a function that uses cat of a here document.
613 # The ksh manual page says:
614 # "Aliasing is performed when scripts are read, not while they are executed.
615 # Therefore, for an alias to take effect, the alias definition command has
616 # to be executed before the command which references the alias is read."
617 # Because of this, we have to play strange tricks with have_echo, to ensure
618 # that the top-level statement containing the test starts after the 'alias'
620 if test -z "$have_echo"; then
627 alias echo=bsd_echo 2>/dev/null
629 if test -z "$have_echo" \
630 && echo '\t' | grep t > /dev/null; then
633 if test -z "$have_echo"; then
634 unalias echo 2>/dev/null
636 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
637 if test -z "$have_echo" \
638 && test "X$1" != "X--no-reexec" \
639 && test -f /bin/ksh; then
640 exec /bin/ksh "$0" --no-reexec "$@"
643 # Otherwise: respawn using /bin/sh.
644 if test -z "$have_echo" \
645 && test "X$1" != "X--no-reexec" \
646 && test -f /bin/sh; then
647 exec /bin/sh "$0" --no-reexec "$@"
650 if test -z "$have_echo"; then
651 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
653 if echo '\t' | grep t > /dev/null; then
656 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
658 if test "X$1" = "X--no-reexec"; then
662 # Command-line option processing.
663 # Removes the OPTIONS from the arguments. Sets the variables:
664 # - mode list or import or create-testdir or create-megatestdir
665 # - destdir from --dir
666 # - local_gnulib_dir from --local-dir
667 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
668 # - libname, supplied_libname from --lib
669 # - sourcebase from --source-base
670 # - m4base from --m4-base
671 # - pobase from --po-base
672 # - docbase from --doc-base
673 # - testsbase from --tests-base
674 # - auxdir from --aux-dir
675 # - inctests true if --with-tests was given, blank otherwise
676 # - avoidlist list of modules to avoid, from --avoid
677 # - lgpl yes or a number if --lgpl was given, blank otherwise
678 # - makefile_name from --makefile-name
679 # - libtool true if --libtool was given, false if --no-libtool was
680 # given, blank otherwise
681 # - macro_prefix from --macro-prefix
682 # - po_domain from --po-domain
683 # - autoconf_minversion minimum supported autoconf version
684 # - do_changelog false if --no-changelog was given, : otherwise
685 # - doit : if actions shall be executed, false if only to be printed
686 # - symbolic true if --symlink or --more-symlinks was given, blank
688 # - lsymbolic true if --local-symlink was given, blank otherwise
689 # - do_copyrights blank if --more-symlinks was given, true otherwise
718 while test $# -gt 0; do
723 --import | --impor | --impo | --imp | --im | --i )
726 --update | --updat | --upda | --upd | --up | --u )
729 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
732 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
733 mode=create-megatestdir
735 --test | --tes | --te | --t )
738 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
742 mode=`echo "X$1" | sed -e 's/^X--//'`
747 func_fatal_error "missing argument for --dir"
752 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
757 func_fatal_error "missing argument for --local-dir"
762 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
764 --verbose | --verbos | --verbo | --verb )
765 verbose=`expr $verbose + 1`
767 --quiet | --quie | --qui | --qu | --q )
768 verbose=`expr $verbose - 1`
773 func_fatal_error "missing argument for --lib"
776 supplied_libname=true
779 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
780 supplied_libname=true
785 func_fatal_error "missing argument for --source-base"
790 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
795 func_fatal_error "missing argument for --m4-base"
800 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
805 func_fatal_error "missing argument for --po-base"
810 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
815 func_fatal_error "missing argument for --doc-base"
820 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
825 func_fatal_error "missing argument for --tests-base"
830 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
835 func_fatal_error "missing argument for --aux-dir"
840 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
848 func_fatal_error "missing argument for --avoid"
850 func_append avoidlist " $1"
853 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
854 func_append avoidlist " $arg"
860 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
863 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
870 func_fatal_error "missing argument for --makefile-name"
875 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
886 func_fatal_error "missing argument for --macro-prefix"
891 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
896 func_fatal_error "missing argument for --po-domain"
901 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
903 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
909 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
912 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
915 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
919 --help | --hel | --he | --h )
922 --version | --versio | --versi | --vers )
926 # Stop option processing
930 echo "gnulib-tool: unknown option $1" 1>&2
931 echo "Try 'gnulib-tool --help' for more information." 1>&2
938 if test "$mode" = update; then
939 if test $# != 0; then
940 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
941 echo "Try 'gnulib-tool --help' for more information." 1>&2
942 echo "If you really want to modify the gnulib configuration of your project," 1>&2
943 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
946 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
947 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
948 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
949 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
950 || test -n "$makefile_name" || test -n "$macro_prefix" \
951 || test -n "$po_domain"; then
952 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
953 echo "Try 'gnulib-tool --help' for more information." 1>&2
954 echo "If you really want to modify the gnulib configuration of your project," 1>&2
955 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
960 if test -n "$pobase" && test -z "$po_domain"; then
961 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
962 echo "Try 'gnulib-tool --help' for more information." 1>&2
965 if test -z "$pobase" && test -n "$po_domain"; then
966 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
969 # Determine the minimum supported autoconf version from the project's
971 DEFAULT_AUTOCONF_MINVERSION="2.59"
974 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
975 if test -f "$destdir"/configure.ac; then
976 configure_ac="$destdir/configure.ac"
978 if test -f "$destdir"/configure.in; then
979 configure_ac="$destdir/configure.in"
983 if test -f configure.ac; then
984 configure_ac="configure.ac"
986 if test -f configure.in; then
987 configure_ac="configure.in"
991 if test -n "$configure_ac"; then
992 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
993 # because when some m4 files are omitted from a CVS repository,
994 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
995 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
996 # autom4te: m4 failed with exit status: 1
1003 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1005 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1006 if test -n "$prereqs"; then
1007 autoconf_minversion=`
1008 for version in $prereqs; do echo $version; done |
1009 LC_ALL=C sort -nru | sed 1q
1013 if test -z "$autoconf_minversion"; then
1014 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1016 case "$autoconf_minversion" in
1017 1.* | 2.[0-4]* | 2.5[0-8]*)
1018 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1021 # Remove trailing slashes from the directory names. This is necessary for
1022 # m4base (to avoid an error in func_import) and optional for the others.
1023 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1024 case "$local_gnulib_dir" in
1025 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1027 case "$sourcebase" in
1028 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1031 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1034 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1037 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1039 case "$testsbase" in
1040 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1043 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1049 trap 'exit_status=$?
1050 if test "$signal" != 0; then
1051 echo "caught signal $signal" >&2
1054 exit $exit_status' 0
1055 for signal in 1 2 3 13 15; do
1056 trap '{ signal='$signal'; func_exit 1; }' $signal
1060 # func_lookup_file file
1061 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1064 # - local_gnulib_dir from --local-dir
1066 # - lookedup_file name of the merged (combined) file
1067 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1071 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1072 lookedup_file="$local_gnulib_dir/$lkfile"
1075 if test -f "$gnulib_dir/$lkfile"; then
1076 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1077 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1078 rm -f "$tmp/$lkbase"
1079 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1080 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1081 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1082 lookedup_file="$tmp/$lkbase"
1085 lookedup_file="$gnulib_dir/$lkfile"
1089 func_fatal_error "file $gnulib_dir/$lkfile not found"
1096 # - local_gnulib_dir from --local-dir
1099 # Filter out metainformation files like README, which are not modules.
1100 # Filter out unit test modules; they can be retrieved through
1101 # --extract-tests-module if desired.
1103 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1104 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1105 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1108 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1109 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1110 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1111 -e '/^README$/d' -e '/\/README$/d' \
1112 -e '/^TEMPLATE$/d' \
1113 -e '/^TEMPLATE-EXTENDED$/d' \
1114 -e '/^TEMPLATE-TESTS$/d' \
1117 | sed -e '/-tests$/d' \
1121 # func_verify_module
1122 # verifies a module name
1124 # - local_gnulib_dir from --local-dir
1125 # - module module name argument
1126 func_verify_module ()
1128 if { test -f "$gnulib_dir/modules/$module" \
1129 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1130 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1131 && test "CVS" != "$module" \
1132 && test "ChangeLog" != "$module" \
1133 && test "COPYING" != "$module" \
1134 && test "README" != "$module" \
1135 && test "TEMPLATE" != "$module" \
1136 && test "TEMPLATE-EXTENDED" != "$module" \
1137 && test "TEMPLATE-TESTS" != "$module"; then
1138 # OK, $module is a correct module name.
1139 # Verify that building the module description with 'patch' succeeds.
1140 func_lookup_file "modules/$module"
1142 echo "gnulib-tool: module $module doesn't exist" 1>&2
1147 # func_verify_nontests_module
1148 # verifies a module name, excluding tests modules
1150 # - local_gnulib_dir from --local-dir
1151 # - module module name argument
1152 func_verify_nontests_module ()
1155 *-tests ) module= ;;
1156 * ) func_verify_module ;;
1160 # func_verify_tests_module
1161 # verifies a module name, considering only tests modules
1163 # - local_gnulib_dir from --local-dir
1164 # - module module name argument
1165 func_verify_tests_module ()
1168 *-tests ) func_verify_module ;;
1173 sed_extract_prog=':[ ]*$/ {
1176 s/^Description:[ ]*$//
1179 s/^Depends-on:[ ]*$//
1180 s/^configure\.ac-early:[ ]*$//
1181 s/^configure\.ac:[ ]*$//
1182 s/^Makefile\.am:[ ]*$//
1186 s/^Maintainer:[ ]*$//
1193 # func_get_description module
1195 # - local_gnulib_dir from --local-dir
1196 func_get_description ()
1198 func_lookup_file "modules/$1"
1199 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1202 # func_get_notice module
1204 # - local_gnulib_dir from --local-dir
1207 func_lookup_file "modules/$1"
1208 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1211 # func_get_filelist module
1213 # - local_gnulib_dir from --local-dir
1214 func_get_filelist ()
1216 func_lookup_file "modules/$1"
1217 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1218 echo m4/gnulib-common.m4
1219 case "$autoconf_minversion" in
1221 #echo m4/onceonly.m4
1222 echo m4/onceonly_2_57.m4
1227 # func_get_dependencies module
1229 # - local_gnulib_dir from --local-dir
1230 func_get_dependencies ()
1232 # ${module}-tests always implicitly depends on ${module}.
1233 echo "$1" | sed -n -e 's/-tests$//p'
1234 # Then the explicit dependencies listed in the module description.
1235 func_lookup_file "modules/$1"
1236 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1239 # func_get_autoconf_early_snippet module
1241 # - local_gnulib_dir from --local-dir
1242 func_get_autoconf_early_snippet ()
1244 func_lookup_file "modules/$1"
1245 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1248 # func_get_autoconf_snippet module
1250 # - local_gnulib_dir from --local-dir
1251 func_get_autoconf_snippet ()
1253 func_lookup_file "modules/$1"
1254 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1257 # func_get_automake_snippet module
1259 # - local_gnulib_dir from --local-dir
1260 func_get_automake_snippet ()
1262 func_lookup_file "modules/$1"
1263 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1266 # *-tests module live in tests/, not lib/.
1267 # Synthesize an EXTRA_DIST augmentation.
1268 all_files=`func_get_filelist $1`
1269 tests_files=`for f in $all_files; do \
1271 tests/*) echo $f ;; \
1273 done | sed -e 's,^tests/,,'`
1274 extra_files="$tests_files"
1275 if test -n "$extra_files"; then
1276 echo "EXTRA_DIST +=" $extra_files
1281 # Synthesize an EXTRA_DIST augmentation.
1282 sed_combine_lines='/\\$/{
1289 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1290 already_mentioned_files=` \
1291 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1292 | sed -e "$sed_combine_lines" \
1293 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1294 all_files=`func_get_filelist $1`
1295 lib_files=`for f in $all_files; do \
1299 done | sed -e 's,^lib/,,'`
1300 # Remove $already_mentioned_files from $lib_files.
1301 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1302 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1303 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1304 if test -n "$extra_files"; then
1305 echo "EXTRA_DIST +=" $extra_files
1308 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1309 # This is necessary so that automake can generate the right list of
1311 # A possible approach would be to use autom4te --trace of the redefined
1312 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1313 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1314 # inside autoconf's built-in macros are not missed).
1315 # But it's simpler and more robust to do it here, based on the file list.
1316 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1317 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1318 # automake will generate a useless dependency; this is harmless.
1320 relocatable-prog-wrapper) ;;
1322 sed_extract_c_files='/\.c$/p'
1323 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1324 if test -n "$extra_files"; then
1325 echo "EXTRA_lib_SOURCES +=" $extra_files
1330 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1331 buildaux_files=`for f in $all_files; do \
1333 build-aux/*) echo $f ;; \
1335 done | sed -e 's,^build-aux/,,'`
1336 if test -n "$buildaux_files"; then
1337 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1338 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1345 # func_get_include_directive module
1347 # - local_gnulib_dir from --local-dir
1348 func_get_include_directive ()
1350 func_lookup_file "modules/$1"
1351 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1352 sed -e 's/^\(["<]\)/#include \1/'
1355 # func_get_link_directive module
1357 # - local_gnulib_dir from --local-dir
1358 func_get_link_directive ()
1360 func_lookup_file "modules/$1"
1361 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1364 # func_get_license module
1366 # - local_gnulib_dir from --local-dir
1369 func_lookup_file "modules/$1"
1370 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1371 # The default is GPL.
1373 } | sed -e 's,^ *$,,' | sed -e 1q
1376 # func_get_maintainer module
1378 # - local_gnulib_dir from --local-dir
1379 func_get_maintainer ()
1381 func_lookup_file "modules/$1"
1382 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1385 # func_get_tests_module module
1387 # - local_gnulib_dir from --local-dir
1388 func_get_tests_module ()
1390 # The naming convention for tests modules is hardwired: ${module}-tests.
1391 if test -f "$gnulib_dir/modules/$1"-tests \
1392 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1393 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1398 # func_acceptable module
1399 # tests whether a module is acceptable.
1401 # - avoidlist list of modules to avoid
1404 for avoid in $avoidlist; do
1405 if test "$avoid" = "$1"; then
1412 # func_modules_transitive_closure
1414 # - local_gnulib_dir from --local-dir
1415 # - modules list of specified modules
1416 # - inctests true if tests should be included, blank otherwise
1417 # - avoidlist list of modules to avoid
1418 # - tmp pathname of a temporary directory
1420 # - modules list of modules, including dependencies
1421 func_modules_transitive_closure ()
1423 # In order to process every module only once (for speed), process an "input
1424 # list" of modules, producing an "output list" of modules. During each round,
1425 # more modules can be queued in the input list. Once a module on the input
1426 # list has been processed, it is added to the "handled list", so we can avoid
1427 # to process it again.
1429 inmodules="$modules"
1431 while test -n "$inmodules"; do
1432 inmodules_this_round="$inmodules"
1433 inmodules= # Accumulator, queue for next round
1434 for module in $inmodules_this_round; do
1436 if test -n "$module"; then
1437 if func_acceptable $module; then
1438 func_append outmodules " $module"
1439 deps=`func_get_dependencies $module`
1440 # Duplicate dependencies are harmless, but Jim wants a warning.
1441 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1442 if test -n "$duplicated_deps"; then
1443 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1445 func_append inmodules " $deps"
1446 if test -n "$inctests"; then
1447 testsmodule=`func_get_tests_module $module`
1448 if test -n "$testsmodule"; then
1449 func_append inmodules " $testsmodule"
1455 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1456 # Remove $handledmodules from $inmodules.
1457 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1458 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1460 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1461 rm -f "$tmp"/queued-modules
1464 # func_modules_add_dummy
1466 # - local_gnulib_dir from --local-dir
1467 # - modules list of modules, including dependencies
1469 # - modules list of modules, including 'dummy' if needed
1470 func_modules_add_dummy ()
1473 sed_remove_backslash_newline=':a
1480 for module in $modules; do
1481 func_verify_nontests_module
1482 if test -n "$module"; then
1483 # Extract the value of "lib_SOURCES += ...".
1484 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1485 # Ignore .h files since they are not compiled.
1488 *) have_lib_SOURCES=yes ;;
1493 # Add the dummy module, to make sure the library will be non-empty.
1494 if test -z "$have_lib_SOURCES"; then
1495 if func_acceptable "dummy"; then
1496 func_append modules " dummy"
1501 # func_modules_notice
1503 # - local_gnulib_dir from --local-dir
1504 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1505 # - modules list of modules, including dependencies
1506 func_modules_notice ()
1508 if test $verbose -ge -1; then
1509 for module in $modules; do
1511 if test -n "$module"; then
1512 msg=`func_get_notice $module`
1513 if test -n "$msg"; then
1514 echo "Notice from module $module:"
1515 echo "$msg" | sed -e 's/^/ /'
1522 # func_modules_to_filelist
1524 # - local_gnulib_dir from --local-dir
1525 # - modules list of modules, including dependencies
1527 # - files list of files
1528 func_modules_to_filelist ()
1531 for module in $modules; do
1533 if test -n "$module"; then
1534 fs=`func_get_filelist $module`
1535 func_append files " $fs"
1538 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1541 # func_execute_command command [args...]
1542 # Executes a command.
1543 # Uses also the variables
1544 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1545 func_execute_command ()
1547 if test $verbose -ge 0; then
1551 # Commands like automake produce output to stderr even when the succeed.
1552 # Turn this output off if the command succeeds.
1553 "$@" > "$tmp"/cmdout 2>&1
1555 if test $cmdret = 0; then
1559 cat "$tmp"/cmdout 1>&2
1566 # func_emit_lib_Makefile_am
1567 # emits the contents of library makefile to standard output.
1569 # - local_gnulib_dir from --local-dir
1570 # - modules list of modules, including dependencies
1571 # - libname library name
1572 # - pobase directory relative to destdir where to place *.po files
1573 # - auxdir directory relative to destdir where to place build aux files
1574 # - makefile_name from --makefile-name
1575 # - libtool true if libtool will be used, false or blank otherwise
1576 # - macro_prefix prefix of gl_LIBOBJS macros to use
1577 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1578 # - actioncmd (optional) command that will reproduce this invocation
1579 # - for_test true if creating a package for testing, false otherwise
1581 # - uses_subdirs nonempty if object files in subdirs exist
1582 func_emit_lib_Makefile_am ()
1584 # When creating an includable Makefile.am snippet, augment variables with
1585 # += instead of assigning them.
1586 if test -n "$makefile_name"; then
1591 if test "$libtool" = true; then
1594 sed_eliminate_LDFLAGS=
1598 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1601 # When creating a package for testing: Attempt to provoke failures,
1602 # especially link errors, already during "make" rather than during
1603 # "make check", because "make check" is not possible in a cross-compiling
1604 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1605 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1607 sed_transform_check_PROGRAMS=
1609 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1610 echo "## Process this file with automake to produce Makefile.in."
1611 func_emit_copyright_notice
1612 if test -n "$actioncmd"; then
1613 echo "# Reproduce by: $actioncmd"
1618 for module in $modules; do
1619 func_verify_nontests_module
1620 if test -n "$module"; then
1622 func_get_automake_snippet "$module" |
1623 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1624 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1625 -e "$sed_eliminate_LDFLAGS" \
1626 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1627 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1628 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1629 -e "$sed_transform_check_PROGRAMS"
1630 if test "$module" = 'alloca'; then
1631 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1632 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1635 # Skip the contents if its entirely empty.
1636 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1637 echo "## begin gnulib module $module"
1640 echo "## end gnulib module $module"
1644 # Test whether there are some source files in subdirectories.
1645 for f in `func_get_filelist "$module"`; do
1647 lib/*/*.c) uses_subdirs=yes ;;
1653 if test -z "$makefile_name"; then
1654 # If there are source files in subdirectories, prevent collision of the
1655 # object files (example: hash.c and libxml/hash.c).
1657 if test -n "$uses_subdirs"; then
1658 subdir_options=' subdir-objects'
1660 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1663 if test -z "$makefile_name"; then
1664 echo "noinst_HEADERS ="
1665 echo "noinst_LIBRARIES ="
1666 echo "noinst_LTLIBRARIES ="
1667 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1668 # if you specify pkgdata_DATA to empty. This is a workaround.
1669 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1670 echo "pkgdata_DATA ="
1673 echo "BUILT_SOURCES ="
1676 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1677 if test -z "$makefile_name"; then
1678 echo "MOSTLYCLEANDIRS ="
1680 echo "DISTCLEANFILES ="
1681 echo "MAINTAINERCLEANFILES ="
1683 echo "AM_CPPFLAGS ="
1686 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1687 # One of the snippets already specifies an installation location for the
1688 # library. Don't confuse automake by saying it should not be installed.
1691 # By default, the generated library should not be installed.
1692 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1695 echo "${libname}_${libext}_SOURCES ="
1696 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1697 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1698 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1699 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1700 echo "EXTRA_${libname}_${libext}_SOURCES ="
1701 if test "$libtool" = true; then
1702 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1705 if test -n "$pobase"; then
1706 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1709 cat allsnippets.tmp \
1710 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1712 echo "mostlyclean-local: mostlyclean-generic"
1713 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1714 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1715 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1719 rm -f allsnippets.tmp
1722 # func_emit_po_Makevars
1723 # emits the contents of po/ makefile parametrization to standard output.
1725 # - local_gnulib_dir from --local-dir
1726 # - sourcebase directory relative to destdir where to place source code
1727 # - pobase directory relative to destdir where to place *.po files
1728 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1729 func_emit_po_Makevars ()
1731 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1732 func_emit_copyright_notice
1734 echo "# Usually the message domain is the same as the package name."
1735 echo "# But here it has a '-gnulib' suffix."
1736 echo "DOMAIN = ${po_domain}-gnulib"
1738 echo "# These two variables depend on the location of this directory."
1739 echo "subdir = ${pobase}"
1740 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1743 # These options get passed to xgettext.
1744 XGETTEXT_OPTIONS = \
1745 --keyword=_ --flag=_:1:pass-c-format \
1746 --keyword=N_ --flag=N_:1:pass-c-format \
1747 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1748 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1749 --flag=error:3:c-format --flag=error_at_line:5:c-format
1751 # This is the copyright holder that gets inserted into the header of the
1752 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1753 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1755 # This is the email address or URL to which the translators shall report
1756 # bugs in the untranslated strings:
1757 # - Strings which are not entire sentences, see the maintainer guidelines
1758 # in the GNU gettext documentation, section 'Preparing Strings'.
1759 # - Strings which use unclear terms or require additional context to be
1761 # - Strings which make invalid assumptions about notation of date, time or
1763 # - Pluralisation problems.
1764 # - Incorrect English spelling.
1765 # - Incorrect formatting.
1766 # It can be your email address, or a mailing list address where translators
1767 # can write to without being subscribed, or the URL of a web page through
1768 # which the translators can contact you.
1769 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1771 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1772 # message catalogs shall be used. It is usually empty.
1773 EXTRA_LOCALE_CATEGORIES =
1775 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1776 # context. Possible values are "yes" and "no". Set this to yes if the
1777 # package uses functions taking also a message context, like pgettext(), or
1778 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1783 # func_emit_po_POTFILES_in
1784 # emits the file list to be passed to xgettext to standard output.
1786 # - local_gnulib_dir from --local-dir
1787 # - sourcebase directory relative to destdir where to place source code
1788 # - files list of new files
1789 func_emit_po_POTFILES_in ()
1791 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1792 func_emit_copyright_notice
1794 echo "# List of files which contain translatable strings."
1795 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1798 # func_emit_tests_Makefile_am
1799 # emits the contents of tests makefile to standard output.
1801 # - local_gnulib_dir from --local-dir
1802 # - modules list of modules, including dependencies
1803 # - libname library name
1804 # - auxdir directory relative to destdir where to place build aux files
1805 # - makefile_name from --makefile-name
1806 # - libtool true if libtool will be used, false or blank otherwise
1807 # - sourcebase relative directory containing lib source code
1808 # - m4base relative directory containing autoconf macros
1809 # - testsbase relative directory containing unit test code
1810 # - macro_prefix prefix of gl_LIBOBJS macros to use
1811 # - for_test true if creating a package for testing, false otherwise
1812 # - use_libtests true if a libtests.a should be built, false otherwise
1814 # - uses_subdirs nonempty if object files in subdirs exist
1815 func_emit_tests_Makefile_am ()
1817 if test "$libtool" = true; then
1819 sed_eliminate_LDFLAGS=
1822 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1825 # When creating a package for testing: Attempt to provoke failures,
1826 # especially link errors, already during "make" rather than during
1827 # "make check", because "make check" is not possible in a cross-compiling
1828 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1829 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1831 sed_transform_check_PROGRAMS=
1833 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1834 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1835 echo "## Process this file with automake to produce Makefile.in."
1836 func_emit_copyright_notice
1840 for module in $modules; do
1842 func_verify_tests_module
1846 if test -n "$module"; then
1848 func_get_automake_snippet "$module" |
1849 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1850 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1851 -e "$sed_eliminate_LDFLAGS" \
1852 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
1853 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1854 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1855 -e "$sed_transform_check_PROGRAMS"
1856 if $use_libtests && test "$module" = 'alloca'; then
1857 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
1858 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1861 # Skip the contents if its entirely empty.
1862 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1863 echo "## begin gnulib module $module"
1866 echo "## end gnulib module $module"
1870 # Test whether there are some source files in subdirectories.
1871 for f in `func_get_filelist "$module"`; do
1873 lib/*/*.c | tests/*/*.c) uses_subdirs=yes ;;
1879 # Generate dependencies here, since it eases the debugging of test failures.
1880 # If there are source files in subdirectories, prevent collision of the
1881 # object files (example: hash.c and libxml/hash.c).
1883 if test -n "$uses_subdirs"; then
1884 subdir_options=' subdir-objects'
1886 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
1889 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1892 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1893 # variable is needed to avoid an error from automake:
1894 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1897 echo "TESTS_ENVIRONMENT ="
1898 echo "noinst_PROGRAMS ="
1899 if ! $for_test; then
1900 echo "check_PROGRAMS ="
1902 echo "noinst_HEADERS ="
1903 echo "noinst_LIBRARIES ="
1904 if $use_libtests; then
1906 echo "noinst_LIBRARIES += libtests.a"
1908 echo "check_LIBRARIES = libtests.a"
1911 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1912 # if you specify pkgdata_DATA to empty. This is a workaround.
1913 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1914 echo "pkgdata_DATA ="
1917 echo "BUILT_SOURCES ="
1919 echo "MOSTLYCLEANFILES = core *.stackdump"
1920 echo "MOSTLYCLEANDIRS ="
1922 echo "DISTCLEANFILES ="
1923 echo "MAINTAINERCLEANFILES ="
1925 echo "AM_CPPFLAGS = \\"
1926 echo " -I. -I\$(srcdir) \\"
1927 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1928 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1930 local_ldadd_before=''
1931 local_ldadd_after=''
1932 if $use_libtests; then
1933 # All test programs need to be linked with libtests.a.
1934 # It needs to be passed to the linker before ${libname}.${libext}, since
1935 # the tests-related modules depend on the main modules.
1936 # It also needs to be passed to the linker after ${libname}.${libext}
1937 # because the latter might contain incomplete modules (such as the 'error'
1938 # module whose dependency to 'progname' is voluntarily omitted).
1939 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
1941 local_ldadd_before=' libtests.a'
1942 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
1944 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
1946 if $use_libtests; then
1947 echo "libtests_a_SOURCES ="
1948 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1949 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1950 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
1951 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
1952 echo "EXTRA_libtests_a_SOURCES ="
1953 # The circular dependency in LDADD requires this.
1954 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
1957 cat allsnippets.tmp \
1958 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1959 echo "# Clean up after Solaris cc."
1961 echo " rm -rf SunWS_cache"
1963 echo "mostlyclean-local: mostlyclean-generic"
1964 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1965 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1966 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1970 rm -f allsnippets.tmp
1973 # func_emit_initmacro_start macro_prefix
1974 # emits the first few statements of the gl_INIT macro to standard output.
1975 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1976 func_emit_initmacro_start ()
1978 macro_prefix_arg="$1"
1979 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1980 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
1981 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1982 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1984 # Furthermore it avoids an automake error like this when a Makefile.am
1985 # that uses pieces of gnulib also uses $(LIBOBJ):
1986 # automatically discovered file `error.c' should not be explicitly mentioned
1987 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
1988 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
1989 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1990 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1991 # automatically discovered file `error.c' should not be explicitly mentioned
1992 # We let automake know about the files to be distributed through the
1993 # EXTRA_lib_SOURCES variable.
1994 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
1997 # func_emit_initmacro_end macro_prefix
1998 # emits the last few statements of the gl_INIT macro to standard output.
1999 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2000 func_emit_initmacro_end ()
2002 macro_prefix_arg="$1"
2003 echo " m4_popdef([AC_LIBSOURCES])"
2004 echo " m4_popdef([AC_REPLACE_FUNCS])"
2005 echo " m4_popdef([AC_LIBOBJ])"
2006 echo " AC_CONFIG_COMMANDS_PRE(["
2007 echo " ${macro_prefix_arg}_libobjs="
2008 echo " ${macro_prefix_arg}_ltlibobjs="
2009 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2010 echo " # Remove the extension."
2011 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2012 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2013 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2014 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2017 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2018 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2022 # func_emit_initmacro_done macro_prefix sourcebase
2023 # emits a few statements after the gl_INIT macro to standard output.
2024 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2025 # - sourcebase directory relative to destdir where to place source code
2026 func_emit_initmacro_done ()
2028 macro_prefix_arg="$1"
2031 echo "# Like AC_LIBOBJ, except that the module name goes"
2032 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2033 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2034 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2035 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2038 echo "# m4_foreach_w is provided by autoconf-2.59c and later."
2039 echo "# This definition is to accommodate developers using versions"
2040 echo "# of autoconf older than that."
2041 echo "m4_ifndef([m4_foreach_w],"
2042 echo " [m4_define([m4_foreach_w],"
2043 echo " [m4_foreach([\$1], m4_split(m4_normalize([\$2]), [ ]), [\$3])])])"
2045 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2046 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2047 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2048 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2049 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2052 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2053 echo "# expected is derived from the gnulib-tool parametrization,"
2054 echo "# and alloca is special cased (for the alloca-opt module)."
2055 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2056 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2057 echo " m4_foreach([_gl_NAME], [\$1], ["
2058 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2059 echo " m4_syscmd([test -r $sourcebase_arg/]_gl_NAME[ || test ! -d $sourcebase_arg])dnl"
2060 echo " m4_if(m4_sysval, [0], [],"
2061 echo " [AC_FATAL([missing $sourcebase_arg/]_gl_NAME)])"
2067 # func_import modules
2068 # Uses also the variables
2069 # - destdir target directory
2070 # - local_gnulib_dir from --local-dir
2071 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2072 # - libname library name
2073 # - sourcebase directory relative to destdir where to place source code
2074 # - m4base directory relative to destdir where to place *.m4 macros
2075 # - pobase directory relative to destdir where to place *.po files
2076 # - docbase directory relative to destdir where to place doc files
2077 # - testsbase directory relative to destdir where to place unit test code
2078 # - auxdir directory relative to destdir where to place build aux files
2079 # - inctests true if --with-tests was given, blank otherwise
2080 # - avoidlist list of modules to avoid, from --avoid
2081 # - lgpl yes or a number if library's license shall be LGPL,
2083 # - makefile_name from --makefile-name
2084 # - libtool true if --libtool was given, false if --no-libtool was
2085 # given, blank otherwise
2086 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2087 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2088 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2089 # - autoconf_minversion minimum supported autoconf version
2090 # - doit : if actions shall be executed, false if only to be printed
2091 # - symbolic true if files should be symlinked, copied otherwise
2092 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2094 # - do_copyrights true if copyright notices in files should be replaced,
2098 # Get the cached settings.
2099 cached_local_gnulib_dir=
2100 cached_specified_modules=
2110 cached_makefile_name=
2112 cached_macro_prefix=
2115 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2116 cached_libtool=false
2122 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
2125 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
2128 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
2131 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
2134 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
2137 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
2140 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
2143 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
2146 s,^.*$,cached_inctests=true,p
2149 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
2152 s,^.*gl_LGPL([[ ]*\([^])]*\).*$,cached_lgpl="\1",p
2155 s,^.*$,cached_lgpl=yes,p
2157 /gl_MAKEFILE_NAME(/ {
2158 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
2161 s,^.*$,cached_libtool=true,p
2163 /gl_MACRO_PREFIX(/ {
2164 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2167 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2169 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2170 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2175 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2176 s,^.*$,cached_files=",p
2188 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2192 # Merge the cached settings with the specified ones.
2193 # The m4base must be the same as expected from the pathname.
2194 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2195 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2197 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2198 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2199 if test -z "$local_gnulib_dir"; then
2200 if test -n "$cached_local_gnulib_dir"; then
2203 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2205 case "$cached_local_gnulib_dir" in
2207 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2209 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2210 local_gnulib_dir="$relconcat" ;;
2215 # Append the cached and the specified module names. So that
2216 # "gnulib-tool --import foo" means to add the module foo.
2217 specified_modules="$cached_specified_modules $1"
2218 # Append the cached and the specified avoidlist. This is probably better
2219 # than dropping the cached one when --avoid is specified at least once.
2220 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2221 avoidlist=`echo $avoidlist`
2223 # The sourcebase defaults to the cached one.
2224 if test -z "$sourcebase"; then
2225 sourcebase="$cached_sourcebase"
2226 if test -z "$sourcebase"; then
2227 func_fatal_error "missing --source-base option"
2230 # The pobase defaults to the cached one.
2231 if test -z "$pobase"; then
2232 pobase="$cached_pobase"
2234 # The docbase defaults to the cached one.
2235 if test -z "$docbase"; then
2236 docbase="$cached_docbase"
2237 if test -z "$docbase"; then
2238 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."
2241 # The testsbase defaults to the cached one.
2242 if test -z "$testsbase"; then
2243 testsbase="$cached_testsbase"
2244 if test -z "$testsbase"; then
2245 func_fatal_error "missing --tests-base option"
2248 # Require the tests if specified either way.
2249 if test -z "$inctests"; then
2250 inctests="$cached_inctests"
2252 # The libname defaults to the cached one.
2253 if test -z "$supplied_libname"; then
2254 libname="$cached_libname"
2255 if test -z "$libname"; then
2256 func_fatal_error "missing --lib option"
2259 # Require LGPL if specified either way.
2260 if test -z "$lgpl"; then
2263 # The makefile_name defaults to the cached one.
2264 if test -z "$makefile_name"; then
2265 makefile_name="$cached_makefile_name"
2267 # Use libtool if specified either way, or if guessed.
2268 if test -z "$libtool"; then
2269 if test -n "$cached_m4base"; then
2270 libtool="$cached_libtool"
2272 libtool="$guessed_libtool"
2275 # The macro_prefix defaults to the cached one.
2276 if test -z "$macro_prefix"; then
2277 macro_prefix="$cached_macro_prefix"
2278 if test -z "$macro_prefix"; then
2279 func_fatal_error "missing --macro-prefix option"
2282 # The po_domain defaults to the cached one.
2283 if test -z "$po_domain"; then
2284 po_domain="$cached_po_domain"
2287 # Canonicalize the list of specified modules.
2288 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2290 # Determine final module list.
2291 modules="$specified_modules"
2292 func_modules_transitive_closure
2293 if test $verbose -ge 0; then
2294 echo "Module list with included dependencies:"
2295 echo "$modules" | sed -e 's/^/ /'
2297 final_modules="$modules"
2299 # Determine main module list and tests-related module list separately.
2300 # The main module list is the transitive closure of the specified modules,
2301 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2302 # is specified, it will consist only of LGPLed source.
2303 # The tests-related module list is the transitive closure of the specified
2304 # modules, including tests modules, minus the main module list. Its lib/*
2305 # sources (brought in through dependencies of *-tests modules) go into
2306 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2307 # Determine main module list.
2308 saved_inctests="$inctests"
2310 modules="$specified_modules"
2311 func_modules_transitive_closure
2312 main_modules="$modules"
2313 inctests="$saved_inctests"
2314 if test $verbose -ge 1; then
2315 echo "Main module list:"
2316 echo "$main_modules" | sed -e 's/^/ /'
2318 # Determine tests-related module list.
2319 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2320 testsrelated_modules=`echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2321 if test $verbose -ge 1; then
2322 echo "Tests-related module list:"
2323 echo "$testsrelated_modules" | sed -e 's/^/ /'
2326 # Add the dummy module to the main module list if needed.
2327 modules="$main_modules"
2328 func_modules_add_dummy
2329 main_modules="$modules"
2331 # Determine whether a $testsbase/libtests.a is needed.
2333 for module in $testsrelated_modules; do
2334 func_verify_nontests_module
2335 if test -n "$module"; then
2336 all_files=`func_get_filelist $module`
2337 lib_files=`for f in $all_files; do \
2341 done | sed -e 's,^lib/,,'`
2342 if test -n "$lib_files"; then
2349 # Add the dummy module to the tests-related module list if needed.
2350 if $use_libtests; then
2351 modules="$testsrelated_modules"
2352 func_modules_add_dummy
2353 testsrelated_modules="$modules"
2356 # If --lgpl, verify that the licenses of modules are compatible.
2357 if test -n "$lgpl"; then
2358 for module in $main_modules; do
2359 license=`func_get_license $module`
2361 'GPLed build tool') ;;
2362 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2368 *) func_fatal_error "incompatible license on module $module: $license" ;;
2374 *) func_fatal_error "incompatible license on module $module: $license" ;;
2377 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2384 # Show banner notice of every module.
2385 modules="$main_modules"
2388 # Determine script to apply to imported library files.
2389 sed_transform_lib_file=
2390 for module in $main_modules; do
2391 if test $module = config-h; then
2392 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2393 sed_transform_lib_file=$sed_transform_lib_file'
2394 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2399 sed_transform_main_lib_file="$sed_transform_lib_file"
2400 if test -n "$do_copyrights"; then
2401 if test -n "$lgpl"; then
2405 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2406 s/GNU General/GNU Lesser General/g
2410 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2411 s/GNU General/GNU Lesser General/g
2412 s/version [23]\([ ,]\)/version 2.1\1/g
2415 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2419 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2420 s/GNU Lesser General/GNU General/g
2421 s/GNU Library General/GNU General/g
2422 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2427 # Determine script to apply to library files that go into $testsbase/.
2428 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2429 if test -n "$do_copyrights"; then
2431 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2432 s/GNU Lesser General/GNU General/g
2433 s/GNU Library General/GNU General/g
2434 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2438 # Determine the final file lists.
2439 # They must be computed separately, because files in lib/* go into
2440 # $sourcebase/ if they are in the main file list but into $testsbase/
2441 # if they are in the tests-related file list. Furthermore lib/dummy.c
2443 # Determine final main file list.
2444 modules="$main_modules"
2445 func_modules_to_filelist
2447 # Determine final tests-related file list.
2448 modules="$testsrelated_modules"
2449 func_modules_to_filelist
2450 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2451 # Merge both file lists.
2452 sed_remove_empty_lines='/^$/d'
2453 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2454 if test $verbose -ge 0; then
2456 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2457 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2461 || func_fatal_error "refusing to do nothing"
2463 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2464 new_files="$files m4/gnulib-tool.m4"
2465 old_files="$cached_files"
2466 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2467 func_append old_files " m4/gnulib-tool.m4"
2470 sed_rewrite_old_files="\
2471 s,^build-aux/,$auxdir/,
2472 s,^doc/,$cached_docbase/,
2473 s,^lib/,$cached_sourcebase/,
2474 s,^m4/,$cached_m4base/,
2475 s,^tests/,$cached_testsbase/,
2476 s,^tests=lib/,$cached_testsbase/,"
2477 sed_rewrite_new_files="\
2478 s,^build-aux/,$auxdir/,
2480 s,^lib/,$sourcebase/,
2482 s,^tests/,$testsbase/,
2483 s,^tests=lib/,$testsbase/,"
2485 # Create directories.
2486 { echo "$sourcebase"
2488 if test -n "$pobase"; then
2491 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2492 if test -n "$docfiles"; then
2495 if test -n "$inctests"; then
2499 for f in $files; do echo $f; done \
2500 | sed -e "$sed_rewrite_new_files" \
2501 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2504 { # Rearrange file descriptors. Needed because "while ... done < ..."
2505 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2506 exec 5<&0 < "$tmp"/dirs
2508 if test ! -d "$destdir/$d"; then
2510 echo "Creating directory $destdir/$d"
2511 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2513 echo "Create directory $destdir/$d"
2520 # func_dest_tmpfilename file
2521 # determines the name of a temporary file (file is relative to destdir).
2523 # - tmpfile absolute filename of the temporary file
2524 func_dest_tmpfilename ()
2527 # Put the new contents of $file in a file in the same directory (needed
2528 # to guarantee that an 'mv' to "$destdir/$file" works).
2529 tmpfile="$destdir/$1.tmp"
2531 # Put the new contents of $file in a file in a temporary directory
2532 # (because the directory of "$file" might not exist).
2533 tmpfile="$tmp"/`basename "$1"`.tmp
2537 # Copy files or make symbolic links. Remove obsolete files.
2541 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2542 # representing the files according to the last gnulib-tool invocation.
2543 for f in $old_files; do echo $f; done \
2544 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2547 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2548 # representing the files after this gnulib-tool invocation.
2549 for f in $new_files; do echo $f; done \
2550 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2553 # First the files that are in old-files, but not in new-files:
2554 sed_take_first_column='s,'"$delimiter"'.*,,'
2555 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2556 # Remove the file. Do nothing if the user already removed it.
2557 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2559 echo "Removing file $g (backup in ${g}~)"
2560 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2562 echo "Remove file $g (backup in ${g}~)"
2564 func_append removed_files "$g$nl"
2567 # func_add_or_update handles a file that ought to be present afterwards.
2569 # - f the original file name
2570 # - g the rewritten file name
2571 # - already_present nonempty if the file already exists, empty otherwise
2572 func_add_or_update ()
2576 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2578 func_dest_tmpfilename "$g"
2579 func_lookup_file "$f"
2580 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2581 if test -n "$sed_transform_main_lib_file"; then
2584 sed -e "$sed_transform_main_lib_file" \
2585 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2589 if test -n "$sed_transform_testsrelated_lib_file"; then
2592 sed -e "$sed_transform_testsrelated_lib_file" \
2593 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2597 if test -f "$destdir/$g"; then
2598 # The file already exists.
2599 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2600 : # The file has not changed.
2604 if test -n "$already_present"; then
2605 echo "Updating file $g (backup in ${g}~)"
2607 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2609 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2610 if { test -n "$symbolic" \
2611 || { test -n "$lsymbolic" \
2612 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2613 && test -z "$lookedup_tmp" \
2614 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2615 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2617 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2620 if test -n "$already_present"; then
2621 echo "Update file $g (backup in ${g}~)"
2623 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2629 # Don't protest if the file should be there but isn't: it happens
2630 # frequently that developers don't put autogenerated files into CVS.
2632 echo "Copying file $g"
2633 if { test -n "$symbolic" \
2634 || { test -n "$lsymbolic" \
2635 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2636 && test -z "$lookedup_tmp" \
2637 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2638 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2640 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2645 func_append added_files "$g$nl"
2649 # Then the files that are in new-files, but not in old-files:
2650 sed_take_last_column='s,^.*'"$delimiter"',,'
2652 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2653 | sed -e "$sed_take_last_column" \
2654 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2655 { # Rearrange file descriptors. Needed because "while ... done < ..."
2656 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2657 exec 5<&0 < "$tmp"/added-files
2663 # Then the files that are in new-files and in old-files:
2664 already_present=true
2665 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2666 | sed -e "$sed_take_last_column" \
2667 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2668 { # Rearrange file descriptors. Needed because "while ... done < ..."
2669 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2670 exec 5<&0 < "$tmp"/kept-files
2677 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2678 actioncmd="gnulib-tool --import"
2679 func_append actioncmd " --dir=$destdir"
2680 if test -n "$local_gnulib_dir"; then
2681 func_append actioncmd " --local-dir=$local_gnulib_dir"
2683 func_append actioncmd " --lib=$libname"
2684 func_append actioncmd " --source-base=$sourcebase"
2685 func_append actioncmd " --m4-base=$m4base"
2686 if test -n "$pobase"; then
2687 func_append actioncmd " --po-base=$pobase"
2689 func_append actioncmd " --doc-base=$docbase"
2690 func_append actioncmd " --aux-dir=$auxdir"
2691 if test -n "$inctests"; then
2692 func_append actioncmd " --with-tests"
2694 for module in $avoidlist; do
2695 func_append actioncmd " --avoid=$module"
2697 if test -n "$lgpl"; then
2698 if test "$lgpl" = yes; then
2699 func_append actioncmd " --lgpl"
2701 func_append actioncmd " --lgpl=$lgpl"
2704 if test -n "$makefile_name"; then
2705 func_append actioncmd " --makefile-name=$makefile_name"
2707 if test "$libtool" = true; then
2708 func_append actioncmd " --libtool"
2710 func_append actioncmd " --no-libtool"
2712 func_append actioncmd " --macro-prefix=$macro_prefix"
2713 if test -n "$po_domain"; then
2714 func_append actioncmd " --po-domain=$po_domain"
2716 func_append actioncmd " `echo $specified_modules`"
2718 # Default the makefile name to Makefile.am.
2719 if test -n "$makefile_name"; then
2720 makefile_am=$makefile_name
2722 makefile_am=Makefile.am
2725 # Create normal Makefile.ams.
2728 # Create library makefile.
2729 func_dest_tmpfilename $sourcebase/$makefile_am
2730 modules="$main_modules"
2731 func_emit_lib_Makefile_am > "$tmpfile"
2732 if test -f "$destdir"/$sourcebase/$makefile_am; then
2733 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2737 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2738 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2739 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2741 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2747 echo "Creating $sourcebase/$makefile_am"
2748 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2750 echo "Create $sourcebase/$makefile_am"
2753 func_append added_files "$sourcebase/$makefile_am$nl"
2756 # Create po/ directory.
2757 if test -n "$pobase"; then
2758 # Create po makefile and auxiliary files.
2759 for file in Makefile.in.in remove-potcdate.sin; do
2760 func_dest_tmpfilename $pobase/$file
2761 func_lookup_file build-aux/po/$file
2762 cat "$lookedup_file" > "$tmpfile"
2763 if test -f "$destdir"/$pobase/$file; then
2764 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
2768 echo "Updating $pobase/$file (backup in $pobase/$file~)"
2769 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
2770 mv -f "$tmpfile" "$destdir"/$pobase/$file
2772 echo "Update $pobase/$file (backup in $pobase/$file~)"
2778 echo "Creating $pobase/$file"
2779 mv -f "$tmpfile" "$destdir"/$pobase/$file
2781 echo "Create $pobase/$file"
2784 func_append added_files "$pobase/$file$nl"
2787 # Create po makefile parametrization, part 1.
2788 func_dest_tmpfilename $pobase/Makevars
2789 func_emit_po_Makevars > "$tmpfile"
2790 if test -f "$destdir"/$pobase/Makevars; then
2791 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
2795 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
2796 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
2797 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2799 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
2805 echo "Creating $pobase/Makevars"
2806 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2808 echo "Create $pobase/Makevars"
2811 func_append added_files "$pobase/Makevars$nl"
2813 # Create po makefile parametrization, part 2.
2814 func_dest_tmpfilename $pobase/POTFILES.in
2815 func_emit_po_POTFILES_in > "$tmpfile"
2816 if test -f "$destdir"/$pobase/POTFILES.in; then
2817 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
2821 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2822 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
2823 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2825 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2831 echo "Creating $pobase/POTFILES.in"
2832 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2834 echo "Create $pobase/POTFILES.in"
2837 func_append added_files "$pobase/POTFILES.in$nl"
2840 TP_URL="http://translationproject.org/latest/"
2841 TP_RSYNC_URI="translationproject.org::tp/latest/"
2843 echo "Fetching gnulib PO files from $TP_URL"
2844 (cd "$destdir"/$pobase \
2845 && { # Prefer rsync over wget if it is available, since it consumes
2846 # less network bandwidth, due to compression.
2847 if type rsync 2>/dev/null | grep / > /dev/null; then
2848 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
2850 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
2855 echo "Fetch gnulib PO files from $TP_URL"
2857 # Create po/LINGUAS.
2859 func_dest_tmpfilename $pobase/LINGUAS
2860 (cd "$destdir"/$pobase \
2861 && { echo '# Set of available languages.'
2862 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
2865 if test -f "$destdir"/$pobase/LINGUAS; then
2866 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
2869 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2870 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
2871 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2874 echo "Creating $pobase/LINGUAS"
2875 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2876 func_append added_files "$pobase/LINGUAS$nl"
2879 if test -f "$destdir"/$pobase/LINGUAS; then
2880 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2882 echo "Create $pobase/LINGUAS"
2887 # Create m4/gnulib-cache.m4.
2888 func_dest_tmpfilename $m4base/gnulib-cache.m4
2890 func_emit_copyright_notice
2892 echo "# This file represents the specification of how gnulib-tool is used."
2893 echo "# It acts as a cache: It is written and read by gnulib-tool."
2894 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2895 echo "# like the configure.ac and various Makefile.am files."
2898 echo "# Specification in the form of a command-line invocation:"
2901 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2902 # Store the local_gnulib_dir relative to destdir.
2903 case "$local_gnulib_dir" in
2905 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2908 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2910 # destdir, local_gnulib_dir are both relative.
2911 func_relativize "$destdir" "$local_gnulib_dir"
2912 relative_local_gnulib_dir="$reldir" ;;
2915 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2916 echo "gl_MODULES(["`echo $specified_modules`"])"
2917 echo "gl_AVOID([$avoidlist])"
2918 echo "gl_SOURCE_BASE([$sourcebase])"
2919 echo "gl_M4_BASE([$m4base])"
2920 echo "gl_PO_BASE([$pobase])"
2921 echo "gl_DOC_BASE([$docbase])"
2922 echo "gl_TESTS_BASE([$testsbase])"
2923 test -z "$inctests" || echo "gl_WITH_TESTS"
2924 echo "gl_LIB([$libname])"
2925 if test -n "$lgpl"; then
2926 if test "$lgpl" = yes; then
2929 echo "gl_LGPL([$lgpl])"
2932 echo "gl_MAKEFILE_NAME([$makefile_name])"
2933 if test "$libtool" = true; then
2936 echo "gl_MACRO_PREFIX([$macro_prefix])"
2937 echo "gl_PO_DOMAIN([$po_domain])"
2939 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2940 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2944 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2945 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2946 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2948 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2952 echo "# gnulib-cache.m4 ends here"
2959 echo "Creating $m4base/gnulib-cache.m4"
2960 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2962 echo "Create $m4base/gnulib-cache.m4"
2968 # Create m4/gnulib-comp.m4.
2969 func_dest_tmpfilename $m4base/gnulib-comp.m4
2971 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2972 func_emit_copyright_notice
2974 echo "# This file represents the compiled summary of the specification in"
2975 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2976 echo "# to be invoked from configure.ac."
2977 echo "# In projects using CVS, this file can be treated like other built files."
2980 echo "# This macro should be invoked from $configure_ac, in the section"
2981 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2982 echo "# any checks for libraries, header files, types and library functions."
2983 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2985 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2986 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2987 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2988 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2989 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2990 if test -n "$uses_subdirs"; then
2991 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2993 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2994 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2996 for module in $final_modules; do
2998 if test -n "$module"; then
2999 func_get_autoconf_early_snippet "$module"
3002 | sed -e '/^$/d;' -e 's/^/ /'
3005 echo "# This macro should be invoked from $configure_ac, in the section"
3006 echo "# \"Check for header files, types and library functions\"."
3007 echo "AC_DEFUN([${macro_prefix}_INIT],"
3009 if test "$libtool" = true; then
3010 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3011 echo " gl_cond_libtool=true"
3013 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3014 echo " gl_cond_libtool=false"
3016 echo " gl_ltlibdeps="
3018 if test "$auxdir" != "build-aux"; then
3019 sed_replace_build_aux='
3021 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3022 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3026 sed_replace_build_aux=
3028 func_emit_initmacro_start $macro_prefix
3029 echo " gl_source_base='$sourcebase'"
3030 for module in $main_modules; do
3032 if test -n "$module"; then
3033 func_get_autoconf_snippet "$module" \
3034 | sed -e '/^$/d;' -e 's/^/ /' \
3035 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3036 -e "$sed_replace_build_aux"
3037 if test "$module" = 'alloca' && test "$libtool" = true; then
3038 echo 'changequote(,)dnl'
3039 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3040 echo 'changequote([, ])dnl'
3041 echo 'AC_SUBST([LTALLOCA])'
3045 func_emit_initmacro_end $macro_prefix
3046 echo " gltests_libdeps="
3047 echo " gltests_ltlibdeps="
3048 func_emit_initmacro_start ${macro_prefix}tests
3049 echo " gl_source_base='$testsbase'"
3050 for module in $testsrelated_modules; do
3052 if test -n "$module"; then
3053 func_get_autoconf_snippet "$module" \
3054 | sed -e '/^$/d;' -e 's/^/ /' \
3055 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3056 -e "$sed_replace_build_aux" \
3057 -e 's/\$gl_cond_libtool/false/g' \
3058 -e 's/gl_libdeps/gltests_libdeps/g' \
3059 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3062 func_emit_initmacro_end ${macro_prefix}tests
3063 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3064 # created using libtool, because libtool already handles the dependencies.
3065 if test "$libtool" != true; then
3066 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3067 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3068 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3069 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3070 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3072 if $use_libtests; then
3073 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3074 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3077 func_emit_initmacro_done $macro_prefix $sourcebase
3078 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3080 echo "# This macro records the list of files which have been installed by"
3081 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3082 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3083 echo "$files" | sed -e 's,^, ,'
3086 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3087 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3091 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3092 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3093 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3095 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3099 echo "# gnulib-comp.m4 ends here"
3106 echo "Creating $m4base/gnulib-comp.m4"
3107 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3109 echo "Create $m4base/gnulib-comp.m4"
3115 if test -n "$inctests"; then
3116 # Create tests makefile.
3117 func_dest_tmpfilename $testsbase/$makefile_am
3118 modules="$testsrelated_modules"
3119 func_emit_tests_Makefile_am > "$tmpfile"
3120 if test -f "$destdir"/$testsbase/$makefile_am; then
3121 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3125 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3126 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3127 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3129 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3135 echo "Creating $testsbase/$makefile_am"
3136 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3138 echo "Create $testsbase/$makefile_am"
3141 func_append added_files "$testsbase/$makefile_am$nl"
3145 # Update the .cvsignore and .gitignore files.
3146 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3147 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3148 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3149 { # Rearrange file descriptors. Needed because "while ... done < ..."
3150 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3151 exec 5<&0 < "$tmp"/fileset-changes
3152 func_update_ignorelist ()
3155 if test -f "$destdir/$dir$ignore"; then
3156 if test -n "$dir_added" || test -n "$dir_removed"; then
3157 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
3158 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3159 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
3160 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3161 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
3162 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3164 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3165 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3166 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
3167 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
3168 | sed -f "$tmp"/sed-ignore-removed \
3169 > "$destdir/$dir$ignore"
3171 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3176 if test -n "$dir_added"; then
3178 echo "Creating $destdir/$dir$ignore"
3180 if test "$ignore" = .cvsignore; then
3182 # Automake generates Makefile rules that create .dirstamp files.
3185 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u
3186 } > "$destdir/$dir$ignore"
3188 echo "Create $destdir/$dir$ignore"
3198 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3199 func_update_ignorelist .cvsignore
3201 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3202 func_update_ignorelist .gitignore
3209 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3210 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3211 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3212 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3213 if test "$next_dir" != "$last_dir"; then
3214 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3215 last_dir="$next_dir"
3220 A) func_append last_dir_added "$file$nl";;
3221 R) func_append last_dir_removed "$file$nl";;
3224 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3230 echo "You may need to add #include directives for the following .h files."
3231 # Intersect $specified_modules and $main_modules
3232 # (since $specified_modules is not necessarily of subset of $main_modules
3233 # - some may have been skipped through --avoid, and since the elements of
3234 # $main_modules but not in $specified_modules can go away without explicit
3235 # notice - through changes in the module dependencies).
3236 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3237 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3238 # First the #include <...> directives without #ifs, sorted for convenience,
3239 # then the #include "..." directives without #ifs, sorted for convenience,
3240 # then the #include directives that are surrounded by #ifs. Not sorted.
3241 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3242 include_directive=`func_get_include_directive "$module"`
3243 case "$nl$include_directive" in
3245 echo "$include_directive" 1>&5
3248 echo "$include_directive" | grep -v 'include "' 1>&6
3249 echo "$include_directive" | grep 'include "' 1>&7
3252 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3254 LC_ALL=C sort -u "$tmp"/include-angles
3255 LC_ALL=C sort -u "$tmp"/include-quotes
3256 cat "$tmp"/include-if
3257 ) | sed -e '/^$/d' -e 's/^/ /'
3258 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3260 for module in $main_modules; do
3261 func_get_link_directive "$module"
3263 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3264 if test `wc -l < "$tmp"/link` != 0; then
3266 echo "You may need to use the following Makefile variables when linking."
3267 echo "Use them in <program>_LDADD when linking a program, or"
3268 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3274 echo "Don't forget to"
3275 if test "$makefile_am" = Makefile.am; then
3276 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3278 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3280 if test -n "$pobase"; then
3281 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3283 if test -n "$inctests"; then
3284 if test "$makefile_am" = Makefile.am; then
3285 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3287 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3290 if test "$makefile_am" = Makefile.am; then
3291 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3292 sourcebase_base=`basename "$sourcebase"`
3293 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
3295 if test -n "$pobase"; then
3296 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3297 pobase_base=`basename "$pobase"`
3298 echo " - mention \"${pobase_base}\" in SUBDIRS in ${pobase_dir}Makefile.am,"
3300 if test -n "$inctests"; then
3301 if test "$makefile_am" = Makefile.am; then
3302 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3303 testsbase_base=`basename "$testsbase"`
3304 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
3307 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
3308 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3309 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3312 # func_create_testdir testdir modules
3314 # - local_gnulib_dir from --local-dir
3315 # - auxdir directory relative to destdir where to place build aux files
3316 func_create_testdir ()
3320 if test -z "$modules"; then
3321 # All modules together.
3322 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3323 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3324 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3325 modules=`func_all_modules`
3326 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3328 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3330 # Check that the license of every module is consistent with the license of
3332 saved_modules="$modules"
3333 saved_inctests="$inctests"
3334 # When computing transitive closures, don't consider $module to depend on
3335 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3336 # on GPL modules - therefore we don't want a warning in this case.
3338 for requested_module in $saved_modules; do
3339 requested_license=`func_get_license "$requested_module"`
3340 if test "$requested_license" != GPL; then
3341 # Here we use func_modules_transitive_closure, not just
3342 # func_get_dependencies, so that we also detect weird situations like
3343 # an LGPL module which depends on a GPLed build tool module which depends
3345 modules="$requested_module"
3346 func_modules_transitive_closure
3347 for module in $modules; do
3348 license=`func_get_license "$module"`
3350 'GPLed build tool') ;;
3351 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3353 case "$requested_license" in
3356 GPLv2+ | LGPLv2+) ;;
3357 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3363 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3369 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3378 modules="$saved_modules"
3379 inctests="$saved_inctests"
3381 # Subdirectory names.
3390 # Determine final module list.
3391 func_modules_transitive_closure
3392 if test $verbose -ge 0; then
3393 echo "Module list with included dependencies:"
3394 echo "$modules" | sed -e 's/^/ /'
3397 # Add the dummy module if needed.
3398 func_modules_add_dummy
3400 # Show banner notice of every module.
3403 # Determine final file list.
3404 func_modules_to_filelist
3405 if test $verbose -ge 0; then
3407 echo "$files" | sed -e 's/^/ /'
3410 sed_rewrite_files="\
3411 s,^build-aux/,$auxdir/,
3413 s,^lib/,$sourcebase/,
3415 s,^tests/,$testsbase/,"
3417 # Create directories.
3418 for f in $files; do echo $f; done \
3419 | sed -e "$sed_rewrite_files" \
3420 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3421 | LC_ALL=C sort -u \
3423 { # Rearrange file descriptors. Needed because "while ... done < ..."
3424 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3425 exec 5<&0 < "$tmp"/dirs
3427 mkdir -p "$testdir/$d"
3432 # Copy files or make symbolic links.
3434 for f in $files; do echo $f; done \
3435 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3438 { # Rearrange file descriptors. Needed because "while ... done < ..."
3439 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3440 exec 5<&0 < "$tmp"/files
3442 func_lookup_file "$f"
3443 if test -n "$lookedup_tmp"; then
3444 cp -p "$lookedup_file" "$testdir/$g"
3446 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3447 if { test -n "$symbolic" \
3448 || { test -n "$lsymbolic" \
3449 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3450 func_ln "$lookedup_file" "$testdir/$g"
3452 cp -p "$lookedup_file" "$testdir/$g"
3459 # Create Makefile.ams that are for testing.
3462 # Create $sourcebase/Makefile.am.
3463 mkdir -p "$testdir/$sourcebase"
3464 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3465 any_uses_subdirs="$uses_subdirs"
3467 # Create $m4base/Makefile.am.
3468 mkdir -p "$testdir/$m4base"
3469 (echo "## Process this file with automake to produce Makefile.in."
3475 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3478 ) > "$testdir/$m4base/Makefile.am"
3480 subdirs="$sourcebase $m4base"
3481 subdirs_with_configure_ac=""
3483 if false && test -f "$testdir"/$m4base/gettext.m4; then
3484 # Avoid stupid error message from automake:
3485 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3486 mkdir -p "$testdir/po"
3487 (echo "## Process this file with automake to produce Makefile.in."
3488 ) > "$testdir/po/Makefile.am"
3489 func_append subdirs " po"
3492 if test -n "$inctests"; then
3493 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3494 # Viewed from the $testsbase subdirectory, $auxdir is different.
3495 saved_auxdir="$auxdir"
3496 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3497 # Create $testsbase/Makefile.am.
3499 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3500 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3501 # Create $testsbase/configure.ac.
3502 (echo "# Process this file with autoconf to produce a configure script."
3503 echo "AC_INIT([dummy], [0])"
3504 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3505 echo "AM_INIT_AUTOMAKE"
3507 echo "AM_CONFIG_HEADER([config.h])"
3510 echo "AC_PROG_INSTALL"
3511 echo "AC_PROG_MAKE_SET"
3512 echo "AC_PROG_RANLIB"
3514 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3515 echo "AC_GNU_SOURCE"
3518 for module in $modules; do
3520 if test -n "$module"; then
3521 func_get_autoconf_early_snippet "$module"
3524 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3525 if test "$libtool" = true; then
3526 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3527 echo "gl_cond_libtool=true"
3529 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3530 echo "gl_cond_libtool=false"
3532 echo "gl_ltlibdeps="
3534 # Wrap the set of autoconf snippets into an autoconf macro that is then
3535 # invoked. This is needed because autoconf does not support AC_REQUIRE
3537 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3538 # but we want the AC_REQUIRE to have its normal meaning (provide one
3539 # expansion of the required macro before the current point, and only one
3541 echo "AC_DEFUN([gl_INIT], ["
3542 sed_replace_build_aux='
3544 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3545 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3548 func_emit_initmacro_start $macro_prefix
3549 # We don't have explicit ordering constraints between the various
3550 # autoconf snippets. It's cleanest to put those of the library before
3551 # those of the tests.
3552 echo "gl_source_base='../$sourcebase'"
3553 for module in $modules; do
3554 func_verify_nontests_module
3555 if test -n "$module"; then
3556 func_get_autoconf_snippet "$module" \
3557 | sed -e "$sed_replace_build_aux"
3560 echo "gl_source_base='.'"
3561 for module in $modules; do
3562 func_verify_tests_module
3563 if test -n "$module"; then
3564 func_get_autoconf_snippet "$module" \
3565 | sed -e "$sed_replace_build_aux"
3568 func_emit_initmacro_end $macro_prefix
3569 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3570 # created using libtool, because libtool already handles the dependencies.
3571 if test "$libtool" != true; then
3572 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3573 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3574 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3575 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3576 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3579 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
3583 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3584 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3585 echo "AH_TOP([#include \"../config.h\"])"
3587 echo "AC_OUTPUT([Makefile])"
3588 ) > "$testdir/$testsbase/configure.ac"
3589 auxdir="$saved_auxdir"
3590 func_append subdirs " $testsbase"
3591 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3594 # Create Makefile.am.
3595 (echo "## Process this file with automake to produce Makefile.in."
3597 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3599 echo "SUBDIRS = $subdirs"
3601 echo "ACLOCAL_AMFLAGS = -I $m4base"
3602 ) > "$testdir/Makefile.am"
3604 # Create configure.ac.
3605 (echo "# Process this file with autoconf to produce a configure script."
3606 echo "AC_INIT([dummy], [0])"
3607 if test "$auxdir" != "."; then
3608 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3610 echo "AM_INIT_AUTOMAKE"
3612 echo "AM_CONFIG_HEADER([config.h])"
3615 echo "AC_PROG_INSTALL"
3616 echo "AC_PROG_MAKE_SET"
3618 echo "# For autobuild."
3619 echo "AC_CANONICAL_BUILD"
3620 echo "AC_CANONICAL_HOST"
3622 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3623 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3624 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3625 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3627 echo "AC_PROG_RANLIB"
3629 if test -n "$any_uses_subdirs"; then
3630 echo "AM_PROG_CC_C_O"
3633 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3634 echo "AC_GNU_SOURCE"
3637 for module in $modules; do
3638 func_verify_nontests_module
3639 if test -n "$module"; then
3640 func_get_autoconf_early_snippet "$module"
3643 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3644 if test "$libtool" = true; then
3645 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3646 echo "gl_cond_libtool=true"
3648 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3649 echo "gl_cond_libtool=false"
3651 echo "gl_ltlibdeps="
3653 # Wrap the set of autoconf snippets into an autoconf macro that is then
3654 # invoked. This is needed because autoconf does not support AC_REQUIRE
3656 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3657 # but we want the AC_REQUIRE to have its normal meaning (provide one
3658 # expansion of the required macro before the current point, and only one
3660 echo "AC_DEFUN([gl_INIT], ["
3661 if test "$auxdir" != "build-aux"; then
3662 sed_replace_build_aux='
3664 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3665 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3669 sed_replace_build_aux=
3671 func_emit_initmacro_start $macro_prefix
3672 echo "gl_source_base='$sourcebase'"
3673 for module in $modules; do
3674 func_verify_nontests_module
3675 if test -n "$module"; then
3676 func_get_autoconf_snippet "$module" \
3677 | sed -e "$sed_replace_build_aux"
3680 func_emit_initmacro_end $macro_prefix
3681 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3682 # created using libtool, because libtool already handles the dependencies.
3683 if test "$libtool" != true; then
3684 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3685 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3686 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3687 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3688 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3691 func_emit_initmacro_done $macro_prefix $sourcebase
3695 if test -n "$subdirs_with_configure_ac"; then
3696 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3698 makefiles="Makefile"
3699 for d in $subdirs; do
3700 # For subdirs that have a configure.ac by their own, it's the subdir's
3701 # configure.ac which creates the subdir's Makefile.am, not this one.
3702 case " $subdirs_with_configure_ac " in
3704 *) func_append makefiles " $d/Makefile" ;;
3707 echo "AC_OUTPUT([$makefiles])"
3708 ) > "$testdir/configure.ac"
3710 # Create autogenerated files.
3712 # Do not use "${AUTORECONF} --force --install", because it may invoke
3713 # autopoint, which brings in older versions of some of our .m4 files.
3714 if test -f $m4base/gettext.m4; then
3715 func_execute_command ${AUTOPOINT} --force || func_exit 1
3716 for f in $m4base/*.m4~; do
3717 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3720 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
3721 if ! test -d build-aux; then
3722 func_execute_command mkdir build-aux || func_exit 1
3724 func_execute_command ${AUTOCONF} || func_exit 1
3725 func_execute_command ${AUTOHEADER} || func_exit 1
3726 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3728 if test -n "$inctests"; then
3729 # Create autogenerated files.
3730 (cd "$testdir/$testsbase" || func_exit 1
3731 # Do not use "${AUTORECONF} --force --install", because it may invoke
3732 # autopoint, which brings in older versions of some of our .m4 files.
3733 if test -f ../$m4base/gettext.m4; then
3734 func_execute_command ${AUTOPOINT} --force || func_exit 1
3735 for f in ../$m4base/*.m4~; do
3736 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3739 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
3740 if ! test -d ../build-aux; then
3741 func_execute_command mkdir ../build-aux
3743 func_execute_command ${AUTOCONF} || func_exit 1
3744 func_execute_command ${AUTOHEADER} || func_exit 1
3745 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3748 # Need to run configure and make once, to create built files that are to be
3749 # distributed (such as getdate.c).
3750 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3751 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3752 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3753 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3754 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3755 # such $(FOO_H) because they don't refer to distributed files.
3756 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3757 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3758 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3759 | sed -e "$sed_remove_make_variables"`
3760 distributed_built_sources=`for file in $built_sources; do
3761 case "$cleaned_files" in
3766 if test -n "$distributed_built_sources"; then
3768 ./configure || func_exit 1
3770 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3771 make built_sources || func_exit 1
3773 make distclean || func_exit 1
3778 # func_create_megatestdir megatestdir allmodules
3780 # - local_gnulib_dir from --local-dir
3781 # - auxdir directory relative to destdir where to place build aux files
3782 func_create_megatestdir ()
3786 if test -z "$allmodules"; then
3787 allmodules=`func_all_modules`
3791 # First, all modules one by one.
3792 for onemodule in $allmodules; do
3793 func_create_testdir "$megatestdir/$onemodule" $onemodule
3794 func_append megasubdirs "$onemodule "
3796 # Then, all modules all together.
3797 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3798 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3799 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3800 func_create_testdir "$megatestdir/ALL" "$allmodules"
3801 func_append megasubdirs "ALL"
3804 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
3805 vc_witness="$gnulib_dir/CVS/Entries"; \
3807 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
3809 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
3810 | sed -e 's,January,01,' -e 's,Jan,01,' \
3811 -e 's,February,02,' -e 's,Feb,02,' \
3812 -e 's,March,03,' -e 's,Mar,03,' \
3813 -e 's,April,04,' -e 's,Apr,04,' \
3815 -e 's,June,06,' -e 's,Jun,06,' \
3816 -e 's,July,07,' -e 's,Jul,07,' \
3817 -e 's,August,08,' -e 's,Aug,08,' \
3818 -e 's,September,09,' -e 's,Sep,09,' \
3819 -e 's,October,10,' -e 's,Oct,10,' \
3820 -e 's,November,11,' -e 's,Nov,11,' \
3821 -e 's,December,12,' -e 's,Dec,12,' \
3822 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3823 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3825 echo "CVSDATE=$cvsdate"
3826 echo "test -d logs || mkdir logs"
3827 echo "for module in $megasubdirs; do"
3828 echo " echo \"Working on module \$module...\""
3829 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3830 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3833 echo " : autobuild project... \$module"
3834 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3835 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3836 echo " : autobuild hostname... \`hostname\`"
3837 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3839 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3841 ) > "$megatestdir/do-autobuild"
3842 chmod a+x "$megatestdir/do-autobuild"
3844 # Create Makefile.am.
3845 (echo "## Process this file with automake to produce Makefile.in."
3847 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3849 echo "SUBDIRS = $megasubdirs"
3851 echo "EXTRA_DIST = do-autobuild"
3852 ) > "$megatestdir/Makefile.am"
3854 # Create configure.ac.
3855 (echo "# Process this file with autoconf to produce a configure script."
3856 echo "AC_INIT([dummy], [0])"
3857 if test "$auxdir" != "."; then
3858 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3860 echo "AM_INIT_AUTOMAKE"
3862 echo "AC_PROG_MAKE_SET"
3864 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3865 echo "AC_OUTPUT([Makefile])"
3866 ) > "$megatestdir/configure.ac"
3868 # Create autogenerated files.
3870 # Do not use "${AUTORECONF} --install", because autoreconf operates
3871 # recursively, but the subdirectories are already finished, therefore
3872 # calling autoreconf here would only waste lots of CPU time.
3873 func_execute_command ${ACLOCAL} || func_exit 1
3874 func_execute_command mkdir build-aux
3875 func_execute_command ${AUTOCONF} || func_exit 1
3876 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3882 func_fatal_error "no mode specified" ;;
3891 if test -z "$destdir"; then
3894 test -d "$destdir" \
3895 || func_fatal_error "destination directory does not exist: $destdir"
3897 # Prefer configure.ac to configure.in.
3898 if test -f "$destdir"/configure.ac; then
3899 configure_ac="$destdir/configure.ac"
3901 if test -f "$destdir"/configure.in; then
3902 configure_ac="$destdir/configure.in"
3904 func_fatal_error "cannot find $destdir/configure.ac"
3908 # Analyze configure.ac.
3910 guessed_libtool=false
3915 /AC_CONFIG_AUX_DIR/ {
3916 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3918 /A[CM]_PROG_LIBTOOL/ {
3919 s,^.*$,guessed_libtool=true,p
3921 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3923 if test -z "$auxdir"; then
3924 auxdir="$guessed_auxdir"
3927 # Determine where to apply func_import.
3928 if test -n "$m4base"; then
3929 # Apply func_import to a particular gnulib directory.
3930 # Any number of additional modules can be given.
3931 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3932 # First use of gnulib in the given m4base.
3933 test -n "$supplied_libname" || supplied_libname=true
3934 test -n "$sourcebase" || sourcebase="lib"
3935 test -n "$docbase" || docbase="doc"
3936 test -n "$testsbase" || testsbase="tests"
3937 test -n "$macro_prefix" || macro_prefix="gl"
3941 # Apply func_import to all gnulib directories.
3942 # To get this list of directories, look at Makefile.am. (Not at
3943 # configure, because it may be omitted from CVS. Also, don't run
3944 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3947 if test -f "$destdir"/Makefile.am; then
3948 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3950 for arg in $aclocal_amflags; do
3951 if test -n "$m4dir_is_next"; then
3952 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3956 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3957 func_append m4dirs " $arg"
3958 m4dirs_count=`expr $m4dirs_count + 1`
3964 if test "X$arg" = "X-I"; then
3972 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3973 if test -f "$destdir"/aclocal.m4; then
3974 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3975 sedexpr2='s,^[^/]*$,.,'
3976 sedexpr3='s,/[^/]*$,,'
3977 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3978 m4dirs_count=`echo "$m4dirs" | wc -l`
3981 if test $m4dirs_count = 0; then
3982 # First use of gnulib in a package.
3983 # Any number of additional modules can be given.
3984 test -n "$supplied_libname" || supplied_libname=true
3985 test -n "$sourcebase" || sourcebase="lib"
3987 test -n "$docbase" || docbase="doc"
3988 test -n "$testsbase" || testsbase="tests"
3989 test -n "$macro_prefix" || macro_prefix="gl"
3992 if test $m4dirs_count = 1; then
3993 # There's only one use of gnulib here. Assume the user means it.
3994 # Any number of additional modules can be given.
3995 for m4base in $m4dirs; do
3999 # Ambiguous - guess what the user meant.
4000 if test $# = 0; then
4001 # No further arguments. Guess the user wants to update all of them.
4002 for m4base in $m4dirs; do
4003 # Perform func_import in a subshell, so that variable values
4005 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
4006 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
4007 # libtool, macro_prefix, po_domain
4008 # don't propagate from one directory to another.
4009 (func_import) || func_exit 1
4013 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4021 if test -z "$destdir"; then
4022 func_fatal_error "please specify --dir option"
4025 test -d "$destdir" \
4026 || func_fatal_error "could not create destination directory"
4027 test -n "$auxdir" || auxdir="build-aux"
4028 func_create_testdir "$destdir" "$*"
4031 create-megatestdir )
4032 if test -z "$destdir"; then
4033 func_fatal_error "please specify --dir option"
4035 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4036 test -n "$auxdir" || auxdir="build-aux"
4037 func_create_megatestdir "$destdir" "$*"
4041 test -n "$destdir" || destdir=testdir$$
4042 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4043 test -n "$auxdir" || auxdir="build-aux"
4044 func_create_testdir "$destdir" "$*"
4048 ../configure || func_exit 1
4050 make check || func_exit 1
4051 make distclean || func_exit 1
4052 remaining=`find . -type f -print`
4053 if test -n "$remaining"; then
4054 echo "Remaining files:" $remaining 1>&2
4055 echo "gnulib-tool: *** Stop." 1>&2
4064 test -n "$destdir" || destdir=testdir$$
4065 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4066 test -n "$auxdir" || auxdir="build-aux"
4067 func_create_megatestdir "$destdir" "$*"
4075 remaining=`find . -type f -print`
4076 if test -n "$remaining"; then
4077 echo "Remaining files:" $remaining 1>&2
4078 echo "gnulib-tool: *** Stop." 1>&2
4086 extract-description )
4090 if test -n "$module"; then
4091 func_get_description "$module"
4100 if test -n "$module"; then
4101 func_get_notice "$module"
4110 if test -n "$module"; then
4111 func_get_filelist "$module"
4116 extract-dependencies )
4120 if test -n "$module"; then
4121 func_get_dependencies "$module"
4126 extract-autoconf-snippet )
4130 if test -n "$module"; then
4131 func_get_autoconf_snippet "$module"
4136 extract-automake-snippet )
4140 if test -n "$module"; then
4141 func_get_automake_snippet "$module"
4146 extract-include-directive )
4150 if test -n "$module"; then
4151 func_get_include_directive "$module"
4156 extract-link-directive )
4160 if test -n "$module"; then
4161 func_get_link_directive "$module"
4170 if test -n "$module"; then
4171 func_get_license "$module"
4176 extract-maintainer )
4180 if test -n "$module"; then
4181 func_get_maintainer "$module"
4186 extract-tests-module )
4190 if test -n "$module"; then
4191 func_get_tests_module "$module"
4197 func_fatal_error "unknown operation mode --$mode" ;;
4201 # Undo the effect of the previous 'trap' command. Some shellology:
4202 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4203 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4204 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4205 # 128 + signal number and is set before the trap-registered command is run.
4207 trap 'func_exit $?' 1 2 3 13 15
4212 # indent-tabs-mode: nil
4213 # whitespace-check-buffer-indent: nil