3 # Copyright (C) 2002-2011 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 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
75 if test -z "${MAKE}"; then
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # AIX 5.3 sed barfs over indented comments.
113 if echo fo | sed -e 's/f/g/
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
123 # outputs to stdout the --help usage message.
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
130 gnulib-tool --add-import [module1 ... moduleN]
131 gnulib-tool --remove-import [module1 ... moduleN]
133 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
134 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
135 gnulib-tool --test --dir=directory module1 ... moduleN
136 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
137 gnulib-tool --extract-description module
138 gnulib-tool --extract-comment module
139 gnulib-tool --extract-status module
140 gnulib-tool --extract-notice module
141 gnulib-tool --extract-applicability module
142 gnulib-tool --extract-filelist module
143 gnulib-tool --extract-dependencies module
144 gnulib-tool --extract-autoconf-snippet module
145 gnulib-tool --extract-automake-snippet module
146 gnulib-tool --extract-include-directive module
147 gnulib-tool --extract-link-directive module
148 gnulib-tool --extract-license module
149 gnulib-tool --extract-maintainer module
150 gnulib-tool --extract-tests-module module
151 gnulib-tool --copy-file file [destination]
155 --list print the available module names
156 --find find the modules which contain the specified file
157 --import import the given modules into the current package
158 --add-import augment the list of imports from gnulib into the
159 current package, by adding the given modules;
160 if no modules are specified, update the current
161 package from the current gnulib
162 --remove-import reduce the list of imports from gnulib into the
163 current package, by removing the given modules
164 --update update the current package, restore files omitted
166 --create-testdir create a scratch package with the given modules
167 --create-megatestdir create a mega scratch package with the given modules
168 one by one and all together
169 --test test the combination of the given modules
170 (recommended to use CC=\"gcc -Wall\" here)
171 --megatest test the given modules one by one and all together
172 (recommended to use CC=\"gcc -Wall\" here)
173 --extract-description extract the description
174 --extract-comment extract the comment
175 --extract-status extract the status (obsolete etc.)
176 --extract-notice extract the notice or banner
177 --extract-applicability extract the applicability
178 --extract-filelist extract the list of files
179 --extract-dependencies extract the dependencies
180 --extract-autoconf-snippet extract the snippet for configure.ac
181 --extract-automake-snippet extract the snippet for library makefile
182 --extract-include-directive extract the #include directive
183 --extract-link-directive extract the linker directive
184 --extract-license report the license terms of the source files
186 --extract-maintainer report the maintainer(s) inside gnulib
187 --extract-tests-module report the unit test module, if it exists
188 --copy-file copy a file that is not part of any module
192 --dir=DIRECTORY Specify the target directory.
193 For --import, this specifies where your
194 configure.ac can be found. Defaults to current
196 --local-dir=DIRECTORY Specify a local override directory where to look
197 up files before looking in gnulib's directory.
198 --cache-modules Enable module caching optimization.
199 --no-cache-modules Disable module caching optimization.
200 --verbose Increase verbosity. May be repeated.
201 --quiet Decrease verbosity. May be repeated.
203 Options for --import, --add/remove-import, --update:
205 --dry-run Only print what would have been done.
207 Options for --import, --add/remove-import,
208 --create-[mega]testdir, --[mega]test:
210 --with-tests Include unit tests for the included modules.
211 --with-obsolete Include obsolete modules when they occur among the
212 dependencies. By default, dependencies to obsolete
214 --with-c++-tests Include even unit tests for C++ interoperability.
215 --with-longrunning-tests
216 Include even unit tests that are long-runners.
217 --with-privileged-tests
218 Include even unit tests that require root
220 --with-unportable-tests
221 Include even unit tests that fail on some platforms.
222 --with-all-tests Include all kinds of problematic unit tests.
223 --avoid=MODULE Avoid including the given MODULE. Useful if you
224 have code that provides equivalent functionality.
225 This option can be repeated.
226 --conditional-dependencies
227 Support conditional dependencies (may save configure
228 time and object code).
229 --no-conditional-dependencies
230 Don't use conditional dependencies.
231 --libtool Use libtool rules.
232 --no-libtool Don't use libtool rules.
234 Options for --import, --add/remove-import:
236 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
237 --source-base=DIRECTORY
238 Directory relative to --dir where source code is
239 placed (default \"lib\").
240 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
241 placed (default \"m4\").
242 --po-base=DIRECTORY Directory relative to --dir where *.po files are
243 placed (default \"po\").
244 --doc-base=DIRECTORY Directory relative to --dir where doc files are
245 placed (default \"doc\").
246 --tests-base=DIRECTORY
247 Directory relative to --dir where unit tests are
248 placed (default \"tests\").
249 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
250 tools are placed (default comes from configure.ac).
251 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
252 Also modify license template from GPL to LGPL.
253 The version number of the LGPL can be specified;
254 the default is currently LGPLv3.
255 --makefile-name=NAME Name of makefile in automake syntax in the
256 source-base and tests-base directories
257 (default \"Makefile.am\").
258 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
259 'gl_INIT'. Default is 'gl'.
260 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
261 the package name. A suffix '-gnulib' is appended.
262 --vc-files Update version control related files.
263 --no-vc-files Don't update version control related files
264 (.gitignore and/or .cvsignore).
265 --no-changelog Don't update or create ChangeLog files.
267 Options for --create-[mega]testdir, --[mega]test:
269 --without-c++-tests Exclude unit tests for C++ interoperability.
270 --without-longrunning-tests
271 Exclude unit tests that are long-runners.
272 --without-privileged-tests
273 Exclude unit tests that require root privileges.
274 --without-unportable-tests
275 Exclude unit tests that fail on some platforms.
276 --single-configure Generate a single configure file, not a separate
277 configure file for the tests directory.
279 Options for --import, --add/remove-import, --update,
280 --create-[mega]testdir, --[mega]test:
282 -s, --symbolic, --symlink Make symbolic links instead of copying files.
283 --local-symlink Make symbolic links instead of copying files, only
284 for files from the local override directory.
286 Options for --import, --add/remove-import, --update:
288 -S, --more-symlinks Make symbolic links instead of copying files, and
289 don't replace copyright notices.
291 Report bugs to <bug-gnulib@gnu.org>."
295 # outputs to stdout the --version message.
299 if test -d "$gnulib_dir"/.git \
300 && (git --version) >/dev/null 2>/dev/null \
301 && (date --version) >/dev/null 2>/dev/null; then
302 # gnulib checked out from git.
303 sed_extract_first_date='/^Date/{
307 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
308 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
309 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
310 date=`echo "$date" | sed -e "$sed_year_before_time"`
311 # Use GNU date to compute the time in GMT.
312 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
313 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
315 if test -d "$gnulib_dir"/CVS \
316 && (cvs --version) >/dev/null 2>/dev/null; then
317 # gnulib checked out from CVS.
318 sed_extract_first_date='/^date: /{
319 s/^date: \([0-9][0-9][0-9][0-9]\).\([0-9][0-9]\).\([0-9][0-9]\) \([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\).*/\1-\2-\3 \4/p
322 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
324 # gnulib copy without versioning information.
325 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
329 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
331 gnulib-tool (GNU $package $date)$version
332 Copyright (C) $year Free Software Foundation, Inc.
333 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
334 This is free software: you are free to change and redistribute it.
335 There is NO WARRANTY, to the extent permitted by law.
337 Written by" "Bruno Haible" "and" "Simon Josefsson"
340 # func_emit_copyright_notice
341 # outputs to stdout a header for a generated file.
342 func_emit_copyright_notice ()
344 sed -n -e '/Copyright/ {
347 }' < "$self_abspathname"
349 echo "# This file is free software, distributed under the terms of the GNU"
350 echo "# General Public License. As a special exception to the GNU General"
351 echo "# Public License, this file may be distributed as part of a program"
352 echo "# that contains a configuration script generated by Autoconf, under"
353 echo "# the same distribution terms as the rest of that program."
355 echo "# Generated by gnulib-tool."
359 # exits with a given status.
360 # This function needs to be used, rather than 'exit', when a 'trap' handler is
361 # in effect that refers to $?.
368 # locates the directory where the gnulib repository lives
370 # - progname name of this program
372 # - self_abspathname absolute pathname of gnulib-tool
373 # - gnulib_dir absolute pathname of gnulib repository
377 /*) self_abspathname="$progname" ;;
378 */*) self_abspathname=`pwd`/"$progname" ;;
381 # Iterate through the elements of $PATH.
382 # We use IFS=: instead of
383 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
384 # because the latter does not work when some PATH element contains spaces.
385 # We use a canonicalized $pathx instead of $PATH, because empty PATH
386 # elements are by definition equivalent to '.', however field splitting
387 # according to IFS=: loses empty fields in many shells:
388 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
389 # beginning, at the end, and in the middle),
390 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
391 # at the beginning and at the end,
392 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
393 # Solaris lose empty fields at the end.
394 # The 'case' statement is an optimization, to avoid evaluating the
395 # explicit canonicalization command when $PATH contains no empty fields.
397 if test "${PATH_SEPARATOR+set}" != set; then
398 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
399 # contains only /bin. Note that ksh looks also at the FPATH variable,
400 # so we have to set that as well for the test.
402 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
403 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
404 || PATH_SEPARATOR=';'
407 if test "$PATH_SEPARATOR" = ";"; then
408 # On Windows, programs are searched in "." before $PATH.
411 # On Unix, we have to convert empty PATH elements to ".".
415 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
420 IFS="$PATH_SEPARATOR"
424 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
425 self_abspathname="$d/$progname"
430 if test -z "$self_abspathname"; then
431 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
435 while test -h "$self_abspathname"; do
436 # Resolve symbolic link.
437 linkval=`func_readlink "$self_abspathname"`
438 test -n "$linkval" || break
440 /* ) self_abspathname="$linkval" ;;
441 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
444 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
448 # creates a temporary directory.
450 # - progname name of this program
452 # - tmp pathname of freshly created temporary directory
455 # Use the environment variable TMPDIR, falling back to /tmp. This allows
456 # users to specify a different temporary directory, for example, if their
457 # /tmp is filled up or too small.
460 # Use the mktemp program if available. If not available, hide the error
462 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
463 test -n "$tmp" && test -d "$tmp"
466 # Use a simple mkdir command. It is guaranteed to fail if the directory
467 # already exists. $RANDOM is bash specific and expands to empty in shells
468 # other than bash, ksh and zsh. Its use does not increase security;
469 # rather, it minimizes the probability of failure in a very cluttered /tmp
471 tmp=$TMPDIR/gl$$-$RANDOM
472 (umask 077 && mkdir "$tmp")
475 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
480 # func_append var value
481 # appends the given value to the shell variable var.
482 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
483 # Use bash's += operator. It reduces complexity of appending repeatedly to
484 # a single variable from O(n^2) to O(n).
489 fast_func_append=true
493 eval "$1=\"\$$1\$2\""
495 fast_func_append=false
498 # func_remove_prefix var prefix
499 # removes the given prefix from the value of the shell variable var.
500 # var should be the name of a shell variable.
501 # Its value should not contain a newline and not start or end with whitespace.
502 # prefix should not contain the characters "$`\{}[]^|.
503 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
504 func_remove_prefix ()
508 fast_func_remove_prefix=true
510 func_remove_prefix ()
512 eval "value=\"\$$1\""
516 sed_escape_dots='s/\([.]\)/\\\1/g'
517 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
520 value=`echo "$value" | sed -e "s|^${prefix}||"`
521 eval "$1=\"\$value\""
523 fast_func_remove_prefix=false
526 # func_remove_suffix var suffix
527 # removes the given suffix from the value of the shell variable var.
528 # var should be the name of a shell variable.
529 # Its value should not contain a newline and not start or end with whitespace.
530 # suffix should not contain the characters "$`\{}[]^|.
531 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
532 func_remove_suffix ()
536 fast_func_remove_suffix=true
538 func_remove_suffix ()
540 eval "value=\"\$$1\""
544 sed_escape_dots='s/\([.]\)/\\\1/g'
545 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
548 value=`echo "$value" | sed -e "s|${suffix}\$||"`
549 eval "$1=\"\$value\""
551 fast_func_remove_suffix=false
554 # func_fatal_error message
555 # outputs to stderr a fatal error message, and terminates the program.
557 # - progname name of this program
560 echo "$progname: *** $1" 1>&2
561 echo "$progname: *** Stop." 1>&2
565 # func_warning message
566 # Outputs to stderr a warning message,
569 echo "gnulib-tool: warning: $1" 1>&2
572 # func_readlink SYMLINK
573 # outputs the target of the given symlink.
574 if (type -p readlink) > /dev/null 2>&1; then
577 # Use the readlink program from GNU coreutils.
583 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
584 # would do the wrong thing if the link target contains " -> ".
585 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
589 # func_relativize DIR1 DIR2
590 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
592 # - DIR1 relative pathname, relative to the current directory
593 # - DIR2 relative pathname, relative to the current directory
595 # - reldir relative pathname of DIR2, relative to DIR1
601 sed_first='s,^\([^/]*\)/.*$,\1,'
602 sed_rest='s,^[^/]*/*,,'
603 sed_last='s,^.*/\([^/]*\)$,\1,'
604 sed_butlast='s,/*[^/]*$,,'
605 while test -n "$dir1"; do
606 first=`echo "$dir1" | sed -e "$sed_first"`
607 if test "$first" != "."; then
608 if test "$first" = ".."; then
609 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
610 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
612 first2=`echo "$dir2" | sed -e "$sed_first"`
613 if test "$first2" = "$first"; then
614 dir2=`echo "$dir2" | sed -e "$sed_rest"`
618 dir0="$dir0"/"$first"
621 dir1=`echo "$dir1" | sed -e "$sed_rest"`
626 # func_relconcat DIR1 DIR2
627 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
629 # - DIR1 relative pathname, relative to the current directory
630 # - DIR2 relative pathname, relative to DIR1
632 # - relconcat DIR1/DIR2, relative to the current directory
637 sed_first='s,^\([^/]*\)/.*$,\1,'
638 sed_rest='s,^[^/]*/*,,'
639 sed_last='s,^.*/\([^/]*\)$,\1,'
640 sed_butlast='s,/*[^/]*$,,'
642 first=`echo "$dir2" | sed -e "$sed_first"`
643 if test "$first" = "."; then
644 dir2=`echo "$dir2" | sed -e "$sed_rest"`
645 if test -z "$dir2"; then
650 last=`echo "$dir1" | sed -e "$sed_last"`
651 while test "$last" = "."; do
652 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
653 last=`echo "$dir1" | sed -e "$sed_last"`
655 if test -z "$dir1"; then
659 if test "$first" = ".."; then
660 if test "$last" = ".."; then
661 relconcat="$dir1/$dir2"
664 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
665 dir2=`echo "$dir2" | sed -e "$sed_rest"`
666 if test -z "$dir1"; then
670 if test -z "$dir2"; then
675 relconcat="$dir1/$dir2"
683 # Like ln -s, except that SRC is given relative to the current directory (or
684 # absolute), not given relative to the directory of DEST.
690 *) # SRC is relative.
693 ln -s "`pwd`/$1" "$2" ;;
694 *) # DEST is relative too.
695 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
696 test -n "$ln_destdir" || ln_destdir="."
697 func_relativize "$ln_destdir" "$1"
705 # func_ln_if_changed SRC DEST
706 # Like func_ln, but avoids munging timestamps if the link is correct.
707 func_ln_if_changed ()
709 if test $# -ne 2; then
710 echo "usage: func_ln_if_changed SRC DEST" >&2
712 ln_target=`func_readlink "$2"`
713 if test -h "$2" && test "$1" = "$ln_target"; then
721 # Ensure an 'echo' command that
722 # 1. does not interpret backslashes and
723 # 2. does not print an error message "broken pipe" when writing into a pipe
726 # Test cases for problem 1:
727 # echo '\n' | wc -l prints 1 when OK, 2 when KO
728 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
729 # Test cases for problem 2:
730 # echo hi | true frequently prints
731 # "bash: echo: write error: Broken pipe"
732 # to standard error in bash 3.2.
734 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
735 # BSD echo interprets '-n' as an option, which is also not desirable).
736 # Nowadays the problem occurs in 4 situations:
737 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
738 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
739 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
740 # - in zsh, when sh-emulation is not set,
741 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
742 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
743 # - in Solaris /bin/sh and OSF/1 /bin/sh.
744 # We try the following workarounds:
745 # - for all: respawn using $CONFIG_SHELL if that is set and works.
746 # - for bash >= 2.04: unset the shell option xpg_echo.
747 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
748 # - for bash < 2.0: define echo to a function that uses cat of a here document.
749 # - for zsh: turn sh-emulation on.
750 # - for ksh: alias echo to 'print -r'.
751 # - for ksh: alias echo to a function that uses cat of a here document.
752 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
753 # the ksh workaround.
754 # - otherwise: respawn using /bin/sh and rely on the workarounds.
755 # When respawning, we pass --no-reexec as first argument, so as to avoid
756 # turning this script into a fork bomb in unlucky situations.
758 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
759 # the 'printf' built-in. See
760 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
761 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
762 # The workaround is: define echo to a function that uses the printf built-in.
764 if echo '\t' | grep t > /dev/null; then
765 have_echo=yes # Lucky!
767 # Try the workarounds.
768 # Respawn using $CONFIG_SHELL if that is set and works.
769 if test -z "$have_echo" \
770 && test "X$1" != "X--no-reexec" \
771 && test -n "$CONFIG_SHELL" \
772 && test -f "$CONFIG_SHELL" \
773 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
774 exec $CONFIG_SHELL "$0" --no-reexec "$@"
777 # For bash >= 2.04: unset the shell option xpg_echo.
778 if test -z "$have_echo" \
779 && test -n "$BASH_VERSION" \
780 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
784 # For bash >= 2.0: define echo to a function that uses the printf built-in.
785 # For bash < 2.0: define echo to a function that uses cat of a here document.
786 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
787 # Also handle problem 2, specific to bash 3.2, here.
788 if { test -z "$have_echo" \
789 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
791 && test -n "$BASH_VERSION"; then \
792 if type printf 2>/dev/null | grep / > /dev/null; then
793 # 'printf' is not a shell built-in.
801 # 'printf' is a shell built-in.
807 if echo '\t' | grep t > /dev/null; then
811 # For zsh: turn sh-emulation on.
812 if test -z "$have_echo" \
813 && test -n "$ZSH_VERSION" \
814 && (emulate sh) >/dev/null 2>&1; then
817 # For ksh: alias echo to 'print -r'.
818 if test -z "$have_echo" \
819 && (type print) >/dev/null 2>&1; then
820 # A 'print' command exists.
821 if type print 2>/dev/null | grep / > /dev/null; then
824 # 'print' is a shell built-in.
825 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
826 # 'print' is the ksh shell built-in.
827 alias echo='print -r'
831 if test -z "$have_echo" \
832 && echo '\t' | grep t > /dev/null; then
835 # For ksh: alias echo to a function that uses cat of a here document.
836 # The ksh manual page says:
837 # "Aliasing is performed when scripts are read, not while they are executed.
838 # Therefore, for an alias to take effect, the alias definition command has
839 # to be executed before the command which references the alias is read."
840 # Because of this, we have to play strange tricks with have_echo, to ensure
841 # that the top-level statement containing the test starts after the 'alias'
843 if test -z "$have_echo"; then
850 if (alias echo=bsd_echo) 2>/dev/null; then
851 alias echo=bsd_echo 2>/dev/null
854 if test -z "$have_echo" \
855 && echo '\t' | grep t > /dev/null; then
858 if test -z "$have_echo"; then
859 if (alias echo=bsd_echo) 2>/dev/null; then
860 unalias echo 2>/dev/null
863 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
864 if test -z "$have_echo" \
865 && test "X$1" != "X--no-reexec" \
866 && test -f /bin/ksh; then
867 exec /bin/ksh "$0" --no-reexec "$@"
870 # Otherwise: respawn using /bin/sh.
871 if test -z "$have_echo" \
872 && test "X$1" != "X--no-reexec" \
873 && test -f /bin/sh; then
874 exec /bin/sh "$0" --no-reexec "$@"
877 if test -z "$have_echo"; then
878 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
880 if echo '\t' | grep t > /dev/null; then
883 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
885 if test "X$1" = "X--no-reexec"; then
889 # Command-line option processing.
890 # Removes the OPTIONS from the arguments. Sets the variables:
891 # - mode list or import or add-import or remove-import or update
892 # or create-testdir or create-megatestdir
893 # - destdir from --dir
894 # - local_gnulib_dir from --local-dir
895 # - modcache true or false, from --cache-modules/--no-cache-modules
896 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
897 # - libname, supplied_libname from --lib
898 # - sourcebase from --source-base
899 # - m4base from --m4-base
900 # - pobase from --po-base
901 # - docbase from --doc-base
902 # - testsbase from --tests-base
903 # - auxdir from --aux-dir
904 # - inctests true if --with-tests was given, blank otherwise
905 # - incobsolete true if --with-obsolete was given, blank otherwise
906 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
907 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
909 # - inc_privileged_tests true if --with-privileged-tests was given, blank
911 # - inc_unportable_tests true if --with-unportable-tests was given, blank
913 # - inc_all_tests true if --with-all-tests was given, blank otherwise
914 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
915 # - excl_longrunning_tests true if --without-longrunning-tests was given,
917 # - excl_privileged_tests true if --without-privileged-tests was given, blank
919 # - excl_unportable_tests true if --without-unportable-tests was given, blank
921 # - single_configure true if --single-configure was given, false otherwise
922 # - avoidlist list of modules to avoid, from --avoid
923 # - cond_dependencies true if --conditional-dependencies was given, false if
924 # --no-conditional-dependencies was given, blank otherwise
925 # - lgpl yes or a number if --lgpl was given, blank otherwise
926 # - makefile_name from --makefile-name
927 # - libtool true if --libtool was given, false if --no-libtool was
928 # given, blank otherwise
929 # - macro_prefix from --macro-prefix
930 # - po_domain from --po-domain
931 # - vc_files true if --vc-files was given, false if --no-vc-files was
932 # given, blank otherwise
933 # - autoconf_minversion minimum supported autoconf version
934 # - do_changelog false if --no-changelog was given, : otherwise
935 # - doit : if actions shall be executed, false if only to be printed
936 # - symbolic true if --symlink or --more-symlinks was given, blank
938 # - lsymbolic true if --local-symlink was given, blank otherwise
939 # - do_copyrights blank if --more-symlinks was given, true otherwise
957 inc_longrunning_tests=
958 inc_privileged_tests=
959 inc_unportable_tests=
962 excl_longrunning_tests=
963 excl_privileged_tests=
964 excl_unportable_tests=
965 single_configure=false
982 while test $# -gt 0; do
987 --find | --fin | --fi | --f )
990 --import | --impor | --impo | --imp | --im | --i )
993 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
996 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
999 --update | --updat | --upda | --upd | --up | --u )
1002 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1005 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1006 mode=create-megatestdir
1008 --test | --tes | --te | --t )
1011 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1015 mode=`echo "X$1" | sed -e 's/^X--//'`
1017 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1022 if test $# = 0; then
1023 func_fatal_error "missing argument for --dir"
1028 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1032 if test $# = 0; then
1033 func_fatal_error "missing argument for --local-dir"
1038 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1040 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1043 --no-cache-modules | --no-cache-module | --no-cache-modul | --no-cache-modu | --no-cache-mod | --no-cache-mo | --no-cache-m | --no-cache- | --no-cache | --no-cach | --no-cac | --no-ca )
1046 --verbose | --verbos | --verbo | --verb )
1047 verbose=`expr $verbose + 1`
1049 --quiet | --quie | --qui | --qu | --q )
1050 verbose=`expr $verbose - 1`
1054 if test $# = 0; then
1055 func_fatal_error "missing argument for --lib"
1058 supplied_libname=true
1061 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1062 supplied_libname=true
1066 if test $# = 0; then
1067 func_fatal_error "missing argument for --source-base"
1072 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1076 if test $# = 0; then
1077 func_fatal_error "missing argument for --m4-base"
1082 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1086 if test $# = 0; then
1087 func_fatal_error "missing argument for --po-base"
1092 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1096 if test $# = 0; then
1097 func_fatal_error "missing argument for --doc-base"
1102 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1106 if test $# = 0; then
1107 func_fatal_error "missing argument for --tests-base"
1112 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1116 if test $# = 0; then
1117 func_fatal_error "missing argument for --aux-dir"
1122 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1124 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1127 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1130 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1133 --with-longrunning-tests | --with-longrunning-test | --with-longrunning-tes | --with-longrunning-te | --with-longrunning-t | --with-longrunning- | --with-longrunning | --with-longrunnin | --with-longrunni | --with-longrunn | --with-longrun | --with-longru | --with-longr | --with-long | --with-lon | --with-lo | --with-l)
1134 inc_longrunning_tests=true
1136 --with-privileged-tests | --with-privileged-test | --with-privileged-tes | --with-privileged-te | --with-privileged-t | --with-privileged- | --with-privileged | --with-privilege | --with-privileg | --with-privile | --with-privil | --with-privi | --with-priv | --with-pri | --with-pr | --with-p)
1137 inc_privileged_tests=true
1139 --with-unportable-tests | --with-unportable-test | --with-unportable-tes | --with-unportable-te | --with-unportable-t | --with-unportable- | --with-unportable | --with-unportabl | --with-unportab | --with-unporta | --with-unport | --with-unpor | --with-unpo | --with-unp | --with-un | --with-u)
1140 inc_unportable_tests=true
1142 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1145 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1148 --without-longrunning-tests | --without-longrunning-test | --without-longrunning-tes | --without-longrunning-te | --without-longrunning-t | --without-longrunning- | --without-longrunning | --without-longrunnin | --without-longrunni | --without-longrunn | --without-longrun | --without-longru | --without-longr | --without-long | --without-lon | --without-lo | --without-l)
1149 excl_longrunning_tests=true
1151 --without-privileged-tests | --without-privileged-test | --without-privileged-tes | --without-privileged-te | --without-privileged-t | --without-privileged- | --without-privileged | --without-privilege | --without-privileg | --without-privile | --without-privil | --without-privi | --without-priv | --without-pri | --without-pr | --without-p)
1152 excl_privileged_tests=true
1154 --without-unportable-tests | --without-unportable-test | --without-unportable-tes | --without-unportable-te | --without-unportable-t | --without-unportable- | --without-unportable | --without-unportabl | --without-unportab | --without-unporta | --without-unport | --without-unpor | --without-unpo | --without-unp | --without-un | --without-u)
1155 excl_unportable_tests=true
1157 --single-configure | --single-configur | --single-configu | --single-config | --single-confi | --single-conf | --single-con | --single-con | --single-co | --single-c | --single- | --single | --singl | --sing | --sin | --si)
1158 single_configure=true
1162 if test $# = 0; then
1163 func_fatal_error "missing argument for --avoid"
1165 func_append avoidlist " $1"
1168 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1169 func_append avoidlist " $arg"
1171 --conditional-dependencies | --conditional-dependencie | --conditional-dependenci | --conditional-dependenc | --conditional-dependen | --conditional-depende | --conditional-depend | --conditional-depen | --conditional-depe | --conditional-dep | --conditional-de | --conditional-d | --conditional- | --conditional | --conditiona | --condition | --conditio | --conditi | --condit | --condi | --cond | --con)
1172 cond_dependencies=true
1174 --no-conditional-dependencies | --no-conditional-dependencie | --no-conditional-dependenci | --no-conditional-dependenc | --no-conditional-dependen | --no-conditional-depende | --no-conditional-depend | --no-conditional-depen | --no-conditional-depe | --no-conditional-dep | --no-conditional-de | --no-conditional-d | --no-conditional- | --no-conditional | --no-conditiona | --no-condition | --no-conditio | --no-conditi | --no-condit | --no-condi | --no-cond | --no-con | --no-co)
1175 cond_dependencies=false
1181 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1184 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1190 if test $# = 0; then
1191 func_fatal_error "missing argument for --makefile-name"
1196 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1206 if test $# = 0; then
1207 func_fatal_error "missing argument for --macro-prefix"
1212 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1216 if test $# = 0; then
1217 func_fatal_error "missing argument for --po-domain"
1222 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1230 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1236 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1239 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1242 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1246 --help | --hel | --he | --h )
1249 --version | --versio | --versi | --vers )
1253 # Stop option processing
1257 echo "gnulib-tool: unknown option $1" 1>&2
1258 echo "Try 'gnulib-tool --help' for more information." 1>&2
1265 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1266 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1267 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1268 || test "$single_configure" != false; then
1269 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1270 echo "Try 'gnulib-tool --help' for more information." 1>&2
1274 # This code helps migrating from --import to --add-import or --update. It can
1275 # be removed on 2012-01-01.
1276 if test "$mode" = import && test $# = 0; then
1277 echo "gnulib-tool: cowardly refusing to erase the module list." 1>&2
1278 echo "The meaning of the option '--import' has changed." 1>&2
1279 echo "See the documentation at" 1>&2
1280 echo "<http://www.gnu.org/software/gnulib/manual/html_node/Modified-imports.html>." 1>&2
1281 echo "For updating to a newer version of gnulib, use" 1>&2
1282 echo " gnulib-tool --add-import" 1>&2
1283 echo "For restoring files that were omitted from version control, use" 1>&2
1284 echo " gnulib-tool --update" 1>&2
1287 if test "$mode" = update; then
1288 if test $# != 0; then
1289 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1290 echo "Try 'gnulib-tool --help' for more information." 1>&2
1291 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1292 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1295 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1296 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1297 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1298 || test -n "$inctests" || test -n "$incobsolete" \
1299 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1300 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1301 || test -n "$inc_all_tests" \
1302 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1303 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1304 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1305 || test -n "$macro_prefix" || test -n "$po_domain" \
1306 || test -n "$vc_files"; then
1307 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1308 echo "Try 'gnulib-tool --help' for more information." 1>&2
1309 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1310 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1315 if test -n "$pobase" && test -z "$po_domain"; then
1316 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1317 echo "Try 'gnulib-tool --help' for more information." 1>&2
1320 if test -z "$pobase" && test -n "$po_domain"; then
1321 func_warning "--po-domain has no effect without a --po-base option"
1323 if test "$cond_dependencies" = true && test -n "$inctests"; then
1324 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1328 # Determine the minimum supported autoconf version from the project's
1330 DEFAULT_AUTOCONF_MINVERSION="2.59"
1331 autoconf_minversion=
1333 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1334 && test -n "$destdir"; then
1335 if test -f "$destdir"/configure.ac; then
1336 configure_ac="$destdir/configure.ac"
1338 if test -f "$destdir"/configure.in; then
1339 configure_ac="$destdir/configure.in"
1343 if test -f configure.ac; then
1344 configure_ac="configure.ac"
1346 if test -f configure.in; then
1347 configure_ac="configure.in"
1351 if test -n "$configure_ac"; then
1352 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1353 # because when some m4 files are omitted from a version control repository,
1354 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1355 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1356 # autom4te: m4 failed with exit status: 1
1363 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1365 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1366 if test -n "$prereqs"; then
1367 autoconf_minversion=`
1368 for version in $prereqs; do echo $version; done |
1369 LC_ALL=C sort -nru | sed -e 1q
1373 if test -z "$autoconf_minversion"; then
1374 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1376 case "$autoconf_minversion" in
1377 1.* | 2.[0-4]* | 2.5[0-8]*)
1378 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1381 # Remove trailing slashes from the directory names. This is necessary for
1382 # m4base (to avoid an error in func_import) and optional for the others.
1383 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1384 case "$local_gnulib_dir" in
1385 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1387 case "$sourcebase" in
1388 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1391 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1394 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1397 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1399 case "$testsbase" in
1400 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1403 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1409 trap 'exit_status=$?
1410 if test "$signal" != 0; then
1411 echo "caught signal $signal" >&2
1414 exit $exit_status' 0
1415 for signal in 1 2 3 13 15; do
1416 trap '{ signal='$signal'; func_exit 1; }' $signal
1420 # Note: The 'eval' silences stderr output in dash.
1421 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1422 # Zsh 4 and Bash 4 have associative arrays.
1423 have_associative=true
1425 # For other shells, use 'eval' with computed shell variable names.
1426 have_associative=false
1429 # func_lookup_file file
1430 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1433 # - local_gnulib_dir from --local-dir
1435 # - lookedup_file name of the merged (combined) file
1436 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1440 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1441 lookedup_file="$local_gnulib_dir/$lkfile"
1444 if test -f "$gnulib_dir/$lkfile"; then
1445 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1446 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1447 rm -f "$tmp/$lkbase"
1448 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1449 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1450 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1451 lookedup_file="$tmp/$lkbase"
1454 lookedup_file="$gnulib_dir/$lkfile"
1458 func_fatal_error "file $gnulib_dir/$lkfile not found"
1463 # func_sanitize_modulelist
1464 # receives a list of possible module names on standard input, one per line.
1465 # It removes those which are just file names unrelated to modules, and outputs
1466 # the resulting list to standard output, one per line.
1467 func_sanitize_modulelist ()
1469 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1470 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1471 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1472 -e '/^README$/d' -e '/\/README$/d' \
1473 -e '/^TEMPLATE$/d' \
1474 -e '/^TEMPLATE-EXTENDED$/d' \
1475 -e '/^TEMPLATE-TESTS$/d' \
1482 # - local_gnulib_dir from --local-dir
1485 # Filter out metainformation files like README, which are not modules.
1486 # Filter out unit test modules; they can be retrieved through
1487 # --extract-tests-module if desired.
1489 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1490 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1491 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1494 | func_sanitize_modulelist \
1495 | sed -e '/-tests$/d' \
1499 # func_exists_module module
1500 # tests whether a module, given by name, exists
1502 # - local_gnulib_dir from --local-dir
1503 func_exists_module ()
1505 { test -f "$gnulib_dir/modules/$1" \
1506 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1507 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1508 && test "CVS" != "$1" \
1509 && test "ChangeLog" != "$1" \
1510 && test "COPYING" != "$1" \
1511 && test "README" != "$1" \
1512 && test "TEMPLATE" != "$1" \
1513 && test "TEMPLATE-EXTENDED" != "$1" \
1514 && test "TEMPLATE-TESTS" != "$1"
1517 # func_verify_module
1518 # verifies a module name
1520 # - local_gnulib_dir from --local-dir
1521 # - module module name argument
1522 func_verify_module ()
1524 if func_exists_module "$module"; then
1525 # OK, $module is a correct module name.
1526 # Verify that building the module description with 'patch' succeeds.
1527 func_lookup_file "modules/$module"
1529 func_warning "module $module doesn't exist"
1534 # func_verify_nontests_module
1535 # verifies a module name, excluding tests modules
1537 # - local_gnulib_dir from --local-dir
1538 # - module module name argument
1539 func_verify_nontests_module ()
1542 *-tests ) module= ;;
1543 * ) func_verify_module ;;
1547 # func_verify_tests_module
1548 # verifies a module name, considering only tests modules
1550 # - local_gnulib_dir from --local-dir
1551 # - module module name argument
1552 func_verify_tests_module ()
1555 *-tests ) func_verify_module ;;
1560 # Suffix of a sed expression that extracts a particular field from a
1561 # module description.
1562 # A field starts with a line that contains a keyword, such as 'Description',
1563 # followed by a colon and optional whitespace. All following lines, up to
1564 # the next field (or end of file if there is none) form the contents of the
1566 # An absent field is equivalent to a field with empty contents.
1567 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1568 sed_extract_prog=':[ ]*$/ {
1571 s/^Description:[ ]*$//
1575 s/^Applicability:[ ]*$//
1577 s/^Depends-on:[ ]*$//
1578 s/^configure\.ac-early:[ ]*$//
1579 s/^configure\.ac:[ ]*$//
1580 s/^Makefile\.am:[ ]*$//
1584 s/^Maintainer:[ ]*$//
1591 # Piece of a sed expression that converts a field header line to a shell
1593 # NOTE: Keep this in sync with sed_extract_prog above!
1594 sed_extract_field_header='
1595 s/^Description:[ ]*$/description/
1596 s/^Comment:[ ]*$/comment/
1597 s/^Status:[ ]*$/status/
1598 s/^Notice:[ ]*$/notice/
1599 s/^Applicability:[ ]*$/applicability/
1600 s/^Files:[ ]*$/files/
1601 s/^Depends-on:[ ]*$/dependson/
1602 s/^configure\.ac-early:[ ]*$/configureac_early/
1603 s/^configure\.ac:[ ]*$/configureac/
1604 s/^Makefile\.am:[ ]*$/makefile/
1605 s/^Include:[ ]*$/include/
1607 s/^License:[ ]*$/license/
1608 s/^Maintainer:[ ]*$/maintainer/'
1612 if $have_associative; then
1614 # Declare the associative arrays.
1615 declare -A modcache_cached
1616 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1617 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1618 eval "$declare_script"
1622 # func_cache_var module
1623 # computes the cache variable name corresponding to $module.
1624 # Note: This computation can map different module names to the same
1625 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1626 # to protect against this case.
1628 # - cachevar a shell variable name
1629 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1630 # Bash 2.0 and newer, ksh, and zsh support the syntax
1631 # ${param//pattern/replacement}
1632 # as a shorthand for
1633 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1634 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1635 eval 'func_cache_var ()
1637 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1644 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1653 # func_init_sed_convert_to_cache_statements
1655 # - modcachevar_assignment
1657 # - sed_convert_to_cache_statements
1658 func_init_sed_convert_to_cache_statements ()
1660 # 'sed' script that turns a module description into shell script
1661 # assignments, suitable to be eval'ed. All active characters are escaped.
1664 # Some module's description
1669 # modcache_description[$1]=\
1670 # 'Some module'"'"'s description
1672 # modcache_files[$1]=\
1675 # c_MODULE_description_set=set; c_MODULE_description=\
1676 # 'Some module'"'"'s description
1678 # c_MODULE_files_set=set; c_MODULE_files=\
1680 # The script consists of two parts:
1681 # 1) Ignore the lines before the first field header.
1682 # 2) A loop, treating non-field-header lines by escaping single quotes
1683 # and adding a closing quote in the last line,
1684 sed_convert_to_cache_statements="
1686 # Here we have not yet seen a field header.
1688 # See if the current line contains a field header.
1691 ${sed_extract_field_header}
1694 # No field header. Ignore the line.
1696 # Read the next line. Upon EOF, just exit.
1701 # The current line contains a field header.
1703 # Turn it into the beginning of an assignment.
1704 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1706 # Move it to the hold space. Don't print it yet,
1707 # because we want no assignment if the field is empty.
1710 # Read the next line.
1711 # Upon EOF, the field was empty. Print no assignment. Just exit.
1714 # See if the current line contains a field header.
1717 ${sed_extract_field_header}
1718 # If it is, the previous field was empty. Print no assignment.
1721 # Not a field header.
1723 # Print the previous line, held in the hold space.
1728 # Transform single quotes.
1731 # Prepend a single quote.
1736 # Move it to the hold space.
1739 # Read the next line.
1746 # See if the current line contains a field header.
1749 ${sed_extract_field_header}
1752 # Print the previous line, held in the hold space.
1757 # Transform single quotes.
1764 # Print the previous line, held in the hold space, with a single quote
1765 # to end the assignment.
1775 # Print the previous line, held in the hold space, with a single quote
1776 # to end the assignment.
1783 if ! $sed_comments; then
1785 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1786 | sed -e 's/^ *//' -e 's/^#.*//'`
1790 if $have_associative; then
1791 # sed_convert_to_cache_statements does not depend on the module.
1792 modcachevar_assignment='modcache_\1[$1]='
1793 func_init_sed_convert_to_cache_statements
1796 # func_cache_lookup_module module
1798 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1799 # of its relevant data in a cache in the memory of the processing shell. If
1800 # already cached, it does not look it up again, thus saving file access time.
1802 # - module non-empty string
1803 # Output if $have_associative:
1804 # - modcache_cached[$module] set to yes
1805 # - modcache_description[$module] ==
1806 # - modcache_status[$module] \ set to the field's value, minus the
1807 # - ... / final newline,
1808 # - modcache_maintainer[$module] == or unset if the field's value is empty
1809 # Output if ! $have_associative:
1810 # - cachevar a shell variable name
1811 # - ${cachevar}_cached set to $module
1812 # - ${cachevar}_description ==
1813 # - ${cachevar}_status \ set to the field's value, minus the
1814 # - ... / final newline,
1815 # - ${cachevar}_maintainer == or unset if the field's value is empty
1816 # - ${cachevar}_description_set ==
1817 # - ${cachevar}_status_set \ set to non-empty if the field's value
1818 # - ... / is non-empty,
1819 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1820 func_cache_lookup_module ()
1822 if $have_associative; then
1823 eval 'cached=${modcache_cached[$1]}'
1826 eval "cached=\"\$${cachevar}_cached\""
1828 if test -z "$cached"; then
1829 # Not found in cache. Look it up on the file system.
1830 func_lookup_file "modules/$1"
1831 if $have_associative; then
1832 eval 'modcache_cached[$1]=yes'
1834 eval "${cachevar}_cached=\"\$1\""
1836 if ! $have_associative; then
1837 # sed_convert_to_cache_statements depends on the module.
1838 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1839 func_init_sed_convert_to_cache_statements
1841 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1842 eval "$cache_statements"
1844 if ! $have_associative; then
1845 if test "$1" != "$cached"; then
1846 func_fatal_error "cache variable collision between $1 and $cached"
1854 # func_get_description module
1856 # - local_gnulib_dir from --local-dir
1857 # - modcache true or false, from --cache-modules/--no-cache-modules
1858 func_get_description ()
1860 if ! $modcache; then
1861 func_lookup_file "modules/$1"
1862 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1864 func_cache_lookup_module "$1"
1865 # Output the field's value, including the final newline (if any).
1866 if $have_associative; then
1867 if eval 'test -n "${modcache_description[$1]+set}"'; then
1868 eval 'echo "${modcache_description[$1]}"'
1871 eval "field_set=\"\$${cachevar}_description_set\""
1872 if test -n "$field_set"; then
1873 eval "field_value=\"\$${cachevar}_description\""
1874 echo "${field_value}"
1880 # func_get_comment module
1882 # - local_gnulib_dir from --local-dir
1883 # - modcache true or false, from --cache-modules/--no-cache-modules
1886 if ! $modcache; then
1887 func_lookup_file "modules/$1"
1888 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1890 func_cache_lookup_module "$1"
1891 # Output the field's value, including the final newline (if any).
1892 if $have_associative; then
1893 if eval 'test -n "${modcache_comment[$1]+set}"'; then
1894 eval 'echo "${modcache_comment[$1]}"'
1897 eval "field_set=\"\$${cachevar}_comment_set\""
1898 if test -n "$field_set"; then
1899 eval "field_value=\"\$${cachevar}_comment\""
1900 echo "${field_value}"
1906 # func_get_status module
1908 # - local_gnulib_dir from --local-dir
1909 # - modcache true or false, from --cache-modules/--no-cache-modules
1912 if ! $modcache; then
1913 func_lookup_file "modules/$1"
1914 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1916 func_cache_lookup_module "$1"
1917 # Output the field's value, including the final newline (if any).
1918 if $have_associative; then
1919 if eval 'test -n "${modcache_status[$1]+set}"'; then
1920 eval 'echo "${modcache_status[$1]}"'
1923 eval "field_set=\"\$${cachevar}_status_set\""
1924 if test -n "$field_set"; then
1925 eval "field_value=\"\$${cachevar}_status\""
1926 echo "${field_value}"
1932 # func_get_notice module
1934 # - local_gnulib_dir from --local-dir
1935 # - modcache true or false, from --cache-modules/--no-cache-modules
1938 if ! $modcache; then
1939 func_lookup_file "modules/$1"
1940 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1942 func_cache_lookup_module "$1"
1943 # Output the field's value, including the final newline (if any).
1944 if $have_associative; then
1945 if eval 'test -n "${modcache_notice[$1]+set}"'; then
1946 eval 'echo "${modcache_notice[$1]}"'
1949 eval "field_set=\"\$${cachevar}_notice_set\""
1950 if test -n "$field_set"; then
1951 eval "field_value=\"\$${cachevar}_notice\""
1952 echo "${field_value}"
1958 # func_get_applicability module
1960 # - local_gnulib_dir from --local-dir
1961 # - modcache true or false, from --cache-modules/--no-cache-modules
1962 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1963 func_get_applicability ()
1965 if ! $modcache; then
1966 func_lookup_file "modules/$1"
1967 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1969 func_cache_lookup_module "$1"
1970 # Get the field's value, without the final newline.
1971 if $have_associative; then
1972 eval 'my_applicability="${modcache_applicability[$1]}"'
1974 eval "my_applicability=\"\$${cachevar}_applicability\""
1977 if test -n "$my_applicability"; then
1978 echo $my_applicability
1980 # The default is 'main' or 'tests', depending on the module's name.
1982 *-tests) echo "tests";;
1988 # func_get_filelist module
1990 # - local_gnulib_dir from --local-dir
1991 # - modcache true or false, from --cache-modules/--no-cache-modules
1992 func_get_filelist ()
1994 if ! $modcache; then
1995 func_lookup_file "modules/$1"
1996 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1998 func_cache_lookup_module "$1"
1999 # Output the field's value, including the final newline (if any).
2000 if $have_associative; then
2001 if eval 'test -n "${modcache_files[$1]+set}"'; then
2002 eval 'echo "${modcache_files[$1]}"'
2005 eval "field_set=\"\$${cachevar}_files_set\""
2006 if test -n "$field_set"; then
2007 eval "field_value=\"\$${cachevar}_files\""
2008 echo "${field_value}"
2013 echo m4/gnulib-common.m4
2014 case "$autoconf_minversion" in
2021 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2022 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2023 # elements starting with prefix and ending with suffix are considered.
2024 # Processing: removed_prefix and removed_suffix are removed from each element,
2025 # added_prefix and added_suffix are added to each element.
2026 # prefix, suffix should not contain shell-special characters.
2027 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2028 # added_prefix, added_suffix should not contain the characters \|&.
2029 func_filter_filelist ()
2031 if test "$2" != "$nl" \
2032 || { $fast_func_append \
2033 && { test -z "$6" || $fast_func_remove_prefix; } \
2034 && { test -z "$7" || $fast_func_remove_suffix; }; \
2038 # Do not quote possibly-empty parameters in case patterns,
2039 # AIX and HP-UX ksh won't match them if they are empty.
2042 if test -n "$6"; then
2043 func_remove_prefix fff "$6"
2045 if test -n "$7"; then
2046 func_remove_suffix fff "$7"
2049 if test -z "$ffflist"; then
2052 func_append ffflist "$2${fff}"
2058 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2059 ffflist=`for fff in $3; do
2061 $4*$5) echo "$fff" ;;
2063 done | sed -e "$sed_fff_filter"`
2065 eval "$1=\"\$ffflist\""
2068 # func_get_dependencies module
2070 # - local_gnulib_dir from --local-dir
2071 # - modcache true or false, from --cache-modules/--no-cache-modules
2072 func_get_dependencies ()
2074 # ${module}-tests implicitly depends on ${module}, if that module exists.
2078 func_remove_suffix fgd1 '-tests'
2079 if func_exists_module "$fgd1"; then
2084 # Then the explicit dependencies listed in the module description.
2085 if ! $modcache; then
2086 func_lookup_file "modules/$1"
2087 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2089 func_cache_lookup_module "$1"
2090 # Output the field's value, including the final newline (if any).
2091 if $have_associative; then
2092 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2093 eval 'echo "${modcache_dependson[$1]}"'
2096 eval "field_set=\"\$${cachevar}_dependson_set\""
2097 if test -n "$field_set"; then
2098 eval "field_value=\"\$${cachevar}_dependson\""
2099 echo "${field_value}"
2105 # func_get_autoconf_early_snippet module
2107 # - local_gnulib_dir from --local-dir
2108 # - modcache true or false, from --cache-modules/--no-cache-modules
2109 func_get_autoconf_early_snippet ()
2111 if ! $modcache; then
2112 func_lookup_file "modules/$1"
2113 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2115 func_cache_lookup_module "$1"
2116 # Output the field's value, including the final newline (if any).
2117 if $have_associative; then
2118 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2119 eval 'echo "${modcache_configureac_early[$1]}"'
2122 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2123 if test -n "$field_set"; then
2124 eval "field_value=\"\$${cachevar}_configureac_early\""
2125 echo "${field_value}"
2131 # func_get_autoconf_snippet module
2133 # - local_gnulib_dir from --local-dir
2134 # - modcache true or false, from --cache-modules/--no-cache-modules
2135 func_get_autoconf_snippet ()
2137 if ! $modcache; then
2138 func_lookup_file "modules/$1"
2139 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2141 func_cache_lookup_module "$1"
2142 # Output the field's value, including the final newline (if any).
2143 if $have_associative; then
2144 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2145 eval 'echo "${modcache_configureac[$1]}"'
2148 eval "field_set=\"\$${cachevar}_configureac_set\""
2149 if test -n "$field_set"; then
2150 eval "field_value=\"\$${cachevar}_configureac\""
2151 echo "${field_value}"
2157 # func_get_automake_snippet_conditional module
2158 # returns the part of the Makefile.am snippet that can be put inside Automake
2161 # - local_gnulib_dir from --local-dir
2162 # - modcache true or false, from --cache-modules/--no-cache-modules
2163 func_get_automake_snippet_conditional ()
2165 if ! $modcache; then
2166 func_lookup_file "modules/$1"
2167 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2169 func_cache_lookup_module "$1"
2170 # Output the field's value, including the final newline (if any).
2171 if $have_associative; then
2172 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2173 eval 'echo "${modcache_makefile[$1]}"'
2176 eval "field_set=\"\$${cachevar}_makefile_set\""
2177 if test -n "$field_set"; then
2178 eval "field_value=\"\$${cachevar}_makefile\""
2179 echo "${field_value}"
2185 # func_get_automake_snippet_unconditional module
2186 # returns the part of the Makefile.am snippet that must stay outside of
2187 # Automake conditionals.
2189 # - local_gnulib_dir from --local-dir
2190 # - modcache true or false, from --cache-modules/--no-cache-modules
2191 func_get_automake_snippet_unconditional ()
2195 # *-tests module live in tests/, not lib/.
2196 # Synthesize an EXTRA_DIST augmentation.
2197 all_files=`func_get_filelist $1`
2198 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2199 extra_files="$tests_files"
2200 if test -n "$extra_files"; then
2201 echo "EXTRA_DIST +=" $extra_files
2206 # Synthesize an EXTRA_DIST augmentation.
2207 sed_combine_lines='/\\$/{
2214 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2215 already_mentioned_files=` \
2216 { if ! $modcache; then
2217 func_lookup_file "modules/$1"
2218 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2220 func_cache_lookup_module "$1"
2221 if $have_associative; then
2222 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2223 eval 'echo "${modcache_makefile[$1]}"'
2226 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2227 if test -n "$field_set"; then
2228 eval 'field_value="$'"${cachevar}"'_makefile"'
2229 echo "${field_value}"
2234 | sed -e "$sed_combine_lines" \
2235 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2236 all_files=`func_get_filelist $1`
2237 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2238 # Remove $already_mentioned_files from $lib_files.
2239 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2240 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2241 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2242 if test -n "$extra_files"; then
2243 echo "EXTRA_DIST +=" $extra_files
2246 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2247 # This is necessary so that automake can generate the right list of
2249 # A possible approach would be to use autom4te --trace of the redefined
2250 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2251 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2252 # inside autoconf's built-in macros are not missed).
2253 # But it's simpler and more robust to do it here, based on the file list.
2254 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2255 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2256 # automake will generate a useless dependency; this is harmless.
2258 relocatable-prog-wrapper) ;;
2261 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2262 if test -n "$extra_files"; then
2263 echo "EXTRA_lib_SOURCES +=" $extra_files
2268 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2269 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2270 if test -n "$buildaux_files"; then
2271 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2272 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2275 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2276 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2277 if test -n "$top_files"; then
2278 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2279 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2286 # func_get_automake_snippet module
2288 # - local_gnulib_dir from --local-dir
2289 # - modcache true or false, from --cache-modules/--no-cache-modules
2290 func_get_automake_snippet ()
2292 func_get_automake_snippet_conditional "$1"
2293 func_get_automake_snippet_unconditional "$1"
2296 # func_get_include_directive module
2298 # - local_gnulib_dir from --local-dir
2299 # - modcache true or false, from --cache-modules/--no-cache-modules
2300 func_get_include_directive ()
2303 if ! $modcache; then
2304 func_lookup_file "modules/$1"
2305 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2307 func_cache_lookup_module "$1"
2308 # Output the field's value, including the final newline (if any).
2309 if $have_associative; then
2310 if eval 'test -n "${modcache_include[$1]+set}"'; then
2311 eval 'echo "${modcache_include[$1]}"'
2314 eval "field_set=\"\$${cachevar}_include_set\""
2315 if test -n "$field_set"; then
2316 eval "field_value=\"\$${cachevar}_include\""
2317 echo "${field_value}"
2321 } | sed -e 's/^\(["<]\)/#include \1/'
2324 # func_get_link_directive module
2326 # - local_gnulib_dir from --local-dir
2327 # - modcache true or false, from --cache-modules/--no-cache-modules
2328 func_get_link_directive ()
2330 if ! $modcache; then
2331 func_lookup_file "modules/$1"
2332 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2334 func_cache_lookup_module "$1"
2335 # Output the field's value, including the final newline (if any).
2336 if $have_associative; then
2337 if eval 'test -n "${modcache_link[$1]+set}"'; then
2338 eval 'echo "${modcache_link[$1]}"'
2341 eval "field_set=\"\$${cachevar}_link_set\""
2342 if test -n "$field_set"; then
2343 eval "field_value=\"\$${cachevar}_link\""
2344 echo "${field_value}"
2350 # func_get_license module
2352 # - local_gnulib_dir from --local-dir
2353 # - modcache true or false, from --cache-modules/--no-cache-modules
2357 if ! $modcache; then
2358 func_lookup_file "modules/$1"
2359 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2361 func_cache_lookup_module "$1"
2362 # Output the field's value, including the final newline (if any).
2363 if $have_associative; then
2364 if eval 'test -n "${modcache_license[$1]+set}"'; then
2365 eval 'echo "${modcache_license[$1]}"'
2368 eval "field_set=\"\$${cachevar}_license_set\""
2369 if test -n "$field_set"; then
2370 eval "field_value=\"\$${cachevar}_license\""
2371 echo "${field_value}"
2375 # The default is GPL.
2377 } | sed -e 's,^ *$,,' | sed -e 1q
2380 # func_get_maintainer module
2382 # - local_gnulib_dir from --local-dir
2383 # - modcache true or false, from --cache-modules/--no-cache-modules
2384 func_get_maintainer ()
2386 if ! $modcache; then
2387 func_lookup_file "modules/$1"
2388 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2390 func_cache_lookup_module "$1"
2391 # Output the field's value, including the final newline (if any).
2392 if $have_associative; then
2393 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2394 eval 'echo "${modcache_maintainer[$1]}"'
2397 eval "field_set=\"\$${cachevar}_maintainer_set\""
2398 if test -n "$field_set"; then
2399 eval "field_value=\"\$${cachevar}_maintainer\""
2400 echo "${field_value}"
2406 # func_get_tests_module module
2408 # - local_gnulib_dir from --local-dir
2409 func_get_tests_module ()
2411 # The naming convention for tests modules is hardwired: ${module}-tests.
2412 if test -f "$gnulib_dir/modules/$1"-tests \
2413 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2414 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2419 # func_acceptable module
2420 # tests whether a module is acceptable.
2422 # - avoidlist list of modules to avoid
2425 for avoid in $avoidlist; do
2426 if test "$avoid" = "$1"; then
2433 # sed expression to keep the first 32 characters of each line.
2434 sed_first_32_chars='s/^\(................................\).*/\1/'
2436 # func_module_shellfunc_name module
2437 # computes the shell function name that will contain the m4 macros for the module.
2439 # - macro_prefix prefix to use
2441 # - shellfunc shell function name
2442 func_module_shellfunc_name ()
2446 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2448 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2452 # func_module_shellvar_name module
2453 # computes the shell variable name the will be set to true once the m4 macros
2454 # for the module have been executed.
2456 # - shellvar shell variable name
2457 func_module_shellvar_name ()
2461 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2463 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2467 # func_module_conditional_name module
2468 # computes the automake conditional name for the module.
2470 # - conditional name of automake conditional
2471 func_module_conditional_name ()
2475 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2477 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2481 # func_uncond_add_module B
2482 # notes the presence of B as an unconditional module.
2484 # func_conddep_add_module A B cond
2485 # notes the presence of a conditional dependency from module A to module B,
2486 # subject to the condition that A is enabled and cond is true.
2488 # func_cond_module_p B
2489 # tests whether module B is conditional.
2491 # func_cond_module_condition A B
2492 # returns the condition when B should be enabled as a dependency of A, once the
2493 # m4 code for A has been executed.
2494 # Output: - condition
2496 if $have_associative; then
2497 declare -A conddep_isuncond
2498 declare -A conddep_dependers
2499 declare -A conddep_condition
2500 func_uncond_add_module ()
2502 eval 'conddep_isuncond[$1]=true'
2503 eval 'unset conddep_dependers[$1]'
2505 func_conddep_add_module ()
2507 eval 'isuncond="${conddep_isuncond[$2]}"'
2508 if test -z "$isuncond"; then
2509 # No unconditional dependency to B known at this point.
2510 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2511 eval 'conddep_condition[$1---$2]="$3"'
2514 func_cond_module_p ()
2516 eval 'previous_dependers="${conddep_dependers[$1]}"'
2517 test -n "$previous_dependers"
2519 func_cond_module_condition ()
2521 eval 'condition="${conddep_condition[$1---$2]}"'
2524 func_uncond_add_module ()
2528 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2532 eval 'conddep_isuncond_'"$suffix"'=true'
2533 eval 'unset conddep_dependers_'"$suffix"
2535 func_conddep_add_module ()
2539 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2543 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2544 if test -z "$isuncond"; then
2545 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2546 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2547 eval 'conddep_condition_'"$suffix"'="$3"'
2550 func_cond_module_p ()
2554 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2558 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2559 test -n "$previous_dependers"
2561 func_cond_module_condition ()
2563 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2564 eval 'condition="${conddep_condition_'"$suffix"'}"'
2568 sed_dependencies_without_conditions='s/ *\[.*//'
2570 # func_modules_transitive_closure
2572 # - local_gnulib_dir from --local-dir
2573 # - modcache true or false, from --cache-modules/--no-cache-modules
2574 # - modules list of specified modules
2575 # - inctests true if tests should be included, blank otherwise
2576 # - incobsolete true if obsolete modules among dependencies should be
2577 # included, blank otherwise
2578 # - inc_cxx_tests true if C++ interoperability tests should be included,
2580 # - inc_longrunning_tests true if long-runnings tests should be included,
2582 # - inc_privileged_tests true if tests that require root privileges should be
2583 # included, blank otherwise
2584 # - inc_unportable_tests true if tests that fail on some platforms should be
2585 # included, blank otherwise
2586 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2587 # the unit tests of the specified modules should be
2588 # included, blank otherwise
2589 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2590 # the unit tests of the dependencies should be
2591 # included, blank otherwise
2592 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2594 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2596 # - excl_privileged_tests true if tests that require root privileges should be
2597 # excluded, blank otherwise
2598 # - excl_unportable_tests true if tests that fail on some platforms should be
2599 # excluded, blank otherwise
2600 # - avoidlist list of modules to avoid
2601 # - cond_dependencies true if conditional dependencies shall be supported,
2603 # - tmp pathname of a temporary directory
2605 # - modules list of modules, including dependencies
2606 # - conddep_dependers, conddep_condition information about conditionally
2608 func_modules_transitive_closure ()
2610 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2611 # In order to process every module only once (for speed), process an "input
2612 # list" of modules, producing an "output list" of modules. During each round,
2613 # more modules can be queued in the input list. Once a module on the input
2614 # list has been processed, it is added to the "handled list", so we can avoid
2615 # to process it again.
2617 inmodules="$modules"
2619 fmtc_inc_all_tests="$inc_all_direct_tests"
2620 if test "$cond_dependencies" = true; then
2621 for module in $inmodules; do
2623 if test -n "$module"; then
2624 if func_acceptable $module; then
2625 func_uncond_add_module $module
2630 while test -n "$inmodules"; do
2631 inmodules_this_round="$inmodules"
2632 inmodules= # Accumulator, queue for next round
2633 for module in $inmodules_this_round; do
2635 if test -n "$module"; then
2636 if func_acceptable $module; then
2637 func_append outmodules " $module"
2638 if test "$cond_dependencies" = true; then
2639 if func_get_automake_snippet_conditional $module | grep '^if ' > /dev/null; then
2640 # A module whose Makefile.am snippet contains a reference to an
2641 # automake conditional. If we were to use it conditionally, we
2642 # would get an error
2643 # configure: error: conditional "..." was never defined.
2644 # because automake 1.11.1 does not handle nested conditionals
2645 # correctly. As a workaround, make the module unconditional.
2646 func_uncond_add_module $module
2648 if func_cond_module_p $module; then
2654 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2655 # Duplicate dependencies are harmless, but Jim wants a warning.
2656 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2657 if test -n "$duplicated_deps"; then
2658 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2660 if test -n "$inctests"; then
2661 testsmodule=`func_get_tests_module $module`
2662 if test -n "$testsmodule"; then
2663 deps="$deps $testsmodule"
2666 for dep in $deps; do
2667 # Determine whether to include the dependency or tests module.
2669 for word in `func_get_status $dep`; do
2672 test -n "$incobsolete" \
2676 test -z "$excl_cxx_tests" \
2678 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2682 test -z "$excl_longrunning_tests" \
2684 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2688 test -z "$excl_privileged_tests" \
2690 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2694 test -z "$excl_unportable_tests" \
2696 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2700 test -n "$fmtc_inc_all_tests" \
2706 func_append inmodules " $dep"
2707 if test "$cond_dependencies" = true; then
2708 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2709 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2712 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2713 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2715 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2716 if test "$condition" = true; then
2719 if test -n "$condition"; then
2720 func_conddep_add_module "$module" "$dep" "$condition"
2722 if $conditional; then
2723 func_conddep_add_module "$module" "$dep" true
2725 func_uncond_add_module "$dep"
2734 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2735 # Remove $handledmodules from $inmodules.
2736 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2737 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2738 fmtc_inc_all_tests="$inc_all_indirect_tests"
2740 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2741 rm -f "$tmp"/queued-modules
2744 # func_show_module_list
2746 # - specified_modules list of specified modules (one per line, sorted)
2747 # - modules complete list of modules (one per line, sorted)
2748 # - tmp pathname of a temporary directory
2749 func_show_module_list ()
2755 # Assume xterm compatible escape sequences.
2756 bold_on=`printf '\x1b[1m'`
2757 bold_off=`printf '\x1b[0m'`
2762 echo "Module list with included dependencies (indented):"
2763 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2764 echo "$modules" | sed -e '/^$/d' \
2765 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2766 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2769 # func_modules_transitive_closure_separately
2770 # Determine main module list and tests-related module list separately.
2771 # The main module list is the transitive closure of the specified modules,
2772 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2773 # is specified, it will consist only of LGPLed source.
2774 # The tests-related module list is the transitive closure of the specified
2775 # modules, including tests modules, minus the main module list excluding
2776 # modules of applicability 'all'. Its lib/* sources (brought in through
2777 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2778 # source, even if --lgpl is specified.
2780 # - local_gnulib_dir from --local-dir
2781 # - modcache true or false, from --cache-modules/--no-cache-modules
2782 # - specified_modules list of specified modules
2783 # - inctests true if tests should be included, blank otherwise
2784 # - incobsolete true if obsolete modules among dependencies should be
2785 # included, blank otherwise
2786 # - inc_cxx_tests true if C++ interoperability tests should be included,
2788 # - inc_longrunning_tests true if long-runnings tests should be included,
2790 # - inc_privileged_tests true if tests that require root privileges should be
2791 # included, blank otherwise
2792 # - inc_unportable_tests true if tests that fail on some platforms should be
2793 # included, blank otherwise
2794 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2795 # the unit tests of the specified modules should be
2796 # included, blank otherwise
2797 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2798 # the unit tests of the dependencies should be
2799 # included, blank otherwise
2800 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2802 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2804 # - excl_privileged_tests true if tests that require root privileges should be
2805 # excluded, blank otherwise
2806 # - excl_unportable_tests true if tests that fail on some platforms should be
2807 # excluded, blank otherwise
2808 # - avoidlist list of modules to avoid
2809 # - cond_dependencies true if conditional dependencies shall be supported,
2811 # - tmp pathname of a temporary directory
2813 # - main_modules list of modules, including dependencies
2814 # - testsrelated_modules list of tests-related modules, including dependencies
2815 # - conddep_dependers, conddep_condition information about conditionally
2817 func_modules_transitive_closure_separately ()
2819 # Determine main module list.
2820 saved_inctests="$inctests"
2822 modules="$specified_modules"
2823 func_modules_transitive_closure
2824 main_modules="$modules"
2825 inctests="$saved_inctests"
2826 if test $verbose -ge 1; then
2827 echo "Main module list:"
2828 echo "$main_modules" | sed -e 's/^/ /'
2830 # Determine tests-related module list.
2831 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2832 testsrelated_modules=`for module in $main_modules; do
2833 if test \`func_get_applicability $module\` = main; then
2837 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2838 if test $verbose -ge 1; then
2839 echo "Tests-related module list:"
2840 echo "$testsrelated_modules" | sed -e 's/^/ /'
2844 # func_determine_use_libtests
2845 # Determines whether a $testsbase/libtests.a is needed.
2847 # - local_gnulib_dir from --local-dir
2848 # - modcache true or false, from --cache-modules/--no-cache-modules
2849 # - testsrelated_modules list of tests-related modules, including dependencies
2851 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2852 func_determine_use_libtests ()
2855 for module in $testsrelated_modules; do
2856 func_verify_nontests_module
2857 if test -n "$module"; then
2858 all_files=`func_get_filelist $module`
2859 # Test whether some file in $all_files lies in lib/.
2860 for f in $all_files; do
2872 # func_modules_add_dummy
2874 # - local_gnulib_dir from --local-dir
2875 # - modcache true or false, from --cache-modules/--no-cache-modules
2876 # - modules list of modules, including dependencies
2878 # - modules list of modules, including 'dummy' if needed
2879 func_modules_add_dummy ()
2881 # Determine whether any module provides a lib_SOURCES augmentation.
2883 sed_remove_backslash_newline=':a
2890 for module in $modules; do
2891 func_verify_nontests_module
2892 if test -n "$module"; then
2893 # Extract the value of "lib_SOURCES += ...".
2894 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2895 # Ignore .h files since they are not compiled.
2899 have_lib_SOURCES=yes
2906 # Add the dummy module, to make sure the library will be non-empty.
2907 if test -z "$have_lib_SOURCES"; then
2908 if func_acceptable "dummy"; then
2909 func_append modules " dummy"
2914 # func_modules_add_dummy_separately
2916 # - local_gnulib_dir from --local-dir
2917 # - modcache true or false, from --cache-modules/--no-cache-modules
2918 # - main_modules list of modules, including dependencies
2919 # - testsrelated_modules list of tests-related modules, including dependencies
2920 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2922 # - main_modules list of modules, including 'dummy' if needed
2923 # - testsrelated_modules list of tests-related modules, including 'dummy' if
2925 func_modules_add_dummy_separately ()
2927 # Add the dummy module to the main module list if needed.
2928 modules="$main_modules"
2929 func_modules_add_dummy
2930 main_modules="$modules"
2932 # Add the dummy module to the tests-related module list if needed.
2933 if $use_libtests; then
2934 modules="$testsrelated_modules"
2935 func_modules_add_dummy
2936 testsrelated_modules="$modules"
2940 # func_modules_notice
2942 # - local_gnulib_dir from --local-dir
2943 # - modcache true or false, from --cache-modules/--no-cache-modules
2944 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2945 # - modules list of modules, including dependencies
2946 func_modules_notice ()
2948 if test $verbose -ge -1; then
2949 for module in $modules; do
2951 if test -n "$module"; then
2952 msg=`func_get_notice $module`
2953 if test -n "$msg"; then
2954 echo "Notice from module $module:"
2955 echo "$msg" | sed -e 's/^/ /'
2962 # func_modules_to_filelist
2964 # - local_gnulib_dir from --local-dir
2965 # - modcache true or false, from --cache-modules/--no-cache-modules
2966 # - modules list of modules, including dependencies
2968 # - files list of files
2969 func_modules_to_filelist ()
2972 for module in $modules; do
2974 if test -n "$module"; then
2975 fs=`func_get_filelist $module`
2976 func_append files " $fs"
2979 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2982 # func_modules_to_filelist_separately
2983 # Determine the final file lists.
2984 # They must be computed separately, because files in lib/* go into
2985 # $sourcebase/ if they are in the main file list but into $testsbase/
2986 # if they are in the tests-related file list. Furthermore lib/dummy.c
2989 # - local_gnulib_dir from --local-dir
2990 # - modcache true or false, from --cache-modules/--no-cache-modules
2991 # - main_modules list of modules, including dependencies
2992 # - testsrelated_modules list of tests-related modules, including dependencies
2993 func_modules_to_filelist_separately ()
2995 # Determine final main file list.
2996 modules="$main_modules"
2997 func_modules_to_filelist
2999 # Determine final tests-related file list.
3000 modules="$testsrelated_modules"
3001 func_modules_to_filelist
3002 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3003 # Merge both file lists.
3004 sed_remove_empty_lines='/^$/d'
3005 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3006 if test $verbose -ge 0; then
3008 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3009 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3013 # func_execute_command command [args...]
3014 # Executes a command.
3015 # Uses also the variables
3016 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3017 func_execute_command ()
3019 if test $verbose -ge 0; then
3023 # Commands like automake produce output to stderr even when they succeed.
3024 # Turn this output off if the command succeeds.
3025 "$@" > "$tmp"/cmdout 2>&1
3027 if test $cmdret = 0; then
3031 cat "$tmp"/cmdout 1>&2
3038 # func_dest_tmpfilename file
3039 # determines the name of a temporary file (file is relative to destdir).
3041 # - destdir target directory
3042 # - doit : if actions shall be executed, false if only to be printed
3043 # - tmp pathname of a temporary directory
3045 # - tmpfile absolute filename of the temporary file
3046 func_dest_tmpfilename ()
3049 # Put the new contents of $file in a file in the same directory (needed
3050 # to guarantee that an 'mv' to "$destdir/$file" works).
3051 tmpfile="$destdir/$1.tmp"
3053 # Put the new contents of $file in a file in a temporary directory
3054 # (because the directory of "$file" might not exist).
3055 tmpfile="$tmp"/`basename "$1"`.tmp
3060 # copies a file from gnulib into the destination directory. The destination
3061 # is known to not exist.
3063 # - destdir target directory
3064 # - local_gnulib_dir from --local-dir
3065 # - modcache true or false, from --cache-modules/--no-cache-modules
3066 # - f the original file name
3067 # - lookedup_file name of the merged (combined) file
3068 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3069 # - g the rewritten file name
3070 # - tmpfile absolute filename of the temporary file
3071 # - doit : if actions shall be executed, false if only to be printed
3072 # - symbolic true if files should be symlinked, copied otherwise
3073 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3078 echo "Copying file $g"
3079 if { test -n "$symbolic" \
3080 || { test -n "$lsymbolic" \
3081 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3082 && test -z "$lookedup_tmp" \
3083 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
3084 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3086 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3094 # copies a file from gnulib into the destination directory. The destination
3095 # is known to exist.
3097 # - destdir target directory
3098 # - local_gnulib_dir from --local-dir
3099 # - modcache true or false, from --cache-modules/--no-cache-modules
3100 # - f the original file name
3101 # - lookedup_file name of the merged (combined) file
3102 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3103 # - g the rewritten file name
3104 # - tmpfile absolute filename of the temporary file
3105 # - doit : if actions shall be executed, false if only to be printed
3106 # - symbolic true if files should be symlinked, copied otherwise
3107 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3109 # - already_present nonempty if the file should already exist, empty otherwise
3112 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
3113 : # The file has not changed.
3117 if test -n "$already_present"; then
3118 echo "Updating file $g (backup in ${g}~)"
3120 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3122 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3123 if { test -n "$symbolic" \
3124 || { test -n "$lsymbolic" \
3125 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3126 && test -z "$lookedup_tmp" \
3127 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
3128 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3130 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3133 if test -n "$already_present"; then
3134 echo "Update file $g (backup in ${g}~)"
3136 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3142 # func_emit_lib_Makefile_am
3143 # emits the contents of library makefile to standard output.
3145 # - local_gnulib_dir from --local-dir
3146 # - modcache true or false, from --cache-modules/--no-cache-modules
3147 # - modules list of modules, including dependencies
3148 # - libname library name
3149 # - pobase directory relative to destdir where to place *.po files
3150 # - auxdir directory relative to destdir where to place build aux files
3151 # - makefile_name from --makefile-name
3152 # - libtool true if libtool will be used, false or blank otherwise
3153 # - macro_prefix prefix of gl_LIBOBJS macros to use
3154 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3155 # - actioncmd (optional) command that will reproduce this invocation
3156 # - for_test true if creating a package for testing, false otherwise
3157 # - destfile filename relative to destdir of makefile being generated
3159 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3160 # list of edits to be done to Makefile.am variables
3162 # - uses_subdirs nonempty if object files in subdirs exist
3163 func_emit_lib_Makefile_am ()
3165 # When creating an includable Makefile.am snippet, augment variables with
3166 # += instead of assigning them.
3167 if test -n "$makefile_name"; then
3172 if test "$libtool" = true; then
3175 sed_eliminate_LDFLAGS="$sed_noop"
3179 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3182 # When creating a package for testing: Attempt to provoke failures,
3183 # especially link errors, already during "make" rather than during
3184 # "make check", because "make check" is not possible in a cross-compiling
3185 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3186 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3188 sed_transform_check_PROGRAMS="$sed_noop"
3190 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3191 echo "## Process this file with automake to produce Makefile.in."
3192 func_emit_copyright_notice
3193 if test -n "$actioncmd"; then
3194 # The maximum line length (excluding the terminating newline) of any file
3195 # that is to be preprocessed by config.status is 3070. config.status uses
3196 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3197 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3198 len=`echo "$actioncmd" | wc -c`
3199 if test -n "$len" && test "$len" -le 3000; then
3200 echo "# Reproduce by: $actioncmd"
3206 for module in $modules; do
3207 func_verify_nontests_module
3208 if test -n "$module"; then
3210 func_get_automake_snippet_conditional "$module" |
3212 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3213 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3214 -e "$sed_eliminate_LDFLAGS" \
3215 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3216 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3217 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3218 -e "$sed_transform_check_PROGRAMS"
3219 if test "$module" = 'alloca'; then
3220 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3221 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3223 } > "$tmp"/amsnippet1
3225 func_get_automake_snippet_unconditional "$module" |
3226 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3227 } > "$tmp"/amsnippet2
3228 # Skip the contents if it's entirely empty.
3229 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3230 echo "## begin gnulib module $module"
3232 if test "$cond_dependencies" = true; then
3233 if func_cond_module_p "$module"; then
3234 func_module_conditional_name "$module"
3235 echo "if $conditional"
3238 cat "$tmp"/amsnippet1
3239 if test "$cond_dependencies" = true; then
3240 if func_cond_module_p "$module"; then
3244 cat "$tmp"/amsnippet2
3245 echo "## end gnulib module $module"
3248 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3249 # Test whether there are some source files in subdirectories.
3250 for f in `func_get_filelist "$module"`; do
3260 } > "$tmp"/allsnippets
3261 if test -z "$makefile_name"; then
3262 # If there are source files in subdirectories, prevent collision of the
3263 # object files (example: hash.c and libxml/hash.c).
3265 if test -n "$uses_subdirs"; then
3266 subdir_options=' subdir-objects'
3268 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
3271 if test -z "$makefile_name"; then
3273 echo "noinst_HEADERS ="
3274 echo "noinst_LIBRARIES ="
3275 echo "noinst_LTLIBRARIES ="
3276 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3277 # if you specify pkgdata_DATA to empty. This is a workaround.
3278 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3279 echo "pkgdata_DATA ="
3282 echo "BUILT_SOURCES ="
3285 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3286 if test -z "$makefile_name"; then
3287 echo "MOSTLYCLEANDIRS ="
3289 echo "DISTCLEANFILES ="
3290 echo "MAINTAINERCLEANFILES ="
3292 # Execute edits that apply to the Makefile.am being generated.
3294 while test $edit != $makefile_am_edits; do
3295 edit=`expr $edit + 1`
3296 eval dir=\"\$makefile_am_edit${edit}_dir\"
3297 eval var=\"\$makefile_am_edit${edit}_var\"
3298 eval val=\"\$makefile_am_edit${edit}_val\"
3299 if test -n "$var"; then
3300 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3301 echo "${var} += ${val}"
3302 eval "makefile_am_edit${edit}_var="
3306 if test -z "$makefile_name"; then
3309 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
3311 echo "AM_CPPFLAGS ="
3316 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3317 || { test -n "$makefile_name" \
3318 && test -f "$sourcebase/Makefile.am" \
3319 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3321 # One of the snippets or the user's Makefile.am already specifies an
3322 # installation location for the library. Don't confuse automake by saying
3323 # it should not be installed.
3326 # By default, the generated library should not be installed.
3327 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3330 echo "${libname}_${libext}_SOURCES ="
3331 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3332 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3333 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3334 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3335 echo "EXTRA_${libname}_${libext}_SOURCES ="
3336 if test "$libtool" = true; then
3337 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3338 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3339 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3340 # the link dependencies of all modules.
3341 for module in $modules; do
3342 func_verify_nontests_module
3343 if test -n "$module"; then
3344 func_get_link_directive "$module"
3347 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3348 | LC_ALL=C sort -u \
3349 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3352 if test -n "$pobase"; then
3353 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3356 cat "$tmp"/allsnippets \
3357 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3359 echo "mostlyclean-local: mostlyclean-generic"
3360 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3361 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3362 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3366 rm -f "$tmp"/allsnippets
3369 # func_emit_po_Makevars
3370 # emits the contents of po/ makefile parameterization to standard output.
3372 # - local_gnulib_dir from --local-dir
3373 # - modcache true or false, from --cache-modules/--no-cache-modules
3374 # - sourcebase directory relative to destdir where to place source code
3375 # - pobase directory relative to destdir where to place *.po files
3376 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3377 func_emit_po_Makevars ()
3379 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3380 func_emit_copyright_notice
3382 echo "# Usually the message domain is the same as the package name."
3383 echo "# But here it has a '-gnulib' suffix."
3384 echo "DOMAIN = ${po_domain}-gnulib"
3386 echo "# These two variables depend on the location of this directory."
3387 echo "subdir = ${pobase}"
3388 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3391 # These options get passed to xgettext.
3392 XGETTEXT_OPTIONS = \
3393 --keyword=_ --flag=_:1:pass-c-format \
3394 --keyword=N_ --flag=N_:1:pass-c-format \
3395 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3396 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3397 --flag=error:3:c-format --flag=error_at_line:5:c-format
3399 # This is the copyright holder that gets inserted into the header of the
3400 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3401 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3403 # This is the email address or URL to which the translators shall report
3404 # bugs in the untranslated strings:
3405 # - Strings which are not entire sentences, see the maintainer guidelines
3406 # in the GNU gettext documentation, section 'Preparing Strings'.
3407 # - Strings which use unclear terms or require additional context to be
3409 # - Strings which make invalid assumptions about notation of date, time or
3411 # - Pluralisation problems.
3412 # - Incorrect English spelling.
3413 # - Incorrect formatting.
3414 # It can be your email address, or a mailing list address where translators
3415 # can write to without being subscribed, or the URL of a web page through
3416 # which the translators can contact you.
3417 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3419 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3420 # message catalogs shall be used. It is usually empty.
3421 EXTRA_LOCALE_CATEGORIES =
3423 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3424 # context. Possible values are "yes" and "no". Set this to yes if the
3425 # package uses functions taking also a message context, like pgettext(), or
3426 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3431 # func_emit_po_POTFILES_in
3432 # emits the file list to be passed to xgettext to standard output.
3434 # - local_gnulib_dir from --local-dir
3435 # - modcache true or false, from --cache-modules/--no-cache-modules
3436 # - sourcebase directory relative to destdir where to place source code
3437 # - files list of new files
3438 func_emit_po_POTFILES_in ()
3440 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3441 func_emit_copyright_notice
3443 echo "# List of files which contain translatable strings."
3444 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3447 # func_emit_tests_Makefile_am witness_macro
3448 # emits the contents of tests makefile to standard output.
3450 # - local_gnulib_dir from --local-dir
3451 # - modcache true or false, from --cache-modules/--no-cache-modules
3452 # - modules list of modules, including dependencies
3453 # - libname library name
3454 # - auxdir directory relative to destdir where to place build aux files
3455 # - makefile_name from --makefile-name
3456 # - libtool true if libtool will be used, false or blank otherwise
3457 # - sourcebase relative directory containing lib source code
3458 # - m4base relative directory containing autoconf macros
3459 # - testsbase relative directory containing unit test code
3460 # - macro_prefix prefix of gl_LIBOBJS macros to use
3461 # - for_test true if creating a package for testing, false otherwise
3462 # - single_configure true if a single configure file should be generated,
3463 # false for a separate configure file for the tests
3464 # - use_libtests true if a libtests.a should be built, false otherwise
3465 # - destfile filename relative to destdir of makefile being generated
3467 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3468 # list of edits to be done to Makefile.am variables
3470 # - uses_subdirs nonempty if object files in subdirs exist
3471 func_emit_tests_Makefile_am ()
3474 if test "$libtool" = true; then
3476 sed_eliminate_LDFLAGS="$sed_noop"
3479 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3482 # When creating a package for testing: Attempt to provoke failures,
3483 # especially link errors, already during "make" rather than during
3484 # "make check", because "make check" is not possible in a cross-compiling
3485 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3486 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3488 sed_transform_check_PROGRAMS="$sed_noop"
3490 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3491 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3492 echo "## Process this file with automake to produce Makefile.in."
3493 func_emit_copyright_notice
3497 for module in $modules; do
3498 if $for_test && ! $single_configure; then
3499 func_verify_tests_module
3503 if test -n "$module"; then
3505 func_get_automake_snippet "$module" |
3507 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3508 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3509 -e "$sed_eliminate_LDFLAGS" \
3510 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3511 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3512 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3513 -e "$sed_transform_check_PROGRAMS"
3514 if $use_libtests && test "$module" = 'alloca'; then
3515 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3516 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3518 } > "$tmp"/amsnippet
3519 # Skip the contents if it's entirely empty.
3520 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3521 # Mention long-running tests at the end.
3523 for word in `func_get_status "$module"`; do
3524 if test "$word" = 'longrunning-test'; then
3529 { echo "## begin gnulib module $module"
3531 cat "$tmp"/amsnippet
3532 echo "## end gnulib module $module"
3536 rm -f "$tmp"/amsnippet
3537 # Test whether there are some source files in subdirectories.
3538 for f in `func_get_filelist "$module"`; do
3540 lib/*/*.c | tests/*/*.c)
3548 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3549 # Generate dependencies here, since it eases the debugging of test failures.
3550 # If there are source files in subdirectories, prevent collision of the
3551 # object files (example: hash.c and libxml/hash.c).
3553 if test -n "$uses_subdirs"; then
3554 subdir_options=' subdir-objects'
3556 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3558 if $for_test && ! $single_configure; then
3559 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3562 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3563 # variable is needed to avoid an error from automake:
3564 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3567 echo "XFAIL_TESTS ="
3568 echo "TESTS_ENVIRONMENT ="
3569 echo "noinst_PROGRAMS ="
3570 if ! $for_test; then
3571 echo "check_PROGRAMS ="
3573 echo "noinst_HEADERS ="
3574 echo "noinst_LIBRARIES ="
3575 if $use_libtests; then
3577 echo "noinst_LIBRARIES += libtests.a"
3579 echo "check_LIBRARIES = libtests.a"
3582 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3583 # if you specify pkgdata_DATA to empty. This is a workaround.
3584 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3585 echo "pkgdata_DATA ="
3588 echo "BUILT_SOURCES ="
3590 echo "MOSTLYCLEANFILES = core *.stackdump"
3591 echo "MOSTLYCLEANDIRS ="
3593 echo "DISTCLEANFILES ="
3594 echo "MAINTAINERCLEANFILES ="
3595 # Execute edits that apply to the Makefile.am being generated.
3597 while test $edit != $makefile_am_edits; do
3598 edit=`expr $edit + 1`
3599 eval dir=\"\$makefile_am_edit${edit}_dir\"
3600 eval var=\"\$makefile_am_edit${edit}_var\"
3601 eval val=\"\$makefile_am_edit${edit}_val\"
3602 if test -n "$var"; then
3603 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3604 echo "${var} += ${val}"
3605 eval "makefile_am_edit${edit}_var="
3610 echo "AM_CPPFLAGS = \\"
3612 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3614 if test -n "${witness_macro}"; then
3615 echo " -D@${witness_macro}@=1 \\"
3617 echo " -I. -I\$(srcdir) \\"
3618 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3619 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3621 local_ldadd_before=''
3622 local_ldadd_after=''
3623 if $use_libtests; then
3624 # All test programs need to be linked with libtests.a.
3625 # It needs to be passed to the linker before ${libname}.${libext}, since
3626 # the tests-related modules depend on the main modules.
3627 # It also needs to be passed to the linker after ${libname}.${libext}
3628 # because the latter might contain incomplete modules (such as the 'error'
3629 # module whose dependency to 'progname' is voluntarily omitted).
3630 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3632 local_ldadd_before=' libtests.a'
3633 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3635 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3637 if $use_libtests; then
3638 echo "libtests_a_SOURCES ="
3639 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3640 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3641 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3642 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3643 echo "EXTRA_libtests_a_SOURCES ="
3644 # The circular dependency in LDADD requires this.
3645 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3648 # Many test scripts use ${EXEEXT} or ${srcdir}.
3649 # EXEEXT is defined by AC_PROG_CC through autoconf.
3650 # srcdir is defined by autoconf and automake.
3651 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3653 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3654 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3655 echo "# Clean up after Solaris cc."
3657 echo " rm -rf SunWS_cache"
3659 echo "mostlyclean-local: mostlyclean-generic"
3660 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3661 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3662 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3666 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3669 # func_emit_initmacro_start macro_prefix
3670 # emits the first few statements of the gl_INIT macro to standard output.
3671 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3672 func_emit_initmacro_start ()
3674 macro_prefix_arg="$1"
3675 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3676 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3677 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3678 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3680 # Furthermore it avoids an automake error like this when a Makefile.am
3681 # that uses pieces of gnulib also uses $(LIBOBJ):
3682 # automatically discovered file `error.c' should not be explicitly mentioned
3683 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3684 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3685 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3686 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3687 # automatically discovered file `error.c' should not be explicitly mentioned
3688 # We let automake know about the files to be distributed through the
3689 # EXTRA_lib_SOURCES variable.
3690 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3691 # Create data variables for checking the presence of files that are mentioned
3692 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3693 # because we want the check to happen when the configure file is created,
3694 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3695 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3696 # in which to expect them.
3697 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3698 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3702 # func_emit_initmacro_end macro_prefix
3703 # emits the last few statements of the gl_INIT macro to standard output.
3704 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3705 func_emit_initmacro_end ()
3707 macro_prefix_arg="$1"
3708 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3709 # The check is performed only when autoconf is run from the directory where
3710 # the configure.ac resides; if it is run from a different directory, the
3712 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3713 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3714 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3715 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3716 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3720 echo " m4_if(m4_sysval, [0], [],"
3721 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3723 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3724 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3725 echo " m4_popdef([AC_LIBSOURCES])"
3726 echo " m4_popdef([AC_REPLACE_FUNCS])"
3727 echo " m4_popdef([AC_LIBOBJ])"
3728 echo " AC_CONFIG_COMMANDS_PRE(["
3729 echo " ${macro_prefix_arg}_libobjs="
3730 echo " ${macro_prefix_arg}_ltlibobjs="
3731 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3732 echo " # Remove the extension."
3733 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3734 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3735 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3736 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3739 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3740 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3744 # func_emit_initmacro_done macro_prefix sourcebase
3745 # emits a few statements after the gl_INIT macro to standard output.
3746 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3747 # - sourcebase directory relative to destdir where to place source code
3748 func_emit_initmacro_done ()
3750 macro_prefix_arg="$1"
3753 echo "# Like AC_LIBOBJ, except that the module name goes"
3754 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3755 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3756 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3757 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3760 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3761 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3762 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3763 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3764 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3767 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3768 echo "# expected is derived from the gnulib-tool parameterization,"
3769 echo "# and alloca is special cased (for the alloca-opt module)."
3770 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3771 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3772 echo " m4_foreach([_gl_NAME], [\$1], ["
3773 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3774 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3775 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3781 # func_emit_autoconf_snippet indentation
3782 # emits the autoconf snippet of a module.
3784 # - local_gnulib_dir from --local-dir
3785 # - modcache true or false, from --cache-modules/--no-cache-modules
3786 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3787 # - module the module name
3788 # - toplevel true or false. 'false' means a subordinate use of
3790 # - disable_libtool true or false. It tells whether to disable libtool
3791 # handling even if it has been specified through the
3792 # command line options.
3793 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3795 # - indentation spaces to prepend on each line
3796 func_emit_autoconf_snippet ()
3798 if { case $module in
3799 gnumakefile | maintainer-makefile)
3800 # These modules are meant to be used only in the top-level directory.
3806 func_get_autoconf_snippet "$module" \
3807 | sed -e '/^$/d;' -e "s/^/$indentation/" \
3808 -e "$sed_replace_build_aux" \
3809 | { if $disable_libtool; then
3810 sed -e 's/\$gl_cond_libtool/false/g' \
3811 -e 's/gl_libdeps/gltests_libdeps/g' \
3812 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3817 | { if $disable_gettext; then
3818 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
3823 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
3824 echo 'changequote(,)dnl'
3825 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3826 echo 'changequote([, ])dnl'
3827 echo 'AC_SUBST([LTALLOCA])'
3832 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
3833 # collects and emit the autoconf snippets of a set of modules.
3835 # - local_gnulib_dir from --local-dir
3836 # - modcache true or false, from --cache-modules/--no-cache-modules
3837 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3838 # - modules the list of modules.
3839 # - verifier one of func_verify_module, func_verify_nontests_module,
3840 # func_verify_tests_module. It selects the subset of
3841 # $modules to consider.
3842 # - toplevel true or false. 'false' means a subordinate use of
3844 # - disable_libtool true or false. It tells whether to disable libtool
3845 # handling even if it has been specified through the
3846 # command line options.
3847 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3849 func_emit_autoconf_snippets ()
3853 disable_libtool="$4"
3854 disable_gettext="$5"
3855 if test "$cond_dependencies" = true; then
3856 # Emit the autoconf code for the unconditional modules.
3857 for module in $1; do
3859 if test -n "$module"; then
3860 if func_cond_module_p "$module"; then
3863 func_emit_autoconf_snippet " "
3867 # Initialize the shell variables indicating that the modules are enabled.
3868 for module in $1; do
3870 if test -n "$module"; then
3871 if func_cond_module_p "$module"; then
3872 func_module_shellvar_name "$module"
3873 echo " $shellvar=false"
3877 # Emit the autoconf code for the conditional modules, each in a separate
3878 # function. This makes it possible to support cycles among conditional
3880 for module in $1; do
3882 if test -n "$module"; then
3883 if func_cond_module_p "$module"; then
3884 func_module_shellfunc_name "$module"
3885 func_module_shellvar_name "$module"
3886 echo " $shellfunc ()"
3888 echo " if ! \$$shellvar; then"
3889 func_emit_autoconf_snippet " "
3890 echo " $shellvar=true"
3891 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3892 for dep in $deps; do
3893 if func_cond_module_p "$dep"; then
3894 func_module_shellfunc_name "$dep"
3895 func_cond_module_condition "$module" "$dep"
3896 if test "$condition" != true; then
3897 echo ' if $condition; then'
3904 # The autoconf code for $dep has already been emitted above and
3905 # therefore is already executed when this function is run.
3914 # Emit the dependencies from the unconditional to the conditional modules.
3915 for module in $1; do
3917 if test -n "$module"; then
3918 if func_cond_module_p "$module"; then
3921 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3922 for dep in $deps; do
3923 if func_cond_module_p "$dep"; then
3924 func_module_shellfunc_name "$dep"
3925 func_cond_module_condition "$module" "$dep"
3926 if test "$condition" != true; then
3927 echo " if $condition; then"
3934 # The autoconf code for $dep has already been emitted above and
3935 # therefore is already executed when this code is run.
3942 # Define the Automake conditionals.
3943 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
3944 for module in $1; do
3946 if test -n "$module"; then
3947 if func_cond_module_p "$module"; then
3948 func_module_conditional_name "$module"
3949 func_module_shellvar_name "$module"
3950 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
3955 # Ignore the conditions, and enable all modules unconditionally.
3956 for module in $1; do
3958 if test -n "$module"; then
3959 func_emit_autoconf_snippet " "
3965 # func_import modules
3966 # Uses also the variables
3967 # - mode import or add-import or remove-import or update
3968 # - destdir target directory
3969 # - local_gnulib_dir from --local-dir
3970 # - modcache true or false, from --cache-modules/--no-cache-modules
3971 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3972 # - libname library name
3973 # - supplied_libname true if --lib was given, blank otherwise
3974 # - sourcebase directory relative to destdir where to place source code
3975 # - m4base directory relative to destdir where to place *.m4 macros
3976 # - pobase directory relative to destdir where to place *.po files
3977 # - docbase directory relative to destdir where to place doc files
3978 # - testsbase directory relative to destdir where to place unit test code
3979 # - auxdir directory relative to destdir where to place build aux files
3980 # - inctests true if --with-tests was given, blank otherwise
3981 # - incobsolete true if --with-obsolete was given, blank otherwise
3982 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3983 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3985 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3987 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3989 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3990 # - avoidlist list of modules to avoid, from --avoid
3991 # - cond_dependencies true if --conditional-dependencies was given, false if
3992 # --no-conditional-dependencies was given, blank otherwise
3993 # - lgpl yes or a number if library's license shall be LGPL,
3995 # - makefile_name from --makefile-name
3996 # - libtool true if --libtool was given, false if --no-libtool was
3997 # given, blank otherwise
3998 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3999 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4000 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4001 # - vc_files true if --vc-files was given, false if --no-vc-files was
4002 # given, blank otherwise
4003 # - autoconf_minversion minimum supported autoconf version
4004 # - doit : if actions shall be executed, false if only to be printed
4005 # - symbolic true if files should be symlinked, copied otherwise
4006 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4008 # - do_copyrights true if copyright notices in files should be replaced,
4012 # Get the cached settings.
4013 # In 'import' mode, we read them only for the purpose of knowing the old
4014 # installed file list, and don't use them as defaults.
4015 cached_local_gnulib_dir=
4016 cached_specified_modules=
4018 cached_inc_cxx_tests=
4019 cached_inc_longrunning_tests=
4020 cached_inc_privileged_tests=
4021 cached_inc_unportable_tests=
4022 cached_inc_all_tests=
4032 cached_makefile_name=
4033 cached_cond_dependencies=
4035 cached_macro_prefix=
4039 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4040 cached_libtool=false
4046 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
4056 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4058 /gl_WITH_OBSOLETE/ {
4059 s,^.*$,cached_incobsolete=true,p
4061 /gl_WITH_CXX_TESTS/ {
4062 s,^.*$,cached_inc_cxx_tests=true,p
4064 /gl_WITH_LONGRUNNING_TESTS/ {
4065 s,^.*$,cached_inc_longrunning_tests=true,p
4067 /gl_WITH_PRIVILEGED_TESTS/ {
4068 s,^.*$,cached_inc_privileged_tests=true,p
4070 /gl_WITH_UNPORTABLE_TESTS/ {
4071 s,^.*$,cached_inc_unportable_tests=true,p
4073 /gl_WITH_ALL_TESTS/ {
4074 s,^.*$,cached_inc_all_tests=true,p
4077 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4080 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4083 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4086 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4089 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4092 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4095 s,^.*$,cached_inctests=true,p
4098 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4101 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4104 s,^.*$,cached_lgpl=yes,p
4106 /gl_MAKEFILE_NAME(/ {
4107 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4109 /gl_CONDITIONAL_DEPENDENCIES/ {
4110 s,^.*$,cached_cond_dependencies=true,p
4113 s,^.*$,cached_libtool=true,p
4115 /gl_MACRO_PREFIX(/ {
4116 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4119 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4122 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4124 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4125 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4130 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4131 s,^.*$,cached_files=",p
4144 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4148 if test "$mode" = import; then
4149 # In 'import' mode, the new set of specified modules overrides the cached
4150 # set of modules. Ignore the cached settings.
4151 specified_modules="$1"
4153 # Merge the cached settings with the specified ones.
4154 # The m4base must be the same as expected from the pathname.
4155 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4156 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4158 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
4159 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4160 if test -z "$local_gnulib_dir"; then
4161 if test -n "$cached_local_gnulib_dir"; then
4164 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4166 case "$cached_local_gnulib_dir" in
4168 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4170 func_relconcat "$destdir" "$cached_local_gnulib_dir"
4171 local_gnulib_dir="$relconcat" ;;
4178 # Append the cached and the specified module names. So that
4179 # "gnulib-tool --add-import foo" means to add the module foo.
4180 specified_modules="$cached_specified_modules $1"
4183 # Take the cached module names, minus the specified module names.
4185 if $have_associative; then
4186 # Use an associative array, for O(N) worst-case run time.
4187 declare -A to_remove
4189 eval 'to_remove[$m]=yes'
4191 for module in $cached_specified_modules; do
4192 if eval 'test -z "${to_remove[$module]}"'; then
4193 func_append specified_modules "$module "
4197 # This loop has O(N²) worst-case run time.
4198 for module in $cached_specified_modules; do
4201 if test "$m" = "$module"; then
4206 if test -z "$to_remove"; then
4207 func_append specified_modules "$module "
4213 # Take the cached module names. There are no specified module names.
4214 specified_modules="$cached_specified_modules"
4217 # Included obsolete modules among the dependencies if specified either way.
4218 if test -z "$incobsolete"; then
4219 incobsolete="$cached_incobsolete"
4221 # Included special kinds of tests modules among the dependencies if specified
4223 if test -z "$inc_cxx_tests"; then
4224 inc_cxx_tests="$cached_inc_cxx_tests"
4226 if test -z "$inc_longrunning_tests"; then
4227 inc_longrunning_tests="$cached_inc_longrunning_tests"
4229 if test -z "$inc_privileged_tests"; then
4230 inc_privileged_tests="$cached_inc_privileged_tests"
4232 if test -z "$inc_unportable_tests"; then
4233 inc_unportable_tests="$cached_inc_unportable_tests"
4235 if test -z "$inc_all_tests"; then
4236 inc_all_tests="$cached_inc_all_tests"
4238 # Append the cached and the specified avoidlist. This is probably better
4239 # than dropping the cached one when --avoid is specified at least once.
4240 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4241 avoidlist=`echo $avoidlist`
4243 # The sourcebase defaults to the cached one.
4244 if test -z "$sourcebase"; then
4245 sourcebase="$cached_sourcebase"
4246 if test -z "$sourcebase"; then
4247 func_fatal_error "missing --source-base option"
4250 # The pobase defaults to the cached one.
4251 if test -z "$pobase"; then
4252 pobase="$cached_pobase"
4254 # The docbase defaults to the cached one.
4255 if test -z "$docbase"; then
4256 docbase="$cached_docbase"
4257 if test -z "$docbase"; then
4258 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."
4261 # The testsbase defaults to the cached one.
4262 if test -z "$testsbase"; then
4263 testsbase="$cached_testsbase"
4264 if test -z "$testsbase"; then
4265 func_fatal_error "missing --tests-base option"
4268 # Require the tests if specified either way.
4269 if test -z "$inctests"; then
4270 inctests="$cached_inctests"
4272 # The libname defaults to the cached one.
4273 if test -z "$supplied_libname"; then
4274 libname="$cached_libname"
4275 if test -z "$libname"; then
4276 func_fatal_error "missing --lib option"
4279 # Require LGPL if specified either way.
4280 if test -z "$lgpl"; then
4283 # The makefile_name defaults to the cached one.
4284 if test -z "$makefile_name"; then
4285 makefile_name="$cached_makefile_name"
4287 # Use conditional dependencies if specified either way.
4288 if test -z "$cond_dependencies"; then
4289 cond_dependencies="$cached_cond_dependencies"
4291 # Use libtool if specified either way, or if guessed.
4292 if test -z "$libtool"; then
4293 if test -n "$cached_m4base"; then
4294 libtool="$cached_libtool"
4296 libtool="$guessed_libtool"
4299 # The macro_prefix defaults to the cached one.
4300 if test -z "$macro_prefix"; then
4301 macro_prefix="$cached_macro_prefix"
4302 if test -z "$macro_prefix"; then
4303 func_fatal_error "missing --macro-prefix option"
4306 # The po_domain defaults to the cached one.
4307 if test -z "$po_domain"; then
4308 po_domain="$cached_po_domain"
4310 # The vc_files defaults to the cached one.
4311 if test -z "$vc_files"; then
4312 vc_files="$cached_vc_files"
4314 # Ensure constraints.
4315 if test "$cond_dependencies" = true && test -n "$inctests"; then
4316 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4320 # --without-*-tests options are not supported here.
4322 excl_longrunning_tests=
4323 excl_privileged_tests=
4324 excl_unportable_tests=
4326 # Canonicalize the list of specified modules.
4327 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4329 # Include all kinds of tests modules if --with-all-tests was specified.
4330 inc_all_direct_tests="$inc_all_tests"
4331 inc_all_indirect_tests="$inc_all_tests"
4333 # Determine final module list.
4334 modules="$specified_modules"
4335 func_modules_transitive_closure
4336 if test $verbose -ge 0; then
4337 func_show_module_list
4339 final_modules="$modules"
4341 # Determine main module list and tests-related module list separately.
4342 func_modules_transitive_closure_separately
4344 # Determine whether a $testsbase/libtests.a is needed.
4345 func_determine_use_libtests
4347 # Add the dummy module to the main module list or to the tests-related module
4349 func_modules_add_dummy_separately
4351 # If --lgpl, verify that the licenses of modules are compatible.
4352 if test -n "$lgpl"; then
4353 license_incompatibilities=
4354 for module in $main_modules; do
4355 license=`func_get_license $module`
4357 'GPLed build tool') ;;
4358 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4363 LGPL | LGPLv2+ | LGPLv3+) ;;
4364 *) func_append license_incompatibilities "$module $license$nl" ;;
4370 *) func_append license_incompatibilities "$module $license$nl" ;;
4373 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4378 if test -n "$license_incompatibilities"; then
4379 # Format the license incompatibilities as a table.
4380 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4381 s,^\(.................................................[^ ]*\) *, \1 ,'
4382 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4383 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4387 # Show banner notice of every module.
4388 modules="$main_modules"
4391 # Determine script to apply to imported library files.
4392 sed_transform_lib_file=
4393 for module in $main_modules; do
4394 if test $module = config-h; then
4395 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4396 sed_transform_lib_file=$sed_transform_lib_file'
4397 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4402 sed_transform_main_lib_file="$sed_transform_lib_file"
4403 if test -n "$do_copyrights"; then
4404 if test -n "$lgpl"; then
4408 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4409 s/GNU General/GNU Lesser General/g
4410 s/General Public License/Lesser General Public License/g
4411 s/Lesser Lesser General Public License/Lesser General Public License/g
4415 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4416 s/GNU General/GNU Lesser General/g
4417 s/General Public License/Lesser General Public License/g
4418 s/Lesser Lesser General Public License/Lesser General Public License/g
4420 s/version [23]\([ ,]\)/version 2.1\1/g
4423 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4427 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4428 s/GNU Lesser General/GNU General/g
4429 s/Lesser General Public License/General Public License/g
4431 s/GNU Library General/GNU General/g
4432 s/Library General Public License/General Public License/g
4434 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4439 # Determine script to apply to auxiliary files that go into $auxdir/.
4440 sed_transform_build_aux_file=
4441 if test -n "$do_copyrights"; then
4443 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4444 s/GNU Lesser General/GNU General/g
4445 s/Lesser General Public License/General Public License/g
4447 s/GNU Library General/GNU General/g
4448 s/Library General Public License/General Public License/g
4450 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4454 # Determine script to apply to library files that go into $testsbase/.
4455 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4456 if test -n "$do_copyrights"; then
4458 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4459 s/GNU Lesser General/GNU General/g
4460 s/Lesser General Public License/General Public License/g
4462 s/GNU Library General/GNU General/g
4463 s/Library General Public License/General Public License/g
4465 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4469 # Determine the final file lists.
4470 func_modules_to_filelist_separately
4473 || func_fatal_error "refusing to do nothing"
4475 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4476 new_files="$files m4/gnulib-tool.m4"
4477 old_files="$cached_files"
4478 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4479 func_append old_files " m4/gnulib-tool.m4"
4482 rewritten='%REWRITTEN%'
4483 sed_rewrite_old_files="\
4484 s,^build-aux/,$rewritten$auxdir/,
4485 s,^doc/,$rewritten$cached_docbase/,
4486 s,^lib/,$rewritten$cached_sourcebase/,
4487 s,^m4/,$rewritten$cached_m4base/,
4488 s,^tests/,$rewritten$cached_testsbase/,
4489 s,^tests=lib/,$rewritten$cached_testsbase/,
4492 sed_rewrite_new_files="\
4493 s,^build-aux/,$rewritten$auxdir/,
4494 s,^doc/,$rewritten$docbase/,
4495 s,^lib/,$rewritten$sourcebase/,
4496 s,^m4/,$rewritten$m4base/,
4497 s,^tests/,$rewritten$testsbase/,
4498 s,^tests=lib/,$rewritten$testsbase/,
4502 # Create directories.
4503 { echo "$sourcebase"
4505 if test -n "$pobase"; then
4508 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4509 if test -n "$docfiles"; then
4512 if test -n "$inctests"; then
4516 for f in $files; do echo $f; done \
4517 | sed -e "$sed_rewrite_new_files" \
4518 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4521 { # Rearrange file descriptors. Needed because "while ... done < ..."
4522 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4523 exec 5<&0 < "$tmp"/dirs
4525 if test ! -d "$destdir/$d"; then
4527 echo "Creating directory $destdir/$d"
4528 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4530 echo "Create directory $destdir/$d"
4537 # Copy files or make symbolic links. Remove obsolete files.
4541 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4542 # representing the files according to the last gnulib-tool invocation.
4543 for f in $old_files; do echo $f; done \
4544 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4547 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4548 # representing the files after this gnulib-tool invocation.
4549 for f in $new_files; do echo $f; done \
4550 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4553 # First the files that are in old-files, but not in new-files:
4554 sed_take_first_column='s,'"$delimiter"'.*,,'
4555 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4556 # Remove the file. Do nothing if the user already removed it.
4557 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4559 echo "Removing file $g (backup in ${g}~)"
4560 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4562 echo "Remove file $g (backup in ${g}~)"
4564 func_append removed_files "$g$nl"
4567 # func_add_or_update handles a file that ought to be present afterwards.
4569 # - f the original file name
4570 # - g the rewritten file name
4571 # - already_present nonempty if the file should already exist, empty
4573 func_add_or_update ()
4577 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4579 func_dest_tmpfilename "$g"
4580 func_lookup_file "$f"
4581 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4582 if test -n "$sed_transform_main_lib_file"; then
4585 sed -e "$sed_transform_main_lib_file" \
4586 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4590 if test -n "$sed_transform_build_aux_file"; then
4593 sed -e "$sed_transform_build_aux_file" \
4594 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4598 if test -n "$sed_transform_testsrelated_lib_file"; then
4601 sed -e "$sed_transform_testsrelated_lib_file" \
4602 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4606 if test -f "$destdir/$g"; then
4607 # The file already exists.
4611 # Don't protest if the file should be there but isn't: it happens
4612 # frequently that developers don't put autogenerated files under version control.
4614 func_append added_files "$g$nl"
4618 # Then the files that are in new-files, but not in old-files:
4619 sed_take_last_column='s,^.*'"$delimiter"',,'
4621 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4622 | sed -e "$sed_take_last_column" \
4623 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4624 { # Rearrange file descriptors. Needed because "while ... done < ..."
4625 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4626 exec 5<&0 < "$tmp"/added-files
4632 # Then the files that are in new-files and in old-files:
4633 already_present=true
4634 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4635 | sed -e "$sed_take_last_column" \
4636 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4637 { # Rearrange file descriptors. Needed because "while ... done < ..."
4638 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4639 exec 5<&0 < "$tmp"/kept-files
4646 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4647 actioncmd="gnulib-tool --import"
4648 func_append actioncmd " --dir=$destdir"
4649 if test -n "$local_gnulib_dir"; then
4650 func_append actioncmd " --local-dir=$local_gnulib_dir"
4652 func_append actioncmd " --lib=$libname"
4653 func_append actioncmd " --source-base=$sourcebase"
4654 func_append actioncmd " --m4-base=$m4base"
4655 if test -n "$pobase"; then
4656 func_append actioncmd " --po-base=$pobase"
4658 func_append actioncmd " --doc-base=$docbase"
4659 func_append actioncmd " --tests-base=$testsbase"
4660 func_append actioncmd " --aux-dir=$auxdir"
4661 if test -n "$inctests"; then
4662 func_append actioncmd " --with-tests"
4664 if test -n "$incobsolete"; then
4665 func_append actioncmd " --with-obsolete"
4667 if test -n "$inc_cxx_tests"; then
4668 func_append actioncmd " --with-c++-tests"
4670 if test -n "$inc_longrunning_tests"; then
4671 func_append actioncmd " --with-longrunning-tests"
4673 if test -n "$inc_privileged_tests"; then
4674 func_append actioncmd " --with-privileged-tests"
4676 if test -n "$inc_unportable_tests"; then
4677 func_append actioncmd " --with-unportable-tests"
4679 if test -n "$inc_all_tests"; then
4680 func_append actioncmd " --with-all-tests"
4682 for module in $avoidlist; do
4683 func_append actioncmd " --avoid=$module"
4685 if test -n "$lgpl"; then
4686 if test "$lgpl" = yes; then
4687 func_append actioncmd " --lgpl"
4689 func_append actioncmd " --lgpl=$lgpl"
4692 if test -n "$makefile_name"; then
4693 func_append actioncmd " --makefile-name=$makefile_name"
4695 if test "$cond_dependencies" = true; then
4696 func_append actioncmd " --conditional-dependencies"
4698 func_append actioncmd " --no-conditional-dependencies"
4700 if test "$libtool" = true; then
4701 func_append actioncmd " --libtool"
4703 func_append actioncmd " --no-libtool"
4705 func_append actioncmd " --macro-prefix=$macro_prefix"
4706 if test -n "$po_domain"; then
4707 func_append actioncmd " --po-domain=$po_domain"
4709 if test -n "$vc_files"; then
4710 if test "$vc_files" = true; then
4711 func_append actioncmd " --vc-files"
4713 func_append actioncmd " --no-vc-files"
4716 func_append actioncmd " `echo $specified_modules`"
4718 # Default the makefile name to Makefile.am.
4719 if test -n "$makefile_name"; then
4720 makefile_am=$makefile_name
4722 makefile_am=Makefile.am
4725 # Create normal Makefile.ams.
4728 # Setup list of Makefile.am edits that are to be performed afterwards.
4729 # Some of these edits apply to files that we will generate; others are
4730 # under the responsibility of the developer.
4732 # func_note_Makefile_am_edit dir var value
4733 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4735 func_note_Makefile_am_edit ()
4737 makefile_am_edits=`expr $makefile_am_edits + 1`
4738 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4739 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4740 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4742 if test "$makefile_am" = Makefile.am; then
4743 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4744 sourcebase_base=`basename "$sourcebase"`
4745 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4747 if test -n "$pobase"; then
4748 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4749 pobase_base=`basename "$pobase"`
4750 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4752 if test -n "$inctests"; then
4753 if test "$makefile_am" = Makefile.am; then
4754 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4755 testsbase_base=`basename "$testsbase"`
4756 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4759 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4761 # Find the first parent directory of $m4base that contains or will contain
4763 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4765 sed_butlast='s,[^/][^/]*//*$,,'
4766 dir1="${m4base}/"; dir2=""
4767 while test -n "$dir1" \
4768 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4769 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4770 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4771 || { test -n "$inctests" \
4772 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4773 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4774 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4775 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4777 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4780 # Create library makefile.
4781 func_dest_tmpfilename $sourcebase/$makefile_am
4782 destfile="$sourcebase/$makefile_am"
4783 modules="$main_modules"
4784 func_emit_lib_Makefile_am > "$tmpfile"
4785 if test -f "$destdir"/$sourcebase/$makefile_am; then
4786 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4790 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4791 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4792 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4794 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4800 echo "Creating $sourcebase/$makefile_am"
4801 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4803 echo "Create $sourcebase/$makefile_am"
4806 func_append added_files "$sourcebase/$makefile_am$nl"
4809 # Create po/ directory.
4810 if test -n "$pobase"; then
4811 # Create po makefile and auxiliary files.
4812 for file in Makefile.in.in remove-potcdate.sin; do
4813 func_dest_tmpfilename $pobase/$file
4814 func_lookup_file build-aux/po/$file
4815 cat "$lookedup_file" > "$tmpfile"
4816 if test -f "$destdir"/$pobase/$file; then
4817 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4821 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4822 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4823 mv -f "$tmpfile" "$destdir"/$pobase/$file
4825 echo "Update $pobase/$file (backup in $pobase/$file~)"
4831 echo "Creating $pobase/$file"
4832 mv -f "$tmpfile" "$destdir"/$pobase/$file
4834 echo "Create $pobase/$file"
4837 func_append added_files "$pobase/$file$nl"
4840 # Create po makefile parameterization, part 1.
4841 func_dest_tmpfilename $pobase/Makevars
4842 func_emit_po_Makevars > "$tmpfile"
4843 if test -f "$destdir"/$pobase/Makevars; then
4844 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4848 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4849 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4850 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4852 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4858 echo "Creating $pobase/Makevars"
4859 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4861 echo "Create $pobase/Makevars"
4864 func_append added_files "$pobase/Makevars$nl"
4866 # Create po makefile parameterization, part 2.
4867 func_dest_tmpfilename $pobase/POTFILES.in
4868 func_emit_po_POTFILES_in > "$tmpfile"
4869 if test -f "$destdir"/$pobase/POTFILES.in; then
4870 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4874 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4875 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4876 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4878 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4884 echo "Creating $pobase/POTFILES.in"
4885 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4887 echo "Create $pobase/POTFILES.in"
4890 func_append added_files "$pobase/POTFILES.in$nl"
4893 TP_URL="http://translationproject.org/latest/"
4894 TP_RSYNC_URI="translationproject.org::tp/latest/"
4896 echo "Fetching gnulib PO files from $TP_URL"
4897 (cd "$destdir"/$pobase \
4898 && { # Prefer rsync over wget if it is available, since it consumes
4899 # less network bandwidth, due to compression.
4900 if type rsync 2>/dev/null | grep / > /dev/null; then
4901 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4903 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4908 echo "Fetch gnulib PO files from $TP_URL"
4910 # Create po/LINGUAS.
4912 func_dest_tmpfilename $pobase/LINGUAS
4913 (cd "$destdir"/$pobase \
4914 && { echo '# Set of available languages.'
4915 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4918 if test -f "$destdir"/$pobase/LINGUAS; then
4919 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4922 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4923 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4924 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4927 echo "Creating $pobase/LINGUAS"
4928 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4929 func_append added_files "$pobase/LINGUAS$nl"
4932 if test -f "$destdir"/$pobase/LINGUAS; then
4933 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4935 echo "Create $pobase/LINGUAS"
4940 # Create m4/gnulib-cache.m4.
4941 func_dest_tmpfilename $m4base/gnulib-cache.m4
4943 func_emit_copyright_notice
4945 echo "# This file represents the specification of how gnulib-tool is used."
4946 echo "# It acts as a cache: It is written and read by gnulib-tool."
4947 echo "# In projects that use version control, this file is meant to be put under"
4948 echo "# version control, like the configure.ac and various Makefile.am files."
4951 echo "# Specification in the form of a command-line invocation:"
4954 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4955 # Store the local_gnulib_dir relative to destdir.
4956 case "$local_gnulib_dir" in
4958 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4961 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4963 # destdir, local_gnulib_dir are both relative.
4964 func_relativize "$destdir" "$local_gnulib_dir"
4965 relative_local_gnulib_dir="$reldir" ;;
4968 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4970 echo "$specified_modules" | sed -e 's/^/ /g'
4972 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4973 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4974 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4975 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4976 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4977 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4978 echo "gl_AVOID([$avoidlist])"
4979 echo "gl_SOURCE_BASE([$sourcebase])"
4980 echo "gl_M4_BASE([$m4base])"
4981 echo "gl_PO_BASE([$pobase])"
4982 echo "gl_DOC_BASE([$docbase])"
4983 echo "gl_TESTS_BASE([$testsbase])"
4984 test -z "$inctests" || echo "gl_WITH_TESTS"
4985 echo "gl_LIB([$libname])"
4986 if test -n "$lgpl"; then
4987 if test "$lgpl" = yes; then
4990 echo "gl_LGPL([$lgpl])"
4993 echo "gl_MAKEFILE_NAME([$makefile_name])"
4994 if test "$cond_dependencies" = true; then
4995 echo "gl_CONDITIONAL_DEPENDENCIES"
4997 if test "$libtool" = true; then
5000 echo "gl_MACRO_PREFIX([$macro_prefix])"
5001 echo "gl_PO_DOMAIN([$po_domain])"
5002 if test -n "$vc_files"; then
5003 echo "gl_VC_FILES([$vc_files])"
5006 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5007 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
5011 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5012 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5013 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5015 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5019 echo "# gnulib-cache.m4 ends here"
5026 echo "Creating $m4base/gnulib-cache.m4"
5027 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5029 echo "Create $m4base/gnulib-cache.m4"
5035 # Create m4/gnulib-comp.m4.
5036 func_dest_tmpfilename $m4base/gnulib-comp.m4
5038 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5039 func_emit_copyright_notice
5041 echo "# This file represents the compiled summary of the specification in"
5042 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5043 echo "# to be invoked from configure.ac."
5044 echo "# In projects that use version control, this file can be treated like"
5045 echo "# other built files."
5048 echo "# This macro should be invoked from $configure_ac, in the section"
5049 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5050 echo "# any checks for libraries, header files, types and library functions."
5051 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5053 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5054 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5055 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5056 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5057 echo " AC_REQUIRE([AC_PROG_RANLIB])"
5058 if test -n "$uses_subdirs"; then
5059 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5061 for module in $final_modules; do
5063 if test -n "$module"; then
5064 echo "# Code from module $module:"
5065 func_get_autoconf_early_snippet "$module"
5068 | sed -e '/^$/d;' -e 's/^/ /'
5071 echo "# This macro should be invoked from $configure_ac, in the section"
5072 echo "# \"Check for header files, types and library functions\"."
5073 echo "AC_DEFUN([${macro_prefix}_INIT],"
5075 if test "$libtool" = true; then
5076 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5077 echo " gl_cond_libtool=true"
5079 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5080 echo " gl_cond_libtool=false"
5082 echo " gl_ltlibdeps="
5084 if test "$auxdir" != "build-aux"; then
5085 sed_replace_build_aux='
5087 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5088 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5092 sed_replace_build_aux="$sed_noop"
5094 echo " gl_m4_base='$m4base'"
5095 func_emit_initmacro_start $macro_prefix
5096 echo " gl_source_base='$sourcebase'"
5097 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
5098 echo " # End of code from modules"
5099 func_emit_initmacro_end $macro_prefix
5100 echo " gltests_libdeps="
5101 echo " gltests_ltlibdeps="
5102 func_emit_initmacro_start ${macro_prefix}tests
5103 echo " gl_source_base='$testsbase'"
5104 # Define a tests witness macro that depends on the package.
5105 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5106 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5107 echo "changequote(,)dnl"
5108 echo " ${macro_prefix}tests_WITNESS=IN_\`echo \"\${PACKAGE-\$PACKAGE_TARNAME}\" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'\`_GNULIB_TESTS"
5109 echo "changequote([, ])dnl"
5110 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5111 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5112 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5113 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
5114 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5115 func_emit_initmacro_end ${macro_prefix}tests
5116 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5117 # created using libtool, because libtool already handles the dependencies.
5118 if test "$libtool" != true; then
5119 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5120 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5121 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5122 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5123 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5125 if $use_libtests; then
5126 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5127 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5130 func_emit_initmacro_done $macro_prefix $sourcebase
5131 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5133 echo "# This macro records the list of files which have been installed by"
5134 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5135 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5136 echo "$files" | sed -e 's,^, ,'
5139 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5140 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
5144 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5145 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5146 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5148 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5152 echo "# gnulib-comp.m4 ends here"
5159 echo "Creating $m4base/gnulib-comp.m4"
5160 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5162 echo "Create $m4base/gnulib-comp.m4"
5168 if test -n "$inctests"; then
5169 # Create tests makefile.
5170 func_dest_tmpfilename $testsbase/$makefile_am
5171 destfile="$testsbase/$makefile_am"
5172 modules="$testsrelated_modules"
5173 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5174 if test -f "$destdir"/$testsbase/$makefile_am; then
5175 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
5179 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5180 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5181 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5183 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5189 echo "Creating $testsbase/$makefile_am"
5190 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5192 echo "Create $testsbase/$makefile_am"
5195 func_append added_files "$testsbase/$makefile_am$nl"
5199 if test "$vc_files" != false; then
5200 # Update the .cvsignore and .gitignore files.
5201 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5202 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5203 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5204 echo "$m4base/|A|gnulib-comp.m4"
5205 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5206 { # Rearrange file descriptors. Needed because "while ... done < ..."
5207 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5208 exec 5<&0 < "$tmp"/fileset-changes
5209 func_update_ignorelist ()
5212 if test "$ignore" = .gitignore; then
5213 # In a .gitignore file, "foo" applies to the current directory and all
5214 # subdirectories, whereas "/foo" applies to the current directory only.
5217 doubly_escaped_anchor='\\/'
5221 doubly_escaped_anchor=''
5223 if test -f "$destdir/$dir$ignore"; then
5224 if test -n "$dir_added" || test -n "$dir_removed"; then
5225 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5226 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5227 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5228 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5229 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
5231 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5233 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5234 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5235 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5236 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5237 } > "$tmp"/sed-ignore-removed
5238 { cat "$destdir/$dir$ignore"~
5239 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5240 } | sed -f "$tmp"/sed-ignore-removed \
5241 > "$destdir/$dir$ignore"
5243 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5248 if test -n "$dir_added"; then
5250 echo "Creating $destdir/$dir$ignore"
5252 if test "$ignore" = .cvsignore; then
5254 # Automake generates Makefile rules that create .dirstamp files.
5257 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5258 } > "$destdir/$dir$ignore"
5260 echo "Create $destdir/$dir$ignore"
5270 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5271 func_update_ignorelist .cvsignore
5273 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5274 func_update_ignorelist .gitignore
5281 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5282 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5283 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5284 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5285 if test "$next_dir" != "$last_dir"; then
5286 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5287 last_dir="$next_dir"
5292 A) func_append last_dir_added "$file$nl";;
5293 R) func_append last_dir_removed "$file$nl";;
5296 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5303 echo "You may need to add #include directives for the following .h files."
5304 # Intersect $specified_modules and $main_modules
5305 # (since $specified_modules is not necessarily of subset of $main_modules
5306 # - some may have been skipped through --avoid, and since the elements of
5307 # $main_modules but not in $specified_modules can go away without explicit
5308 # notice - through changes in the module dependencies).
5309 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5310 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5311 # First the #include <...> directives without #ifs, sorted for convenience,
5312 # then the #include "..." directives without #ifs, sorted for convenience,
5313 # then the #include directives that are surrounded by #ifs. Not sorted.
5314 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5315 include_directive=`func_get_include_directive "$module"`
5316 case "$nl$include_directive" in
5318 echo "$include_directive" 1>&5
5321 echo "$include_directive" | grep -v 'include "' 1>&6
5322 echo "$include_directive" | grep 'include "' 1>&7
5325 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5327 LC_ALL=C sort -u "$tmp"/include-angles
5328 LC_ALL=C sort -u "$tmp"/include-quotes
5329 cat "$tmp"/include-if
5330 ) | sed -e '/^$/d' -e 's/^/ /'
5331 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5333 for module in $main_modules; do
5334 func_get_link_directive "$module"
5336 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5337 if test `wc -l < "$tmp"/link` != 0; then
5339 echo "You may need to use the following Makefile variables when linking."
5340 echo "Use them in <program>_LDADD when linking a program, or"
5341 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5347 echo "Don't forget to"
5348 if test "$makefile_am" = Makefile.am; then
5349 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5351 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5353 if test -n "$pobase"; then
5354 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5356 if test -n "$inctests"; then
5357 if test "$makefile_am" = Makefile.am; then
5358 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5360 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5364 while test $edit != $makefile_am_edits; do
5365 edit=`expr $edit + 1`
5366 eval dir=\"\$makefile_am_edit${edit}_dir\"
5367 eval var=\"\$makefile_am_edit${edit}_var\"
5368 eval val=\"\$makefile_am_edit${edit}_val\"
5369 if test -n "$var"; then
5370 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5373 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
5374 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5377 # func_create_testdir testdir modules
5379 # - local_gnulib_dir from --local-dir
5380 # - modcache true or false, from --cache-modules/--no-cache-modules
5381 # - auxdir directory relative to destdir where to place build aux files
5382 # - inctests true if tests should be included, blank otherwise
5383 # - incobsolete true if obsolete modules among dependencies should be
5384 # included, blank otherwise
5385 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5387 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5389 # - excl_privileged_tests true if tests that require root privileges should be
5390 # excluded, blank otherwise
5391 # - excl_unportable_tests true if tests that fail on some platforms should be
5392 # excluded, blank otherwise
5393 # - single_configure true if a single configure file should be generated,
5394 # false for a separate configure file for the tests
5395 # - avoidlist list of modules to avoid
5396 # - cond_dependencies true if --conditional-dependencies was given, false if
5397 # --no-conditional-dependencies was given, blank otherwise
5398 # - libtool true if --libtool was given, false if --no-libtool was
5399 # given, blank otherwise
5400 # - symbolic true if files should be symlinked, copied otherwise
5401 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
5403 func_create_testdir ()
5407 if test -z "$modules"; then
5408 # All modules together.
5409 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5410 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5411 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5412 modules=`func_all_modules`
5413 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5415 specified_modules="$modules"
5417 # Canonicalize the list of specified modules.
5418 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5420 # Unlike in func_import, here we want to include all kinds of tests for the
5421 # directly specified modules, but not for dependencies.
5422 inc_all_direct_tests=true
5423 inc_all_indirect_tests="$inc_all_tests"
5425 # Check that the license of every module is consistent with the license of
5427 saved_inctests="$inctests"
5428 # When computing transitive closures, don't consider $module to depend on
5429 # $module-tests. Need this becauses tests are implicitly GPL and may depend
5430 # on GPL modules - therefore we don't want a warning in this case.
5432 for requested_module in $specified_modules; do
5433 requested_license=`func_get_license "$requested_module"`
5434 if test "$requested_license" != GPL; then
5435 # Here we use func_modules_transitive_closure, not just
5436 # func_get_dependencies, so that we also detect weird situations like
5437 # an LGPL module which depends on a GPLed build tool module which depends
5439 modules="$requested_module"
5440 func_modules_transitive_closure
5441 for module in $modules; do
5442 license=`func_get_license "$module"`
5444 'GPLed build tool') ;;
5445 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5447 case "$requested_license" in
5450 GPLv2+ | LGPLv2+) ;;
5451 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5457 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5463 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5472 inctests="$saved_inctests"
5474 # Subdirectory names.
5484 # Determine final module list.
5485 modules="$specified_modules"
5486 func_modules_transitive_closure
5487 if test $verbose -ge 0; then
5488 func_show_module_list
5490 final_modules="$modules"
5492 if $single_configure; then
5493 # Determine main module list and tests-related module list separately.
5494 func_modules_transitive_closure_separately
5497 if $single_configure; then
5498 # Determine whether a $testsbase/libtests.a is needed.
5499 func_determine_use_libtests
5502 # Add the dummy module if needed.
5503 if $single_configure; then
5504 func_modules_add_dummy_separately
5506 func_modules_add_dummy
5509 # Show banner notice of every module.
5510 if $single_configure; then
5511 modules="$main_modules"
5517 # Determine final file list.
5518 if $single_configure; then
5519 func_modules_to_filelist_separately
5521 func_modules_to_filelist
5522 if test $verbose -ge 0; then
5524 echo "$files" | sed -e 's/^/ /'
5527 # Add files for which the copy in gnulib is newer than the one that
5528 # "automake --add-missing --copy" would provide.
5529 files="$files build-aux/config.guess"
5530 files="$files build-aux/config.sub"
5531 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5533 rewritten='%REWRITTEN%'
5534 sed_rewrite_files="\
5535 s,^build-aux/,$rewritten$auxdir/,
5536 s,^doc/,$rewritten$docbase/,
5537 s,^lib/,$rewritten$sourcebase/,
5538 s,^m4/,$rewritten$m4base/,
5539 s,^tests/,$rewritten$testsbase/,
5540 s,^tests=lib/,$rewritten$testsbase/,
5544 # Create directories.
5545 for f in $files; do echo $f; done \
5546 | sed -e "$sed_rewrite_files" \
5547 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5548 | LC_ALL=C sort -u \
5550 { # Rearrange file descriptors. Needed because "while ... done < ..."
5551 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5552 exec 5<&0 < "$tmp"/dirs
5554 mkdir -p "$testdir/$d"
5559 # Copy files or make symbolic links.
5561 for f in $files; do echo $f; done \
5562 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5565 { # Rearrange file descriptors. Needed because "while ... done < ..."
5566 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5567 exec 5<&0 < "$tmp"/files
5570 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5572 func_lookup_file "$f"
5573 if test -n "$lookedup_tmp"; then
5574 cp -p "$lookedup_file" "$testdir/$g"
5576 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5577 if { test -n "$symbolic" \
5578 || { test -n "$lsymbolic" \
5579 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5580 func_ln "$lookedup_file" "$testdir/$g"
5582 cp -p "$lookedup_file" "$testdir/$g"
5589 # Create Makefile.ams that are for testing.
5592 # No special edits are needed.
5595 # Create $sourcebase/Makefile.am.
5596 mkdir -p "$testdir/$sourcebase"
5597 destfile="$sourcebase/Makefile.am"
5598 if $single_configure; then
5599 modules="$main_modules"
5601 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5602 any_uses_subdirs="$uses_subdirs"
5604 # Create $m4base/Makefile.am.
5605 mkdir -p "$testdir/$m4base"
5606 (echo "## Process this file with automake to produce Makefile.in."
5612 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5615 ) > "$testdir/$m4base/Makefile.am"
5617 subdirs="$sourcebase $m4base"
5618 subdirs_with_configure_ac=""
5620 if false && test -f "$testdir"/$m4base/gettext.m4; then
5621 # Avoid stupid error message from automake:
5622 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5623 mkdir -p "$testdir/po"
5624 (echo "## Process this file with automake to produce Makefile.in."
5625 ) > "$testdir/po/Makefile.am"
5626 func_append subdirs " po"
5629 if test -n "$inctests"; then
5630 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5631 if $single_configure; then
5632 # Create $testsbase/Makefile.am.
5633 destfile="$testsbase/Makefile.am"
5634 modules="$testsrelated_modules"
5635 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
5637 # Viewed from the $testsbase subdirectory, $auxdir is different.
5638 saved_auxdir="$auxdir"
5639 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5640 # Create $testsbase/Makefile.am.
5642 destfile="$testsbase/Makefile.am"
5643 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5644 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5645 # Create $testsbase/configure.ac.
5646 (echo "# Process this file with autoconf to produce a configure script."
5647 echo "AC_INIT([dummy], [0])"
5648 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5649 echo "AM_INIT_AUTOMAKE"
5651 echo "AC_CONFIG_HEADERS([config.h])"
5654 echo "AC_PROG_INSTALL"
5655 echo "AC_PROG_MAKE_SET"
5656 echo "AC_PROG_RANLIB"
5658 if test -n "$uses_subdirs"; then
5659 echo "AM_PROG_CC_C_O"
5662 for module in $modules; do
5664 if test -n "$module"; then
5666 gnumakefile | maintainer-makefile)
5667 # These modules are meant to be used only in the top-level directory.
5670 func_get_autoconf_early_snippet "$module"
5675 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5676 if test "$libtool" = true; then
5677 echo "LT_INIT([win32-dll])"
5678 echo "LT_LANG([C++])"
5679 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5680 echo "gl_cond_libtool=true"
5682 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5683 echo "gl_cond_libtool=false"
5685 echo "gl_ltlibdeps="
5687 # Wrap the set of autoconf snippets into an autoconf macro that is then
5688 # invoked. This is needed because autoconf does not support AC_REQUIRE
5690 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5691 # but we want the AC_REQUIRE to have its normal meaning (provide one
5692 # expansion of the required macro before the current point, and only one
5694 echo "AC_DEFUN([gl_INIT], ["
5695 sed_replace_build_aux='
5697 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5698 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5701 echo "gl_m4_base='../$m4base'"
5702 func_emit_initmacro_start $macro_prefix
5703 # We don't have explicit ordering constraints between the various
5704 # autoconf snippets. It's cleanest to put those of the library before
5705 # those of the tests.
5706 echo "gl_source_base='../$sourcebase'"
5707 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
5708 echo "gl_source_base='.'"
5709 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
5710 func_emit_initmacro_end $macro_prefix
5711 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5712 # created using libtool, because libtool already handles the dependencies.
5713 if test "$libtool" != true; then
5714 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5715 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5716 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5717 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5718 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5721 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5725 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5726 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5727 echo "AH_TOP([#include \"../config.h\"])"
5729 echo "AC_CONFIG_FILES([Makefile])"
5731 ) > "$testdir/$testsbase/configure.ac"
5732 auxdir="$saved_auxdir"
5733 func_append subdirs " $testsbase"
5734 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5736 subdirs="$subdirs $testsbase"
5739 # Create Makefile.am.
5740 (echo "## Process this file with automake to produce Makefile.in."
5742 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5744 echo "SUBDIRS = $subdirs"
5746 echo "ACLOCAL_AMFLAGS = -I $m4base"
5747 ) > "$testdir/Makefile.am"
5749 # Create configure.ac.
5750 (echo "# Process this file with autoconf to produce a configure script."
5751 echo "AC_INIT([dummy], [0])"
5752 if test "$auxdir" != "."; then
5753 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5755 echo "AM_INIT_AUTOMAKE"
5757 echo "AC_CONFIG_HEADERS([config.h])"
5760 echo "AC_PROG_INSTALL"
5761 echo "AC_PROG_MAKE_SET"
5763 echo "# For autobuild."
5764 echo "AC_CANONICAL_BUILD"
5765 echo "AC_CANONICAL_HOST"
5767 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5768 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5769 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5770 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5772 echo "AC_PROG_RANLIB"
5774 if test -n "$any_uses_subdirs"; then
5775 echo "AM_PROG_CC_C_O"
5778 for module in $final_modules; do
5779 if $single_configure; then
5782 func_verify_nontests_module
5784 if test -n "$module"; then
5785 func_get_autoconf_early_snippet "$module"
5788 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5789 if test "$libtool" = true; then
5790 echo "LT_INIT([win32-dll])"
5791 echo "LT_LANG([C++])"
5792 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5793 echo "gl_cond_libtool=true"
5795 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5796 echo "gl_cond_libtool=false"
5798 echo "gl_ltlibdeps="
5800 # Wrap the set of autoconf snippets into an autoconf macro that is then
5801 # invoked. This is needed because autoconf does not support AC_REQUIRE
5803 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5804 # but we want the AC_REQUIRE to have its normal meaning (provide one
5805 # expansion of the required macro before the current point, and only one
5807 echo "AC_DEFUN([gl_INIT], ["
5808 if test "$auxdir" != "build-aux"; then
5809 sed_replace_build_aux='
5811 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5812 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5816 sed_replace_build_aux="$sed_noop"
5818 echo "gl_m4_base='$m4base'"
5819 func_emit_initmacro_start $macro_prefix
5820 echo "gl_source_base='$sourcebase'"
5821 if $single_configure; then
5822 func_emit_autoconf_snippets "$main_modules" func_verify_module true false false
5824 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
5826 func_emit_initmacro_end $macro_prefix
5827 if $single_configure; then
5828 echo " gltests_libdeps="
5829 echo " gltests_ltlibdeps="
5830 func_emit_initmacro_start ${macro_prefix}tests
5831 echo " gl_source_base='$testsbase'"
5832 # Define a tests witness macro.
5833 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
5834 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5835 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5836 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5837 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true false false
5838 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5839 func_emit_initmacro_end ${macro_prefix}tests
5841 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5842 # created using libtool, because libtool already handles the dependencies.
5843 if test "$libtool" != true; then
5844 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5845 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5846 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5847 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5848 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5850 if $single_configure; then
5851 if $use_libtests; then
5852 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5853 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5857 func_emit_initmacro_done $macro_prefix $sourcebase
5858 if $single_configure; then
5859 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5864 if test -n "$subdirs_with_configure_ac"; then
5865 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5867 makefiles="Makefile"
5868 for d in $subdirs; do
5869 # For subdirs that have a configure.ac by their own, it's the subdir's
5870 # configure.ac which creates the subdir's Makefile.am, not this one.
5871 case " $subdirs_with_configure_ac " in
5873 *) func_append makefiles " $d/Makefile" ;;
5876 echo "AC_CONFIG_FILES([$makefiles])"
5878 ) > "$testdir/configure.ac"
5880 # Create autogenerated files.
5882 # Do not use "${AUTORECONF} --force --install", because it may invoke
5883 # autopoint, which brings in older versions of some of our .m4 files.
5884 if test -f $m4base/gettext.m4; then
5885 func_execute_command ${AUTOPOINT} --force || func_exit 1
5886 for f in $m4base/*.m4~; do
5888 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5892 if test "$libtool" = true; then
5893 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5895 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5896 if ! test -d build-aux; then
5897 func_execute_command mkdir build-aux || func_exit 1
5899 func_execute_command ${AUTOCONF} || func_exit 1
5900 func_execute_command ${AUTOHEADER} || func_exit 1
5901 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5903 if test -n "$inctests" && ! $single_configure; then
5904 # Create autogenerated files.
5905 (cd "$testdir/$testsbase" || func_exit 1
5906 # Do not use "${AUTORECONF} --force --install", because it may invoke
5907 # autopoint, which brings in older versions of some of our .m4 files.
5908 if test -f ../$m4base/gettext.m4; then
5909 func_execute_command ${AUTOPOINT} --force || func_exit 1
5910 for f in ../$m4base/*.m4~; do
5912 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5916 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5917 if ! test -d ../build-aux; then
5918 func_execute_command mkdir ../build-aux
5920 func_execute_command ${AUTOCONF} || func_exit 1
5921 func_execute_command ${AUTOHEADER} || func_exit 1
5922 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5925 # Need to run configure and make once, to create built files that are to be
5926 # distributed (such as parse-datetime.c).
5927 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5928 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5929 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5930 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5931 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5932 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5933 # such $(FOO_H) because they don't refer to distributed files.
5934 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5935 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5936 | sed -e "$sed_remove_make_variables"`
5937 distributed_built_sources=`for file in $built_sources; do
5938 case "$cleaned_files" in
5943 tests_distributed_built_sources=
5944 if test -n "$inctests"; then
5945 # Likewise for built files in the $testsbase directory.
5946 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5947 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5948 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5949 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5950 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5951 | sed -e "$sed_remove_make_variables"`
5952 tests_distributed_built_sources=`for file in $tests_built_sources; do
5953 case "$tests_cleaned_files" in
5959 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5961 ./configure || func_exit 1
5962 if test -n "$distributed_built_sources"; then
5964 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5965 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5970 if test -n "$tests_distributed_built_sources"; then
5972 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5973 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5978 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5985 # func_create_megatestdir megatestdir allmodules
5987 # - local_gnulib_dir from --local-dir
5988 # - modcache true or false, from --cache-modules/--no-cache-modules
5989 # - auxdir directory relative to destdir where to place build aux files
5990 func_create_megatestdir ()
5994 if test -z "$allmodules"; then
5995 allmodules=`func_all_modules`
5999 # First, all modules one by one.
6000 for onemodule in $allmodules; do
6001 func_create_testdir "$megatestdir/$onemodule" $onemodule
6002 func_append megasubdirs "$onemodule "
6004 # Then, all modules all together.
6005 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6006 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6007 func_create_testdir "$megatestdir/ALL" "$allmodules"
6008 func_append megasubdirs "ALL"
6011 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
6012 vc_witness="$gnulib_dir/CVS/Entries"; \
6014 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6016 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6017 | sed -e 's,January,01,' -e 's,Jan,01,' \
6018 -e 's,February,02,' -e 's,Feb,02,' \
6019 -e 's,March,03,' -e 's,Mar,03,' \
6020 -e 's,April,04,' -e 's,Apr,04,' \
6022 -e 's,June,06,' -e 's,Jun,06,' \
6023 -e 's,July,07,' -e 's,Jul,07,' \
6024 -e 's,August,08,' -e 's,Aug,08,' \
6025 -e 's,September,09,' -e 's,Sep,09,' \
6026 -e 's,October,10,' -e 's,Oct,10,' \
6027 -e 's,November,11,' -e 's,Nov,11,' \
6028 -e 's,December,12,' -e 's,Dec,12,' \
6029 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6030 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6032 echo "CVSDATE=$cvsdate"
6033 echo ": \${MAKE=make}"
6034 echo "test -d logs || mkdir logs"
6035 echo "for module in $megasubdirs; do"
6036 echo " echo \"Working on module \$module...\""
6037 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6038 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6041 echo " : autobuild project... \$module"
6042 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6043 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6044 echo " : autobuild hostname... \`hostname\`"
6045 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6047 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6049 ) > "$megatestdir/do-autobuild"
6050 chmod a+x "$megatestdir/do-autobuild"
6052 # Create Makefile.am.
6053 (echo "## Process this file with automake to produce Makefile.in."
6055 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
6057 echo "SUBDIRS = $megasubdirs"
6059 echo "EXTRA_DIST = do-autobuild"
6060 ) > "$megatestdir/Makefile.am"
6062 # Create configure.ac.
6063 (echo "# Process this file with autoconf to produce a configure script."
6064 echo "AC_INIT([dummy], [0])"
6065 if test "$auxdir" != "."; then
6066 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6068 echo "AM_INIT_AUTOMAKE"
6070 echo "AC_PROG_MAKE_SET"
6072 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6073 echo "AC_CONFIG_FILES([Makefile])"
6075 ) > "$megatestdir/configure.ac"
6077 # Create autogenerated files.
6079 # Do not use "${AUTORECONF} --install", because autoreconf operates
6080 # recursively, but the subdirectories are already finished, therefore
6081 # calling autoreconf here would only waste lots of CPU time.
6082 func_execute_command ${ACLOCAL} || func_exit 1
6083 func_execute_command mkdir build-aux
6084 func_execute_command ${AUTOCONF} || func_exit 1
6085 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6091 func_fatal_error "no mode specified" ;;
6098 # sed expression that converts a literal to a basic regular expression.
6099 # Needs to handle . [ \ * ^ $.
6100 sed_literal_to_basic_regex='s/\\/\\\\/g
6106 if test -f "$gnulib_dir/$filename" \
6107 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
6108 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6109 filename_line_regex='^'"$filename_anywhere_regex"'$'
6112 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6113 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
6114 (cd "$local_gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_anywhere_regex" /dev/null | sed -e 's,^modules/,,' -e 's,\.diff$,,')
6117 | func_sanitize_modulelist \
6120 for module in $module_candidates; do
6121 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6126 func_warning "file $filename does not exist"
6131 import | add-import | remove-import | update )
6134 if test -z "$destdir"; then
6137 test -d "$destdir" \
6138 || func_fatal_error "destination directory does not exist: $destdir"
6140 # Prefer configure.ac to configure.in.
6141 if test -f "$destdir"/configure.ac; then
6142 configure_ac="$destdir/configure.ac"
6144 if test -f "$destdir"/configure.in; then
6145 configure_ac="$destdir/configure.in"
6147 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6151 # Analyze configure.ac.
6153 guessed_libtool=false
6158 /AC_CONFIG_AUX_DIR/ {
6159 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6161 /A[CM]_PROG_LIBTOOL/ {
6162 s,^.*$,guessed_libtool=true,p
6164 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6166 if test -z "$auxdir"; then
6167 auxdir="$guessed_auxdir"
6170 # Determine where to apply func_import.
6171 if test "$mode" = import; then
6172 # Apply func_import to a particular gnulib directory.
6173 # The command line contains the complete specification; don't look at
6174 # the contents of gnulib-cache.m4.
6175 test -n "$supplied_libname" || supplied_libname=true
6176 test -n "$sourcebase" || sourcebase="lib"
6177 test -n "$m4base" || m4base="m4"
6178 test -n "$docbase" || docbase="doc"
6179 test -n "$testsbase" || testsbase="tests"
6180 test -n "$macro_prefix" || macro_prefix="gl"
6183 if test -n "$m4base"; then
6184 # Apply func_import to a particular gnulib directory.
6185 # Any number of additional modules can be given.
6186 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6187 # First use of gnulib in the given m4base.
6188 test -n "$supplied_libname" || supplied_libname=true
6189 test -n "$sourcebase" || sourcebase="lib"
6190 test -n "$docbase" || docbase="doc"
6191 test -n "$testsbase" || testsbase="tests"
6192 test -n "$macro_prefix" || macro_prefix="gl"
6196 # Apply func_import to all gnulib directories.
6197 # To get this list of directories, look at Makefile.am. (Not at
6198 # configure, because it may be omitted from version control. Also,
6199 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6203 if test -f "$destdir"/Makefile.am; then
6204 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6206 for arg in $aclocal_amflags; do
6207 if test -n "$m4dir_is_next"; then
6208 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6212 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6213 func_append m4dirs " $arg"
6214 m4dirs_count=`expr $m4dirs_count + 1`
6220 if test "X$arg" = "X-I"; then
6228 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6229 if test -f "$destdir"/aclocal.m4; then
6230 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6231 sedexpr2='s,^[^/]*$,.,'
6232 sedexpr3='s,/[^/]*$,,'
6233 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6234 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6235 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6238 if test $m4dirs_count = 0; then
6239 # First use of gnulib in a package.
6240 # Any number of additional modules can be given.
6241 test -n "$supplied_libname" || supplied_libname=true
6242 test -n "$sourcebase" || sourcebase="lib"
6244 test -n "$docbase" || docbase="doc"
6245 test -n "$testsbase" || testsbase="tests"
6246 test -n "$macro_prefix" || macro_prefix="gl"
6249 if test $m4dirs_count = 1; then
6250 # There's only one use of gnulib here. Assume the user means it.
6251 # Any number of additional modules can be given.
6252 for m4base in $m4dirs; do
6256 # Ambiguous - guess what the user meant.
6257 if test $# = 0; then
6258 # No further arguments. Guess the user wants to update all of them.
6259 for m4base in $m4dirs; do
6260 # Perform func_import in a subshell, so that variable values
6262 # local_gnulib_dir, incobsolete, inc_cxx_tests,
6263 # inc_longrunning_tests, inc_privileged_tests,
6264 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6265 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6266 # makefile_name, libtool, macro_prefix, po_domain, vc_files
6267 # don't propagate from one directory to another.
6268 (func_import) || func_exit 1
6272 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6281 if test -z "$destdir"; then
6282 func_fatal_error "please specify --dir option"
6285 test -d "$destdir" \
6286 || func_fatal_error "could not create destination directory"
6287 test -n "$auxdir" || auxdir="build-aux"
6288 func_create_testdir "$destdir" "$*"
6291 create-megatestdir )
6292 if test -z "$destdir"; then
6293 func_fatal_error "please specify --dir option"
6295 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6296 test -n "$auxdir" || auxdir="build-aux"
6297 func_create_megatestdir "$destdir" "$*"
6301 test -n "$destdir" || destdir=testdir$$
6302 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6303 test -n "$auxdir" || auxdir="build-aux"
6304 func_create_testdir "$destdir" "$*"
6308 ../configure || func_exit 1
6309 $MAKE || func_exit 1
6310 $MAKE check || func_exit 1
6311 $MAKE distclean || func_exit 1
6312 remaining=`find . -type f -print`
6313 if test -n "$remaining"; then
6314 echo "Remaining files:" $remaining 1>&2
6315 echo "gnulib-tool: *** Stop." 1>&2
6324 test -n "$destdir" || destdir=testdir$$
6325 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6326 test -n "$auxdir" || auxdir="build-aux"
6327 func_create_megatestdir "$destdir" "$*"
6335 remaining=`find . -type f -print`
6336 if test -n "$remaining"; then
6337 echo "Remaining files:" $remaining 1>&2
6338 echo "gnulib-tool: *** Stop." 1>&2
6346 extract-description )
6350 if test -n "$module"; then
6351 func_get_description "$module"
6360 if test -n "$module"; then
6361 func_get_comment "$module"
6370 if test -n "$module"; then
6371 func_get_status "$module"
6380 if test -n "$module"; then
6381 func_get_notice "$module"
6386 extract-applicability )
6390 if test -n "$module"; then
6391 func_get_applicability "$module"
6400 if test -n "$module"; then
6401 func_get_filelist "$module"
6406 extract-dependencies )
6410 if test -n "$module"; then
6411 func_get_dependencies "$module"
6416 extract-autoconf-snippet )
6420 if test -n "$module"; then
6421 func_get_autoconf_snippet "$module"
6426 extract-automake-snippet )
6430 if test -n "$module"; then
6431 func_get_automake_snippet "$module"
6436 extract-include-directive )
6440 if test -n "$module"; then
6441 func_get_include_directive "$module"
6446 extract-link-directive )
6450 if test -n "$module"; then
6451 func_get_link_directive "$module"
6460 if test -n "$module"; then
6461 func_get_license "$module"
6466 extract-maintainer )
6470 if test -n "$module"; then
6471 func_get_maintainer "$module"
6476 extract-tests-module )
6480 if test -n "$module"; then
6481 func_get_tests_module "$module"
6487 # Verify the number of arguments.
6488 if test $# -lt 1 || test $# -gt 2; then
6489 func_fatal_error "invalid number of arguments for --$mode"
6492 # The first argument is the file to be copied.
6494 # Verify the file exists.
6495 func_lookup_file "$f"
6497 # The second argument is the destination; either a directory ot a file.
6498 # It defaults to the current directory.
6500 test -n "$dest" || dest='.'
6501 test -n "$sourcebase" || sourcebase="lib"
6502 test -n "$m4base" || m4base="m4"
6503 test -n "$docbase" || docbase="doc"
6504 test -n "$testsbase" || testsbase="tests"
6505 test -n "$auxdir" || auxdir="build-aux"
6506 rewritten='%REWRITTEN%'
6507 sed_rewrite_files="\
6508 s,^build-aux/,$rewritten$auxdir/,
6509 s,^doc/,$rewritten$docbase/,
6510 s,^lib/,$rewritten$sourcebase/,
6511 s,^m4/,$rewritten$m4base/,
6512 s,^tests/,$rewritten$testsbase/,
6515 if test -d "$dest"; then
6517 g=`echo "$f" | sed -e "$sed_rewrite_files"`
6519 destdir=`dirname "$dest"`
6520 g=`basename "$dest"`
6523 # Create the directory for destfile.
6524 d=`dirname "$destdir/$g"`
6526 if test -n "$d" && test ! -d "$d"; then
6527 mkdir -p "$d" || func_fatal_error "failed"
6531 func_dest_tmpfilename "$g"
6532 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
6533 already_present=true
6534 if test -f "$destdir/$g"; then
6535 # The file already exists.
6539 # Don't protest if the file should be there but isn't: it happens
6540 # frequently that developers don't put autogenerated files under version
6548 func_fatal_error "unknown operation mode --$mode" ;;
6552 # Undo the effect of the previous 'trap' command. Some shellology:
6553 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6554 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6555 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6556 # 128 + signal number and is set before the trap-registered command is run.
6558 trap 'func_exit $?' 1 2 3 13 15
6563 # indent-tabs-mode: nil
6564 # whitespace-check-buffer-indent: nil