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 sed -n '/Copyright/ {
217 }' < "$self_abspathname"
219 echo "# This file is free software, distributed under the terms of the GNU"
220 echo "# General Public License. As a special exception to the GNU General"
221 echo "# Public License, this file may be distributed as part of a program"
222 echo "# that contains a configuration script generated by Autoconf, under"
223 echo "# the same distribution terms as the rest of that program."
225 echo "# Generated by gnulib-tool."
236 # locates the directory where the gnulib repository lives
238 # - self_abspathname absolute pathname of gnulib-tool
239 # - gnulib_dir absolute pathname of gnulib repository
243 /*) self_abspathname="$0" ;;
244 */*) self_abspathname=`pwd`/"$0" ;;
247 # Iterate through the elements of $PATH.
248 # We use IFS=: instead of
249 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
250 # because the latter does not work when some PATH element contains spaces.
251 # We use a canonicalized $pathx instead of $PATH, because empty PATH
252 # elements are by definition equivalent to '.', however field splitting
253 # according to IFS=: loses empty fields in many shells:
254 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
255 # beginning, at the end, and in the middle),
256 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
257 # at the beginning and at the end,
258 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
259 # Solaris lose empty fields at the end.
260 # The 'case' statement is an optimization, to avoid evaluating the
261 # explicit canonicalization command when $PATH contains no empty fields.
263 if test "${PATH_SEPARATOR+set}" != set; then
265 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
266 chmod +x "$tmp"/conf.sh
267 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
274 if test "$PATH_SEPARATOR" = ";"; then
275 # On Windows, programs are searched in "." before $PATH.
278 # On Unix, we have to convert empty PATH elements to ".".
282 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
287 IFS="$PATH_SEPARATOR"
291 if test -x "$d/$0" && test ! -d "$d/$0"; then
292 self_abspathname="$d/$0"
297 if test -z "$self_abspathname"; then
298 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
302 while test -h "$self_abspathname"; do
303 # Resolve symbolic link.
304 linkval=`func_readlink "$self_abspathname"`
305 test -n "$linkval" || break
307 /* ) self_abspathname="$linkval" ;;
308 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
311 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
315 # creates a temporary directory.
317 # - tmp pathname of freshly created temporary directory
320 # Use the environment variable TMPDIR, falling back to /tmp. This allows
321 # users to specify a different temporary directory, for example, if their
322 # /tmp is filled up or too small.
325 # Use the mktemp program if available. If not available, hide the error
327 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
328 test -n "$tmp" && test -d "$tmp"
331 # Use a simple mkdir command. It is guaranteed to fail if the directory
332 # already exists. $RANDOM is bash specific and expands to empty in shells
333 # other than bash, ksh and zsh. Its use does not increase security;
334 # rather, it minimizes the probability of failure in a very cluttered /tmp
336 tmp=$TMPDIR/gl$$-$RANDOM
337 (umask 077 && mkdir "$tmp")
340 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
345 # func_append var value
346 # appends the given value to the shell variable var.
347 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
348 # Use bash's += operator. It reduces complexity of appending repeatedly to
349 # a single variable from O(n^2) to O(n).
357 eval "$1=\"\$$1\$2\""
361 # func_fatal_error message
362 # outputs to stderr a fatal error message, and terminates the program.
365 echo "gnulib-tool: *** $1" 1>&2
366 echo "gnulib-tool: *** Stop." 1>&2
370 # func_readlink SYMLINK
371 # outputs the target of the given symlink.
372 if (type -p readlink) > /dev/null 2>&1; then
375 # Use the readlink program from GNU coreutils.
381 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
382 # would do the wrong thing if the link target contains " -> ".
383 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
387 # func_relativize DIR1 DIR2
388 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
390 # - DIR1 relative pathname, relative to the current directory
391 # - DIR2 relative pathname, relative to the current directory
393 # - reldir relative pathname of DIR2, relative to DIR1
399 sed_first='s,^\([^/]*\)/.*$,\1,'
400 sed_rest='s,^[^/]*/*,,'
401 sed_last='s,^.*/\([^/]*\)$,\1,'
402 sed_butlast='s,/*[^/]*$,,'
403 while test -n "$dir1"; do
404 first=`echo "$dir1" | sed -e "$sed_first"`
405 if test "$first" != "."; then
406 if test "$first" = ".."; then
407 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
408 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
410 first2=`echo "$dir2" | sed -e "$sed_first"`
411 if test "$first2" = "$first"; then
412 dir2=`echo "$dir2" | sed -e "$sed_rest"`
416 dir0="$dir0"/"$first"
419 dir1=`echo "$dir1" | sed -e "$sed_rest"`
424 # func_relconcat DIR1 DIR2
425 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
427 # - DIR1 relative pathname, relative to the current directory
428 # - DIR2 relative pathname, relative to DIR1
430 # - relconcat DIR1/DIR2, relative to the current directory
435 sed_first='s,^\([^/]*\)/.*$,\1,'
436 sed_rest='s,^[^/]*/*,,'
437 sed_last='s,^.*/\([^/]*\)$,\1,'
438 sed_butlast='s,/*[^/]*$,,'
440 first=`echo "$dir2" | sed -e "$sed_first"`
441 if test "$first" = "."; then
442 dir2=`echo "$dir2" | sed -e "$sed_rest"`
443 if test -z "$dir2"; then
448 last=`echo "$dir1" | sed -e "$sed_last"`
449 while test "$last" = "."; do
450 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
451 last=`echo "$dir1" | sed -e "$sed_last"`
453 if test -z "$dir1"; then
457 if test "$first" = ".."; then
458 if test "$last" = ".."; then
459 relconcat="$dir1/$dir2"
462 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
463 dir2=`echo "$dir2" | sed -e "$sed_rest"`
464 if test -z "$dir1"; then
468 if test -z "$dir2"; then
473 relconcat="$dir1/$dir2"
481 # Like ln -s, except that SRC is given relative to the current directory (or
482 # absolute), not given relative to the directory of DEST.
488 *) # SRC is relative.
491 ln -s "`pwd`/$1" "$2" ;;
492 *) # DEST is relative too.
493 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
494 test -n "$ln_destdir" || ln_destdir="."
495 func_relativize "$ln_destdir" "$1"
503 # func_ln_if_changed SRC DEST
504 # Like func_ln, but avoids munging timestamps if the link is correct.
505 func_ln_if_changed ()
507 if test $# -ne 2; then
508 echo "usage: func_ln_if_changed SRC DEST" >&2
510 ln_target=`func_readlink "$2"`
511 if test -h "$2" && test "$1" = "$ln_target"; then
519 # Ensure an 'echo' command that does not interpret backslashes.
521 # echo '\n' | wc -l prints 1 when OK, 2 when KO
522 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
523 # This problem is a weird heritage from SVR4. BSD got it right (except that
524 # BSD echo interprets '-n' as an option, which is also not desirable).
525 # Nowadays the problem occurs in 4 situations:
526 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
527 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
528 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
529 # - in zsh, when sh-emulation is not set,
530 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
531 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
532 # - in Solaris /bin/sh and OSF/1 /bin/sh.
533 # We try the following workarounds:
534 # - for all: respawn using $CONFIG_SHELL if that is set and works.
535 # - for bash >= 2.04: unset the shell option xpg_echo.
536 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
537 # - for bash < 2.0: define echo to a function that uses cat of a here document.
538 # - for zsh: turn sh-emulation on.
539 # - for ksh: alias echo to 'print -r'.
540 # - for ksh: alias echo to a function that uses cat of a here document.
541 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
542 # the ksh workaround.
543 # - otherwise: respawn using /bin/sh and rely on the workarounds.
544 # When respawning, we pass --no-reexec as first argument, so as to avoid
545 # turning this script into a fork bomb in unlucky situations.
547 if echo '\t' | grep t > /dev/null; then
548 have_echo=yes # Lucky!
550 # Try the workarounds.
551 # Respawn using $CONFIG_SHELL if that is set and works.
552 if test -z "$have_echo" \
553 && test "X$1" != "X--no-reexec" \
554 && test -n "$CONFIG_SHELL" \
555 && test -f "$CONFIG_SHELL" \
556 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
557 exec $CONFIG_SHELL "$0" --no-reexec "$@"
560 # For bash >= 2.04: unset the shell option xpg_echo.
561 if test -z "$have_echo" \
562 && test -n "$BASH_VERSION" \
563 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
567 # For bash >= 2.0: define echo to a function that uses the printf built-in.
568 # For bash < 2.0: define echo to a function that uses cat of a here document.
569 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
570 if test -z "$have_echo" \
571 && test -n "$BASH_VERSION"; then \
572 if type printf 2>/dev/null | grep / > /dev/null; then
573 # 'printf' is not a shell built-in.
581 # 'printf' is a shell built-in.
587 if echo '\t' | grep t > /dev/null; then
591 # For zsh: turn sh-emulation on.
592 if test -z "$have_echo" \
593 && test -n "$ZSH_VERSION" \
594 && (emulate sh) >/dev/null 2>&1; then
597 # For ksh: alias echo to 'print -r'.
598 if test -z "$have_echo" \
599 && (type print) >/dev/null 2>&1; then
600 # A 'print' command exists.
601 if type print 2>/dev/null | grep / > /dev/null; then
604 # 'print' is a shell built-in.
605 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
606 # 'print' is the ksh shell built-in.
607 alias echo='print -r'
611 if test -z "$have_echo" \
612 && echo '\t' | grep t > /dev/null; then
615 # For ksh: alias echo to a function that uses cat of a here document.
616 # The ksh manual page says:
617 # "Aliasing is performed when scripts are read, not while they are executed.
618 # Therefore, for an alias to take effect, the alias definition command has
619 # to be executed before the command which references the alias is read."
620 # Because of this, we have to play strange tricks with have_echo, to ensure
621 # that the top-level statement containing the test starts after the 'alias'
623 if test -z "$have_echo"; then
630 alias echo=bsd_echo 2>/dev/null
632 if test -z "$have_echo" \
633 && echo '\t' | grep t > /dev/null; then
636 if test -z "$have_echo"; then
637 unalias echo 2>/dev/null
639 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
640 if test -z "$have_echo" \
641 && test "X$1" != "X--no-reexec" \
642 && test -f /bin/ksh; then
643 exec /bin/ksh "$0" --no-reexec "$@"
646 # Otherwise: respawn using /bin/sh.
647 if test -z "$have_echo" \
648 && test "X$1" != "X--no-reexec" \
649 && test -f /bin/sh; then
650 exec /bin/sh "$0" --no-reexec "$@"
653 if test -z "$have_echo"; then
654 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
656 if echo '\t' | grep t > /dev/null; then
659 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
661 if test "X$1" = "X--no-reexec"; then
665 # Command-line option processing.
666 # Removes the OPTIONS from the arguments. Sets the variables:
667 # - mode list or import or create-testdir or create-megatestdir
668 # - destdir from --dir
669 # - local_gnulib_dir from --local-dir
670 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
671 # - libname, supplied_libname from --lib
672 # - sourcebase from --source-base
673 # - m4base from --m4-base
674 # - pobase from --po-base
675 # - docbase from --doc-base
676 # - testsbase from --tests-base
677 # - auxdir from --aux-dir
678 # - inctests true if --with-tests was given, blank otherwise
679 # - avoidlist list of modules to avoid, from --avoid
680 # - lgpl yes or a number if --lgpl was given, blank otherwise
681 # - makefile_name from --makefile-name
682 # - libtool true if --libtool was given, false if --no-libtool was
683 # given, blank otherwise
684 # - macro_prefix from --macro-prefix
685 # - po_domain from --po-domain
686 # - autoconf_minversion minimum supported autoconf version
687 # - do_changelog false if --no-changelog was given, : otherwise
688 # - doit : if actions shall be executed, false if only to be printed
689 # - symbolic true if --symlink or --more-symlinks was given, blank
691 # - lsymbolic true if --local-symlink was given, blank otherwise
692 # - do_copyrights blank if --more-symlinks was given, true otherwise
721 while test $# -gt 0; do
726 --import | --impor | --impo | --imp | --im | --i )
729 --update | --updat | --upda | --upd | --up | --u )
732 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
735 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
736 mode=create-megatestdir
738 --test | --tes | --te | --t )
741 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
745 mode=`echo "X$1" | sed -e 's/^X--//'`
750 func_fatal_error "missing argument for --dir"
755 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
760 func_fatal_error "missing argument for --local-dir"
765 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
767 --verbose | --verbos | --verbo | --verb )
768 verbose=`expr $verbose + 1`
770 --quiet | --quie | --qui | --qu | --q )
771 verbose=`expr $verbose - 1`
776 func_fatal_error "missing argument for --lib"
779 supplied_libname=true
782 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
783 supplied_libname=true
788 func_fatal_error "missing argument for --source-base"
793 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
798 func_fatal_error "missing argument for --m4-base"
803 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
808 func_fatal_error "missing argument for --po-base"
813 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
818 func_fatal_error "missing argument for --doc-base"
823 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
828 func_fatal_error "missing argument for --tests-base"
833 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
838 func_fatal_error "missing argument for --aux-dir"
843 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
851 func_fatal_error "missing argument for --avoid"
853 func_append avoidlist " $1"
856 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
857 func_append avoidlist " $arg"
863 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
866 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
873 func_fatal_error "missing argument for --makefile-name"
878 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
889 func_fatal_error "missing argument for --macro-prefix"
894 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
899 func_fatal_error "missing argument for --po-domain"
904 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
906 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
912 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
915 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
918 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
922 --help | --hel | --he | --h )
925 --version | --versio | --versi | --vers )
929 # Stop option processing
933 echo "gnulib-tool: unknown option $1" 1>&2
934 echo "Try 'gnulib-tool --help' for more information." 1>&2
941 if test "$mode" = update; then
942 if test $# != 0; then
943 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
944 echo "Try 'gnulib-tool --help' for more information." 1>&2
945 echo "If you really want to modify the gnulib configuration of your project," 1>&2
946 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
949 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
950 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
951 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
952 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
953 || test -n "$makefile_name" || test -n "$macro_prefix" \
954 || test -n "$po_domain"; then
955 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
956 echo "Try 'gnulib-tool --help' for more information." 1>&2
957 echo "If you really want to modify the gnulib configuration of your project," 1>&2
958 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
963 if test -n "$pobase" && test -z "$po_domain"; then
964 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
965 echo "Try 'gnulib-tool --help' for more information." 1>&2
968 if test -z "$pobase" && test -n "$po_domain"; then
969 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
972 # Determine the minimum supported autoconf version from the project's
974 DEFAULT_AUTOCONF_MINVERSION="2.59"
977 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
978 if test -f "$destdir"/configure.ac; then
979 configure_ac="$destdir/configure.ac"
981 if test -f "$destdir"/configure.in; then
982 configure_ac="$destdir/configure.in"
986 if test -f configure.ac; then
987 configure_ac="configure.ac"
989 if test -f configure.in; then
990 configure_ac="configure.in"
994 if test -n "$configure_ac"; then
995 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
996 # because when some m4 files are omitted from a CVS repository,
997 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
998 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
999 # autom4te: m4 failed with exit status: 1
1006 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1008 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1009 if test -n "$prereqs"; then
1010 autoconf_minversion=`
1011 for version in $prereqs; do echo $version; done |
1012 LC_ALL=C sort -nru | sed 1q
1016 if test -z "$autoconf_minversion"; then
1017 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1019 case "$autoconf_minversion" in
1020 1.* | 2.[0-4]* | 2.5[0-8]*)
1021 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1024 # Remove trailing slashes from the directory names. This is necessary for
1025 # m4base (to avoid an error in func_import) and optional for the others.
1026 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1027 case "$local_gnulib_dir" in
1028 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1030 case "$sourcebase" in
1031 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1034 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1037 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1040 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1042 case "$testsbase" in
1043 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1046 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1052 trap 'exit_status=$?
1053 if test "$signal" != 0; then
1054 echo "caught signal $signal" >&2
1057 exit $exit_status' 0
1058 for signal in 1 2 3 13 15; do
1059 trap '{ signal='$signal'; func_exit 1; }' $signal
1063 # func_lookup_file file
1064 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1067 # - local_gnulib_dir from --local-dir
1069 # - lookedup_file name of the merged (combined) file
1070 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1074 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1075 lookedup_file="$local_gnulib_dir/$lkfile"
1078 if test -f "$gnulib_dir/$lkfile"; then
1079 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1080 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1081 rm -f "$tmp/$lkbase"
1082 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1083 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1084 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1085 lookedup_file="$tmp/$lkbase"
1088 lookedup_file="$gnulib_dir/$lkfile"
1092 func_fatal_error "file $gnulib_dir/$lkfile not found"
1099 # - local_gnulib_dir from --local-dir
1102 # Filter out metainformation files like README, which are not modules.
1103 # Filter out unit test modules; they can be retrieved through
1104 # --extract-tests-module if desired.
1106 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1107 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1108 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1111 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1112 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1113 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1114 -e '/^README$/d' -e '/\/README$/d' \
1115 -e '/^TEMPLATE$/d' \
1116 -e '/^TEMPLATE-EXTENDED$/d' \
1117 -e '/^TEMPLATE-TESTS$/d' \
1120 | sed -e '/-tests$/d' \
1124 # func_verify_module
1125 # verifies a module name
1127 # - local_gnulib_dir from --local-dir
1128 # - module module name argument
1129 func_verify_module ()
1131 if { test -f "$gnulib_dir/modules/$module" \
1132 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1133 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1134 && test "CVS" != "$module" \
1135 && test "ChangeLog" != "$module" \
1136 && test "COPYING" != "$module" \
1137 && test "README" != "$module" \
1138 && test "TEMPLATE" != "$module" \
1139 && test "TEMPLATE-EXTENDED" != "$module" \
1140 && test "TEMPLATE-TESTS" != "$module"; then
1141 # OK, $module is a correct module name.
1142 # Verify that building the module description with 'patch' succeeds.
1143 func_lookup_file "modules/$module"
1145 echo "gnulib-tool: module $module doesn't exist" 1>&2
1150 # func_verify_nontests_module
1151 # verifies a module name, excluding tests modules
1153 # - local_gnulib_dir from --local-dir
1154 # - module module name argument
1155 func_verify_nontests_module ()
1158 *-tests ) module= ;;
1159 * ) func_verify_module ;;
1163 # func_verify_tests_module
1164 # verifies a module name, considering only tests modules
1166 # - local_gnulib_dir from --local-dir
1167 # - module module name argument
1168 func_verify_tests_module ()
1171 *-tests ) func_verify_module ;;
1176 sed_extract_prog=':[ ]*$/ {
1179 s/^Description:[ ]*$//
1182 s/^Depends-on:[ ]*$//
1183 s/^configure\.ac-early:[ ]*$//
1184 s/^configure\.ac:[ ]*$//
1185 s/^Makefile\.am:[ ]*$//
1189 s/^Maintainer:[ ]*$//
1196 # func_get_description module
1198 # - local_gnulib_dir from --local-dir
1199 func_get_description ()
1201 func_lookup_file "modules/$1"
1202 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1205 # func_get_notice module
1207 # - local_gnulib_dir from --local-dir
1210 func_lookup_file "modules/$1"
1211 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1214 # func_get_filelist module
1216 # - local_gnulib_dir from --local-dir
1217 func_get_filelist ()
1219 func_lookup_file "modules/$1"
1220 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1221 echo m4/gnulib-common.m4
1222 case "$autoconf_minversion" in
1224 #echo m4/onceonly.m4
1225 echo m4/onceonly_2_57.m4
1230 # func_get_dependencies module
1232 # - local_gnulib_dir from --local-dir
1233 func_get_dependencies ()
1235 # ${module}-tests always implicitly depends on ${module}.
1236 echo "$1" | sed -n -e 's/-tests$//p'
1237 # Then the explicit dependencies listed in the module description.
1238 func_lookup_file "modules/$1"
1239 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1242 # func_get_autoconf_early_snippet module
1244 # - local_gnulib_dir from --local-dir
1245 func_get_autoconf_early_snippet ()
1247 func_lookup_file "modules/$1"
1248 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1251 # func_get_autoconf_snippet module
1253 # - local_gnulib_dir from --local-dir
1254 func_get_autoconf_snippet ()
1256 func_lookup_file "modules/$1"
1257 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1260 # func_get_automake_snippet module
1262 # - local_gnulib_dir from --local-dir
1263 func_get_automake_snippet ()
1265 func_lookup_file "modules/$1"
1266 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1269 # *-tests module live in tests/, not lib/.
1270 # Synthesize an EXTRA_DIST augmentation.
1271 all_files=`func_get_filelist $1`
1272 tests_files=`for f in $all_files; do \
1274 tests/*) echo $f ;; \
1276 done | sed -e 's,^tests/,,'`
1277 extra_files="$tests_files"
1278 if test -n "$extra_files"; then
1279 echo "EXTRA_DIST +=" $extra_files
1284 # Synthesize an EXTRA_DIST augmentation.
1285 sed_combine_lines='/\\$/{
1292 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1293 already_mentioned_files=` \
1294 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1295 | sed -e "$sed_combine_lines" \
1296 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1297 all_files=`func_get_filelist $1`
1298 lib_files=`for f in $all_files; do \
1302 done | sed -e 's,^lib/,,'`
1303 # Remove $already_mentioned_files from $lib_files.
1304 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1305 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1306 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1307 if test -n "$extra_files"; then
1308 echo "EXTRA_DIST +=" $extra_files
1311 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1312 # This is necessary so that automake can generate the right list of
1314 # A possible approach would be to use autom4te --trace of the redefined
1315 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1316 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1317 # inside autoconf's built-in macros are not missed).
1318 # But it's simpler and more robust to do it here, based on the file list.
1319 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1320 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1321 # automake will generate a useless dependency; this is harmless.
1323 relocatable-prog-wrapper) ;;
1325 sed_extract_c_files='/\.c$/p'
1326 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1327 if test -n "$extra_files"; then
1328 echo "EXTRA_lib_SOURCES +=" $extra_files
1333 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1334 buildaux_files=`for f in $all_files; do \
1336 build-aux/*) echo $f ;; \
1338 done | sed -e 's,^build-aux/,,'`
1339 if test -n "$buildaux_files"; then
1340 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1341 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1348 # func_get_include_directive module
1350 # - local_gnulib_dir from --local-dir
1351 func_get_include_directive ()
1353 func_lookup_file "modules/$1"
1354 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1355 sed -e 's/^\(["<]\)/#include \1/'
1358 # func_get_link_directive module
1360 # - local_gnulib_dir from --local-dir
1361 func_get_link_directive ()
1363 func_lookup_file "modules/$1"
1364 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1367 # func_get_license module
1369 # - local_gnulib_dir from --local-dir
1372 func_lookup_file "modules/$1"
1373 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1374 # The default is GPL.
1376 } | sed -e 's,^ *$,,' | sed -e 1q
1379 # func_get_maintainer module
1381 # - local_gnulib_dir from --local-dir
1382 func_get_maintainer ()
1384 func_lookup_file "modules/$1"
1385 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1388 # func_get_tests_module module
1390 # - local_gnulib_dir from --local-dir
1391 func_get_tests_module ()
1393 # The naming convention for tests modules is hardwired: ${module}-tests.
1394 if test -f "$gnulib_dir/modules/$1"-tests \
1395 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1396 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1401 # func_acceptable module
1402 # tests whether a module is acceptable.
1404 # - avoidlist list of modules to avoid
1407 for avoid in $avoidlist; do
1408 if test "$avoid" = "$1"; then
1415 # func_modules_transitive_closure
1417 # - local_gnulib_dir from --local-dir
1418 # - modules list of specified modules
1419 # - inctests true if tests should be included, blank otherwise
1420 # - avoidlist list of modules to avoid
1421 # - tmp pathname of a temporary directory
1423 # - modules list of modules, including dependencies
1424 func_modules_transitive_closure ()
1426 # In order to process every module only once (for speed), process an "input
1427 # list" of modules, producing an "output list" of modules. During each round,
1428 # more modules can be queued in the input list. Once a module on the input
1429 # list has been processed, it is added to the "handled list", so we can avoid
1430 # to process it again.
1432 inmodules="$modules"
1434 while test -n "$inmodules"; do
1435 inmodules_this_round="$inmodules"
1436 inmodules= # Accumulator, queue for next round
1437 for module in $inmodules_this_round; do
1439 if test -n "$module"; then
1440 if func_acceptable $module; then
1441 func_append outmodules " $module"
1442 deps=`func_get_dependencies $module`
1443 # Duplicate dependencies are harmless, but Jim wants a warning.
1444 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1445 if test -n "$duplicated_deps"; then
1446 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1448 func_append inmodules " $deps"
1449 if test -n "$inctests"; then
1450 testsmodule=`func_get_tests_module $module`
1451 if test -n "$testsmodule"; then
1452 func_append inmodules " $testsmodule"
1458 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1459 # Remove $handledmodules from $inmodules.
1460 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1461 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1463 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1464 rm -f "$tmp"/queued-modules
1467 # func_modules_add_dummy
1469 # - local_gnulib_dir from --local-dir
1470 # - modules list of modules, including dependencies
1472 # - modules list of modules, including 'dummy' if needed
1473 func_modules_add_dummy ()
1476 sed_remove_backslash_newline=':a
1483 for module in $modules; do
1484 func_verify_nontests_module
1485 if test -n "$module"; then
1486 # Extract the value of "lib_SOURCES += ...".
1487 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1488 # Ignore .h files since they are not compiled.
1491 *) have_lib_SOURCES=yes ;;
1496 # Add the dummy module, to make sure the library will be non-empty.
1497 if test -z "$have_lib_SOURCES"; then
1498 if func_acceptable "dummy"; then
1499 func_append modules " dummy"
1504 # func_modules_notice
1506 # - local_gnulib_dir from --local-dir
1507 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1508 # - modules list of modules, including dependencies
1509 func_modules_notice ()
1511 if test $verbose -ge -1; then
1512 for module in $modules; do
1514 if test -n "$module"; then
1515 msg=`func_get_notice $module`
1516 if test -n "$msg"; then
1517 echo "Notice from module $module:"
1518 echo "$msg" | sed -e 's/^/ /'
1525 # func_modules_to_filelist
1527 # - local_gnulib_dir from --local-dir
1528 # - modules list of modules, including dependencies
1530 # - files list of files
1531 func_modules_to_filelist ()
1534 for module in $modules; do
1536 if test -n "$module"; then
1537 fs=`func_get_filelist $module`
1538 func_append files " $fs"
1541 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1544 # func_execute_command command [args...]
1545 # Executes a command.
1546 # Uses also the variables
1547 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1548 func_execute_command ()
1550 if test $verbose -ge 0; then
1554 # Commands like automake produce output to stderr even when the succeed.
1555 # Turn this output off if the command succeeds.
1556 "$@" > "$tmp"/cmdout 2>&1
1558 if test $cmdret = 0; then
1562 cat "$tmp"/cmdout 1>&2
1569 # func_emit_lib_Makefile_am
1570 # emits the contents of library makefile to standard output.
1572 # - local_gnulib_dir from --local-dir
1573 # - modules list of modules, including dependencies
1574 # - libname library name
1575 # - pobase directory relative to destdir where to place *.po files
1576 # - auxdir directory relative to destdir where to place build aux files
1577 # - makefile_name from --makefile-name
1578 # - libtool true if libtool will be used, false or blank otherwise
1579 # - macro_prefix prefix of gl_LIBOBJS macros to use
1580 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1581 # - actioncmd (optional) command that will reproduce this invocation
1582 # - for_test true if creating a package for testing, false otherwise
1584 # - uses_subdirs nonempty if object files in subdirs exist
1585 func_emit_lib_Makefile_am ()
1587 # When creating an includable Makefile.am snippet, augment variables with
1588 # += instead of assigning them.
1589 if test -n "$makefile_name"; then
1594 if test "$libtool" = true; then
1597 sed_eliminate_LDFLAGS=
1601 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1604 # When creating a package for testing: Attempt to provoke failures,
1605 # especially link errors, already during "make" rather than during
1606 # "make check", because "make check" is not possible in a cross-compiling
1607 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1608 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1610 sed_transform_check_PROGRAMS=
1612 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1613 echo "## Process this file with automake to produce Makefile.in."
1614 func_emit_copyright_notice
1615 if test -n "$actioncmd"; then
1616 echo "# Reproduce by: $actioncmd"
1621 for module in $modules; do
1622 func_verify_nontests_module
1623 if test -n "$module"; then
1625 func_get_automake_snippet "$module" |
1626 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1627 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1628 -e "$sed_eliminate_LDFLAGS" \
1629 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1630 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1631 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1632 -e "$sed_transform_check_PROGRAMS"
1633 if test "$module" = 'alloca'; then
1634 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1635 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1638 # Skip the contents if its entirely empty.
1639 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1640 echo "## begin gnulib module $module"
1643 echo "## end gnulib module $module"
1647 # Test whether there are some source files in subdirectories.
1648 for f in `func_get_filelist "$module"`; do
1650 lib/*/*.c) uses_subdirs=yes ;;
1656 if test -z "$makefile_name"; then
1657 # If there are source files in subdirectories, prevent collision of the
1658 # object files (example: hash.c and libxml/hash.c).
1660 if test -n "$uses_subdirs"; then
1661 subdir_options=' subdir-objects'
1663 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1666 if test -z "$makefile_name"; then
1667 echo "noinst_HEADERS ="
1668 echo "noinst_LIBRARIES ="
1669 echo "noinst_LTLIBRARIES ="
1670 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1671 # if you specify pkgdata_DATA to empty. This is a workaround.
1672 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1673 echo "pkgdata_DATA ="
1676 echo "BUILT_SOURCES ="
1679 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1680 if test -z "$makefile_name"; then
1681 echo "MOSTLYCLEANDIRS ="
1683 echo "DISTCLEANFILES ="
1684 echo "MAINTAINERCLEANFILES ="
1686 echo "AM_CPPFLAGS ="
1689 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1690 # One of the snippets already specifies an installation location for the
1691 # library. Don't confuse automake by saying it should not be installed.
1694 # By default, the generated library should not be installed.
1695 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1698 echo "${libname}_${libext}_SOURCES ="
1699 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1700 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1701 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1702 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1703 echo "EXTRA_${libname}_${libext}_SOURCES ="
1704 if test "$libtool" = true; then
1705 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1708 if test -n "$pobase"; then
1709 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1712 cat allsnippets.tmp \
1713 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1715 echo "mostlyclean-local: mostlyclean-generic"
1716 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1717 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1718 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1722 rm -f allsnippets.tmp
1725 # func_emit_po_Makevars
1726 # emits the contents of po/ makefile parametrization to standard output.
1728 # - local_gnulib_dir from --local-dir
1729 # - sourcebase directory relative to destdir where to place source code
1730 # - pobase directory relative to destdir where to place *.po files
1731 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1732 func_emit_po_Makevars ()
1734 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1735 func_emit_copyright_notice
1737 echo "# Usually the message domain is the same as the package name."
1738 echo "# But here it has a '-gnulib' suffix."
1739 echo "DOMAIN = ${po_domain}-gnulib"
1741 echo "# These two variables depend on the location of this directory."
1742 echo "subdir = ${pobase}"
1743 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1746 # These options get passed to xgettext.
1747 XGETTEXT_OPTIONS = \
1748 --keyword=_ --flag=_:1:pass-c-format \
1749 --keyword=N_ --flag=N_:1:pass-c-format \
1750 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1751 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1752 --flag=error:3:c-format --flag=error_at_line:5:c-format
1754 # This is the copyright holder that gets inserted into the header of the
1755 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1756 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1758 # This is the email address or URL to which the translators shall report
1759 # bugs in the untranslated strings:
1760 # - Strings which are not entire sentences, see the maintainer guidelines
1761 # in the GNU gettext documentation, section 'Preparing Strings'.
1762 # - Strings which use unclear terms or require additional context to be
1764 # - Strings which make invalid assumptions about notation of date, time or
1766 # - Pluralisation problems.
1767 # - Incorrect English spelling.
1768 # - Incorrect formatting.
1769 # It can be your email address, or a mailing list address where translators
1770 # can write to without being subscribed, or the URL of a web page through
1771 # which the translators can contact you.
1772 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1774 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1775 # message catalogs shall be used. It is usually empty.
1776 EXTRA_LOCALE_CATEGORIES =
1778 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1779 # context. Possible values are "yes" and "no". Set this to yes if the
1780 # package uses functions taking also a message context, like pgettext(), or
1781 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1786 # func_emit_po_POTFILES_in
1787 # emits the file list to be passed to xgettext to standard output.
1789 # - local_gnulib_dir from --local-dir
1790 # - sourcebase directory relative to destdir where to place source code
1791 # - files list of new files
1792 func_emit_po_POTFILES_in ()
1794 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1795 func_emit_copyright_notice
1797 echo "# List of files which contain translatable strings."
1798 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1801 # func_emit_tests_Makefile_am
1802 # emits the contents of tests makefile to standard output.
1804 # - local_gnulib_dir from --local-dir
1805 # - modules list of modules, including dependencies
1806 # - libname library name
1807 # - auxdir directory relative to destdir where to place build aux files
1808 # - makefile_name from --makefile-name
1809 # - libtool true if libtool will be used, false or blank otherwise
1810 # - sourcebase relative directory containing lib source code
1811 # - m4base relative directory containing autoconf macros
1812 # - testsbase relative directory containing unit test code
1813 # - macro_prefix prefix of gl_LIBOBJS macros to use
1814 # - for_test true if creating a package for testing, false otherwise
1815 # - use_libtests true if a libtests.a should be built, false otherwise
1817 # - uses_subdirs nonempty if object files in subdirs exist
1818 func_emit_tests_Makefile_am ()
1820 if test "$libtool" = true; then
1822 sed_eliminate_LDFLAGS=
1825 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1828 # When creating a package for testing: Attempt to provoke failures,
1829 # especially link errors, already during "make" rather than during
1830 # "make check", because "make check" is not possible in a cross-compiling
1831 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1832 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1834 sed_transform_check_PROGRAMS=
1836 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1837 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1838 echo "## Process this file with automake to produce Makefile.in."
1839 func_emit_copyright_notice
1843 for module in $modules; do
1845 func_verify_tests_module
1849 if test -n "$module"; then
1851 func_get_automake_snippet "$module" |
1852 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1853 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1854 -e "$sed_eliminate_LDFLAGS" \
1855 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
1856 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1857 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1858 -e "$sed_transform_check_PROGRAMS"
1859 if $use_libtests && test "$module" = 'alloca'; then
1860 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
1861 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1864 # Skip the contents if its entirely empty.
1865 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1866 echo "## begin gnulib module $module"
1869 echo "## end gnulib module $module"
1873 # Test whether there are some source files in subdirectories.
1874 for f in `func_get_filelist "$module"`; do
1876 lib/*/*.c | tests/*/*.c) uses_subdirs=yes ;;
1882 # Generate dependencies here, since it eases the debugging of test failures.
1883 # If there are source files in subdirectories, prevent collision of the
1884 # object files (example: hash.c and libxml/hash.c).
1886 if test -n "$uses_subdirs"; then
1887 subdir_options=' subdir-objects'
1889 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
1892 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1895 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1896 # variable is needed to avoid an error from automake:
1897 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1900 echo "TESTS_ENVIRONMENT ="
1901 echo "noinst_PROGRAMS ="
1902 if ! $for_test; then
1903 echo "check_PROGRAMS ="
1905 echo "noinst_HEADERS ="
1906 echo "noinst_LIBRARIES ="
1907 if $use_libtests; then
1909 echo "noinst_LIBRARIES += libtests.a"
1911 echo "check_LIBRARIES = libtests.a"
1914 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1915 # if you specify pkgdata_DATA to empty. This is a workaround.
1916 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1917 echo "pkgdata_DATA ="
1920 echo "BUILT_SOURCES ="
1922 echo "MOSTLYCLEANFILES = core *.stackdump"
1923 echo "MOSTLYCLEANDIRS ="
1925 echo "DISTCLEANFILES ="
1926 echo "MAINTAINERCLEANFILES ="
1928 echo "AM_CPPFLAGS = \\"
1929 echo " -I. -I\$(srcdir) \\"
1930 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1931 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1933 local_ldadd_before=''
1934 local_ldadd_after=''
1935 if $use_libtests; then
1936 # All test programs need to be linked with libtests.a.
1937 # It needs to be passed to the linker before ${libname}.${libext}, since
1938 # the tests-related modules depend on the main modules.
1939 # It also needs to be passed to the linker after ${libname}.${libext}
1940 # because the latter might contain incomplete modules (such as the 'error'
1941 # module whose dependency to 'progname' is voluntarily omitted).
1942 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
1944 local_ldadd_before=' libtests.a'
1945 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
1947 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
1949 if $use_libtests; then
1950 echo "libtests_a_SOURCES ="
1951 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1952 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1953 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
1954 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
1955 echo "EXTRA_libtests_a_SOURCES ="
1956 # The circular dependency in LDADD requires this.
1957 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
1960 cat allsnippets.tmp \
1961 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1962 echo "# Clean up after Solaris cc."
1964 echo " rm -rf SunWS_cache"
1966 echo "mostlyclean-local: mostlyclean-generic"
1967 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1968 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1969 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1973 rm -f allsnippets.tmp
1976 # func_emit_initmacro_start macro_prefix
1977 # emits the first few statements of the gl_INIT macro to standard output.
1978 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1979 func_emit_initmacro_start ()
1981 macro_prefix_arg="$1"
1982 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1983 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
1984 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1985 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1987 # Furthermore it avoids an automake error like this when a Makefile.am
1988 # that uses pieces of gnulib also uses $(LIBOBJ):
1989 # automatically discovered file `error.c' should not be explicitly mentioned
1990 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
1991 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
1992 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1993 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1994 # automatically discovered file `error.c' should not be explicitly mentioned
1995 # We let automake know about the files to be distributed through the
1996 # EXTRA_lib_SOURCES variable.
1997 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2000 # func_emit_initmacro_end macro_prefix
2001 # emits the last few statements of the gl_INIT macro to standard output.
2002 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2003 func_emit_initmacro_end ()
2005 macro_prefix_arg="$1"
2006 echo " m4_popdef([AC_LIBSOURCES])"
2007 echo " m4_popdef([AC_REPLACE_FUNCS])"
2008 echo " m4_popdef([AC_LIBOBJ])"
2009 echo " AC_CONFIG_COMMANDS_PRE(["
2010 echo " ${macro_prefix_arg}_libobjs="
2011 echo " ${macro_prefix_arg}_ltlibobjs="
2012 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2013 echo " # Remove the extension."
2014 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2015 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2016 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2017 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2020 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2021 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2025 # func_emit_initmacro_done macro_prefix sourcebase
2026 # emits a few statements after the gl_INIT macro to standard output.
2027 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2028 # - sourcebase directory relative to destdir where to place source code
2029 func_emit_initmacro_done ()
2031 macro_prefix_arg="$1"
2034 echo "# Like AC_LIBOBJ, except that the module name goes"
2035 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2036 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2037 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2038 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2041 echo "# m4_foreach_w is provided by autoconf-2.59c and later."
2042 echo "# This definition is to accommodate developers using versions"
2043 echo "# of autoconf older than that."
2044 echo "m4_ifndef([m4_foreach_w],"
2045 echo " [m4_define([m4_foreach_w],"
2046 echo " [m4_foreach([\$1], m4_split(m4_normalize([\$2]), [ ]), [\$3])])])"
2048 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2049 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2050 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2051 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2052 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2055 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2056 echo "# expected is derived from the gnulib-tool parametrization,"
2057 echo "# and alloca is special cased (for the alloca-opt module)."
2058 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2059 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2060 echo " m4_foreach([_gl_NAME], [\$1], ["
2061 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2062 echo " m4_syscmd([test -r $sourcebase_arg/]_gl_NAME[ || test ! -d $sourcebase_arg])dnl"
2063 echo " m4_if(m4_sysval, [0], [],"
2064 echo " [AC_FATAL([missing $sourcebase_arg/]_gl_NAME)])"
2070 # func_import modules
2071 # Uses also the variables
2072 # - destdir target directory
2073 # - local_gnulib_dir from --local-dir
2074 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2075 # - libname library name
2076 # - sourcebase directory relative to destdir where to place source code
2077 # - m4base directory relative to destdir where to place *.m4 macros
2078 # - pobase directory relative to destdir where to place *.po files
2079 # - docbase directory relative to destdir where to place doc files
2080 # - testsbase directory relative to destdir where to place unit test code
2081 # - auxdir directory relative to destdir where to place build aux files
2082 # - inctests true if --with-tests was given, blank otherwise
2083 # - avoidlist list of modules to avoid, from --avoid
2084 # - lgpl yes or a number if library's license shall be LGPL,
2086 # - makefile_name from --makefile-name
2087 # - libtool true if --libtool was given, false if --no-libtool was
2088 # given, blank otherwise
2089 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2090 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2091 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2092 # - autoconf_minversion minimum supported autoconf version
2093 # - doit : if actions shall be executed, false if only to be printed
2094 # - symbolic true if files should be symlinked, copied otherwise
2095 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2097 # - do_copyrights true if copyright notices in files should be replaced,
2101 # Get the cached settings.
2102 cached_local_gnulib_dir=
2103 cached_specified_modules=
2113 cached_makefile_name=
2115 cached_macro_prefix=
2118 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2119 cached_libtool=false
2125 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
2128 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
2131 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
2134 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
2137 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
2140 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
2143 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
2146 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
2149 s,^.*$,cached_inctests=true,p
2152 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
2155 s,^.*gl_LGPL([[ ]*\([^])]*\).*$,cached_lgpl="\1",p
2158 s,^.*$,cached_lgpl=yes,p
2160 /gl_MAKEFILE_NAME(/ {
2161 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
2164 s,^.*$,cached_libtool=true,p
2166 /gl_MACRO_PREFIX(/ {
2167 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2170 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2172 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2173 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2178 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2179 s,^.*$,cached_files=",p
2191 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2195 # Merge the cached settings with the specified ones.
2196 # The m4base must be the same as expected from the pathname.
2197 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2198 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2200 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2201 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2202 if test -z "$local_gnulib_dir"; then
2203 if test -n "$cached_local_gnulib_dir"; then
2206 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2208 case "$cached_local_gnulib_dir" in
2210 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2212 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2213 local_gnulib_dir="$relconcat" ;;
2218 # Append the cached and the specified module names. So that
2219 # "gnulib-tool --import foo" means to add the module foo.
2220 specified_modules="$cached_specified_modules $1"
2221 # Append the cached and the specified avoidlist. This is probably better
2222 # than dropping the cached one when --avoid is specified at least once.
2223 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2224 avoidlist=`echo $avoidlist`
2226 # The sourcebase defaults to the cached one.
2227 if test -z "$sourcebase"; then
2228 sourcebase="$cached_sourcebase"
2229 if test -z "$sourcebase"; then
2230 func_fatal_error "missing --source-base option"
2233 # The pobase defaults to the cached one.
2234 if test -z "$pobase"; then
2235 pobase="$cached_pobase"
2237 # The docbase defaults to the cached one.
2238 if test -z "$docbase"; then
2239 docbase="$cached_docbase"
2240 if test -z "$docbase"; then
2241 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."
2244 # The testsbase defaults to the cached one.
2245 if test -z "$testsbase"; then
2246 testsbase="$cached_testsbase"
2247 if test -z "$testsbase"; then
2248 func_fatal_error "missing --tests-base option"
2251 # Require the tests if specified either way.
2252 if test -z "$inctests"; then
2253 inctests="$cached_inctests"
2255 # The libname defaults to the cached one.
2256 if test -z "$supplied_libname"; then
2257 libname="$cached_libname"
2258 if test -z "$libname"; then
2259 func_fatal_error "missing --lib option"
2262 # Require LGPL if specified either way.
2263 if test -z "$lgpl"; then
2266 # The makefile_name defaults to the cached one.
2267 if test -z "$makefile_name"; then
2268 makefile_name="$cached_makefile_name"
2270 # Use libtool if specified either way, or if guessed.
2271 if test -z "$libtool"; then
2272 if test -n "$cached_m4base"; then
2273 libtool="$cached_libtool"
2275 libtool="$guessed_libtool"
2278 # The macro_prefix defaults to the cached one.
2279 if test -z "$macro_prefix"; then
2280 macro_prefix="$cached_macro_prefix"
2281 if test -z "$macro_prefix"; then
2282 func_fatal_error "missing --macro-prefix option"
2285 # The po_domain defaults to the cached one.
2286 if test -z "$po_domain"; then
2287 po_domain="$cached_po_domain"
2290 # Canonicalize the list of specified modules.
2291 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2293 # Determine final module list.
2294 modules="$specified_modules"
2295 func_modules_transitive_closure
2296 if test $verbose -ge 0; then
2297 echo "Module list with included dependencies:"
2298 echo "$modules" | sed -e 's/^/ /'
2300 final_modules="$modules"
2302 # Determine main module list and tests-related module list separately.
2303 # The main module list is the transitive closure of the specified modules,
2304 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2305 # is specified, it will consist only of LGPLed source.
2306 # The tests-related module list is the transitive closure of the specified
2307 # modules, including tests modules, minus the main module list. Its lib/*
2308 # sources (brought in through dependencies of *-tests modules) go into
2309 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2310 # Determine main module list.
2311 saved_inctests="$inctests"
2313 modules="$specified_modules"
2314 func_modules_transitive_closure
2315 main_modules="$modules"
2316 inctests="$saved_inctests"
2317 if test $verbose -ge 1; then
2318 echo "Main module list:"
2319 echo "$main_modules" | sed -e 's/^/ /'
2321 # Determine tests-related module list.
2322 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2323 testsrelated_modules=`echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2324 if test $verbose -ge 1; then
2325 echo "Tests-related module list:"
2326 echo "$testsrelated_modules" | sed -e 's/^/ /'
2329 # Add the dummy module to the main module list if needed.
2330 modules="$main_modules"
2331 func_modules_add_dummy
2332 main_modules="$modules"
2334 # Determine whether a $testsbase/libtests.a is needed.
2336 for module in $testsrelated_modules; do
2337 func_verify_nontests_module
2338 if test -n "$module"; then
2339 all_files=`func_get_filelist $module`
2340 lib_files=`for f in $all_files; do \
2344 done | sed -e 's,^lib/,,'`
2345 if test -n "$lib_files"; then
2352 # Add the dummy module to the tests-related module list if needed.
2353 if $use_libtests; then
2354 modules="$testsrelated_modules"
2355 func_modules_add_dummy
2356 testsrelated_modules="$modules"
2359 # If --lgpl, verify that the licenses of modules are compatible.
2360 if test -n "$lgpl"; then
2361 for module in $main_modules; do
2362 license=`func_get_license $module`
2364 'GPLed build tool') ;;
2365 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2371 *) func_fatal_error "incompatible license on module $module: $license" ;;
2377 *) func_fatal_error "incompatible license on module $module: $license" ;;
2380 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2387 # Show banner notice of every module.
2388 modules="$main_modules"
2391 # Determine script to apply to imported library files.
2392 sed_transform_lib_file=
2393 for module in $main_modules; do
2394 if test $module = config-h; then
2395 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2396 sed_transform_lib_file=$sed_transform_lib_file'
2397 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2402 sed_transform_main_lib_file="$sed_transform_lib_file"
2403 if test -n "$do_copyrights"; then
2404 if test -n "$lgpl"; then
2408 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2409 s/GNU General/GNU Lesser General/g
2413 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2414 s/GNU General/GNU Lesser General/g
2415 s/version [23]\([ ,]\)/version 2.1\1/g
2418 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2422 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2423 s/GNU Lesser General/GNU General/g
2424 s/GNU Library General/GNU General/g
2425 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2430 # Determine script to apply to library files that go into $testsbase/.
2431 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2432 if test -n "$do_copyrights"; then
2434 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2435 s/GNU Lesser General/GNU General/g
2436 s/GNU Library General/GNU General/g
2437 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2441 # Determine the final file lists.
2442 # They must be computed separately, because files in lib/* go into
2443 # $sourcebase/ if they are in the main file list but into $testsbase/
2444 # if they are in the tests-related file list. Furthermore lib/dummy.c
2446 # Determine final main file list.
2447 modules="$main_modules"
2448 func_modules_to_filelist
2450 # Determine final tests-related file list.
2451 modules="$testsrelated_modules"
2452 func_modules_to_filelist
2453 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2454 # Merge both file lists.
2455 sed_remove_empty_lines='/^$/d'
2456 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2457 if test $verbose -ge 0; then
2459 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2460 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2464 || func_fatal_error "refusing to do nothing"
2466 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2467 new_files="$files m4/gnulib-tool.m4"
2468 old_files="$cached_files"
2469 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2470 func_append old_files " m4/gnulib-tool.m4"
2473 sed_rewrite_old_files="\
2474 s,^build-aux/,$auxdir/,
2475 s,^doc/,$cached_docbase/,
2476 s,^lib/,$cached_sourcebase/,
2477 s,^m4/,$cached_m4base/,
2478 s,^tests/,$cached_testsbase/,
2479 s,^tests=lib/,$cached_testsbase/,"
2480 sed_rewrite_new_files="\
2481 s,^build-aux/,$auxdir/,
2483 s,^lib/,$sourcebase/,
2485 s,^tests/,$testsbase/,
2486 s,^tests=lib/,$testsbase/,"
2488 # Create directories.
2489 { echo "$sourcebase"
2491 if test -n "$pobase"; then
2494 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2495 if test -n "$docfiles"; then
2498 if test -n "$inctests"; then
2502 for f in $files; do echo $f; done \
2503 | sed -e "$sed_rewrite_new_files" \
2504 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2507 { # Rearrange file descriptors. Needed because "while ... done < ..."
2508 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2509 exec 5<&0 < "$tmp"/dirs
2511 if test ! -d "$destdir/$d"; then
2513 echo "Creating directory $destdir/$d"
2514 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2516 echo "Create directory $destdir/$d"
2523 # func_dest_tmpfilename file
2524 # determines the name of a temporary file (file is relative to destdir).
2526 # - tmpfile absolute filename of the temporary file
2527 func_dest_tmpfilename ()
2530 # Put the new contents of $file in a file in the same directory (needed
2531 # to guarantee that an 'mv' to "$destdir/$file" works).
2532 tmpfile="$destdir/$1.tmp"
2534 # Put the new contents of $file in a file in a temporary directory
2535 # (because the directory of "$file" might not exist).
2536 tmpfile="$tmp"/`basename "$1"`.tmp
2540 # Copy files or make symbolic links. Remove obsolete files.
2544 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2545 # representing the files according to the last gnulib-tool invocation.
2546 for f in $old_files; do echo $f; done \
2547 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2550 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2551 # representing the files after this gnulib-tool invocation.
2552 for f in $new_files; do echo $f; done \
2553 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2556 # First the files that are in old-files, but not in new-files:
2557 sed_take_first_column='s,'"$delimiter"'.*,,'
2558 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2559 # Remove the file. Do nothing if the user already removed it.
2560 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2562 echo "Removing file $g (backup in ${g}~)"
2563 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2565 echo "Remove file $g (backup in ${g}~)"
2567 func_append removed_files "$g$nl"
2570 # func_add_or_update handles a file that ought to be present afterwards.
2572 # - f the original file name
2573 # - g the rewritten file name
2574 # - already_present nonempty if the file already exists, empty otherwise
2575 func_add_or_update ()
2579 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2581 func_dest_tmpfilename "$g"
2582 func_lookup_file "$f"
2583 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2584 if test -n "$sed_transform_main_lib_file"; then
2587 sed -e "$sed_transform_main_lib_file" \
2588 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2592 if test -n "$sed_transform_testsrelated_lib_file"; then
2595 sed -e "$sed_transform_testsrelated_lib_file" \
2596 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2600 if test -f "$destdir/$g"; then
2601 # The file already exists.
2602 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2603 : # The file has not changed.
2607 if test -n "$already_present"; then
2608 echo "Updating file $g (backup in ${g}~)"
2610 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2612 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2613 if { test -n "$symbolic" \
2614 || { test -n "$lsymbolic" \
2615 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2616 && test -z "$lookedup_tmp" \
2617 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2618 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2620 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2623 if test -n "$already_present"; then
2624 echo "Update file $g (backup in ${g}~)"
2626 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2632 # Don't protest if the file should be there but isn't: it happens
2633 # frequently that developers don't put autogenerated files into CVS.
2635 echo "Copying file $g"
2636 if { test -n "$symbolic" \
2637 || { test -n "$lsymbolic" \
2638 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2639 && test -z "$lookedup_tmp" \
2640 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2641 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2643 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2648 func_append added_files "$g$nl"
2652 # Then the files that are in new-files, but not in old-files:
2653 sed_take_last_column='s,^.*'"$delimiter"',,'
2655 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2656 | sed -e "$sed_take_last_column" \
2657 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2658 { # Rearrange file descriptors. Needed because "while ... done < ..."
2659 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2660 exec 5<&0 < "$tmp"/added-files
2666 # Then the files that are in new-files and in old-files:
2667 already_present=true
2668 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2669 | sed -e "$sed_take_last_column" \
2670 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2671 { # Rearrange file descriptors. Needed because "while ... done < ..."
2672 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2673 exec 5<&0 < "$tmp"/kept-files
2680 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2681 actioncmd="gnulib-tool --import"
2682 func_append actioncmd " --dir=$destdir"
2683 if test -n "$local_gnulib_dir"; then
2684 func_append actioncmd " --local-dir=$local_gnulib_dir"
2686 func_append actioncmd " --lib=$libname"
2687 func_append actioncmd " --source-base=$sourcebase"
2688 func_append actioncmd " --m4-base=$m4base"
2689 if test -n "$pobase"; then
2690 func_append actioncmd " --po-base=$pobase"
2692 func_append actioncmd " --doc-base=$docbase"
2693 func_append actioncmd " --aux-dir=$auxdir"
2694 if test -n "$inctests"; then
2695 func_append actioncmd " --with-tests"
2697 for module in $avoidlist; do
2698 func_append actioncmd " --avoid=$module"
2700 if test -n "$lgpl"; then
2701 if test "$lgpl" = yes; then
2702 func_append actioncmd " --lgpl"
2704 func_append actioncmd " --lgpl=$lgpl"
2707 if test -n "$makefile_name"; then
2708 func_append actioncmd " --makefile-name=$makefile_name"
2710 if test "$libtool" = true; then
2711 func_append actioncmd " --libtool"
2713 func_append actioncmd " --no-libtool"
2715 func_append actioncmd " --macro-prefix=$macro_prefix"
2716 if test -n "$po_domain"; then
2717 func_append actioncmd " --po-domain=$po_domain"
2719 func_append actioncmd " `echo $specified_modules`"
2721 # Default the makefile name to Makefile.am.
2722 if test -n "$makefile_name"; then
2723 makefile_am=$makefile_name
2725 makefile_am=Makefile.am
2728 # Create normal Makefile.ams.
2731 # Create library makefile.
2732 func_dest_tmpfilename $sourcebase/$makefile_am
2733 modules="$main_modules"
2734 func_emit_lib_Makefile_am > "$tmpfile"
2735 if test -f "$destdir"/$sourcebase/$makefile_am; then
2736 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2740 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2741 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2742 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2744 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2750 echo "Creating $sourcebase/$makefile_am"
2751 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2753 echo "Create $sourcebase/$makefile_am"
2756 func_append added_files "$sourcebase/$makefile_am$nl"
2759 # Create po/ directory.
2760 if test -n "$pobase"; then
2761 # Create po makefile and auxiliary files.
2762 for file in Makefile.in.in remove-potcdate.sin; do
2763 func_dest_tmpfilename $pobase/$file
2764 func_lookup_file build-aux/po/$file
2765 cat "$lookedup_file" > "$tmpfile"
2766 if test -f "$destdir"/$pobase/$file; then
2767 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
2771 echo "Updating $pobase/$file (backup in $pobase/$file~)"
2772 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
2773 mv -f "$tmpfile" "$destdir"/$pobase/$file
2775 echo "Update $pobase/$file (backup in $pobase/$file~)"
2781 echo "Creating $pobase/$file"
2782 mv -f "$tmpfile" "$destdir"/$pobase/$file
2784 echo "Create $pobase/$file"
2787 func_append added_files "$pobase/$file$nl"
2790 # Create po makefile parametrization, part 1.
2791 func_dest_tmpfilename $pobase/Makevars
2792 func_emit_po_Makevars > "$tmpfile"
2793 if test -f "$destdir"/$pobase/Makevars; then
2794 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
2798 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
2799 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
2800 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2802 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
2808 echo "Creating $pobase/Makevars"
2809 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2811 echo "Create $pobase/Makevars"
2814 func_append added_files "$pobase/Makevars$nl"
2816 # Create po makefile parametrization, part 2.
2817 func_dest_tmpfilename $pobase/POTFILES.in
2818 func_emit_po_POTFILES_in > "$tmpfile"
2819 if test -f "$destdir"/$pobase/POTFILES.in; then
2820 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
2824 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2825 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
2826 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2828 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2834 echo "Creating $pobase/POTFILES.in"
2835 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2837 echo "Create $pobase/POTFILES.in"
2840 func_append added_files "$pobase/POTFILES.in$nl"
2843 TP_URL="http://translationproject.org/latest/"
2844 TP_RSYNC_URI="translationproject.org::tp/latest/"
2846 echo "Fetching gnulib PO files from $TP_URL"
2847 (cd "$destdir"/$pobase \
2848 && { # Prefer rsync over wget if it is available, since it consumes
2849 # less network bandwidth, due to compression.
2850 if type rsync 2>/dev/null | grep / > /dev/null; then
2851 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
2853 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
2858 echo "Fetch gnulib PO files from $TP_URL"
2860 # Create po/LINGUAS.
2862 func_dest_tmpfilename $pobase/LINGUAS
2863 (cd "$destdir"/$pobase \
2864 && { echo '# Set of available languages.'
2865 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
2868 if test -f "$destdir"/$pobase/LINGUAS; then
2869 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
2872 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2873 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
2874 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2877 echo "Creating $pobase/LINGUAS"
2878 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2879 func_append added_files "$pobase/LINGUAS$nl"
2882 if test -f "$destdir"/$pobase/LINGUAS; then
2883 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2885 echo "Create $pobase/LINGUAS"
2890 # Create m4/gnulib-cache.m4.
2891 func_dest_tmpfilename $m4base/gnulib-cache.m4
2893 func_emit_copyright_notice
2895 echo "# This file represents the specification of how gnulib-tool is used."
2896 echo "# It acts as a cache: It is written and read by gnulib-tool."
2897 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2898 echo "# like the configure.ac and various Makefile.am files."
2901 echo "# Specification in the form of a command-line invocation:"
2904 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2905 # Store the local_gnulib_dir relative to destdir.
2906 case "$local_gnulib_dir" in
2908 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2911 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2913 # destdir, local_gnulib_dir are both relative.
2914 func_relativize "$destdir" "$local_gnulib_dir"
2915 relative_local_gnulib_dir="$reldir" ;;
2918 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2919 echo "gl_MODULES(["`echo $specified_modules`"])"
2920 echo "gl_AVOID([$avoidlist])"
2921 echo "gl_SOURCE_BASE([$sourcebase])"
2922 echo "gl_M4_BASE([$m4base])"
2923 echo "gl_PO_BASE([$pobase])"
2924 echo "gl_DOC_BASE([$docbase])"
2925 echo "gl_TESTS_BASE([$testsbase])"
2926 test -z "$inctests" || echo "gl_WITH_TESTS"
2927 echo "gl_LIB([$libname])"
2928 if test -n "$lgpl"; then
2929 if test "$lgpl" = yes; then
2932 echo "gl_LGPL([$lgpl])"
2935 echo "gl_MAKEFILE_NAME([$makefile_name])"
2936 if test "$libtool" = true; then
2939 echo "gl_MACRO_PREFIX([$macro_prefix])"
2940 echo "gl_PO_DOMAIN([$po_domain])"
2942 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2943 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2947 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2948 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2949 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2951 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2955 echo "# gnulib-cache.m4 ends here"
2962 echo "Creating $m4base/gnulib-cache.m4"
2963 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2965 echo "Create $m4base/gnulib-cache.m4"
2971 # Create m4/gnulib-comp.m4.
2972 func_dest_tmpfilename $m4base/gnulib-comp.m4
2974 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2975 func_emit_copyright_notice
2977 echo "# This file represents the compiled summary of the specification in"
2978 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2979 echo "# to be invoked from configure.ac."
2980 echo "# In projects using CVS, this file can be treated like other built files."
2983 echo "# This macro should be invoked from $configure_ac, in the section"
2984 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2985 echo "# any checks for libraries, header files, types and library functions."
2986 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2988 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2989 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2990 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2991 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2992 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2993 if test -n "$uses_subdirs"; then
2994 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2996 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2997 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2999 for module in $final_modules; do
3001 if test -n "$module"; then
3002 func_get_autoconf_early_snippet "$module"
3005 | sed -e '/^$/d;' -e 's/^/ /'
3008 echo "# This macro should be invoked from $configure_ac, in the section"
3009 echo "# \"Check for header files, types and library functions\"."
3010 echo "AC_DEFUN([${macro_prefix}_INIT],"
3012 if test "$libtool" = true; then
3013 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3014 echo " gl_cond_libtool=true"
3016 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3017 echo " gl_cond_libtool=false"
3019 echo " gl_ltlibdeps="
3021 if test "$auxdir" != "build-aux"; then
3022 sed_replace_build_aux='
3024 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3025 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3029 sed_replace_build_aux=
3031 func_emit_initmacro_start $macro_prefix
3032 echo " gl_source_base='$sourcebase'"
3033 for module in $main_modules; do
3035 if test -n "$module"; then
3036 func_get_autoconf_snippet "$module" \
3037 | sed -e '/^$/d;' -e 's/^/ /' \
3038 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3039 -e "$sed_replace_build_aux"
3040 if test "$module" = 'alloca' && test "$libtool" = true; then
3041 echo 'changequote(,)dnl'
3042 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3043 echo 'changequote([, ])dnl'
3044 echo 'AC_SUBST([LTALLOCA])'
3048 func_emit_initmacro_end $macro_prefix
3049 echo " gltests_libdeps="
3050 echo " gltests_ltlibdeps="
3051 func_emit_initmacro_start ${macro_prefix}tests
3052 echo " gl_source_base='$testsbase'"
3053 for module in $testsrelated_modules; do
3055 if test -n "$module"; then
3056 func_get_autoconf_snippet "$module" \
3057 | sed -e '/^$/d;' -e 's/^/ /' \
3058 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3059 -e "$sed_replace_build_aux" \
3060 -e 's/\$gl_cond_libtool/false/g' \
3061 -e 's/gl_libdeps/gltests_libdeps/g' \
3062 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3065 func_emit_initmacro_end ${macro_prefix}tests
3066 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3067 # created using libtool, because libtool already handles the dependencies.
3068 if test "$libtool" != true; then
3069 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3070 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3071 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3072 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3073 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3075 if $use_libtests; then
3076 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3077 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3080 func_emit_initmacro_done $macro_prefix $sourcebase
3081 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3083 echo "# This macro records the list of files which have been installed by"
3084 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3085 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3086 echo "$files" | sed -e 's,^, ,'
3089 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3090 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3094 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3095 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3096 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3098 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3102 echo "# gnulib-comp.m4 ends here"
3109 echo "Creating $m4base/gnulib-comp.m4"
3110 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3112 echo "Create $m4base/gnulib-comp.m4"
3118 if test -n "$inctests"; then
3119 # Create tests makefile.
3120 func_dest_tmpfilename $testsbase/$makefile_am
3121 modules="$testsrelated_modules"
3122 func_emit_tests_Makefile_am > "$tmpfile"
3123 if test -f "$destdir"/$testsbase/$makefile_am; then
3124 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3128 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3129 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3130 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3132 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3138 echo "Creating $testsbase/$makefile_am"
3139 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3141 echo "Create $testsbase/$makefile_am"
3144 func_append added_files "$testsbase/$makefile_am$nl"
3148 # Update the .cvsignore and .gitignore files.
3149 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3150 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3151 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3152 { # Rearrange file descriptors. Needed because "while ... done < ..."
3153 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3154 exec 5<&0 < "$tmp"/fileset-changes
3155 func_update_ignorelist ()
3158 if test -f "$destdir/$dir$ignore"; then
3159 if test -n "$dir_added" || test -n "$dir_removed"; then
3160 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
3161 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3162 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
3163 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3164 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
3165 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3167 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3168 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3169 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
3170 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
3171 | sed -f "$tmp"/sed-ignore-removed \
3172 > "$destdir/$dir$ignore"
3174 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3179 if test -n "$dir_added"; then
3181 echo "Creating $destdir/$dir$ignore"
3183 if test "$ignore" = .cvsignore; then
3185 # Automake generates Makefile rules that create .dirstamp files.
3188 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u
3189 } > "$destdir/$dir$ignore"
3191 echo "Create $destdir/$dir$ignore"
3201 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3202 func_update_ignorelist .cvsignore
3204 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3205 func_update_ignorelist .gitignore
3212 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3213 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3214 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3215 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3216 if test "$next_dir" != "$last_dir"; then
3217 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3218 last_dir="$next_dir"
3223 A) func_append last_dir_added "$file$nl";;
3224 R) func_append last_dir_removed "$file$nl";;
3227 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3233 echo "You may need to add #include directives for the following .h files."
3234 # Intersect $specified_modules and $main_modules
3235 # (since $specified_modules is not necessarily of subset of $main_modules
3236 # - some may have been skipped through --avoid, and since the elements of
3237 # $main_modules but not in $specified_modules can go away without explicit
3238 # notice - through changes in the module dependencies).
3239 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3240 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3241 # First the #include <...> directives without #ifs, sorted for convenience,
3242 # then the #include "..." directives without #ifs, sorted for convenience,
3243 # then the #include directives that are surrounded by #ifs. Not sorted.
3244 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3245 include_directive=`func_get_include_directive "$module"`
3246 case "$nl$include_directive" in
3248 echo "$include_directive" 1>&5
3251 echo "$include_directive" | grep -v 'include "' 1>&6
3252 echo "$include_directive" | grep 'include "' 1>&7
3255 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3257 LC_ALL=C sort -u "$tmp"/include-angles
3258 LC_ALL=C sort -u "$tmp"/include-quotes
3259 cat "$tmp"/include-if
3260 ) | sed -e '/^$/d' -e 's/^/ /'
3261 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3263 for module in $main_modules; do
3264 func_get_link_directive "$module"
3266 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3267 if test `wc -l < "$tmp"/link` != 0; then
3269 echo "You may need to use the following Makefile variables when linking."
3270 echo "Use them in <program>_LDADD when linking a program, or"
3271 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3277 echo "Don't forget to"
3278 if test "$makefile_am" = Makefile.am; then
3279 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3281 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3283 if test -n "$pobase"; then
3284 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3286 if test -n "$inctests"; then
3287 if test "$makefile_am" = Makefile.am; then
3288 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3290 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3293 if test "$makefile_am" = Makefile.am; then
3294 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3295 sourcebase_base=`basename "$sourcebase"`
3296 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
3298 if test -n "$pobase"; then
3299 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3300 pobase_base=`basename "$pobase"`
3301 echo " - mention \"${pobase_base}\" in SUBDIRS in ${pobase_dir}Makefile.am,"
3303 if test -n "$inctests"; then
3304 if test "$makefile_am" = Makefile.am; then
3305 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3306 testsbase_base=`basename "$testsbase"`
3307 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
3310 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
3311 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3312 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3315 # func_create_testdir testdir modules
3317 # - local_gnulib_dir from --local-dir
3318 # - auxdir directory relative to destdir where to place build aux files
3319 func_create_testdir ()
3323 if test -z "$modules"; then
3324 # All modules together.
3325 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3326 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3327 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3328 modules=`func_all_modules`
3329 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3331 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3333 # Check that the license of every module is consistent with the license of
3335 saved_modules="$modules"
3336 saved_inctests="$inctests"
3337 # When computing transitive closures, don't consider $module to depend on
3338 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3339 # on GPL modules - therefore we don't want a warning in this case.
3341 for requested_module in $saved_modules; do
3342 requested_license=`func_get_license "$requested_module"`
3343 if test "$requested_license" != GPL; then
3344 # Here we use func_modules_transitive_closure, not just
3345 # func_get_dependencies, so that we also detect weird situations like
3346 # an LGPL module which depends on a GPLed build tool module which depends
3348 modules="$requested_module"
3349 func_modules_transitive_closure
3350 for module in $modules; do
3351 license=`func_get_license "$module"`
3353 'GPLed build tool') ;;
3354 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3356 case "$requested_license" in
3359 GPLv2+ | LGPLv2+) ;;
3360 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3366 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3372 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3381 modules="$saved_modules"
3382 inctests="$saved_inctests"
3384 # Subdirectory names.
3393 # Determine final module list.
3394 func_modules_transitive_closure
3395 if test $verbose -ge 0; then
3396 echo "Module list with included dependencies:"
3397 echo "$modules" | sed -e 's/^/ /'
3400 # Add the dummy module if needed.
3401 func_modules_add_dummy
3403 # Show banner notice of every module.
3406 # Determine final file list.
3407 func_modules_to_filelist
3408 if test $verbose -ge 0; then
3410 echo "$files" | sed -e 's/^/ /'
3413 sed_rewrite_files="\
3414 s,^build-aux/,$auxdir/,
3416 s,^lib/,$sourcebase/,
3418 s,^tests/,$testsbase/,"
3420 # Create directories.
3421 for f in $files; do echo $f; done \
3422 | sed -e "$sed_rewrite_files" \
3423 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3424 | LC_ALL=C sort -u \
3426 { # Rearrange file descriptors. Needed because "while ... done < ..."
3427 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3428 exec 5<&0 < "$tmp"/dirs
3430 mkdir -p "$testdir/$d"
3435 # Copy files or make symbolic links.
3437 for f in $files; do echo $f; done \
3438 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3441 { # Rearrange file descriptors. Needed because "while ... done < ..."
3442 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3443 exec 5<&0 < "$tmp"/files
3445 func_lookup_file "$f"
3446 if test -n "$lookedup_tmp"; then
3447 cp -p "$lookedup_file" "$testdir/$g"
3449 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3450 if { test -n "$symbolic" \
3451 || { test -n "$lsymbolic" \
3452 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3453 func_ln "$lookedup_file" "$testdir/$g"
3455 cp -p "$lookedup_file" "$testdir/$g"
3462 # Create Makefile.ams that are for testing.
3465 # Create $sourcebase/Makefile.am.
3466 mkdir -p "$testdir/$sourcebase"
3467 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3468 any_uses_subdirs="$uses_subdirs"
3470 # Create $m4base/Makefile.am.
3471 mkdir -p "$testdir/$m4base"
3472 (echo "## Process this file with automake to produce Makefile.in."
3478 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3481 ) > "$testdir/$m4base/Makefile.am"
3483 subdirs="$sourcebase $m4base"
3484 subdirs_with_configure_ac=""
3486 if false && test -f "$testdir"/$m4base/gettext.m4; then
3487 # Avoid stupid error message from automake:
3488 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3489 mkdir -p "$testdir/po"
3490 (echo "## Process this file with automake to produce Makefile.in."
3491 ) > "$testdir/po/Makefile.am"
3492 func_append subdirs " po"
3495 if test -n "$inctests"; then
3496 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3497 # Viewed from the $testsbase subdirectory, $auxdir is different.
3498 saved_auxdir="$auxdir"
3499 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3500 # Create $testsbase/Makefile.am.
3502 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3503 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3504 # Create $testsbase/configure.ac.
3505 (echo "# Process this file with autoconf to produce a configure script."
3506 echo "AC_INIT([dummy], [0])"
3507 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3508 echo "AM_INIT_AUTOMAKE"
3510 echo "AM_CONFIG_HEADER([config.h])"
3513 echo "AC_PROG_INSTALL"
3514 echo "AC_PROG_MAKE_SET"
3515 echo "AC_PROG_RANLIB"
3517 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3518 echo "AC_GNU_SOURCE"
3521 for module in $modules; do
3523 if test -n "$module"; then
3524 func_get_autoconf_early_snippet "$module"
3527 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3528 if test "$libtool" = true; then
3529 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3530 echo "gl_cond_libtool=true"
3532 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3533 echo "gl_cond_libtool=false"
3535 echo "gl_ltlibdeps="
3537 # Wrap the set of autoconf snippets into an autoconf macro that is then
3538 # invoked. This is needed because autoconf does not support AC_REQUIRE
3540 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3541 # but we want the AC_REQUIRE to have its normal meaning (provide one
3542 # expansion of the required macro before the current point, and only one
3544 echo "AC_DEFUN([gl_INIT], ["
3545 sed_replace_build_aux='
3547 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3548 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3551 func_emit_initmacro_start $macro_prefix
3552 # We don't have explicit ordering constraints between the various
3553 # autoconf snippets. It's cleanest to put those of the library before
3554 # those of the tests.
3555 echo "gl_source_base='../$sourcebase'"
3556 for module in $modules; do
3557 func_verify_nontests_module
3558 if test -n "$module"; then
3559 func_get_autoconf_snippet "$module" \
3560 | sed -e "$sed_replace_build_aux"
3563 echo "gl_source_base='.'"
3564 for module in $modules; do
3565 func_verify_tests_module
3566 if test -n "$module"; then
3567 func_get_autoconf_snippet "$module" \
3568 | sed -e "$sed_replace_build_aux"
3571 func_emit_initmacro_end $macro_prefix
3572 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3573 # created using libtool, because libtool already handles the dependencies.
3574 if test "$libtool" != true; then
3575 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3576 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3577 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3578 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3579 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3582 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
3586 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3587 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3588 echo "AH_TOP([#include \"../config.h\"])"
3590 echo "AC_OUTPUT([Makefile])"
3591 ) > "$testdir/$testsbase/configure.ac"
3592 auxdir="$saved_auxdir"
3593 func_append subdirs " $testsbase"
3594 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3597 # Create Makefile.am.
3598 (echo "## Process this file with automake to produce Makefile.in."
3600 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3602 echo "SUBDIRS = $subdirs"
3604 echo "ACLOCAL_AMFLAGS = -I $m4base"
3605 ) > "$testdir/Makefile.am"
3607 # Create configure.ac.
3608 (echo "# Process this file with autoconf to produce a configure script."
3609 echo "AC_INIT([dummy], [0])"
3610 if test "$auxdir" != "."; then
3611 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3613 echo "AM_INIT_AUTOMAKE"
3615 echo "AM_CONFIG_HEADER([config.h])"
3618 echo "AC_PROG_INSTALL"
3619 echo "AC_PROG_MAKE_SET"
3621 echo "# For autobuild."
3622 echo "AC_CANONICAL_BUILD"
3623 echo "AC_CANONICAL_HOST"
3625 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3626 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3627 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3628 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3630 echo "AC_PROG_RANLIB"
3632 if test -n "$any_uses_subdirs"; then
3633 echo "AM_PROG_CC_C_O"
3636 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3637 echo "AC_GNU_SOURCE"
3640 for module in $modules; do
3641 func_verify_nontests_module
3642 if test -n "$module"; then
3643 func_get_autoconf_early_snippet "$module"
3646 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3647 if test "$libtool" = true; then
3648 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3649 echo "gl_cond_libtool=true"
3651 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3652 echo "gl_cond_libtool=false"
3654 echo "gl_ltlibdeps="
3656 # Wrap the set of autoconf snippets into an autoconf macro that is then
3657 # invoked. This is needed because autoconf does not support AC_REQUIRE
3659 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3660 # but we want the AC_REQUIRE to have its normal meaning (provide one
3661 # expansion of the required macro before the current point, and only one
3663 echo "AC_DEFUN([gl_INIT], ["
3664 if test "$auxdir" != "build-aux"; then
3665 sed_replace_build_aux='
3667 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3668 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3672 sed_replace_build_aux=
3674 func_emit_initmacro_start $macro_prefix
3675 echo "gl_source_base='$sourcebase'"
3676 for module in $modules; do
3677 func_verify_nontests_module
3678 if test -n "$module"; then
3679 func_get_autoconf_snippet "$module" \
3680 | sed -e "$sed_replace_build_aux"
3683 func_emit_initmacro_end $macro_prefix
3684 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3685 # created using libtool, because libtool already handles the dependencies.
3686 if test "$libtool" != true; then
3687 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3688 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3689 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3690 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3691 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3694 func_emit_initmacro_done $macro_prefix $sourcebase
3698 if test -n "$subdirs_with_configure_ac"; then
3699 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3701 makefiles="Makefile"
3702 for d in $subdirs; do
3703 # For subdirs that have a configure.ac by their own, it's the subdir's
3704 # configure.ac which creates the subdir's Makefile.am, not this one.
3705 case " $subdirs_with_configure_ac " in
3707 *) func_append makefiles " $d/Makefile" ;;
3710 echo "AC_OUTPUT([$makefiles])"
3711 ) > "$testdir/configure.ac"
3713 # Create autogenerated files.
3715 # Do not use "${AUTORECONF} --force --install", because it may invoke
3716 # autopoint, which brings in older versions of some of our .m4 files.
3717 if test -f $m4base/gettext.m4; then
3718 func_execute_command ${AUTOPOINT} --force || func_exit 1
3719 for f in $m4base/*.m4~; do
3720 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3723 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
3724 if ! test -d build-aux; then
3725 func_execute_command mkdir build-aux || func_exit 1
3727 func_execute_command ${AUTOCONF} || func_exit 1
3728 func_execute_command ${AUTOHEADER} || func_exit 1
3729 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3731 if test -n "$inctests"; then
3732 # Create autogenerated files.
3733 (cd "$testdir/$testsbase" || func_exit 1
3734 # Do not use "${AUTORECONF} --force --install", because it may invoke
3735 # autopoint, which brings in older versions of some of our .m4 files.
3736 if test -f ../$m4base/gettext.m4; then
3737 func_execute_command ${AUTOPOINT} --force || func_exit 1
3738 for f in ../$m4base/*.m4~; do
3739 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3742 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
3743 if ! test -d ../build-aux; then
3744 func_execute_command mkdir ../build-aux
3746 func_execute_command ${AUTOCONF} || func_exit 1
3747 func_execute_command ${AUTOHEADER} || func_exit 1
3748 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3751 # Need to run configure and make once, to create built files that are to be
3752 # distributed (such as getdate.c).
3753 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3754 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3755 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3756 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3757 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3758 # such $(FOO_H) because they don't refer to distributed files.
3759 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3760 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3761 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3762 | sed -e "$sed_remove_make_variables"`
3763 distributed_built_sources=`for file in $built_sources; do
3764 case "$cleaned_files" in
3769 if test -n "$distributed_built_sources"; then
3771 ./configure || func_exit 1
3773 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3774 make built_sources || func_exit 1
3776 make distclean || func_exit 1
3781 # func_create_megatestdir megatestdir allmodules
3783 # - local_gnulib_dir from --local-dir
3784 # - auxdir directory relative to destdir where to place build aux files
3785 func_create_megatestdir ()
3789 if test -z "$allmodules"; then
3790 allmodules=`func_all_modules`
3794 # First, all modules one by one.
3795 for onemodule in $allmodules; do
3796 func_create_testdir "$megatestdir/$onemodule" $onemodule
3797 func_append megasubdirs "$onemodule "
3799 # Then, all modules all together.
3800 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3801 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3802 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3803 func_create_testdir "$megatestdir/ALL" "$allmodules"
3804 func_append megasubdirs "ALL"
3807 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
3808 vc_witness="$gnulib_dir/CVS/Entries"; \
3810 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
3812 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
3813 | sed -e 's,January,01,' -e 's,Jan,01,' \
3814 -e 's,February,02,' -e 's,Feb,02,' \
3815 -e 's,March,03,' -e 's,Mar,03,' \
3816 -e 's,April,04,' -e 's,Apr,04,' \
3818 -e 's,June,06,' -e 's,Jun,06,' \
3819 -e 's,July,07,' -e 's,Jul,07,' \
3820 -e 's,August,08,' -e 's,Aug,08,' \
3821 -e 's,September,09,' -e 's,Sep,09,' \
3822 -e 's,October,10,' -e 's,Oct,10,' \
3823 -e 's,November,11,' -e 's,Nov,11,' \
3824 -e 's,December,12,' -e 's,Dec,12,' \
3825 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3826 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3828 echo "CVSDATE=$cvsdate"
3829 echo "test -d logs || mkdir logs"
3830 echo "for module in $megasubdirs; do"
3831 echo " echo \"Working on module \$module...\""
3832 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3833 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3836 echo " : autobuild project... \$module"
3837 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3838 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3839 echo " : autobuild hostname... \`hostname\`"
3840 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3842 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3844 ) > "$megatestdir/do-autobuild"
3845 chmod a+x "$megatestdir/do-autobuild"
3847 # Create Makefile.am.
3848 (echo "## Process this file with automake to produce Makefile.in."
3850 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3852 echo "SUBDIRS = $megasubdirs"
3854 echo "EXTRA_DIST = do-autobuild"
3855 ) > "$megatestdir/Makefile.am"
3857 # Create configure.ac.
3858 (echo "# Process this file with autoconf to produce a configure script."
3859 echo "AC_INIT([dummy], [0])"
3860 if test "$auxdir" != "."; then
3861 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3863 echo "AM_INIT_AUTOMAKE"
3865 echo "AC_PROG_MAKE_SET"
3867 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3868 echo "AC_OUTPUT([Makefile])"
3869 ) > "$megatestdir/configure.ac"
3871 # Create autogenerated files.
3873 # Do not use "${AUTORECONF} --install", because autoreconf operates
3874 # recursively, but the subdirectories are already finished, therefore
3875 # calling autoreconf here would only waste lots of CPU time.
3876 func_execute_command ${ACLOCAL} || func_exit 1
3877 func_execute_command mkdir build-aux
3878 func_execute_command ${AUTOCONF} || func_exit 1
3879 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3885 func_fatal_error "no mode specified" ;;
3894 if test -z "$destdir"; then
3897 test -d "$destdir" \
3898 || func_fatal_error "destination directory does not exist: $destdir"
3900 # Prefer configure.ac to configure.in.
3901 if test -f "$destdir"/configure.ac; then
3902 configure_ac="$destdir/configure.ac"
3904 if test -f "$destdir"/configure.in; then
3905 configure_ac="$destdir/configure.in"
3907 func_fatal_error "cannot find $destdir/configure.ac"
3911 # Analyze configure.ac.
3913 guessed_libtool=false
3918 /AC_CONFIG_AUX_DIR/ {
3919 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3921 /A[CM]_PROG_LIBTOOL/ {
3922 s,^.*$,guessed_libtool=true,p
3924 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3926 if test -z "$auxdir"; then
3927 auxdir="$guessed_auxdir"
3930 # Determine where to apply func_import.
3931 if test -n "$m4base"; then
3932 # Apply func_import to a particular gnulib directory.
3933 # Any number of additional modules can be given.
3934 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3935 # First use of gnulib in the given m4base.
3936 test -n "$supplied_libname" || supplied_libname=true
3937 test -n "$sourcebase" || sourcebase="lib"
3938 test -n "$docbase" || docbase="doc"
3939 test -n "$testsbase" || testsbase="tests"
3940 test -n "$macro_prefix" || macro_prefix="gl"
3944 # Apply func_import to all gnulib directories.
3945 # To get this list of directories, look at Makefile.am. (Not at
3946 # configure, because it may be omitted from CVS. Also, don't run
3947 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3950 if test -f "$destdir"/Makefile.am; then
3951 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3953 for arg in $aclocal_amflags; do
3954 if test -n "$m4dir_is_next"; then
3955 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3959 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3960 func_append m4dirs " $arg"
3961 m4dirs_count=`expr $m4dirs_count + 1`
3967 if test "X$arg" = "X-I"; then
3975 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3976 if test -f "$destdir"/aclocal.m4; then
3977 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3978 sedexpr2='s,^[^/]*$,.,'
3979 sedexpr3='s,/[^/]*$,,'
3980 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3981 m4dirs_count=`echo "$m4dirs" | wc -l`
3984 if test $m4dirs_count = 0; then
3985 # First use of gnulib in a package.
3986 # Any number of additional modules can be given.
3987 test -n "$supplied_libname" || supplied_libname=true
3988 test -n "$sourcebase" || sourcebase="lib"
3990 test -n "$docbase" || docbase="doc"
3991 test -n "$testsbase" || testsbase="tests"
3992 test -n "$macro_prefix" || macro_prefix="gl"
3995 if test $m4dirs_count = 1; then
3996 # There's only one use of gnulib here. Assume the user means it.
3997 # Any number of additional modules can be given.
3998 for m4base in $m4dirs; do
4002 # Ambiguous - guess what the user meant.
4003 if test $# = 0; then
4004 # No further arguments. Guess the user wants to update all of them.
4005 for m4base in $m4dirs; do
4006 # Perform func_import in a subshell, so that variable values
4008 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
4009 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
4010 # libtool, macro_prefix, po_domain
4011 # don't propagate from one directory to another.
4012 (func_import) || func_exit 1
4016 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4024 if test -z "$destdir"; then
4025 func_fatal_error "please specify --dir option"
4028 test -d "$destdir" \
4029 || func_fatal_error "could not create destination directory"
4030 test -n "$auxdir" || auxdir="build-aux"
4031 func_create_testdir "$destdir" "$*"
4034 create-megatestdir )
4035 if test -z "$destdir"; then
4036 func_fatal_error "please specify --dir option"
4038 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4039 test -n "$auxdir" || auxdir="build-aux"
4040 func_create_megatestdir "$destdir" "$*"
4044 test -n "$destdir" || destdir=testdir$$
4045 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4046 test -n "$auxdir" || auxdir="build-aux"
4047 func_create_testdir "$destdir" "$*"
4051 ../configure || func_exit 1
4053 make check || func_exit 1
4054 make distclean || func_exit 1
4055 remaining=`find . -type f -print`
4056 if test -n "$remaining"; then
4057 echo "Remaining files:" $remaining 1>&2
4058 echo "gnulib-tool: *** Stop." 1>&2
4067 test -n "$destdir" || destdir=testdir$$
4068 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4069 test -n "$auxdir" || auxdir="build-aux"
4070 func_create_megatestdir "$destdir" "$*"
4078 remaining=`find . -type f -print`
4079 if test -n "$remaining"; then
4080 echo "Remaining files:" $remaining 1>&2
4081 echo "gnulib-tool: *** Stop." 1>&2
4089 extract-description )
4093 if test -n "$module"; then
4094 func_get_description "$module"
4103 if test -n "$module"; then
4104 func_get_notice "$module"
4113 if test -n "$module"; then
4114 func_get_filelist "$module"
4119 extract-dependencies )
4123 if test -n "$module"; then
4124 func_get_dependencies "$module"
4129 extract-autoconf-snippet )
4133 if test -n "$module"; then
4134 func_get_autoconf_snippet "$module"
4139 extract-automake-snippet )
4143 if test -n "$module"; then
4144 func_get_automake_snippet "$module"
4149 extract-include-directive )
4153 if test -n "$module"; then
4154 func_get_include_directive "$module"
4159 extract-link-directive )
4163 if test -n "$module"; then
4164 func_get_link_directive "$module"
4173 if test -n "$module"; then
4174 func_get_license "$module"
4179 extract-maintainer )
4183 if test -n "$module"; then
4184 func_get_maintainer "$module"
4189 extract-tests-module )
4193 if test -n "$module"; then
4194 func_get_tests_module "$module"
4200 func_fatal_error "unknown operation mode --$mode" ;;
4204 # Undo the effect of the previous 'trap' command. Some shellology:
4205 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4206 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4207 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4208 # 128 + signal number and is set before the trap-registered command is run.
4210 trap 'func_exit $?' 1 2 3 13 15
4215 # indent-tabs-mode: nil
4216 # whitespace-check-buffer-indent: nil