3 # Copyright (C) 2002-2012 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 (pass --with-tests to include the unit tests)
168 --create-megatestdir create a mega scratch package with the given modules
169 one by one and all together
170 (pass --with-tests to include the unit tests)
171 --test test the combination of the given modules
172 (pass --with-tests to include the unit tests)
173 (recommended to use CC=\"gcc -Wall\" here)
174 --megatest test the given modules one by one and all together
175 (pass --with-tests to include the unit tests)
176 (recommended to use CC=\"gcc -Wall\" here)
177 --extract-description extract the description
178 --extract-comment extract the comment
179 --extract-status extract the status (obsolete etc.)
180 --extract-notice extract the notice or banner
181 --extract-applicability extract the applicability
182 --extract-filelist extract the list of files
183 --extract-dependencies extract the dependencies
184 --extract-autoconf-snippet extract the snippet for configure.ac
185 --extract-automake-snippet extract the snippet for library makefile
186 --extract-include-directive extract the #include directive
187 --extract-link-directive extract the linker directive
188 --extract-license report the license terms of the source files
190 --extract-maintainer report the maintainer(s) inside gnulib
191 --extract-tests-module report the unit test module, if it exists
192 --copy-file copy a file that is not part of any module
193 --help Show this help text.
194 --version Show version and authorship information.
198 --dir=DIRECTORY Specify the target directory.
199 For --import, this specifies where your
200 configure.ac can be found. Defaults to current
202 --local-dir=DIRECTORY Specify a local override directory where to look
203 up files before looking in gnulib's directory.
204 --cache-modules Enable module caching optimization.
205 --no-cache-modules Disable module caching optimization.
206 --verbose Increase verbosity. May be repeated.
207 --quiet Decrease verbosity. May be repeated.
209 Options for --import, --add/remove-import, --update:
211 --dry-run Only print what would have been done.
213 Options for --import, --add/remove-import,
214 --create-[mega]testdir, --[mega]test:
216 --with-tests Include unit tests for the included modules.
217 --with-obsolete Include obsolete modules when they occur among the
218 dependencies. By default, dependencies to obsolete
220 --with-c++-tests Include even unit tests for C++ interoperability.
221 --with-longrunning-tests
222 Include even unit tests that are long-runners.
223 --with-privileged-tests
224 Include even unit tests that require root
226 --with-unportable-tests
227 Include even unit tests that fail on some platforms.
228 --with-all-tests Include all kinds of problematic unit tests.
229 --avoid=MODULE Avoid including the given MODULE. Useful if you
230 have code that provides equivalent functionality.
231 This option can be repeated.
232 --conditional-dependencies
233 Support conditional dependencies (may save configure
234 time and object code).
235 --no-conditional-dependencies
236 Don't use conditional dependencies.
237 --libtool Use libtool rules.
238 --no-libtool Don't use libtool rules.
240 Options for --import, --add/remove-import:
242 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
243 --source-base=DIRECTORY
244 Directory relative to --dir where source code is
245 placed (default \"lib\").
246 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
247 placed (default \"m4\").
248 --po-base=DIRECTORY Directory relative to --dir where *.po files are
249 placed (default \"po\").
250 --doc-base=DIRECTORY Directory relative to --dir where doc files are
251 placed (default \"doc\").
252 --tests-base=DIRECTORY
253 Directory relative to --dir where unit tests are
254 placed (default \"tests\").
255 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
256 tools are placed (default comes from configure.ac).
257 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
258 Also modify license template from GPL to LGPL.
259 The version number of the LGPL can be specified;
260 the default is currently LGPLv3.
261 --makefile-name=NAME Name of makefile in automake syntax in the
262 source-base and tests-base directories
263 (default \"Makefile.am\").
264 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
265 'gl_INIT'. Default is 'gl'.
266 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
267 the package name. A suffix '-gnulib' is appended.
268 --witness-c-macro=NAME Specify the C macro that is defined when the
269 sources in this directory are compiled or used.
270 --vc-files Update version control related files.
271 --no-vc-files Don't update version control related files
272 (.gitignore and/or .cvsignore).
273 --no-changelog Don't update or create ChangeLog files.
275 Options for --create-[mega]testdir, --[mega]test:
277 --without-c++-tests Exclude unit tests for C++ interoperability.
278 --without-longrunning-tests
279 Exclude unit tests that are long-runners.
280 --without-privileged-tests
281 Exclude unit tests that require root privileges.
282 --without-unportable-tests
283 Exclude unit tests that fail on some platforms.
284 --single-configure Generate a single configure file, not a separate
285 configure file for the tests directory.
287 Options for --import, --add/remove-import, --update,
288 --create-[mega]testdir, --[mega]test:
290 -s, --symbolic, --symlink Make symbolic links instead of copying files.
291 --local-symlink Make symbolic links instead of copying files, only
292 for files from the local override directory.
294 Options for --import, --add/remove-import, --update:
296 -S, --more-symlinks Make symbolic links instead of copying files, and
297 don't replace copyright notices.
299 Report bugs to <bug-gnulib@gnu.org>."
303 # outputs to stdout the --version message.
307 if test -d "$gnulib_dir"/.git \
308 && (git --version) >/dev/null 2>/dev/null \
309 && (date --version) >/dev/null 2>/dev/null; then
310 # gnulib checked out from git.
311 sed_extract_first_date='/^Date/{
315 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
316 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
317 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
318 date=`echo "$date" | sed -e "$sed_year_before_time"`
319 # Use GNU date to compute the time in GMT.
320 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
321 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
323 if test -d "$gnulib_dir"/CVS \
324 && (cvs --version) >/dev/null 2>/dev/null; then
325 # gnulib checked out from CVS.
326 sed_extract_first_date='/^date: /{
327 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
330 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
332 # gnulib copy without versioning information.
333 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
337 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
339 gnulib-tool (GNU $package $date)$version
340 Copyright (C) $year Free Software Foundation, Inc.
341 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
342 This is free software: you are free to change and redistribute it.
343 There is NO WARRANTY, to the extent permitted by law.
345 printf "Written by %s, %s, and %s.\n" "Bruno Haible" "Paul Eggert" "Simon Josefsson"
348 # func_emit_copyright_notice
349 # outputs to stdout a header for a generated file.
350 func_emit_copyright_notice ()
352 sed -n -e '/Copyright/ {
355 }' < "$self_abspathname"
357 echo "# This file is free software; you can redistribute it and/or modify"
358 echo "# it under the terms of the GNU General Public License as published by"
359 echo "# the Free Software Foundation; either version 3 of the License, or"
360 echo "# (at your option) any later version."
362 echo "# This file is distributed in the hope that it will be useful,"
363 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
364 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
365 echo "# GNU General Public License for more details."
367 echo "# You should have received a copy of the GNU General Public License"
368 echo "# along with this file. If not, see <http://www.gnu.org/licenses/>."
370 echo "# As a special exception to the GNU General Public License,"
371 echo "# this file may be distributed as part of a program that"
372 echo "# contains a configuration script generated by Autoconf, under"
373 echo "# the same distribution terms as the rest of that program."
375 echo "# Generated by gnulib-tool."
379 # exits with a given status.
380 # This function needs to be used, rather than 'exit', when a 'trap' handler is
381 # in effect that refers to $?.
388 # locates the directory where the gnulib repository lives
390 # - progname name of this program
392 # - self_abspathname absolute pathname of gnulib-tool
393 # - gnulib_dir absolute pathname of gnulib repository
397 /*) self_abspathname="$progname" ;;
398 */*) self_abspathname=`pwd`/"$progname" ;;
401 # Iterate through the elements of $PATH.
402 # We use IFS=: instead of
403 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
404 # because the latter does not work when some PATH element contains spaces.
405 # We use a canonicalized $pathx instead of $PATH, because empty PATH
406 # elements are by definition equivalent to '.', however field splitting
407 # according to IFS=: loses empty fields in many shells:
408 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
409 # beginning, at the end, and in the middle),
410 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
411 # at the beginning and at the end,
412 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
413 # Solaris lose empty fields at the end.
414 # The 'case' statement is an optimization, to avoid evaluating the
415 # explicit canonicalization command when $PATH contains no empty fields.
417 if test "${PATH_SEPARATOR+set}" != set; then
418 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
419 # contains only /bin. Note that ksh looks also at the FPATH variable,
420 # so we have to set that as well for the test.
422 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
423 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
424 || PATH_SEPARATOR=';'
427 if test "$PATH_SEPARATOR" = ";"; then
428 # On Windows, programs are searched in "." before $PATH.
431 # On Unix, we have to convert empty PATH elements to ".".
435 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
440 IFS="$PATH_SEPARATOR"
444 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
445 self_abspathname="$d/$progname"
450 if test -z "$self_abspathname"; then
451 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
455 while test -h "$self_abspathname"; do
456 # Resolve symbolic link.
457 linkval=`func_readlink "$self_abspathname"`
458 test -n "$linkval" || break
460 /* ) self_abspathname="$linkval" ;;
461 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
464 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
468 # creates a temporary directory.
470 # - progname name of this program
472 # - tmp pathname of freshly created temporary directory
475 # Use the environment variable TMPDIR, falling back to /tmp. This allows
476 # users to specify a different temporary directory, for example, if their
477 # /tmp is filled up or too small.
480 # Use the mktemp program if available. If not available, hide the error
482 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
483 test -n "$tmp" && test -d "$tmp"
486 # Use a simple mkdir command. It is guaranteed to fail if the directory
487 # already exists. $RANDOM is bash specific and expands to empty in shells
488 # other than bash, ksh and zsh. Its use does not increase security;
489 # rather, it minimizes the probability of failure in a very cluttered /tmp
491 tmp=$TMPDIR/gl$$-$RANDOM
492 (umask 077 && mkdir "$tmp")
495 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
500 # func_append var value
501 # appends the given value to the shell variable var.
502 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
503 # Use bash's += operator. It reduces complexity of appending repeatedly to
504 # a single variable from O(n^2) to O(n).
509 fast_func_append=true
513 eval "$1=\"\$$1\$2\""
515 fast_func_append=false
518 # func_remove_prefix var prefix
519 # removes the given prefix from the value of the shell variable var.
520 # var should be the name of a shell variable.
521 # Its value should not contain a newline and not start or end with whitespace.
522 # prefix should not contain the characters "$`\{}[]^|.
523 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
524 func_remove_prefix ()
528 fast_func_remove_prefix=true
530 func_remove_prefix ()
532 eval "value=\"\$$1\""
536 sed_escape_dots='s/\([.]\)/\\\1/g'
537 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
540 value=`echo "$value" | sed -e "s|^${prefix}||"`
541 eval "$1=\"\$value\""
543 fast_func_remove_prefix=false
546 # func_remove_suffix var suffix
547 # removes the given suffix from the value of the shell variable var.
548 # var should be the name of a shell variable.
549 # Its value should not contain a newline and not start or end with whitespace.
550 # suffix should not contain the characters "$`\{}[]^|.
551 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
552 func_remove_suffix ()
556 fast_func_remove_suffix=true
558 func_remove_suffix ()
560 eval "value=\"\$$1\""
564 sed_escape_dots='s/\([.]\)/\\\1/g'
565 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
568 value=`echo "$value" | sed -e "s|${suffix}\$||"`
569 eval "$1=\"\$value\""
571 fast_func_remove_suffix=false
574 # func_fatal_error message
575 # outputs to stderr a fatal error message, and terminates the program.
577 # - progname name of this program
580 echo "$progname: *** $1" 1>&2
581 echo "$progname: *** Stop." 1>&2
585 # func_warning message
586 # Outputs to stderr a warning message,
589 echo "gnulib-tool: warning: $1" 1>&2
592 # func_readlink SYMLINK
593 # outputs the target of the given symlink.
594 if (type -p readlink) > /dev/null 2>&1; then
597 # Use the readlink program from GNU coreutils.
603 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
604 # would do the wrong thing if the link target contains " -> ".
605 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
609 # func_relativize DIR1 DIR2
610 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
612 # - DIR1 relative pathname, relative to the current directory
613 # - DIR2 relative pathname, relative to the current directory
615 # - reldir relative pathname of DIR2, relative to DIR1
621 sed_first='s,^\([^/]*\)/.*$,\1,'
622 sed_rest='s,^[^/]*/*,,'
623 sed_last='s,^.*/\([^/]*\)$,\1,'
624 sed_butlast='s,/*[^/]*$,,'
625 while test -n "$dir1"; do
626 first=`echo "$dir1" | sed -e "$sed_first"`
627 if test "$first" != "."; then
628 if test "$first" = ".."; then
629 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
630 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
632 first2=`echo "$dir2" | sed -e "$sed_first"`
633 if test "$first2" = "$first"; then
634 dir2=`echo "$dir2" | sed -e "$sed_rest"`
638 dir0="$dir0"/"$first"
641 dir1=`echo "$dir1" | sed -e "$sed_rest"`
646 # func_relconcat DIR1 DIR2
647 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
649 # - DIR1 relative pathname, relative to the current directory
650 # - DIR2 relative pathname, relative to DIR1
652 # - relconcat DIR1/DIR2, relative to the current directory
657 sed_first='s,^\([^/]*\)/.*$,\1,'
658 sed_rest='s,^[^/]*/*,,'
659 sed_last='s,^.*/\([^/]*\)$,\1,'
660 sed_butlast='s,/*[^/]*$,,'
662 first=`echo "$dir2" | sed -e "$sed_first"`
663 if test "$first" = "."; then
664 dir2=`echo "$dir2" | sed -e "$sed_rest"`
665 if test -z "$dir2"; then
670 last=`echo "$dir1" | sed -e "$sed_last"`
671 while test "$last" = "."; do
672 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
673 last=`echo "$dir1" | sed -e "$sed_last"`
675 if test -z "$dir1"; then
679 if test "$first" = ".."; then
680 if test "$last" = ".."; then
681 relconcat="$dir1/$dir2"
684 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
685 dir2=`echo "$dir2" | sed -e "$sed_rest"`
686 if test -z "$dir1"; then
690 if test -z "$dir2"; then
695 relconcat="$dir1/$dir2"
703 # Like ln -s, except that SRC is given relative to the current directory (or
704 # absolute), not given relative to the directory of DEST.
710 *) # SRC is relative.
713 ln -s "`pwd`/$1" "$2" ;;
714 *) # DEST is relative too.
715 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
716 test -n "$ln_destdir" || ln_destdir="."
717 func_relativize "$ln_destdir" "$1"
725 # func_ln_if_changed SRC DEST
726 # Like func_ln, but avoids munging timestamps if the link is correct.
727 func_ln_if_changed ()
729 if test $# -ne 2; then
730 echo "usage: func_ln_if_changed SRC DEST" >&2
732 ln_target=`func_readlink "$2"`
733 if test -h "$2" && test "$1" = "$ln_target"; then
741 # Ensure an 'echo' command that
742 # 1. does not interpret backslashes and
743 # 2. does not print an error message "broken pipe" when writing into a pipe
746 # Test cases for problem 1:
747 # echo '\n' | wc -l prints 1 when OK, 2 when KO
748 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
749 # Test cases for problem 2:
750 # echo hi | true frequently prints
751 # "bash: echo: write error: Broken pipe"
752 # to standard error in bash 3.2.
754 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
755 # BSD echo interprets '-n' as an option, which is also not desirable).
756 # Nowadays the problem occurs in 4 situations:
757 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
758 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
759 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
760 # - in zsh, when sh-emulation is not set,
761 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
762 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
763 # - in Solaris /bin/sh and OSF/1 /bin/sh.
764 # We try the following workarounds:
765 # - for all: respawn using $CONFIG_SHELL if that is set and works.
766 # - for bash >= 2.04: unset the shell option xpg_echo.
767 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
768 # - for bash < 2.0: define echo to a function that uses cat of a here document.
769 # - for zsh: turn sh-emulation on.
770 # - for ksh: alias echo to 'print -r'.
771 # - for ksh: alias echo to a function that uses cat of a here document.
772 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
773 # the ksh workaround.
774 # - otherwise: respawn using /bin/sh and rely on the workarounds.
775 # When respawning, we pass --no-reexec as first argument, so as to avoid
776 # turning this script into a fork bomb in unlucky situations.
778 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
779 # the 'printf' built-in. See
780 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
781 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
782 # The workaround is: define echo to a function that uses the printf built-in.
784 if echo '\t' | grep t > /dev/null; then
785 have_echo=yes # Lucky!
787 # Try the workarounds.
788 # Respawn using $CONFIG_SHELL if that is set and works.
789 if test -z "$have_echo" \
790 && test "X$1" != "X--no-reexec" \
791 && test -n "$CONFIG_SHELL" \
792 && test -f "$CONFIG_SHELL" \
793 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
794 exec $CONFIG_SHELL "$0" --no-reexec "$@"
797 # For bash >= 2.04: unset the shell option xpg_echo.
798 if test -z "$have_echo" \
799 && test -n "$BASH_VERSION" \
800 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
804 # For bash >= 2.0: define echo to a function that uses the printf built-in.
805 # For bash < 2.0: define echo to a function that uses cat of a here document.
806 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
807 # Also handle problem 2, specific to bash 3.2, here.
808 if { test -z "$have_echo" \
809 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
811 && test -n "$BASH_VERSION"; then \
812 if type printf 2>/dev/null | grep / > /dev/null; then
813 # 'printf' is not a shell built-in.
821 # 'printf' is a shell built-in.
827 if echo '\t' | grep t > /dev/null; then
831 # For zsh: turn sh-emulation on.
832 if test -z "$have_echo" \
833 && test -n "$ZSH_VERSION" \
834 && (emulate sh) >/dev/null 2>&1; then
837 # For ksh: alias echo to 'print -r'.
838 if test -z "$have_echo" \
839 && (type print) >/dev/null 2>&1; then
840 # A 'print' command exists.
841 if type print 2>/dev/null | grep / > /dev/null; then
844 # 'print' is a shell built-in.
845 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
846 # 'print' is the ksh shell built-in.
847 alias echo='print -r'
851 if test -z "$have_echo" \
852 && echo '\t' | grep t > /dev/null; then
855 # For ksh: alias echo to a function that uses cat of a here document.
856 # The ksh manual page says:
857 # "Aliasing is performed when scripts are read, not while they are executed.
858 # Therefore, for an alias to take effect, the alias definition command has
859 # to be executed before the command which references the alias is read."
860 # Because of this, we have to play strange tricks with have_echo, to ensure
861 # that the top-level statement containing the test starts after the 'alias'
863 if test -z "$have_echo"; then
870 if (alias echo=bsd_echo) 2>/dev/null; then
871 alias echo=bsd_echo 2>/dev/null
874 if test -z "$have_echo" \
875 && echo '\t' | grep t > /dev/null; then
878 if test -z "$have_echo"; then
879 if (alias echo=bsd_echo) 2>/dev/null; then
880 unalias echo 2>/dev/null
883 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
884 if test -z "$have_echo" \
885 && test "X$1" != "X--no-reexec" \
886 && test -f /bin/ksh; then
887 exec /bin/ksh "$0" --no-reexec "$@"
890 # Otherwise: respawn using /bin/sh.
891 if test -z "$have_echo" \
892 && test "X$1" != "X--no-reexec" \
893 && test -f /bin/sh; then
894 exec /bin/sh "$0" --no-reexec "$@"
897 if test -z "$have_echo"; then
898 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
900 if echo '\t' | grep t > /dev/null; then
903 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
905 if test "X$1" = "X--no-reexec"; then
909 # Command-line option processing.
910 # Removes the OPTIONS from the arguments. Sets the variables:
911 # - mode list or import or add-import or remove-import or update
912 # or create-testdir or create-megatestdir
913 # - destdir from --dir
914 # - local_gnulib_dir from --local-dir
915 # - modcache true or false, from --cache-modules/--no-cache-modules
916 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
917 # - libname, supplied_libname from --lib
918 # - sourcebase from --source-base
919 # - m4base from --m4-base
920 # - pobase from --po-base
921 # - docbase from --doc-base
922 # - testsbase from --tests-base
923 # - auxdir from --aux-dir
924 # - inctests true if --with-tests was given, blank otherwise
925 # - incobsolete true if --with-obsolete was given, blank otherwise
926 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
927 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
929 # - inc_privileged_tests true if --with-privileged-tests was given, blank
931 # - inc_unportable_tests true if --with-unportable-tests was given, blank
933 # - inc_all_tests true if --with-all-tests was given, blank otherwise
934 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
935 # - excl_longrunning_tests true if --without-longrunning-tests was given,
937 # - excl_privileged_tests true if --without-privileged-tests was given, blank
939 # - excl_unportable_tests true if --without-unportable-tests was given, blank
941 # - single_configure true if --single-configure was given, false otherwise
942 # - avoidlist list of modules to avoid, from --avoid
943 # - cond_dependencies true if --conditional-dependencies was given, false if
944 # --no-conditional-dependencies was given, blank otherwise
945 # - lgpl yes or a number if --lgpl was given, blank otherwise
946 # - makefile_name from --makefile-name
947 # - libtool true if --libtool was given, false if --no-libtool was
948 # given, blank otherwise
949 # - macro_prefix from --macro-prefix
950 # - po_domain from --po-domain
951 # - witness_c_macro from --witness-c-macro
952 # - vc_files true if --vc-files was given, false if --no-vc-files was
953 # given, blank otherwise
954 # - autoconf_minversion minimum supported autoconf version
955 # - do_changelog false if --no-changelog was given, : otherwise
956 # - doit : if actions shall be executed, false if only to be printed
957 # - symbolic true if --symlink or --more-symlinks was given, blank
959 # - lsymbolic true if --local-symlink was given, blank otherwise
960 # - do_copyrights blank if --more-symlinks was given, true otherwise
978 inc_longrunning_tests=
979 inc_privileged_tests=
980 inc_unportable_tests=
983 excl_longrunning_tests=
984 excl_privileged_tests=
985 excl_unportable_tests=
986 single_configure=false
1004 while test $# -gt 0; do
1009 --find | --fin | --fi | --f )
1012 --import | --impor | --impo | --imp | --im | --i )
1015 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1018 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1021 --update | --updat | --upda | --upd | --up | --u )
1024 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1027 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1028 mode=create-megatestdir
1030 --test | --tes | --te | --t )
1033 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1037 mode=`echo "X$1" | sed -e 's/^X--//'`
1039 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1044 if test $# = 0; then
1045 func_fatal_error "missing argument for --dir"
1050 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1054 if test $# = 0; then
1055 func_fatal_error "missing argument for --local-dir"
1060 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1062 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1065 --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 )
1068 --verbose | --verbos | --verbo | --verb )
1069 verbose=`expr $verbose + 1`
1071 --quiet | --quie | --qui | --qu | --q )
1072 verbose=`expr $verbose - 1`
1076 if test $# = 0; then
1077 func_fatal_error "missing argument for --lib"
1080 supplied_libname=true
1083 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1084 supplied_libname=true
1088 if test $# = 0; then
1089 func_fatal_error "missing argument for --source-base"
1094 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1098 if test $# = 0; then
1099 func_fatal_error "missing argument for --m4-base"
1104 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1108 if test $# = 0; then
1109 func_fatal_error "missing argument for --po-base"
1114 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1118 if test $# = 0; then
1119 func_fatal_error "missing argument for --doc-base"
1124 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1128 if test $# = 0; then
1129 func_fatal_error "missing argument for --tests-base"
1134 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1138 if test $# = 0; then
1139 func_fatal_error "missing argument for --aux-dir"
1144 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1146 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1149 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1152 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1155 --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)
1156 inc_longrunning_tests=true
1158 --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)
1159 inc_privileged_tests=true
1161 --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)
1162 inc_unportable_tests=true
1164 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1167 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1170 --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)
1171 excl_longrunning_tests=true
1173 --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)
1174 excl_privileged_tests=true
1176 --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)
1177 excl_unportable_tests=true
1179 --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)
1180 single_configure=true
1184 if test $# = 0; then
1185 func_fatal_error "missing argument for --avoid"
1187 func_append avoidlist " $1"
1190 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1191 func_append avoidlist " $arg"
1193 --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)
1194 cond_dependencies=true
1196 --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)
1197 cond_dependencies=false
1203 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1206 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1212 if test $# = 0; then
1213 func_fatal_error "missing argument for --makefile-name"
1218 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1228 if test $# = 0; then
1229 func_fatal_error "missing argument for --macro-prefix"
1234 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1238 if test $# = 0; then
1239 func_fatal_error "missing argument for --po-domain"
1244 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1248 if test $# = 0; then
1249 func_fatal_error "missing argument for --witness-c-macro"
1251 witness_c_macro="$1"
1253 --witness-c-macro=* )
1254 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1262 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1268 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1271 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1274 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1278 --help | --hel | --he | --h )
1281 --version | --versio | --versi | --vers )
1285 # Stop option processing
1289 echo "gnulib-tool: unknown option $1" 1>&2
1290 echo "Try 'gnulib-tool --help' for more information." 1>&2
1297 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1298 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1299 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1300 || test "$single_configure" != false; then
1301 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1302 echo "Try 'gnulib-tool --help' for more information." 1>&2
1306 # This code helps migrating from --import to --add-import or --update. It can
1307 # be removed on 2012-01-01.
1308 if test "$mode" = import && test $# = 0; then
1309 echo "gnulib-tool: cowardly refusing to erase the module list." 1>&2
1310 echo "The meaning of the option '--import' has changed." 1>&2
1311 echo "See the documentation at" 1>&2
1312 echo "<http://www.gnu.org/software/gnulib/manual/html_node/Modified-imports.html>." 1>&2
1313 echo "For updating to a newer version of gnulib, use" 1>&2
1314 echo " gnulib-tool --add-import" 1>&2
1315 echo "For restoring files that were omitted from version control, use" 1>&2
1316 echo " gnulib-tool --update" 1>&2
1319 if test "$mode" = update; then
1320 if test $# != 0; then
1321 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1322 echo "Try 'gnulib-tool --help' for more information." 1>&2
1323 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1324 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1327 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1328 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1329 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1330 || test -n "$inctests" || test -n "$incobsolete" \
1331 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1332 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1333 || test -n "$inc_all_tests" \
1334 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1335 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1336 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1337 || test -n "$macro_prefix" || test -n "$po_domain" \
1338 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1339 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1340 echo "Try 'gnulib-tool --help' for more information." 1>&2
1341 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1342 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1347 if test -n "$pobase" && test -z "$po_domain"; then
1348 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1349 echo "Try 'gnulib-tool --help' for more information." 1>&2
1352 if test -z "$pobase" && test -n "$po_domain"; then
1353 func_warning "--po-domain has no effect without a --po-base option"
1355 if test "$cond_dependencies" = true && test -n "$inctests"; then
1356 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1360 # Determine the minimum supported autoconf version from the project's
1362 DEFAULT_AUTOCONF_MINVERSION="2.59"
1363 autoconf_minversion=
1365 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1366 && test -n "$destdir"; then
1367 if test -f "$destdir"/configure.ac; then
1368 configure_ac="$destdir/configure.ac"
1370 if test -f "$destdir"/configure.in; then
1371 configure_ac="$destdir/configure.in"
1375 if test -f configure.ac; then
1376 configure_ac="configure.ac"
1378 if test -f configure.in; then
1379 configure_ac="configure.in"
1383 if test -n "$configure_ac"; then
1384 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1385 # because when some m4 files are omitted from a version control repository,
1386 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1387 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1388 # autom4te: m4 failed with exit status: 1
1395 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1397 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1398 if test -n "$prereqs"; then
1399 autoconf_minversion=`
1400 for version in $prereqs; do echo $version; done |
1401 LC_ALL=C sort -nru | sed -e 1q
1405 if test -z "$autoconf_minversion"; then
1406 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1408 case "$autoconf_minversion" in
1409 1.* | 2.[0-4]* | 2.5[0-8]*)
1410 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1413 # Remove trailing slashes from the directory names. This is necessary for
1414 # m4base (to avoid an error in func_import) and optional for the others.
1415 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1416 case "$local_gnulib_dir" in
1417 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1419 case "$sourcebase" in
1420 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1423 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1426 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1429 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1431 case "$testsbase" in
1432 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1435 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1441 trap 'exit_status=$?
1442 if test "$signal" != 0; then
1443 echo "caught signal $signal" >&2
1446 exit $exit_status' 0
1447 for signal in 1 2 3 13 15; do
1448 trap '{ signal='$signal'; func_exit 1; }' $signal
1452 # Note: The 'eval' silences stderr output in dash.
1453 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1454 # Zsh 4 and Bash 4 have associative arrays.
1455 have_associative=true
1457 # For other shells, use 'eval' with computed shell variable names.
1458 have_associative=false
1461 # func_lookup_file file
1462 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1465 # - local_gnulib_dir from --local-dir
1467 # - lookedup_file name of the merged (combined) file
1468 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1472 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1473 lookedup_file="$local_gnulib_dir/$lkfile"
1476 if test -f "$gnulib_dir/$lkfile"; then
1477 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1478 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1479 rm -f "$tmp/$lkbase"
1480 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1481 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1482 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1483 lookedup_file="$tmp/$lkbase"
1486 lookedup_file="$gnulib_dir/$lkfile"
1490 func_fatal_error "file $gnulib_dir/$lkfile not found"
1495 # func_sanitize_modulelist
1496 # receives a list of possible module names on standard input, one per line.
1497 # It removes those which are just file names unrelated to modules, and outputs
1498 # the resulting list to standard output, one per line.
1499 func_sanitize_modulelist ()
1501 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1502 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1503 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1504 -e '/^README$/d' -e '/\/README$/d' \
1505 -e '/^TEMPLATE$/d' \
1506 -e '/^TEMPLATE-EXTENDED$/d' \
1507 -e '/^TEMPLATE-TESTS$/d' \
1514 # - local_gnulib_dir from --local-dir
1517 # Filter out metainformation files like README, which are not modules.
1518 # Filter out unit test modules; they can be retrieved through
1519 # --extract-tests-module if desired.
1521 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1522 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1523 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1526 | func_sanitize_modulelist \
1527 | sed -e '/-tests$/d' \
1531 # func_exists_module module
1532 # tests whether a module, given by name, exists
1534 # - local_gnulib_dir from --local-dir
1535 func_exists_module ()
1537 { test -f "$gnulib_dir/modules/$1" \
1538 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1539 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1540 && test "CVS" != "$1" \
1541 && test "ChangeLog" != "$1" \
1542 && test "COPYING" != "$1" \
1543 && test "README" != "$1" \
1544 && test "TEMPLATE" != "$1" \
1545 && test "TEMPLATE-EXTENDED" != "$1" \
1546 && test "TEMPLATE-TESTS" != "$1"
1549 # func_verify_module
1550 # verifies a module name
1552 # - local_gnulib_dir from --local-dir
1553 # - module module name argument
1554 func_verify_module ()
1556 if func_exists_module "$module"; then
1557 # OK, $module is a correct module name.
1558 # Verify that building the module description with 'patch' succeeds.
1559 func_lookup_file "modules/$module"
1561 func_warning "module $module doesn't exist"
1566 # func_verify_nontests_module
1567 # verifies a module name, excluding tests modules
1569 # - local_gnulib_dir from --local-dir
1570 # - module module name argument
1571 func_verify_nontests_module ()
1574 *-tests ) module= ;;
1575 * ) func_verify_module ;;
1579 # func_verify_tests_module
1580 # verifies a module name, considering only tests modules
1582 # - local_gnulib_dir from --local-dir
1583 # - module module name argument
1584 func_verify_tests_module ()
1587 *-tests ) func_verify_module ;;
1592 # Suffix of a sed expression that extracts a particular field from a
1593 # module description.
1594 # A field starts with a line that contains a keyword, such as 'Description',
1595 # followed by a colon and optional whitespace. All following lines, up to
1596 # the next field (or end of file if there is none) form the contents of the
1598 # An absent field is equivalent to a field with empty contents.
1599 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1600 sed_extract_prog=':[ ]*$/ {
1603 s/^Description:[ ]*$//
1607 s/^Applicability:[ ]*$//
1609 s/^Depends-on:[ ]*$//
1610 s/^configure\.ac-early:[ ]*$//
1611 s/^configure\.ac:[ ]*$//
1612 s/^Makefile\.am:[ ]*$//
1616 s/^Maintainer:[ ]*$//
1623 # Piece of a sed expression that converts a field header line to a shell
1625 # NOTE: Keep this in sync with sed_extract_prog above!
1626 sed_extract_field_header='
1627 s/^Description:[ ]*$/description/
1628 s/^Comment:[ ]*$/comment/
1629 s/^Status:[ ]*$/status/
1630 s/^Notice:[ ]*$/notice/
1631 s/^Applicability:[ ]*$/applicability/
1632 s/^Files:[ ]*$/files/
1633 s/^Depends-on:[ ]*$/dependson/
1634 s/^configure\.ac-early:[ ]*$/configureac_early/
1635 s/^configure\.ac:[ ]*$/configureac/
1636 s/^Makefile\.am:[ ]*$/makefile/
1637 s/^Include:[ ]*$/include/
1639 s/^License:[ ]*$/license/
1640 s/^Maintainer:[ ]*$/maintainer/'
1644 if $have_associative; then
1646 # Declare the associative arrays.
1647 declare -A modcache_cached
1648 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1649 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1650 eval "$declare_script"
1654 # func_cache_var module
1655 # computes the cache variable name corresponding to $module.
1656 # Note: This computation can map different module names to the same
1657 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1658 # to protect against this case.
1660 # - cachevar a shell variable name
1661 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1662 # Bash 2.0 and newer, ksh, and zsh support the syntax
1663 # ${param//pattern/replacement}
1664 # as a shorthand for
1665 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1666 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1667 eval 'func_cache_var ()
1669 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1676 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1685 # func_init_sed_convert_to_cache_statements
1687 # - modcachevar_assignment
1689 # - sed_convert_to_cache_statements
1690 func_init_sed_convert_to_cache_statements ()
1692 # 'sed' script that turns a module description into shell script
1693 # assignments, suitable to be eval'ed. All active characters are escaped.
1696 # Some module's description
1701 # modcache_description[$1]=\
1702 # 'Some module'"'"'s description
1704 # modcache_files[$1]=\
1707 # c_MODULE_description_set=set; c_MODULE_description=\
1708 # 'Some module'"'"'s description
1710 # c_MODULE_files_set=set; c_MODULE_files=\
1712 # The script consists of two parts:
1713 # 1) Ignore the lines before the first field header.
1714 # 2) A loop, treating non-field-header lines by escaping single quotes
1715 # and adding a closing quote in the last line,
1716 sed_convert_to_cache_statements="
1718 # Here we have not yet seen a field header.
1720 # See if the current line contains a field header.
1723 ${sed_extract_field_header}
1726 # No field header. Ignore the line.
1728 # Read the next line. Upon EOF, just exit.
1733 # The current line contains a field header.
1735 # Turn it into the beginning of an assignment.
1736 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1738 # Move it to the hold space. Don't print it yet,
1739 # because we want no assignment if the field is empty.
1742 # Read the next line.
1743 # Upon EOF, the field was empty. Print no assignment. Just exit.
1746 # See if the current line contains a field header.
1749 ${sed_extract_field_header}
1750 # If it is, the previous field was empty. Print no assignment.
1753 # Not a field header.
1755 # Print the previous line, held in the hold space.
1760 # Transform single quotes.
1763 # Prepend a single quote.
1768 # Move it to the hold space.
1771 # Read the next line.
1778 # See if the current line contains a field header.
1781 ${sed_extract_field_header}
1784 # Print the previous line, held in the hold space.
1789 # Transform single quotes.
1796 # Print the previous line, held in the hold space, with a single quote
1797 # to end the assignment.
1807 # Print the previous line, held in the hold space, with a single quote
1808 # to end the assignment.
1815 if ! $sed_comments; then
1817 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1818 | sed -e 's/^ *//' -e 's/^#.*//'`
1822 if $have_associative; then
1823 # sed_convert_to_cache_statements does not depend on the module.
1824 modcachevar_assignment='modcache_\1[$1]='
1825 func_init_sed_convert_to_cache_statements
1828 # func_cache_lookup_module module
1830 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1831 # of its relevant data in a cache in the memory of the processing shell. If
1832 # already cached, it does not look it up again, thus saving file access time.
1834 # - module non-empty string
1835 # Output if $have_associative:
1836 # - modcache_cached[$module] set to yes
1837 # - modcache_description[$module] ==
1838 # - modcache_status[$module] \ set to the field's value, minus the
1839 # - ... / final newline,
1840 # - modcache_maintainer[$module] == or unset if the field's value is empty
1841 # Output if ! $have_associative:
1842 # - cachevar a shell variable name
1843 # - ${cachevar}_cached set to $module
1844 # - ${cachevar}_description ==
1845 # - ${cachevar}_status \ set to the field's value, minus the
1846 # - ... / final newline,
1847 # - ${cachevar}_maintainer == or unset if the field's value is empty
1848 # - ${cachevar}_description_set ==
1849 # - ${cachevar}_status_set \ set to non-empty if the field's value
1850 # - ... / is non-empty,
1851 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1852 func_cache_lookup_module ()
1854 if $have_associative; then
1855 eval 'cached=${modcache_cached[$1]}'
1858 eval "cached=\"\$${cachevar}_cached\""
1860 if test -z "$cached"; then
1861 # Not found in cache. Look it up on the file system.
1862 func_lookup_file "modules/$1"
1863 if $have_associative; then
1864 eval 'modcache_cached[$1]=yes'
1866 eval "${cachevar}_cached=\"\$1\""
1868 if ! $have_associative; then
1869 # sed_convert_to_cache_statements depends on the module.
1870 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1871 func_init_sed_convert_to_cache_statements
1873 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1874 eval "$cache_statements"
1876 if ! $have_associative; then
1877 if test "$1" != "$cached"; then
1878 func_fatal_error "cache variable collision between $1 and $cached"
1886 # func_get_description module
1888 # - local_gnulib_dir from --local-dir
1889 # - modcache true or false, from --cache-modules/--no-cache-modules
1890 func_get_description ()
1892 if ! $modcache; then
1893 func_lookup_file "modules/$1"
1894 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1896 func_cache_lookup_module "$1"
1897 # Output the field's value, including the final newline (if any).
1898 if $have_associative; then
1899 if eval 'test -n "${modcache_description[$1]+set}"'; then
1900 eval 'echo "${modcache_description[$1]}"'
1903 eval "field_set=\"\$${cachevar}_description_set\""
1904 if test -n "$field_set"; then
1905 eval "field_value=\"\$${cachevar}_description\""
1906 echo "${field_value}"
1912 # func_get_comment module
1914 # - local_gnulib_dir from --local-dir
1915 # - modcache true or false, from --cache-modules/--no-cache-modules
1918 if ! $modcache; then
1919 func_lookup_file "modules/$1"
1920 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1922 func_cache_lookup_module "$1"
1923 # Output the field's value, including the final newline (if any).
1924 if $have_associative; then
1925 if eval 'test -n "${modcache_comment[$1]+set}"'; then
1926 eval 'echo "${modcache_comment[$1]}"'
1929 eval "field_set=\"\$${cachevar}_comment_set\""
1930 if test -n "$field_set"; then
1931 eval "field_value=\"\$${cachevar}_comment\""
1932 echo "${field_value}"
1938 # func_get_status module
1940 # - local_gnulib_dir from --local-dir
1941 # - modcache true or false, from --cache-modules/--no-cache-modules
1944 if ! $modcache; then
1945 func_lookup_file "modules/$1"
1946 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1948 func_cache_lookup_module "$1"
1949 # Output the field's value, including the final newline (if any).
1950 if $have_associative; then
1951 if eval 'test -n "${modcache_status[$1]+set}"'; then
1952 eval 'echo "${modcache_status[$1]}"'
1955 eval "field_set=\"\$${cachevar}_status_set\""
1956 if test -n "$field_set"; then
1957 eval "field_value=\"\$${cachevar}_status\""
1958 echo "${field_value}"
1964 # func_get_notice module
1966 # - local_gnulib_dir from --local-dir
1967 # - modcache true or false, from --cache-modules/--no-cache-modules
1970 if ! $modcache; then
1971 func_lookup_file "modules/$1"
1972 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1974 func_cache_lookup_module "$1"
1975 # Output the field's value, including the final newline (if any).
1976 if $have_associative; then
1977 if eval 'test -n "${modcache_notice[$1]+set}"'; then
1978 eval 'echo "${modcache_notice[$1]}"'
1981 eval "field_set=\"\$${cachevar}_notice_set\""
1982 if test -n "$field_set"; then
1983 eval "field_value=\"\$${cachevar}_notice\""
1984 echo "${field_value}"
1990 # func_get_applicability module
1992 # - local_gnulib_dir from --local-dir
1993 # - modcache true or false, from --cache-modules/--no-cache-modules
1994 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1995 func_get_applicability ()
1997 if ! $modcache; then
1998 func_lookup_file "modules/$1"
1999 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2001 func_cache_lookup_module "$1"
2002 # Get the field's value, without the final newline.
2003 if $have_associative; then
2004 eval 'my_applicability="${modcache_applicability[$1]}"'
2006 eval "my_applicability=\"\$${cachevar}_applicability\""
2009 if test -n "$my_applicability"; then
2010 echo $my_applicability
2012 # The default is 'main' or 'tests', depending on the module's name.
2014 *-tests) echo "tests";;
2020 # func_get_filelist module
2022 # - local_gnulib_dir from --local-dir
2023 # - modcache true or false, from --cache-modules/--no-cache-modules
2024 func_get_filelist ()
2026 if ! $modcache; then
2027 func_lookup_file "modules/$1"
2028 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2030 func_cache_lookup_module "$1"
2031 # Output the field's value, including the final newline (if any).
2032 if $have_associative; then
2033 if eval 'test -n "${modcache_files[$1]+set}"'; then
2034 eval 'echo "${modcache_files[$1]}"'
2037 eval "field_set=\"\$${cachevar}_files_set\""
2038 if test -n "$field_set"; then
2039 eval "field_value=\"\$${cachevar}_files\""
2040 echo "${field_value}"
2045 echo m4/gnulib-common.m4
2046 case "$autoconf_minversion" in
2053 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2054 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2055 # elements starting with prefix and ending with suffix are considered.
2056 # Processing: removed_prefix and removed_suffix are removed from each element,
2057 # added_prefix and added_suffix are added to each element.
2058 # prefix, suffix should not contain shell-special characters.
2059 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2060 # added_prefix, added_suffix should not contain the characters \|&.
2061 func_filter_filelist ()
2063 if test "$2" != "$nl" \
2064 || { $fast_func_append \
2065 && { test -z "$6" || $fast_func_remove_prefix; } \
2066 && { test -z "$7" || $fast_func_remove_suffix; }; \
2070 # Do not quote possibly-empty parameters in case patterns,
2071 # AIX and HP-UX ksh won't match them if they are empty.
2074 if test -n "$6"; then
2075 func_remove_prefix fff "$6"
2077 if test -n "$7"; then
2078 func_remove_suffix fff "$7"
2081 if test -z "$ffflist"; then
2084 func_append ffflist "$2${fff}"
2090 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2091 ffflist=`for fff in $3; do
2093 $4*$5) echo "$fff" ;;
2095 done | sed -e "$sed_fff_filter"`
2097 eval "$1=\"\$ffflist\""
2100 # func_get_dependencies module
2102 # - local_gnulib_dir from --local-dir
2103 # - modcache true or false, from --cache-modules/--no-cache-modules
2104 func_get_dependencies ()
2106 # ${module}-tests implicitly depends on ${module}, if that module exists.
2110 func_remove_suffix fgd1 '-tests'
2111 if func_exists_module "$fgd1"; then
2116 # Then the explicit dependencies listed in the module description.
2117 { if ! $modcache; then
2118 func_lookup_file "modules/$1"
2119 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2121 func_cache_lookup_module "$1"
2122 # Output the field's value, including the final newline (if any).
2123 if $have_associative; then
2124 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2125 eval 'echo "${modcache_dependson[$1]}"'
2128 eval "field_set=\"\$${cachevar}_dependson_set\""
2129 if test -n "$field_set"; then
2130 eval "field_value=\"\$${cachevar}_dependson\""
2131 echo "${field_value}"
2139 # func_get_autoconf_early_snippet module
2141 # - local_gnulib_dir from --local-dir
2142 # - modcache true or false, from --cache-modules/--no-cache-modules
2143 func_get_autoconf_early_snippet ()
2145 if ! $modcache; then
2146 func_lookup_file "modules/$1"
2147 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2149 func_cache_lookup_module "$1"
2150 # Output the field's value, including the final newline (if any).
2151 if $have_associative; then
2152 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2153 eval 'echo "${modcache_configureac_early[$1]}"'
2156 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2157 if test -n "$field_set"; then
2158 eval "field_value=\"\$${cachevar}_configureac_early\""
2159 echo "${field_value}"
2165 # func_get_autoconf_snippet module
2167 # - local_gnulib_dir from --local-dir
2168 # - modcache true or false, from --cache-modules/--no-cache-modules
2169 func_get_autoconf_snippet ()
2171 if ! $modcache; then
2172 func_lookup_file "modules/$1"
2173 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2175 func_cache_lookup_module "$1"
2176 # Output the field's value, including the final newline (if any).
2177 if $have_associative; then
2178 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2179 eval 'echo "${modcache_configureac[$1]}"'
2182 eval "field_set=\"\$${cachevar}_configureac_set\""
2183 if test -n "$field_set"; then
2184 eval "field_value=\"\$${cachevar}_configureac\""
2185 echo "${field_value}"
2191 # func_get_automake_snippet_conditional module
2192 # returns the part of the Makefile.am snippet that can be put inside Automake
2195 # - local_gnulib_dir from --local-dir
2196 # - modcache true or false, from --cache-modules/--no-cache-modules
2197 func_get_automake_snippet_conditional ()
2199 if ! $modcache; then
2200 func_lookup_file "modules/$1"
2201 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2203 func_cache_lookup_module "$1"
2204 # Output the field's value, including the final newline (if any).
2205 if $have_associative; then
2206 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2207 eval 'echo "${modcache_makefile[$1]}"'
2210 eval "field_set=\"\$${cachevar}_makefile_set\""
2211 if test -n "$field_set"; then
2212 eval "field_value=\"\$${cachevar}_makefile\""
2213 echo "${field_value}"
2219 # func_get_automake_snippet_unconditional module
2220 # returns the part of the Makefile.am snippet that must stay outside of
2221 # Automake conditionals.
2223 # - local_gnulib_dir from --local-dir
2224 # - modcache true or false, from --cache-modules/--no-cache-modules
2225 func_get_automake_snippet_unconditional ()
2229 # *-tests module live in tests/, not lib/.
2230 # Synthesize an EXTRA_DIST augmentation.
2231 all_files=`func_get_filelist $1`
2232 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2233 extra_files="$tests_files"
2234 if test -n "$extra_files"; then
2235 echo "EXTRA_DIST +=" $extra_files
2240 # Synthesize an EXTRA_DIST augmentation.
2241 sed_combine_lines='/\\$/{
2248 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2249 already_mentioned_files=` \
2250 { if ! $modcache; then
2251 func_lookup_file "modules/$1"
2252 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2254 func_cache_lookup_module "$1"
2255 if $have_associative; then
2256 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2257 eval 'echo "${modcache_makefile[$1]}"'
2260 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2261 if test -n "$field_set"; then
2262 eval 'field_value="$'"${cachevar}"'_makefile"'
2263 echo "${field_value}"
2268 | sed -e "$sed_combine_lines" \
2269 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2270 all_files=`func_get_filelist $1`
2271 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2272 # Remove $already_mentioned_files from $lib_files.
2273 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2274 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2275 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2276 if test -n "$extra_files"; then
2277 echo "EXTRA_DIST +=" $extra_files
2280 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2281 # This is necessary so that automake can generate the right list of
2283 # A possible approach would be to use autom4te --trace of the redefined
2284 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2285 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2286 # inside autoconf's built-in macros are not missed).
2287 # But it's simpler and more robust to do it here, based on the file list.
2288 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2289 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2290 # automake will generate a useless dependency; this is harmless.
2292 relocatable-prog-wrapper) ;;
2295 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2296 if test -n "$extra_files"; then
2297 echo "EXTRA_lib_SOURCES +=" $extra_files
2302 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2303 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2304 if test -n "$buildaux_files"; then
2305 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2306 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2309 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2310 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2311 if test -n "$top_files"; then
2312 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2313 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2320 # func_get_automake_snippet module
2322 # - local_gnulib_dir from --local-dir
2323 # - modcache true or false, from --cache-modules/--no-cache-modules
2324 func_get_automake_snippet ()
2326 func_get_automake_snippet_conditional "$1"
2327 func_get_automake_snippet_unconditional "$1"
2330 # func_get_include_directive module
2332 # - local_gnulib_dir from --local-dir
2333 # - modcache true or false, from --cache-modules/--no-cache-modules
2334 func_get_include_directive ()
2337 if ! $modcache; then
2338 func_lookup_file "modules/$1"
2339 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2341 func_cache_lookup_module "$1"
2342 # Output the field's value, including the final newline (if any).
2343 if $have_associative; then
2344 if eval 'test -n "${modcache_include[$1]+set}"'; then
2345 eval 'echo "${modcache_include[$1]}"'
2348 eval "field_set=\"\$${cachevar}_include_set\""
2349 if test -n "$field_set"; then
2350 eval "field_value=\"\$${cachevar}_include\""
2351 echo "${field_value}"
2355 } | sed -e 's/^\(["<]\)/#include \1/'
2358 # func_get_link_directive module
2360 # - local_gnulib_dir from --local-dir
2361 # - modcache true or false, from --cache-modules/--no-cache-modules
2362 func_get_link_directive ()
2364 if ! $modcache; then
2365 func_lookup_file "modules/$1"
2366 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2368 func_cache_lookup_module "$1"
2369 # Output the field's value, including the final newline (if any).
2370 if $have_associative; then
2371 if eval 'test -n "${modcache_link[$1]+set}"'; then
2372 eval 'echo "${modcache_link[$1]}"'
2375 eval "field_set=\"\$${cachevar}_link_set\""
2376 if test -n "$field_set"; then
2377 eval "field_value=\"\$${cachevar}_link\""
2378 echo "${field_value}"
2384 # func_get_license_raw module
2386 # - local_gnulib_dir from --local-dir
2387 # - modcache true or false, from --cache-modules/--no-cache-modules
2388 func_get_license_raw ()
2390 if ! $modcache; then
2391 func_lookup_file "modules/$1"
2392 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2394 func_cache_lookup_module "$1"
2395 # Output the field's value, including the final newline (if any).
2396 if $have_associative; then
2397 if eval 'test -n "${modcache_license[$1]+set}"'; then
2398 eval 'echo "${modcache_license[$1]}"'
2401 eval "field_set=\"\$${cachevar}_license_set\""
2402 if test -n "$field_set"; then
2403 eval "field_value=\"\$${cachevar}_license\""
2404 echo "${field_value}"
2410 # func_get_license module
2412 # - local_gnulib_dir from --local-dir
2413 # - modcache true or false, from --cache-modules/--no-cache-modules
2416 # Warn if the License field is missing.
2420 license=`func_get_license_raw "$1"`
2421 if test -z "$license"; then
2422 func_warning "module $1 lacks a License"
2427 func_get_license_raw "$1"
2428 # The default is GPL.
2430 } | sed -e 's,^ *$,,' | sed -e 1q
2433 # func_get_maintainer module
2435 # - local_gnulib_dir from --local-dir
2436 # - modcache true or false, from --cache-modules/--no-cache-modules
2437 func_get_maintainer ()
2439 if ! $modcache; then
2440 func_lookup_file "modules/$1"
2441 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2443 func_cache_lookup_module "$1"
2444 # Output the field's value, including the final newline (if any).
2445 if $have_associative; then
2446 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2447 eval 'echo "${modcache_maintainer[$1]}"'
2450 eval "field_set=\"\$${cachevar}_maintainer_set\""
2451 if test -n "$field_set"; then
2452 eval "field_value=\"\$${cachevar}_maintainer\""
2453 echo "${field_value}"
2459 # func_get_tests_module module
2461 # - local_gnulib_dir from --local-dir
2462 func_get_tests_module ()
2464 # The naming convention for tests modules is hardwired: ${module}-tests.
2465 if test -f "$gnulib_dir/modules/$1"-tests \
2466 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2467 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2472 # func_acceptable module
2473 # tests whether a module is acceptable.
2475 # - avoidlist list of modules to avoid
2478 for avoid in $avoidlist; do
2479 if test "$avoid" = "$1"; then
2486 # sed expression to keep the first 32 characters of each line.
2487 sed_first_32_chars='s/^\(................................\).*/\1/'
2489 # func_module_shellfunc_name module
2490 # computes the shell function name that will contain the m4 macros for the module.
2492 # - macro_prefix prefix to use
2494 # - shellfunc shell function name
2495 func_module_shellfunc_name ()
2499 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2501 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2505 # func_module_shellvar_name module
2506 # computes the shell variable name the will be set to true once the m4 macros
2507 # for the module have been executed.
2509 # - shellvar shell variable name
2510 func_module_shellvar_name ()
2514 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2516 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2520 # func_module_conditional_name module
2521 # computes the automake conditional name for the module.
2523 # - conditional name of automake conditional
2524 func_module_conditional_name ()
2528 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2530 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2534 # func_uncond_add_module B
2535 # notes the presence of B as an unconditional module.
2537 # func_conddep_add_module A B cond
2538 # notes the presence of a conditional dependency from module A to module B,
2539 # subject to the condition that A is enabled and cond is true.
2541 # func_cond_module_p B
2542 # tests whether module B is conditional.
2544 # func_cond_module_condition A B
2545 # returns the condition when B should be enabled as a dependency of A, once the
2546 # m4 code for A has been executed.
2547 # Output: - condition
2549 if $have_associative; then
2550 declare -A conddep_isuncond
2551 declare -A conddep_dependers
2552 declare -A conddep_condition
2553 func_uncond_add_module ()
2555 eval 'conddep_isuncond[$1]=true'
2556 eval 'unset conddep_dependers[$1]'
2558 func_conddep_add_module ()
2560 eval 'isuncond="${conddep_isuncond[$2]}"'
2561 if test -z "$isuncond"; then
2562 # No unconditional dependency to B known at this point.
2563 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2564 eval 'conddep_condition[$1---$2]="$3"'
2567 func_cond_module_p ()
2569 eval 'previous_dependers="${conddep_dependers[$1]}"'
2570 test -n "$previous_dependers"
2572 func_cond_module_condition ()
2574 eval 'condition="${conddep_condition[$1---$2]}"'
2577 func_uncond_add_module ()
2581 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2585 eval 'conddep_isuncond_'"$suffix"'=true'
2586 eval 'unset conddep_dependers_'"$suffix"
2588 func_conddep_add_module ()
2592 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2596 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2597 if test -z "$isuncond"; then
2598 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2599 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2600 eval 'conddep_condition_'"$suffix"'="$3"'
2603 func_cond_module_p ()
2607 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2611 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2612 test -n "$previous_dependers"
2614 func_cond_module_condition ()
2616 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2617 eval 'condition="${conddep_condition_'"$suffix"'}"'
2621 sed_dependencies_without_conditions='s/ *\[.*//'
2623 # func_modules_transitive_closure
2625 # - local_gnulib_dir from --local-dir
2626 # - modcache true or false, from --cache-modules/--no-cache-modules
2627 # - modules list of specified modules
2628 # - inctests true if tests should be included, blank otherwise
2629 # - incobsolete true if obsolete modules among dependencies should be
2630 # included, blank otherwise
2631 # - inc_cxx_tests true if C++ interoperability tests should be included,
2633 # - inc_longrunning_tests true if long-runnings tests should be included,
2635 # - inc_privileged_tests true if tests that require root privileges should be
2636 # included, blank otherwise
2637 # - inc_unportable_tests true if tests that fail on some platforms should be
2638 # included, blank otherwise
2639 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2640 # the unit tests of the specified modules should be
2641 # included, blank otherwise
2642 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2643 # the unit tests of the dependencies should be
2644 # included, blank otherwise
2645 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2647 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2649 # - excl_privileged_tests true if tests that require root privileges should be
2650 # excluded, blank otherwise
2651 # - excl_unportable_tests true if tests that fail on some platforms should be
2652 # excluded, blank otherwise
2653 # - avoidlist list of modules to avoid
2654 # - cond_dependencies true if conditional dependencies shall be supported,
2656 # - tmp pathname of a temporary directory
2658 # - modules list of modules, including dependencies
2659 # - conddep_dependers, conddep_condition information about conditionally
2661 func_modules_transitive_closure ()
2663 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2664 # In order to process every module only once (for speed), process an "input
2665 # list" of modules, producing an "output list" of modules. During each round,
2666 # more modules can be queued in the input list. Once a module on the input
2667 # list has been processed, it is added to the "handled list", so we can avoid
2668 # to process it again.
2670 inmodules="$modules"
2672 fmtc_inc_all_tests="$inc_all_direct_tests"
2673 if test "$cond_dependencies" = true; then
2674 for module in $inmodules; do
2676 if test -n "$module"; then
2677 if func_acceptable $module; then
2678 func_uncond_add_module $module
2683 while test -n "$inmodules"; do
2684 inmodules_this_round="$inmodules"
2685 inmodules= # Accumulator, queue for next round
2686 for module in $inmodules_this_round; do
2688 if test -n "$module"; then
2689 if func_acceptable $module; then
2690 func_append outmodules " $module"
2691 if test "$cond_dependencies" = true; then
2692 if func_get_automake_snippet_conditional $module | grep '^if ' > /dev/null; then
2693 # A module whose Makefile.am snippet contains a reference to an
2694 # automake conditional. If we were to use it conditionally, we
2695 # would get an error
2696 # configure: error: conditional "..." was never defined.
2697 # because automake 1.11.1 does not handle nested conditionals
2698 # correctly. As a workaround, make the module unconditional.
2699 func_uncond_add_module $module
2701 if func_cond_module_p $module; then
2707 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2708 # Duplicate dependencies are harmless, but Jim wants a warning.
2709 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2710 if test -n "$duplicated_deps"; then
2711 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2713 if test -n "$inctests"; then
2714 testsmodule=`func_get_tests_module $module`
2715 if test -n "$testsmodule"; then
2716 deps="$deps $testsmodule"
2719 for dep in $deps; do
2720 # Determine whether to include the dependency or tests module.
2722 for word in `func_get_status $dep`; do
2725 test -n "$incobsolete" \
2729 test -z "$excl_cxx_tests" \
2731 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2735 test -z "$excl_longrunning_tests" \
2737 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2741 test -z "$excl_privileged_tests" \
2743 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2747 test -z "$excl_unportable_tests" \
2749 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2753 test -n "$fmtc_inc_all_tests" \
2758 if $inc && func_acceptable "$dep"; then
2759 func_append inmodules " $dep"
2760 if test "$cond_dependencies" = true; then
2761 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2762 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2765 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2766 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2768 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2769 if test "$condition" = true; then
2772 if test -n "$condition"; then
2773 func_conddep_add_module "$module" "$dep" "$condition"
2775 if $conditional; then
2776 func_conddep_add_module "$module" "$dep" true
2778 func_uncond_add_module "$dep"
2787 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2788 # Remove $handledmodules from $inmodules.
2789 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2790 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2791 fmtc_inc_all_tests="$inc_all_indirect_tests"
2793 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2794 rm -f "$tmp"/queued-modules
2797 # func_show_module_list
2799 # - specified_modules list of specified modules (one per line, sorted)
2800 # - modules complete list of modules (one per line, sorted)
2801 # - tmp pathname of a temporary directory
2802 func_show_module_list ()
2808 # Assume xterm compatible escape sequences.
2809 bold_on=`printf '\x1b[1m'`
2810 bold_off=`printf '\x1b[0m'`
2815 echo "Module list with included dependencies (indented):"
2816 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2817 echo "$modules" | sed -e '/^$/d' \
2818 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2819 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2822 # func_modules_transitive_closure_separately
2823 # Determine main module list and tests-related module list separately.
2824 # The main module list is the transitive closure of the specified modules,
2825 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2826 # is specified, it will consist only of LGPLed source.
2827 # The tests-related module list is the transitive closure of the specified
2828 # modules, including tests modules, minus the main module list excluding
2829 # modules of applicability 'all'. Its lib/* sources (brought in through
2830 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2831 # source, even if --lgpl is specified.
2833 # - local_gnulib_dir from --local-dir
2834 # - modcache true or false, from --cache-modules/--no-cache-modules
2835 # - specified_modules list of specified modules
2836 # - inctests true if tests should be included, blank otherwise
2837 # - incobsolete true if obsolete modules among dependencies should be
2838 # included, blank otherwise
2839 # - inc_cxx_tests true if C++ interoperability tests should be included,
2841 # - inc_longrunning_tests true if long-runnings tests should be included,
2843 # - inc_privileged_tests true if tests that require root privileges should be
2844 # included, blank otherwise
2845 # - inc_unportable_tests true if tests that fail on some platforms should be
2846 # included, blank otherwise
2847 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2848 # the unit tests of the specified modules should be
2849 # included, blank otherwise
2850 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2851 # the unit tests of the dependencies should be
2852 # included, blank otherwise
2853 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2855 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2857 # - excl_privileged_tests true if tests that require root privileges should be
2858 # excluded, blank otherwise
2859 # - excl_unportable_tests true if tests that fail on some platforms should be
2860 # excluded, blank otherwise
2861 # - avoidlist list of modules to avoid
2862 # - cond_dependencies true if conditional dependencies shall be supported,
2864 # - tmp pathname of a temporary directory
2866 # - main_modules list of modules, including dependencies
2867 # - testsrelated_modules list of tests-related modules, including dependencies
2868 # - conddep_dependers, conddep_condition information about conditionally
2870 func_modules_transitive_closure_separately ()
2872 # Determine main module list.
2873 saved_inctests="$inctests"
2875 modules="$specified_modules"
2876 func_modules_transitive_closure
2877 main_modules="$modules"
2878 inctests="$saved_inctests"
2879 if test $verbose -ge 1; then
2880 echo "Main module list:"
2881 echo "$main_modules" | sed -e 's/^/ /'
2883 # Determine tests-related module list.
2884 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2885 testsrelated_modules=`for module in $main_modules; do
2886 if test \`func_get_applicability $module\` = main; then
2890 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2891 if test $verbose -ge 1; then
2892 echo "Tests-related module list:"
2893 echo "$testsrelated_modules" | sed -e 's/^/ /'
2897 # func_determine_use_libtests
2898 # Determines whether a $testsbase/libtests.a is needed.
2900 # - local_gnulib_dir from --local-dir
2901 # - modcache true or false, from --cache-modules/--no-cache-modules
2902 # - testsrelated_modules list of tests-related modules, including dependencies
2904 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2905 func_determine_use_libtests ()
2908 for module in $testsrelated_modules; do
2909 func_verify_nontests_module
2910 if test -n "$module"; then
2911 all_files=`func_get_filelist $module`
2912 # Test whether some file in $all_files lies in lib/.
2913 for f in $all_files; do
2925 # func_modules_add_dummy
2927 # - local_gnulib_dir from --local-dir
2928 # - modcache true or false, from --cache-modules/--no-cache-modules
2929 # - modules list of modules, including dependencies
2931 # - modules list of modules, including 'dummy' if needed
2932 func_modules_add_dummy ()
2934 # Determine whether any module provides a lib_SOURCES augmentation.
2936 sed_remove_backslash_newline=':a
2943 for module in $modules; do
2944 func_verify_nontests_module
2945 if test -n "$module"; then
2946 # Extract the value of "lib_SOURCES += ...".
2947 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2948 # Ignore .h files since they are not compiled.
2952 have_lib_SOURCES=yes
2959 # Add the dummy module, to make sure the library will be non-empty.
2960 if test -z "$have_lib_SOURCES"; then
2961 if func_acceptable "dummy"; then
2962 func_append modules " dummy"
2967 # func_modules_add_dummy_separately
2969 # - local_gnulib_dir from --local-dir
2970 # - modcache true or false, from --cache-modules/--no-cache-modules
2971 # - main_modules list of modules, including dependencies
2972 # - testsrelated_modules list of tests-related modules, including dependencies
2973 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2975 # - main_modules list of modules, including 'dummy' if needed
2976 # - testsrelated_modules list of tests-related modules, including 'dummy' if
2978 func_modules_add_dummy_separately ()
2980 # Add the dummy module to the main module list if needed.
2981 modules="$main_modules"
2982 func_modules_add_dummy
2983 main_modules="$modules"
2985 # Add the dummy module to the tests-related module list if needed.
2986 if $use_libtests; then
2987 modules="$testsrelated_modules"
2988 func_modules_add_dummy
2989 testsrelated_modules="$modules"
2993 # func_modules_notice
2995 # - local_gnulib_dir from --local-dir
2996 # - modcache true or false, from --cache-modules/--no-cache-modules
2997 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2998 # - modules list of modules, including dependencies
2999 func_modules_notice ()
3001 if test $verbose -ge -1; then
3002 for module in $modules; do
3004 if test -n "$module"; then
3005 msg=`func_get_notice $module`
3006 if test -n "$msg"; then
3007 echo "Notice from module $module:"
3008 echo "$msg" | sed -e 's/^/ /'
3015 # func_modules_to_filelist
3017 # - local_gnulib_dir from --local-dir
3018 # - modcache true or false, from --cache-modules/--no-cache-modules
3019 # - modules list of modules, including dependencies
3021 # - files list of files
3022 func_modules_to_filelist ()
3025 for module in $modules; do
3027 if test -n "$module"; then
3028 fs=`func_get_filelist $module`
3029 func_append files " $fs"
3032 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3035 # func_modules_to_filelist_separately
3036 # Determine the final file lists.
3037 # They must be computed separately, because files in lib/* go into
3038 # $sourcebase/ if they are in the main file list but into $testsbase/
3039 # if they are in the tests-related file list. Furthermore lib/dummy.c
3042 # - local_gnulib_dir from --local-dir
3043 # - modcache true or false, from --cache-modules/--no-cache-modules
3044 # - main_modules list of modules, including dependencies
3045 # - testsrelated_modules list of tests-related modules, including dependencies
3046 func_modules_to_filelist_separately ()
3048 # Determine final main file list.
3049 modules="$main_modules"
3050 func_modules_to_filelist
3052 # Determine final tests-related file list.
3053 modules="$testsrelated_modules"
3054 func_modules_to_filelist
3055 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3056 # Merge both file lists.
3057 sed_remove_empty_lines='/^$/d'
3058 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3059 if test $verbose -ge 0; then
3061 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3062 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3066 # func_compute_include_guard_prefix
3067 # Determine include_guard_prefix.
3069 # - macro_prefix prefix of gl_LIBOBJS macros to use
3071 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3072 # - sed_replace_include_guard_prefix
3073 # sed expression for resolving ${gl_include_guard_prefix}
3074 func_compute_include_guard_prefix ()
3076 if test "$macro_prefix" = gl; then
3077 include_guard_prefix='GL'
3079 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3081 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3084 # func_execute_command command [args...]
3085 # Executes a command.
3086 # Uses also the variables
3087 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3088 func_execute_command ()
3090 if test $verbose -ge 0; then
3094 # Commands like automake produce output to stderr even when they succeed.
3095 # Turn this output off if the command succeeds.
3096 "$@" > "$tmp"/cmdout 2>&1
3098 if test $cmdret = 0; then
3102 cat "$tmp"/cmdout 1>&2
3109 # func_dest_tmpfilename file
3110 # determines the name of a temporary file (file is relative to destdir).
3112 # - destdir target directory
3113 # - doit : if actions shall be executed, false if only to be printed
3114 # - tmp pathname of a temporary directory
3116 # - tmpfile absolute filename of the temporary file
3117 func_dest_tmpfilename ()
3120 # Put the new contents of $file in a file in the same directory (needed
3121 # to guarantee that an 'mv' to "$destdir/$file" works).
3122 tmpfile="$destdir/$1.tmp"
3124 # Put the new contents of $file in a file in a temporary directory
3125 # (because the directory of "$file" might not exist).
3126 tmpfile="$tmp"/`basename "$1"`.tmp
3131 # copies a file from gnulib into the destination directory. The destination
3132 # is known to not exist.
3134 # - destdir target directory
3135 # - local_gnulib_dir from --local-dir
3136 # - modcache true or false, from --cache-modules/--no-cache-modules
3137 # - f the original file name
3138 # - lookedup_file name of the merged (combined) file
3139 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3140 # - g the rewritten file name
3141 # - tmpfile absolute filename of the temporary file
3142 # - doit : if actions shall be executed, false if only to be printed
3143 # - symbolic true if files should be symlinked, copied otherwise
3144 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3149 echo "Copying file $g"
3150 if { test -n "$symbolic" \
3151 || { test -n "$lsymbolic" \
3152 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3153 && test -z "$lookedup_tmp" \
3154 && cmp -s "$lookedup_file" "$tmpfile"; then
3155 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3157 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3165 # copies a file from gnulib into the destination directory. The destination
3166 # is known to exist.
3168 # - destdir target directory
3169 # - local_gnulib_dir from --local-dir
3170 # - modcache true or false, from --cache-modules/--no-cache-modules
3171 # - f the original file name
3172 # - lookedup_file name of the merged (combined) file
3173 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3174 # - g the rewritten file name
3175 # - tmpfile absolute filename of the temporary file
3176 # - doit : if actions shall be executed, false if only to be printed
3177 # - symbolic true if files should be symlinked, copied otherwise
3178 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3180 # - already_present nonempty if the file should already exist, empty otherwise
3183 if cmp -s "$destdir/$g" "$tmpfile"; then
3184 : # The file has not changed.
3188 if test -n "$already_present"; then
3189 echo "Updating file $g (backup in ${g}~)"
3191 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3193 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3194 if { test -n "$symbolic" \
3195 || { test -n "$lsymbolic" \
3196 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3197 && test -z "$lookedup_tmp" \
3198 && cmp -s "$lookedup_file" "$tmpfile"; then
3199 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3201 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3204 if test -n "$already_present"; then
3205 echo "Update file $g (backup in ${g}~)"
3207 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3213 # func_emit_lib_Makefile_am
3214 # emits the contents of library makefile to standard output.
3216 # - local_gnulib_dir from --local-dir
3217 # - modcache true or false, from --cache-modules/--no-cache-modules
3218 # - modules list of modules, including dependencies
3219 # - libname library name
3220 # - pobase directory relative to destdir where to place *.po files
3221 # - auxdir directory relative to destdir where to place build aux files
3222 # - makefile_name from --makefile-name
3223 # - libtool true if libtool will be used, false or blank otherwise
3224 # - macro_prefix prefix of gl_LIBOBJS macros to use
3225 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3226 # - witness_c_macro from --witness-c-macro
3227 # - actioncmd (optional) command that will reproduce this invocation
3228 # - for_test true if creating a package for testing, false otherwise
3229 # - sed_replace_include_guard_prefix
3230 # sed expression for resolving ${gl_include_guard_prefix}
3231 # - destfile filename relative to destdir of makefile being generated
3233 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3234 # list of edits to be done to Makefile.am variables
3236 # - uses_subdirs nonempty if object files in subdirs exist
3237 func_emit_lib_Makefile_am ()
3239 # When creating an includable Makefile.am snippet, augment variables with
3240 # += instead of assigning them.
3241 if test -n "$makefile_name"; then
3246 if test "$libtool" = true; then
3249 sed_eliminate_LDFLAGS="$sed_noop"
3253 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3256 # When creating a package for testing: Attempt to provoke failures,
3257 # especially link errors, already during "make" rather than during
3258 # "make check", because "make check" is not possible in a cross-compiling
3259 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3260 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3262 sed_transform_check_PROGRAMS="$sed_noop"
3264 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3265 echo "## Process this file with automake to produce Makefile.in."
3266 func_emit_copyright_notice
3267 if test -n "$actioncmd"; then
3268 # The maximum line length (excluding the terminating newline) of any file
3269 # that is to be preprocessed by config.status is 3070. config.status uses
3270 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3271 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3272 len=`echo "$actioncmd" | wc -c`
3273 if test -n "$len" && test "$len" -le 3000; then
3274 echo "# Reproduce by: $actioncmd"
3280 for module in $modules; do
3281 func_verify_nontests_module
3282 if test -n "$module"; then
3284 func_get_automake_snippet_conditional "$module" |
3286 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3287 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3288 -e "$sed_eliminate_LDFLAGS" \
3289 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3290 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3291 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3292 -e "$sed_transform_check_PROGRAMS" \
3293 -e "$sed_replace_include_guard_prefix"
3294 if test "$module" = 'alloca'; then
3295 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3296 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3298 } > "$tmp"/amsnippet1
3300 func_get_automake_snippet_unconditional "$module" |
3301 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3302 } > "$tmp"/amsnippet2
3303 # Skip the contents if it's entirely empty.
3304 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3305 echo "## begin gnulib module $module"
3307 if test "$cond_dependencies" = true; then
3308 if func_cond_module_p "$module"; then
3309 func_module_conditional_name "$module"
3310 echo "if $conditional"
3313 cat "$tmp"/amsnippet1
3314 if test "$cond_dependencies" = true; then
3315 if func_cond_module_p "$module"; then
3319 cat "$tmp"/amsnippet2
3320 echo "## end gnulib module $module"
3323 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3324 # Test whether there are some source files in subdirectories.
3325 for f in `func_get_filelist "$module"`; do
3335 } > "$tmp"/allsnippets
3336 if test -z "$makefile_name"; then
3337 # If there are source files in subdirectories, prevent collision of the
3338 # object files (example: hash.c and libxml/hash.c).
3340 if test -n "$uses_subdirs"; then
3341 subdir_options=' subdir-objects'
3343 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
3346 if test -z "$makefile_name"; then
3348 echo "noinst_HEADERS ="
3349 echo "noinst_LIBRARIES ="
3350 echo "noinst_LTLIBRARIES ="
3351 # Automake versions < 1.11.4 create an empty pkgdatadir at
3352 # installation time if you specify pkgdata_DATA to empty.
3353 # See automake bugs #10997 and #11030:
3354 # * http://debbugs.gnu.org/10997
3355 # * http://debbugs.gnu.org/11030
3356 # So we need this workaround.
3357 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3358 echo "pkgdata_DATA ="
3361 echo "BUILT_SOURCES ="
3364 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3365 if test -z "$makefile_name"; then
3366 echo "MOSTLYCLEANDIRS ="
3368 echo "DISTCLEANFILES ="
3369 echo "MAINTAINERCLEANFILES ="
3371 # Execute edits that apply to the Makefile.am being generated.
3373 while test $edit != $makefile_am_edits; do
3374 edit=`expr $edit + 1`
3375 eval dir=\"\$makefile_am_edit${edit}_dir\"
3376 eval var=\"\$makefile_am_edit${edit}_var\"
3377 eval val=\"\$makefile_am_edit${edit}_val\"
3378 if test -n "$var"; then
3379 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3380 echo "${var} += ${val}"
3381 eval "makefile_am_edit${edit}_var="
3385 if test -n "$witness_c_macro"; then
3386 cppflags_part1=" -D$witness_c_macro=1"
3391 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3395 if test -z "$makefile_name"; then
3397 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3400 if test -n "$cppflags_part1$cppflags_part2"; then
3402 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3406 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3407 || { test -n "$makefile_name" \
3408 && test -f "$sourcebase/Makefile.am" \
3409 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3411 # One of the snippets or the user's Makefile.am already specifies an
3412 # installation location for the library. Don't confuse automake by saying
3413 # it should not be installed.
3416 # By default, the generated library should not be installed.
3417 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3420 echo "${libname}_${libext}_SOURCES ="
3421 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3422 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3423 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3424 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3425 echo "EXTRA_${libname}_${libext}_SOURCES ="
3426 if test "$libtool" = true; then
3427 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3428 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3429 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3430 # the link dependencies of all modules.
3431 for module in $modules; do
3432 func_verify_nontests_module
3433 if test -n "$module"; then
3434 func_get_link_directive "$module"
3437 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3438 | LC_ALL=C sort -u \
3439 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3442 if test -n "$pobase"; then
3443 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3446 cat "$tmp"/allsnippets \
3447 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3449 echo "mostlyclean-local: mostlyclean-generic"
3450 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3451 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3452 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3456 rm -f "$tmp"/allsnippets
3459 # func_emit_po_Makevars
3460 # emits the contents of po/ makefile parameterization to standard output.
3462 # - local_gnulib_dir from --local-dir
3463 # - modcache true or false, from --cache-modules/--no-cache-modules
3464 # - sourcebase directory relative to destdir where to place source code
3465 # - pobase directory relative to destdir where to place *.po files
3466 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3467 func_emit_po_Makevars ()
3469 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3470 func_emit_copyright_notice
3472 echo "# Usually the message domain is the same as the package name."
3473 echo "# But here it has a '-gnulib' suffix."
3474 echo "DOMAIN = ${po_domain}-gnulib"
3476 echo "# These two variables depend on the location of this directory."
3477 echo "subdir = ${pobase}"
3478 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3481 # These options get passed to xgettext.
3482 XGETTEXT_OPTIONS = \
3483 --keyword=_ --flag=_:1:pass-c-format \
3484 --keyword=N_ --flag=N_:1:pass-c-format \
3485 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3486 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3487 --flag=error:3:c-format --flag=error_at_line:5:c-format
3489 # This is the copyright holder that gets inserted into the header of the
3490 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3491 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3493 # This is the email address or URL to which the translators shall report
3494 # bugs in the untranslated strings:
3495 # - Strings which are not entire sentences, see the maintainer guidelines
3496 # in the GNU gettext documentation, section 'Preparing Strings'.
3497 # - Strings which use unclear terms or require additional context to be
3499 # - Strings which make invalid assumptions about notation of date, time or
3501 # - Pluralisation problems.
3502 # - Incorrect English spelling.
3503 # - Incorrect formatting.
3504 # It can be your email address, or a mailing list address where translators
3505 # can write to without being subscribed, or the URL of a web page through
3506 # which the translators can contact you.
3507 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3509 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3510 # message catalogs shall be used. It is usually empty.
3511 EXTRA_LOCALE_CATEGORIES =
3513 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3514 # context. Possible values are "yes" and "no". Set this to yes if the
3515 # package uses functions taking also a message context, like pgettext(), or
3516 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3521 # func_emit_po_POTFILES_in
3522 # emits the file list to be passed to xgettext to standard output.
3524 # - local_gnulib_dir from --local-dir
3525 # - modcache true or false, from --cache-modules/--no-cache-modules
3526 # - sourcebase directory relative to destdir where to place source code
3527 # - files list of new files
3528 func_emit_po_POTFILES_in ()
3530 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3531 func_emit_copyright_notice
3533 echo "# List of files which contain translatable strings."
3534 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3537 # func_emit_tests_Makefile_am witness_macro
3538 # emits the contents of tests makefile to standard output.
3540 # - local_gnulib_dir from --local-dir
3541 # - modcache true or false, from --cache-modules/--no-cache-modules
3542 # - modules list of modules, including dependencies
3543 # - libname library name
3544 # - auxdir directory relative to destdir where to place build aux files
3545 # - makefile_name from --makefile-name
3546 # - libtool true if libtool will be used, false or blank otherwise
3547 # - sourcebase relative directory containing lib source code
3548 # - m4base relative directory containing autoconf macros
3549 # - testsbase relative directory containing unit test code
3550 # - macro_prefix prefix of gl_LIBOBJS macros to use
3551 # - witness_c_macro from --witness-c-macro
3552 # - for_test true if creating a package for testing, false otherwise
3553 # - single_configure true if a single configure file should be generated,
3554 # false for a separate configure file for the tests
3555 # - use_libtests true if a libtests.a should be built, false otherwise
3556 # - sed_replace_include_guard_prefix
3557 # sed expression for resolving ${gl_include_guard_prefix}
3558 # - destfile filename relative to destdir of makefile being generated
3560 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3561 # list of edits to be done to Makefile.am variables
3563 # - uses_subdirs nonempty if object files in subdirs exist
3564 func_emit_tests_Makefile_am ()
3567 if test "$libtool" = true; then
3569 sed_eliminate_LDFLAGS="$sed_noop"
3572 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3575 # When creating a package for testing: Attempt to provoke failures,
3576 # especially link errors, already during "make" rather than during
3577 # "make check", because "make check" is not possible in a cross-compiling
3578 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3579 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3581 sed_transform_check_PROGRAMS="$sed_noop"
3583 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3584 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3585 echo "## Process this file with automake to produce Makefile.in."
3586 func_emit_copyright_notice
3590 for module in $modules; do
3591 if $for_test && ! $single_configure; then
3592 func_verify_tests_module
3596 if test -n "$module"; then
3598 func_get_automake_snippet "$module" |
3600 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3601 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3602 -e "$sed_eliminate_LDFLAGS" \
3603 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3604 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3605 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3606 -e "$sed_transform_check_PROGRAMS" \
3607 -e "$sed_replace_include_guard_prefix"
3608 if $use_libtests && test "$module" = 'alloca'; then
3609 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3610 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3612 } > "$tmp"/amsnippet
3613 # Skip the contents if it's entirely empty.
3614 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3615 # Mention long-running tests at the end.
3617 for word in `func_get_status "$module"`; do
3618 if test "$word" = 'longrunning-test'; then
3623 { echo "## begin gnulib module $module"
3625 cat "$tmp"/amsnippet
3626 echo "## end gnulib module $module"
3630 rm -f "$tmp"/amsnippet
3631 # Test whether there are some source files in subdirectories.
3632 for f in `func_get_filelist "$module"`; do
3634 lib/*/*.c | tests/*/*.c)
3642 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3643 # Generate dependencies here, since it eases the debugging of test failures.
3644 # If there are source files in subdirectories, prevent collision of the
3645 # object files (example: hash.c and libxml/hash.c).
3647 if test -n "$uses_subdirs"; then
3648 subdir_options=' subdir-objects'
3650 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3652 if $for_test && ! $single_configure; then
3653 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3656 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3657 # variable is needed to avoid an error from automake:
3658 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3661 echo "XFAIL_TESTS ="
3662 echo "TESTS_ENVIRONMENT ="
3663 echo "noinst_PROGRAMS ="
3664 if ! $for_test; then
3665 echo "check_PROGRAMS ="
3667 echo "noinst_HEADERS ="
3668 echo "noinst_LIBRARIES ="
3669 if $use_libtests; then
3671 echo "noinst_LIBRARIES += libtests.a"
3673 echo "check_LIBRARIES = libtests.a"
3676 # Automake versions < 1.11.4 create an empty pkgdatadir at
3677 # installation time if you specify pkgdata_DATA to empty.
3678 # See automake bugs #10997 and #11030:
3679 # * http://debbugs.gnu.org/10997
3680 # * http://debbugs.gnu.org/11030
3681 # So we need this workaround.
3682 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3683 echo "pkgdata_DATA ="
3686 echo "BUILT_SOURCES ="
3688 echo "MOSTLYCLEANFILES = core *.stackdump"
3689 echo "MOSTLYCLEANDIRS ="
3691 echo "DISTCLEANFILES ="
3692 echo "MAINTAINERCLEANFILES ="
3693 # Execute edits that apply to the Makefile.am being generated.
3695 while test $edit != $makefile_am_edits; do
3696 edit=`expr $edit + 1`
3697 eval dir=\"\$makefile_am_edit${edit}_dir\"
3698 eval var=\"\$makefile_am_edit${edit}_var\"
3699 eval val=\"\$makefile_am_edit${edit}_val\"
3700 if test -n "$var"; then
3701 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3702 echo "${var} += ${val}"
3703 eval "makefile_am_edit${edit}_var="
3708 echo "AM_CPPFLAGS = \\"
3710 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3712 if test -n "$witness_c_macro"; then
3713 echo " -D$witness_c_macro=1 \\"
3715 if test -n "${witness_macro}"; then
3716 echo " -D@${witness_macro}@=1 \\"
3718 echo " -I. -I\$(srcdir) \\"
3719 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3720 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3722 local_ldadd_before=''
3723 local_ldadd_after=''
3724 if $use_libtests; then
3725 # All test programs need to be linked with libtests.a.
3726 # It needs to be passed to the linker before ${libname}.${libext}, since
3727 # the tests-related modules depend on the main modules.
3728 # It also needs to be passed to the linker after ${libname}.${libext}
3729 # because the latter might contain incomplete modules (such as the 'error'
3730 # module whose dependency to 'progname' is voluntarily omitted).
3731 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3733 local_ldadd_before=' libtests.a'
3734 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3736 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3738 if $use_libtests; then
3739 echo "libtests_a_SOURCES ="
3740 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3741 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3742 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3743 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3744 echo "EXTRA_libtests_a_SOURCES ="
3745 # The circular dependency in LDADD requires this.
3746 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3749 # Many test scripts use ${EXEEXT} or ${srcdir}.
3750 # EXEEXT is defined by AC_PROG_CC through autoconf.
3751 # srcdir is defined by autoconf and automake.
3752 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3754 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3755 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3756 echo "# Clean up after Solaris cc."
3758 echo " rm -rf SunWS_cache"
3760 echo "mostlyclean-local: mostlyclean-generic"
3761 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3762 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3763 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3767 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3770 # func_emit_initmacro_start macro_prefix
3771 # emits the first few statements of the gl_INIT macro to standard output.
3772 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3773 func_emit_initmacro_start ()
3775 macro_prefix_arg="$1"
3776 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3777 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3778 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3779 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3781 # Furthermore it avoids an automake error like this when a Makefile.am
3782 # that uses pieces of gnulib also uses $(LIBOBJ):
3783 # automatically discovered file `error.c' should not be explicitly mentioned
3784 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3785 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3786 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3787 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3788 # automatically discovered file `error.c' should not be explicitly mentioned
3789 # We let automake know about the files to be distributed through the
3790 # EXTRA_lib_SOURCES variable.
3791 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3792 # Create data variables for checking the presence of files that are mentioned
3793 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3794 # because we want the check to happen when the configure file is created,
3795 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3796 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3797 # in which to expect them.
3798 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3799 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3803 # func_emit_initmacro_end macro_prefix
3804 # emits the last few statements of the gl_INIT macro to standard output.
3805 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3806 func_emit_initmacro_end ()
3808 macro_prefix_arg="$1"
3809 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3810 # The check is performed only when autoconf is run from the directory where
3811 # the configure.ac resides; if it is run from a different directory, the
3813 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3814 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3815 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3816 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3817 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3821 echo " m4_if(m4_sysval, [0], [],"
3822 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3824 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3825 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3826 echo " m4_popdef([AC_LIBSOURCES])"
3827 echo " m4_popdef([AC_REPLACE_FUNCS])"
3828 echo " m4_popdef([AC_LIBOBJ])"
3829 echo " AC_CONFIG_COMMANDS_PRE(["
3830 echo " ${macro_prefix_arg}_libobjs="
3831 echo " ${macro_prefix_arg}_ltlibobjs="
3832 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3833 echo " # Remove the extension."
3834 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3835 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3836 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3837 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3840 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3841 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3845 # func_emit_initmacro_done macro_prefix sourcebase
3846 # emits a few statements after the gl_INIT macro to standard output.
3847 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3848 # - sourcebase directory relative to destdir where to place source code
3849 func_emit_initmacro_done ()
3851 macro_prefix_arg="$1"
3854 echo "# Like AC_LIBOBJ, except that the module name goes"
3855 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3856 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3857 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3858 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3861 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3862 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3863 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3864 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3865 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3868 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3869 echo "# expected is derived from the gnulib-tool parameterization,"
3870 echo "# and alloca is special cased (for the alloca-opt module)."
3871 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3872 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3873 echo " m4_foreach([_gl_NAME], [\$1], ["
3874 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3875 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3876 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3882 # func_emit_autoconf_snippet indentation
3883 # emits the autoconf snippet of a module.
3885 # - local_gnulib_dir from --local-dir
3886 # - modcache true or false, from --cache-modules/--no-cache-modules
3887 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3888 # - sed_replace_include_guard_prefix
3889 # sed expression for resolving ${gl_include_guard_prefix}
3890 # - module the module name
3891 # - toplevel true or false. 'false' means a subordinate use of
3893 # - disable_libtool true or false. It tells whether to disable libtool
3894 # handling even if it has been specified through the
3895 # command line options.
3896 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3898 # - indentation spaces to prepend on each line
3899 func_emit_autoconf_snippet ()
3901 if { case $module in
3902 gnumakefile | maintainer-makefile)
3903 # These modules are meant to be used only in the top-level directory.
3909 func_get_autoconf_snippet "$module" \
3910 | sed -e '/^$/d;' -e "s/^/$indentation/" \
3911 -e "$sed_replace_build_aux" \
3912 -e "$sed_replace_include_guard_prefix" \
3913 | { if $disable_libtool; then
3914 sed -e 's/\$gl_cond_libtool/false/g' \
3915 -e 's/gl_libdeps/gltests_libdeps/g' \
3916 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3921 | { if $disable_gettext; then
3922 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
3927 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
3928 echo 'changequote(,)dnl'
3929 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3930 echo 'changequote([, ])dnl'
3931 echo 'AC_SUBST([LTALLOCA])'
3936 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
3937 # collects and emit the autoconf snippets of a set of modules.
3939 # - local_gnulib_dir from --local-dir
3940 # - modcache true or false, from --cache-modules/--no-cache-modules
3941 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3942 # - sed_replace_include_guard_prefix
3943 # sed expression for resolving ${gl_include_guard_prefix}
3944 # - modules the list of modules.
3945 # - verifier one of func_verify_module, func_verify_nontests_module,
3946 # func_verify_tests_module. It selects the subset of
3947 # $modules to consider.
3948 # - toplevel true or false. 'false' means a subordinate use of
3950 # - disable_libtool true or false. It tells whether to disable libtool
3951 # handling even if it has been specified through the
3952 # command line options.
3953 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3955 func_emit_autoconf_snippets ()
3959 disable_libtool="$4"
3960 disable_gettext="$5"
3961 if test "$cond_dependencies" = true; then
3962 for m in $modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
3963 # Emit the autoconf code for the unconditional modules.
3964 for module in $1; do
3966 if test -n "$module"; then
3967 if func_cond_module_p "$module"; then
3970 func_emit_autoconf_snippet " "
3974 # Initialize the shell variables indicating that the modules are enabled.
3975 for module in $1; do
3977 if test -n "$module"; then
3978 if func_cond_module_p "$module"; then
3979 func_module_shellvar_name "$module"
3980 echo " $shellvar=false"
3984 # Emit the autoconf code for the conditional modules, each in a separate
3985 # function. This makes it possible to support cycles among conditional
3987 for module in $1; do
3989 if test -n "$module"; then
3990 if func_cond_module_p "$module"; then
3991 func_module_shellfunc_name "$module"
3992 func_module_shellvar_name "$module"
3993 echo " $shellfunc ()"
3995 echo " if ! \$$shellvar; then"
3996 func_emit_autoconf_snippet " "
3997 echo " $shellvar=true"
3998 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3999 # Intersect $deps with the modules list $1.
4000 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4001 for dep in $deps; do
4002 if func_cond_module_p "$dep"; then
4003 func_module_shellfunc_name "$dep"
4004 func_cond_module_condition "$module" "$dep"
4005 if test "$condition" != true; then
4006 echo " if $condition; then"
4013 # The autoconf code for $dep has already been emitted above and
4014 # therefore is already executed when this function is run.
4023 # Emit the dependencies from the unconditional to the conditional modules.
4024 for module in $1; do
4026 if test -n "$module"; then
4027 if func_cond_module_p "$module"; then
4030 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4031 # Intersect $deps with the modules list $1.
4032 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4033 for dep in $deps; do
4034 if func_cond_module_p "$dep"; then
4035 func_module_shellfunc_name "$dep"
4036 func_cond_module_condition "$module" "$dep"
4037 if test "$condition" != true; then
4038 echo " if $condition; then"
4045 # The autoconf code for $dep has already been emitted above and
4046 # therefore is already executed when this code is run.
4053 # Define the Automake conditionals.
4054 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4055 for module in $1; do
4057 if test -n "$module"; then
4058 if func_cond_module_p "$module"; then
4059 func_module_conditional_name "$module"
4060 func_module_shellvar_name "$module"
4061 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4066 # Ignore the conditions, and enable all modules unconditionally.
4067 for module in $1; do
4069 if test -n "$module"; then
4070 func_emit_autoconf_snippet " "
4076 # func_import modules
4077 # Uses also the variables
4078 # - mode import or add-import or remove-import or update
4079 # - destdir target directory
4080 # - local_gnulib_dir from --local-dir
4081 # - modcache true or false, from --cache-modules/--no-cache-modules
4082 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4083 # - libname library name
4084 # - supplied_libname true if --lib was given, blank otherwise
4085 # - sourcebase directory relative to destdir where to place source code
4086 # - m4base directory relative to destdir where to place *.m4 macros
4087 # - pobase directory relative to destdir where to place *.po files
4088 # - docbase directory relative to destdir where to place doc files
4089 # - testsbase directory relative to destdir where to place unit test code
4090 # - auxdir directory relative to destdir where to place build aux files
4091 # - inctests true if --with-tests was given, blank otherwise
4092 # - incobsolete true if --with-obsolete was given, blank otherwise
4093 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4094 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4096 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4098 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4100 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4101 # - avoidlist list of modules to avoid, from --avoid
4102 # - cond_dependencies true if --conditional-dependencies was given, false if
4103 # --no-conditional-dependencies was given, blank otherwise
4104 # - lgpl yes or a number if library's license shall be LGPL,
4106 # - makefile_name from --makefile-name
4107 # - libtool true if --libtool was given, false if --no-libtool was
4108 # given, blank otherwise
4109 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4110 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4111 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4112 # - witness_c_macro from --witness-c-macro
4113 # - vc_files true if --vc-files was given, false if --no-vc-files was
4114 # given, blank otherwise
4115 # - autoconf_minversion minimum supported autoconf version
4116 # - doit : if actions shall be executed, false if only to be printed
4117 # - symbolic true if files should be symlinked, copied otherwise
4118 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4120 # - do_copyrights true if copyright notices in files should be replaced,
4124 # Get the cached settings.
4125 # In 'import' mode, we read them only for the purpose of knowing the old
4126 # installed file list, and don't use them as defaults.
4127 cached_local_gnulib_dir=
4128 cached_specified_modules=
4130 cached_inc_cxx_tests=
4131 cached_inc_longrunning_tests=
4132 cached_inc_privileged_tests=
4133 cached_inc_unportable_tests=
4134 cached_inc_all_tests=
4144 cached_makefile_name=
4145 cached_cond_dependencies=
4147 cached_macro_prefix=
4149 cached_witness_c_macro=
4152 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4153 cached_libtool=false
4159 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
4169 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4171 /gl_WITH_OBSOLETE/ {
4172 s,^.*$,cached_incobsolete=true,p
4174 /gl_WITH_CXX_TESTS/ {
4175 s,^.*$,cached_inc_cxx_tests=true,p
4177 /gl_WITH_LONGRUNNING_TESTS/ {
4178 s,^.*$,cached_inc_longrunning_tests=true,p
4180 /gl_WITH_PRIVILEGED_TESTS/ {
4181 s,^.*$,cached_inc_privileged_tests=true,p
4183 /gl_WITH_UNPORTABLE_TESTS/ {
4184 s,^.*$,cached_inc_unportable_tests=true,p
4186 /gl_WITH_ALL_TESTS/ {
4187 s,^.*$,cached_inc_all_tests=true,p
4190 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4193 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4196 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4199 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4202 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4205 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4208 s,^.*$,cached_inctests=true,p
4211 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4214 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4217 s,^.*$,cached_lgpl=yes,p
4219 /gl_MAKEFILE_NAME(/ {
4220 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4222 /gl_CONDITIONAL_DEPENDENCIES/ {
4223 s,^.*$,cached_cond_dependencies=true,p
4226 s,^.*$,cached_libtool=true,p
4228 /gl_MACRO_PREFIX(/ {
4229 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4232 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4234 /gl_WITNESS_C_MACRO(/ {
4235 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4238 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4240 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4241 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4246 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4247 s,^.*$,cached_files=",p
4260 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4264 if test "$mode" = import; then
4265 # In 'import' mode, the new set of specified modules overrides the cached
4266 # set of modules. Ignore the cached settings.
4267 specified_modules="$1"
4269 # Merge the cached settings with the specified ones.
4270 # The m4base must be the same as expected from the pathname.
4271 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4272 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4274 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
4275 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4276 if test -z "$local_gnulib_dir"; then
4277 if test -n "$cached_local_gnulib_dir"; then
4280 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4282 case "$cached_local_gnulib_dir" in
4284 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4286 func_relconcat "$destdir" "$cached_local_gnulib_dir"
4287 local_gnulib_dir="$relconcat" ;;
4294 # Append the cached and the specified module names. So that
4295 # "gnulib-tool --add-import foo" means to add the module foo.
4296 specified_modules="$cached_specified_modules $1"
4299 # Take the cached module names, minus the specified module names.
4301 if $have_associative; then
4302 # Use an associative array, for O(N) worst-case run time.
4303 declare -A to_remove
4305 eval 'to_remove[$m]=yes'
4307 for module in $cached_specified_modules; do
4308 if eval 'test -z "${to_remove[$module]}"'; then
4309 func_append specified_modules "$module "
4313 # This loop has O(N²) worst-case run time.
4314 for module in $cached_specified_modules; do
4317 if test "$m" = "$module"; then
4322 if test -z "$to_remove"; then
4323 func_append specified_modules "$module "
4329 # Take the cached module names. There are no specified module names.
4330 specified_modules="$cached_specified_modules"
4333 # Included obsolete modules among the dependencies if specified either way.
4334 if test -z "$incobsolete"; then
4335 incobsolete="$cached_incobsolete"
4337 # Included special kinds of tests modules among the dependencies if specified
4339 if test -z "$inc_cxx_tests"; then
4340 inc_cxx_tests="$cached_inc_cxx_tests"
4342 if test -z "$inc_longrunning_tests"; then
4343 inc_longrunning_tests="$cached_inc_longrunning_tests"
4345 if test -z "$inc_privileged_tests"; then
4346 inc_privileged_tests="$cached_inc_privileged_tests"
4348 if test -z "$inc_unportable_tests"; then
4349 inc_unportable_tests="$cached_inc_unportable_tests"
4351 if test -z "$inc_all_tests"; then
4352 inc_all_tests="$cached_inc_all_tests"
4354 # Append the cached and the specified avoidlist. This is probably better
4355 # than dropping the cached one when --avoid is specified at least once.
4356 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4357 avoidlist=`echo $avoidlist`
4359 # The sourcebase defaults to the cached one.
4360 if test -z "$sourcebase"; then
4361 sourcebase="$cached_sourcebase"
4362 if test -z "$sourcebase"; then
4363 func_fatal_error "missing --source-base option"
4366 # The pobase defaults to the cached one.
4367 if test -z "$pobase"; then
4368 pobase="$cached_pobase"
4370 # The docbase defaults to the cached one.
4371 if test -z "$docbase"; then
4372 docbase="$cached_docbase"
4373 if test -z "$docbase"; then
4374 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."
4377 # The testsbase defaults to the cached one.
4378 if test -z "$testsbase"; then
4379 testsbase="$cached_testsbase"
4380 if test -z "$testsbase"; then
4381 func_fatal_error "missing --tests-base option"
4384 # Require the tests if specified either way.
4385 if test -z "$inctests"; then
4386 inctests="$cached_inctests"
4388 # The libname defaults to the cached one.
4389 if test -z "$supplied_libname"; then
4390 libname="$cached_libname"
4391 if test -z "$libname"; then
4392 func_fatal_error "missing --lib option"
4395 # Require LGPL if specified either way.
4396 if test -z "$lgpl"; then
4399 # The makefile_name defaults to the cached one.
4400 if test -z "$makefile_name"; then
4401 makefile_name="$cached_makefile_name"
4403 # Use conditional dependencies if specified either way.
4404 if test -z "$cond_dependencies"; then
4405 cond_dependencies="$cached_cond_dependencies"
4407 # Use libtool if specified either way, or if guessed.
4408 if test -z "$libtool"; then
4409 if test -n "$cached_m4base"; then
4410 libtool="$cached_libtool"
4412 libtool="$guessed_libtool"
4415 # The macro_prefix defaults to the cached one.
4416 if test -z "$macro_prefix"; then
4417 macro_prefix="$cached_macro_prefix"
4418 if test -z "$macro_prefix"; then
4419 func_fatal_error "missing --macro-prefix option"
4422 # The po_domain defaults to the cached one.
4423 if test -z "$po_domain"; then
4424 po_domain="$cached_po_domain"
4426 # The witness_c_macro defaults to the cached one.
4427 if test -z "$witness_c_macro"; then
4428 witness_c_macro="$cached_witness_c_macro"
4430 # The vc_files defaults to the cached one.
4431 if test -z "$vc_files"; then
4432 vc_files="$cached_vc_files"
4434 # Ensure constraints.
4435 if test "$cond_dependencies" = true && test -n "$inctests"; then
4436 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4440 # --without-*-tests options are not supported here.
4442 excl_longrunning_tests=
4443 excl_privileged_tests=
4444 excl_unportable_tests=
4446 # Canonicalize the list of specified modules.
4447 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4449 # Include all kinds of tests modules if --with-all-tests was specified.
4450 inc_all_direct_tests="$inc_all_tests"
4451 inc_all_indirect_tests="$inc_all_tests"
4453 # Determine final module list.
4454 modules="$specified_modules"
4455 func_modules_transitive_closure
4456 if test $verbose -ge 0; then
4457 func_show_module_list
4459 final_modules="$modules"
4461 # Determine main module list and tests-related module list separately.
4462 func_modules_transitive_closure_separately
4464 # Determine whether a $testsbase/libtests.a is needed.
4465 func_determine_use_libtests
4467 # Add the dummy module to the main module list or to the tests-related module
4469 func_modules_add_dummy_separately
4471 # If --lgpl, verify that the licenses of modules are compatible.
4472 if test -n "$lgpl"; then
4473 license_incompatibilities=
4474 for module in $main_modules; do
4475 license=`func_get_license $module`
4477 'GPLed build tool') ;;
4478 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4483 LGPL | LGPLv2+ | LGPLv3+) ;;
4484 *) func_append license_incompatibilities "$module $license$nl" ;;
4490 *) func_append license_incompatibilities "$module $license$nl" ;;
4493 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4498 if test -n "$license_incompatibilities"; then
4499 # Format the license incompatibilities as a table.
4500 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4501 s,^\(.................................................[^ ]*\) *, \1 ,'
4502 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4503 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4507 # Show banner notice of every module.
4508 modules="$main_modules"
4511 # Determine script to apply to imported library files.
4512 sed_transform_lib_file=
4513 for module in $main_modules; do
4514 if test $module = config-h; then
4515 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4516 sed_transform_lib_file=$sed_transform_lib_file'
4517 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4522 sed_transform_main_lib_file="$sed_transform_lib_file"
4523 if test -n "$do_copyrights"; then
4524 if test -n "$lgpl"; then
4528 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4529 s/GNU General/GNU Lesser General/g
4530 s/General Public License/Lesser General Public License/g
4531 s/Lesser Lesser General Public License/Lesser General Public License/g
4535 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4536 s/GNU General/GNU Lesser General/g
4537 s/General Public License/Lesser General Public License/g
4538 s/Lesser Lesser General Public License/Lesser General Public License/g
4540 s/version [23]\([ ,]\)/version 2.1\1/g
4543 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4547 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4548 s/GNU Lesser General/GNU General/g
4549 s/Lesser General Public License/General Public License/g
4551 s/GNU Library General/GNU General/g
4552 s/Library General Public License/General Public License/g
4554 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4559 # Determine script to apply to auxiliary files that go into $auxdir/.
4560 sed_transform_build_aux_file=
4561 if test -n "$do_copyrights"; then
4563 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4564 s/GNU Lesser General/GNU General/g
4565 s/Lesser General Public License/General Public License/g
4567 s/GNU Library General/GNU General/g
4568 s/Library General Public License/General Public License/g
4570 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4574 # Determine script to apply to library files that go into $testsbase/.
4575 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4576 if test -n "$do_copyrights"; then
4578 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4579 s/GNU Lesser General/GNU General/g
4580 s/Lesser General Public License/General Public License/g
4582 s/GNU Library General/GNU General/g
4583 s/Library General Public License/General Public License/g
4585 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4589 # Determine the final file lists.
4590 func_modules_to_filelist_separately
4593 || func_fatal_error "refusing to do nothing"
4595 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4596 new_files="$files m4/gnulib-tool.m4"
4597 old_files="$cached_files"
4598 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4599 func_append old_files " m4/gnulib-tool.m4"
4602 rewritten='%REWRITTEN%'
4603 sed_rewrite_old_files="\
4604 s,^build-aux/,$rewritten$auxdir/,
4605 s,^doc/,$rewritten$cached_docbase/,
4606 s,^lib/,$rewritten$cached_sourcebase/,
4607 s,^m4/,$rewritten$cached_m4base/,
4608 s,^tests/,$rewritten$cached_testsbase/,
4609 s,^tests=lib/,$rewritten$cached_testsbase/,
4612 sed_rewrite_new_files="\
4613 s,^build-aux/,$rewritten$auxdir/,
4614 s,^doc/,$rewritten$docbase/,
4615 s,^lib/,$rewritten$sourcebase/,
4616 s,^m4/,$rewritten$m4base/,
4617 s,^tests/,$rewritten$testsbase/,
4618 s,^tests=lib/,$rewritten$testsbase/,
4622 # Create directories.
4623 { echo "$sourcebase"
4625 if test -n "$pobase"; then
4628 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4629 if test -n "$docfiles"; then
4632 if test -n "$inctests"; then
4636 for f in $files; do echo $f; done \
4637 | sed -e "$sed_rewrite_new_files" \
4638 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4641 { # Rearrange file descriptors. Needed because "while ... done < ..."
4642 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4643 exec 5<&0 < "$tmp"/dirs
4645 if test ! -d "$destdir/$d"; then
4647 echo "Creating directory $destdir/$d"
4648 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4650 echo "Create directory $destdir/$d"
4657 # Copy files or make symbolic links. Remove obsolete files.
4661 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4662 # representing the files according to the last gnulib-tool invocation.
4663 for f in $old_files; do echo $f; done \
4664 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4667 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4668 # representing the files after this gnulib-tool invocation.
4669 for f in $new_files; do echo $f; done \
4670 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4673 # First the files that are in old-files, but not in new-files:
4674 sed_take_first_column='s,'"$delimiter"'.*,,'
4675 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4676 # Remove the file. Do nothing if the user already removed it.
4677 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4679 echo "Removing file $g (backup in ${g}~)"
4680 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4682 echo "Remove file $g (backup in ${g}~)"
4684 func_append removed_files "$g$nl"
4687 # func_add_or_update handles a file that ought to be present afterwards.
4689 # - f the original file name
4690 # - g the rewritten file name
4691 # - already_present nonempty if the file should already exist, empty
4693 func_add_or_update ()
4697 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4699 func_dest_tmpfilename "$g"
4700 func_lookup_file "$f"
4701 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4702 if test -n "$sed_transform_main_lib_file"; then
4705 sed -e "$sed_transform_main_lib_file" \
4706 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4710 if test -n "$sed_transform_build_aux_file"; then
4713 sed -e "$sed_transform_build_aux_file" \
4714 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4718 if test -n "$sed_transform_testsrelated_lib_file"; then
4721 sed -e "$sed_transform_testsrelated_lib_file" \
4722 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4726 if test -f "$destdir/$g"; then
4727 # The file already exists.
4731 # Don't protest if the file should be there but isn't: it happens
4732 # frequently that developers don't put autogenerated files under version control.
4734 func_append added_files "$g$nl"
4738 # Then the files that are in new-files, but not in old-files:
4739 sed_take_last_column='s,^.*'"$delimiter"',,'
4741 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4742 | sed -e "$sed_take_last_column" \
4743 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4744 { # Rearrange file descriptors. Needed because "while ... done < ..."
4745 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4746 exec 5<&0 < "$tmp"/added-files
4752 # Then the files that are in new-files and in old-files:
4753 already_present=true
4754 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4755 | sed -e "$sed_take_last_column" \
4756 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4757 { # Rearrange file descriptors. Needed because "while ... done < ..."
4758 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4759 exec 5<&0 < "$tmp"/kept-files
4766 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4767 actioncmd="gnulib-tool --import"
4768 func_append actioncmd " --dir=$destdir"
4769 if test -n "$local_gnulib_dir"; then
4770 func_append actioncmd " --local-dir=$local_gnulib_dir"
4772 func_append actioncmd " --lib=$libname"
4773 func_append actioncmd " --source-base=$sourcebase"
4774 func_append actioncmd " --m4-base=$m4base"
4775 if test -n "$pobase"; then
4776 func_append actioncmd " --po-base=$pobase"
4778 func_append actioncmd " --doc-base=$docbase"
4779 func_append actioncmd " --tests-base=$testsbase"
4780 func_append actioncmd " --aux-dir=$auxdir"
4781 if test -n "$inctests"; then
4782 func_append actioncmd " --with-tests"
4784 if test -n "$incobsolete"; then
4785 func_append actioncmd " --with-obsolete"
4787 if test -n "$inc_cxx_tests"; then
4788 func_append actioncmd " --with-c++-tests"
4790 if test -n "$inc_longrunning_tests"; then
4791 func_append actioncmd " --with-longrunning-tests"
4793 if test -n "$inc_privileged_tests"; then
4794 func_append actioncmd " --with-privileged-tests"
4796 if test -n "$inc_unportable_tests"; then
4797 func_append actioncmd " --with-unportable-tests"
4799 if test -n "$inc_all_tests"; then
4800 func_append actioncmd " --with-all-tests"
4802 for module in $avoidlist; do
4803 func_append actioncmd " --avoid=$module"
4805 if test -n "$lgpl"; then
4806 if test "$lgpl" = yes; then
4807 func_append actioncmd " --lgpl"
4809 func_append actioncmd " --lgpl=$lgpl"
4812 if test -n "$makefile_name"; then
4813 func_append actioncmd " --makefile-name=$makefile_name"
4815 if test "$cond_dependencies" = true; then
4816 func_append actioncmd " --conditional-dependencies"
4818 func_append actioncmd " --no-conditional-dependencies"
4820 if test "$libtool" = true; then
4821 func_append actioncmd " --libtool"
4823 func_append actioncmd " --no-libtool"
4825 func_append actioncmd " --macro-prefix=$macro_prefix"
4826 if test -n "$po_domain"; then
4827 func_append actioncmd " --po-domain=$po_domain"
4829 if test -n "$witness_c_macro"; then
4830 func_append actioncmd " --witness-c-macro=$witness_c_macro"
4832 if test -n "$vc_files"; then
4833 if test "$vc_files" = true; then
4834 func_append actioncmd " --vc-files"
4836 func_append actioncmd " --no-vc-files"
4839 func_append actioncmd " `echo $specified_modules`"
4841 # Determine include_guard_prefix.
4842 func_compute_include_guard_prefix
4844 # Default the makefile name to Makefile.am.
4845 if test -n "$makefile_name"; then
4846 makefile_am=$makefile_name
4848 makefile_am=Makefile.am
4851 # Create normal Makefile.ams.
4854 # Setup list of Makefile.am edits that are to be performed afterwards.
4855 # Some of these edits apply to files that we will generate; others are
4856 # under the responsibility of the developer.
4858 # func_note_Makefile_am_edit dir var value
4859 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4861 func_note_Makefile_am_edit ()
4863 makefile_am_edits=`expr $makefile_am_edits + 1`
4864 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4865 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4866 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4868 if test "$makefile_am" = Makefile.am; then
4869 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4870 sourcebase_base=`basename "$sourcebase"`
4871 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4873 if test -n "$pobase"; then
4874 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4875 pobase_base=`basename "$pobase"`
4876 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4878 if test -n "$inctests"; then
4879 if test "$makefile_am" = Makefile.am; then
4880 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4881 testsbase_base=`basename "$testsbase"`
4882 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4885 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4887 # Find the first parent directory of $m4base that contains or will contain
4889 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4891 sed_butlast='s,[^/][^/]*//*$,,'
4892 dir1="${m4base}/"; dir2=""
4893 while test -n "$dir1" \
4894 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4895 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4896 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4897 || { test -n "$inctests" \
4898 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4899 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4900 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4901 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4903 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4906 # Create library makefile.
4907 func_dest_tmpfilename $sourcebase/$makefile_am
4908 destfile="$sourcebase/$makefile_am"
4909 modules="$main_modules"
4910 func_emit_lib_Makefile_am > "$tmpfile"
4911 if test -f "$destdir"/$sourcebase/$makefile_am; then
4912 if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
4916 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4917 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4918 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4920 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4926 echo "Creating $sourcebase/$makefile_am"
4927 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4929 echo "Create $sourcebase/$makefile_am"
4932 func_append added_files "$sourcebase/$makefile_am$nl"
4935 # Create po/ directory.
4936 if test -n "$pobase"; then
4937 # Create po makefile and auxiliary files.
4938 for file in Makefile.in.in remove-potcdate.sin; do
4939 func_dest_tmpfilename $pobase/$file
4940 func_lookup_file build-aux/po/$file
4941 cat "$lookedup_file" > "$tmpfile"
4942 if test -f "$destdir"/$pobase/$file; then
4943 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
4947 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4948 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4949 mv -f "$tmpfile" "$destdir"/$pobase/$file
4951 echo "Update $pobase/$file (backup in $pobase/$file~)"
4957 echo "Creating $pobase/$file"
4958 mv -f "$tmpfile" "$destdir"/$pobase/$file
4960 echo "Create $pobase/$file"
4963 func_append added_files "$pobase/$file$nl"
4966 # Create po makefile parameterization, part 1.
4967 func_dest_tmpfilename $pobase/Makevars
4968 func_emit_po_Makevars > "$tmpfile"
4969 if test -f "$destdir"/$pobase/Makevars; then
4970 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
4974 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4975 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4976 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4978 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4984 echo "Creating $pobase/Makevars"
4985 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4987 echo "Create $pobase/Makevars"
4990 func_append added_files "$pobase/Makevars$nl"
4992 # Create po makefile parameterization, part 2.
4993 func_dest_tmpfilename $pobase/POTFILES.in
4994 func_emit_po_POTFILES_in > "$tmpfile"
4995 if test -f "$destdir"/$pobase/POTFILES.in; then
4996 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5000 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5001 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5002 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5004 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5010 echo "Creating $pobase/POTFILES.in"
5011 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5013 echo "Create $pobase/POTFILES.in"
5016 func_append added_files "$pobase/POTFILES.in$nl"
5019 TP_URL="http://translationproject.org/latest/"
5020 TP_RSYNC_URI="translationproject.org::tp/latest/"
5022 echo "Fetching gnulib PO files from $TP_URL"
5023 (cd "$destdir"/$pobase \
5024 && { # Prefer rsync over wget if it is available, since it consumes
5025 # less network bandwidth, due to compression.
5026 if type rsync 2>/dev/null | grep / > /dev/null; then
5027 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
5029 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
5034 echo "Fetch gnulib PO files from $TP_URL"
5036 # Create po/LINGUAS.
5038 func_dest_tmpfilename $pobase/LINGUAS
5039 (cd "$destdir"/$pobase \
5040 && { echo '# Set of available languages.'
5041 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5044 if test -f "$destdir"/$pobase/LINGUAS; then
5045 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5048 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5049 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5050 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5053 echo "Creating $pobase/LINGUAS"
5054 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5055 func_append added_files "$pobase/LINGUAS$nl"
5058 if test -f "$destdir"/$pobase/LINGUAS; then
5059 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5061 echo "Create $pobase/LINGUAS"
5066 # Create m4/gnulib-cache.m4.
5067 func_dest_tmpfilename $m4base/gnulib-cache.m4
5069 func_emit_copyright_notice
5071 echo "# This file represents the specification of how gnulib-tool is used."
5072 echo "# It acts as a cache: It is written and read by gnulib-tool."
5073 echo "# In projects that use version control, this file is meant to be put under"
5074 echo "# version control, like the configure.ac and various Makefile.am files."
5077 echo "# Specification in the form of a command-line invocation:"
5080 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5081 # Store the local_gnulib_dir relative to destdir.
5082 case "$local_gnulib_dir" in
5084 relative_local_gnulib_dir="$local_gnulib_dir" ;;
5087 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
5089 # destdir, local_gnulib_dir are both relative.
5090 func_relativize "$destdir" "$local_gnulib_dir"
5091 relative_local_gnulib_dir="$reldir" ;;
5094 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
5096 echo "$specified_modules" | sed -e 's/^/ /g'
5098 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5099 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5100 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5101 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5102 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5103 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5104 echo "gl_AVOID([$avoidlist])"
5105 echo "gl_SOURCE_BASE([$sourcebase])"
5106 echo "gl_M4_BASE([$m4base])"
5107 echo "gl_PO_BASE([$pobase])"
5108 echo "gl_DOC_BASE([$docbase])"
5109 echo "gl_TESTS_BASE([$testsbase])"
5110 test -z "$inctests" || echo "gl_WITH_TESTS"
5111 echo "gl_LIB([$libname])"
5112 if test -n "$lgpl"; then
5113 if test "$lgpl" = yes; then
5116 echo "gl_LGPL([$lgpl])"
5119 echo "gl_MAKEFILE_NAME([$makefile_name])"
5120 if test "$cond_dependencies" = true; then
5121 echo "gl_CONDITIONAL_DEPENDENCIES"
5123 if test "$libtool" = true; then
5126 echo "gl_MACRO_PREFIX([$macro_prefix])"
5127 echo "gl_PO_DOMAIN([$po_domain])"
5128 echo "gl_WITNESS_C_DOMAIN([$witness_c_macro])"
5129 if test -n "$vc_files"; then
5130 echo "gl_VC_FILES([$vc_files])"
5133 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5134 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
5138 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5139 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5140 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5142 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5146 echo "# gnulib-cache.m4 ends here"
5153 echo "Creating $m4base/gnulib-cache.m4"
5154 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5156 echo "Create $m4base/gnulib-cache.m4"
5162 # Create m4/gnulib-comp.m4.
5163 func_dest_tmpfilename $m4base/gnulib-comp.m4
5165 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5166 func_emit_copyright_notice
5168 echo "# This file represents the compiled summary of the specification in"
5169 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5170 echo "# to be invoked from configure.ac."
5171 echo "# In projects that use version control, this file can be treated like"
5172 echo "# other built files."
5175 echo "# This macro should be invoked from $configure_ac, in the section"
5176 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5177 echo "# any checks for libraries, header files, types and library functions."
5178 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5180 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5181 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5182 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5183 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5184 echo " AC_REQUIRE([gl_PROG_AR_RANLIB])"
5185 if test -n "$uses_subdirs"; then
5186 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5188 for module in $final_modules; do
5190 if test -n "$module"; then
5191 echo "# Code from module $module:"
5192 func_get_autoconf_early_snippet "$module"
5195 | sed -e '/^$/d;' -e 's/^/ /'
5198 echo "# This macro should be invoked from $configure_ac, in the section"
5199 echo "# \"Check for header files, types and library functions\"."
5200 echo "AC_DEFUN([${macro_prefix}_INIT],"
5202 if test "$libtool" = true; then
5203 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5204 echo " gl_cond_libtool=true"
5206 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5207 echo " gl_cond_libtool=false"
5209 echo " gl_ltlibdeps="
5211 if test "$auxdir" != "build-aux"; then
5212 sed_replace_build_aux='
5214 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5215 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5219 sed_replace_build_aux="$sed_noop"
5221 echo " gl_m4_base='$m4base'"
5222 func_emit_initmacro_start $macro_prefix
5223 echo " gl_source_base='$sourcebase'"
5224 if test -n "$witness_c_macro"; then
5225 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5227 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
5228 if test -n "$witness_c_macro"; then
5229 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5231 echo " # End of code from modules"
5232 func_emit_initmacro_end $macro_prefix
5233 echo " gltests_libdeps="
5234 echo " gltests_ltlibdeps="
5235 func_emit_initmacro_start ${macro_prefix}tests
5236 echo " gl_source_base='$testsbase'"
5237 # Define a tests witness macro that depends on the package.
5238 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5239 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5240 echo "changequote(,)dnl"
5241 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"
5242 echo "changequote([, ])dnl"
5243 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5244 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5245 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5246 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
5247 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5248 func_emit_initmacro_end ${macro_prefix}tests
5249 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5250 # created using libtool, because libtool already handles the dependencies.
5251 if test "$libtool" != true; then
5252 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5253 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5254 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5255 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5256 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5258 if $use_libtests; then
5259 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5260 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5263 func_emit_initmacro_done $macro_prefix $sourcebase
5264 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5266 echo "# This macro records the list of files which have been installed by"
5267 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5268 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5269 echo "$files" | sed -e 's,^, ,'
5272 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5273 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
5277 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5278 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5279 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5281 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5285 echo "# gnulib-comp.m4 ends here"
5292 echo "Creating $m4base/gnulib-comp.m4"
5293 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5295 echo "Create $m4base/gnulib-comp.m4"
5301 if test -n "$inctests"; then
5302 # Create tests makefile.
5303 func_dest_tmpfilename $testsbase/$makefile_am
5304 destfile="$testsbase/$makefile_am"
5305 modules="$testsrelated_modules"
5306 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5307 if test -f "$destdir"/$testsbase/$makefile_am; then
5308 if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
5312 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5313 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5314 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5316 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5322 echo "Creating $testsbase/$makefile_am"
5323 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5325 echo "Create $testsbase/$makefile_am"
5328 func_append added_files "$testsbase/$makefile_am$nl"
5332 if test "$vc_files" != false; then
5333 # Update the .cvsignore and .gitignore files.
5334 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5335 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5336 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5337 echo "$m4base/|A|gnulib-comp.m4"
5338 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5339 { # Rearrange file descriptors. Needed because "while ... done < ..."
5340 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5341 exec 5<&0 < "$tmp"/fileset-changes
5342 func_update_ignorelist ()
5345 if test "$ignore" = .gitignore; then
5346 # In a .gitignore file, "foo" applies to the current directory and all
5347 # subdirectories, whereas "/foo" applies to the current directory only.
5350 doubly_escaped_anchor='\\/'
5354 doubly_escaped_anchor=''
5356 if test -f "$destdir/$dir$ignore"; then
5357 if test -n "$dir_added" || test -n "$dir_removed"; then
5358 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5359 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5360 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5361 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5362 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
5364 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5366 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5367 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5368 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5369 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5370 } > "$tmp"/sed-ignore-removed
5371 { cat "$destdir/$dir$ignore"~
5372 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5373 } | sed -f "$tmp"/sed-ignore-removed \
5374 > "$destdir/$dir$ignore"
5376 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5381 if test -n "$dir_added"; then
5383 echo "Creating $destdir/$dir$ignore"
5385 if test "$ignore" = .cvsignore; then
5387 # Automake generates Makefile rules that create .dirstamp files.
5390 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5391 } > "$destdir/$dir$ignore"
5393 echo "Create $destdir/$dir$ignore"
5403 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5404 func_update_ignorelist .cvsignore
5406 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5407 func_update_ignorelist .gitignore
5414 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5415 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5416 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5417 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5418 if test "$next_dir" != "$last_dir"; then
5419 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5420 last_dir="$next_dir"
5425 A) func_append last_dir_added "$file$nl";;
5426 R) func_append last_dir_removed "$file$nl";;
5429 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5436 echo "You may need to add #include directives for the following .h files."
5437 # Intersect $specified_modules and $main_modules
5438 # (since $specified_modules is not necessarily of subset of $main_modules
5439 # - some may have been skipped through --avoid, and since the elements of
5440 # $main_modules but not in $specified_modules can go away without explicit
5441 # notice - through changes in the module dependencies).
5442 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5443 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5444 # First the #include <...> directives without #ifs, sorted for convenience,
5445 # then the #include "..." directives without #ifs, sorted for convenience,
5446 # then the #include directives that are surrounded by #ifs. Not sorted.
5447 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5448 include_directive=`func_get_include_directive "$module"`
5449 case "$nl$include_directive" in
5451 echo "$include_directive" 1>&5
5454 echo "$include_directive" | grep -v 'include "' 1>&6
5455 echo "$include_directive" | grep 'include "' 1>&7
5458 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5460 LC_ALL=C sort -u "$tmp"/include-angles
5461 LC_ALL=C sort -u "$tmp"/include-quotes
5462 cat "$tmp"/include-if
5463 ) | sed -e '/^$/d' -e 's/^/ /'
5464 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5466 for module in $main_modules; do
5467 func_get_link_directive "$module"
5469 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5470 if test `wc -l < "$tmp"/link` != 0; then
5472 echo "You may need to use the following Makefile variables when linking."
5473 echo "Use them in <program>_LDADD when linking a program, or"
5474 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5480 echo "Don't forget to"
5481 if test "$makefile_am" = Makefile.am; then
5482 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5484 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5486 if test -n "$pobase"; then
5487 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5489 if test -n "$inctests"; then
5490 if test "$makefile_am" = Makefile.am; then
5491 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5493 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5497 while test $edit != $makefile_am_edits; do
5498 edit=`expr $edit + 1`
5499 eval dir=\"\$makefile_am_edit${edit}_dir\"
5500 eval var=\"\$makefile_am_edit${edit}_var\"
5501 eval val=\"\$makefile_am_edit${edit}_val\"
5502 if test -n "$var"; then
5503 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5506 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
5507 position_early_after=AC_PROG_CC_STDC
5509 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
5510 position_early_after=AC_PROG_CC_C99
5512 position_early_after=AC_PROG_CC
5515 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
5516 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5519 # func_create_testdir testdir modules
5521 # - local_gnulib_dir from --local-dir
5522 # - modcache true or false, from --cache-modules/--no-cache-modules
5523 # - auxdir directory relative to destdir where to place build aux files
5524 # - inctests true if tests should be included, blank otherwise
5525 # - incobsolete true if obsolete modules among dependencies should be
5526 # included, blank otherwise
5527 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5529 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5531 # - excl_privileged_tests true if tests that require root privileges should be
5532 # excluded, blank otherwise
5533 # - excl_unportable_tests true if tests that fail on some platforms should be
5534 # excluded, blank otherwise
5535 # - single_configure true if a single configure file should be generated,
5536 # false for a separate configure file for the tests
5537 # - avoidlist list of modules to avoid
5538 # - cond_dependencies true if --conditional-dependencies was given, false if
5539 # --no-conditional-dependencies was given, blank otherwise
5540 # - libtool true if --libtool was given, false if --no-libtool was
5541 # given, blank otherwise
5542 # - symbolic true if files should be symlinked, copied otherwise
5543 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
5545 func_create_testdir ()
5549 if test -z "$modules"; then
5550 # All modules together.
5551 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5552 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5553 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5554 modules=`func_all_modules`
5555 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5557 specified_modules="$modules"
5559 # Canonicalize the list of specified modules.
5560 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5562 # Unlike in func_import, here we want to include all kinds of tests for the
5563 # directly specified modules, but not for dependencies.
5564 inc_all_direct_tests=true
5565 inc_all_indirect_tests="$inc_all_tests"
5567 # Check that the license of every module is consistent with the license of
5569 saved_inctests="$inctests"
5570 # When computing transitive closures, don't consider $module to depend on
5571 # $module-tests. Need this because tests are implicitly GPL and may depend
5572 # on GPL modules - therefore we don't want a warning in this case.
5574 for requested_module in $specified_modules; do
5575 requested_license=`func_get_license "$requested_module"`
5576 if test "$requested_license" != GPL; then
5577 # Here we use func_modules_transitive_closure, not just
5578 # func_get_dependencies, so that we also detect weird situations like
5579 # an LGPL module which depends on a GPLed build tool module which depends
5581 modules="$requested_module"
5582 func_modules_transitive_closure
5583 for module in $modules; do
5584 license=`func_get_license "$module"`
5586 'GPLed build tool') ;;
5587 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5589 case "$requested_license" in
5592 GPLv2+ | LGPLv2+) ;;
5593 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5599 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5605 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5614 inctests="$saved_inctests"
5616 # Subdirectory names.
5627 # Determine final module list.
5628 modules="$specified_modules"
5629 func_modules_transitive_closure
5630 if test $verbose -ge 0; then
5631 func_show_module_list
5633 final_modules="$modules"
5635 if $single_configure; then
5636 # Determine main module list and tests-related module list separately.
5637 func_modules_transitive_closure_separately
5640 if $single_configure; then
5641 # Determine whether a $testsbase/libtests.a is needed.
5642 func_determine_use_libtests
5645 # Add the dummy module if needed.
5646 if $single_configure; then
5647 func_modules_add_dummy_separately
5649 func_modules_add_dummy
5652 # Show banner notice of every module.
5653 if $single_configure; then
5654 modules="$main_modules"
5660 # Determine final file list.
5661 if $single_configure; then
5662 func_modules_to_filelist_separately
5664 func_modules_to_filelist
5665 if test $verbose -ge 0; then
5667 echo "$files" | sed -e 's/^/ /'
5670 # Add files for which the copy in gnulib is newer than the one that
5671 # "automake --add-missing --copy" would provide.
5672 files="$files build-aux/config.guess"
5673 files="$files build-aux/config.sub"
5674 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5676 rewritten='%REWRITTEN%'
5677 sed_rewrite_files="\
5678 s,^build-aux/,$rewritten$auxdir/,
5679 s,^doc/,$rewritten$docbase/,
5680 s,^lib/,$rewritten$sourcebase/,
5681 s,^m4/,$rewritten$m4base/,
5682 s,^tests/,$rewritten$testsbase/,
5683 s,^tests=lib/,$rewritten$testsbase/,
5687 # Create directories.
5688 for f in $files; do echo $f; done \
5689 | sed -e "$sed_rewrite_files" \
5690 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5691 | LC_ALL=C sort -u \
5693 { # Rearrange file descriptors. Needed because "while ... done < ..."
5694 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5695 exec 5<&0 < "$tmp"/dirs
5697 mkdir -p "$testdir/$d"
5702 # Copy files or make symbolic links.
5704 for f in $files; do echo $f; done \
5705 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5708 { # Rearrange file descriptors. Needed because "while ... done < ..."
5709 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5710 exec 5<&0 < "$tmp"/files
5713 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5715 func_lookup_file "$f"
5716 if test -n "$lookedup_tmp"; then
5717 cp -p "$lookedup_file" "$testdir/$g"
5719 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5720 if { test -n "$symbolic" \
5721 || { test -n "$lsymbolic" \
5722 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5723 func_ln "$lookedup_file" "$testdir/$g"
5725 cp -p "$lookedup_file" "$testdir/$g"
5732 # Determine include_guard_prefix.
5733 func_compute_include_guard_prefix
5735 # Create Makefile.ams that are for testing.
5738 # No special edits are needed.
5741 # Create $sourcebase/Makefile.am.
5742 mkdir -p "$testdir/$sourcebase"
5743 destfile="$sourcebase/Makefile.am"
5744 if $single_configure; then
5745 modules="$main_modules"
5747 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5748 any_uses_subdirs="$uses_subdirs"
5750 # Create $m4base/Makefile.am.
5751 mkdir -p "$testdir/$m4base"
5752 (echo "## Process this file with automake to produce Makefile.in."
5758 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5761 ) > "$testdir/$m4base/Makefile.am"
5763 subdirs="$sourcebase $m4base"
5764 subdirs_with_configure_ac=""
5766 if false && test -f "$testdir"/$m4base/gettext.m4; then
5767 # Avoid stupid error message from automake:
5768 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5769 mkdir -p "$testdir/po"
5770 (echo "## Process this file with automake to produce Makefile.in."
5771 ) > "$testdir/po/Makefile.am"
5772 func_append subdirs " po"
5775 if test -n "$inctests"; then
5776 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5777 if $single_configure; then
5778 # Create $testsbase/Makefile.am.
5779 destfile="$testsbase/Makefile.am"
5780 modules="$testsrelated_modules"
5781 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
5783 # Viewed from the $testsbase subdirectory, $auxdir is different.
5784 saved_auxdir="$auxdir"
5785 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5786 # Create $testsbase/Makefile.am.
5788 destfile="$testsbase/Makefile.am"
5789 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5790 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5791 # Create $testsbase/configure.ac.
5792 (echo "# Process this file with autoconf to produce a configure script."
5793 echo "AC_INIT([dummy], [0])"
5794 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5795 echo "AM_INIT_AUTOMAKE"
5797 echo "AC_CONFIG_HEADERS([config.h])"
5800 echo "AC_PROG_INSTALL"
5801 echo "AC_PROG_MAKE_SET"
5802 echo "gl_PROG_AR_RANLIB"
5804 if test -n "$uses_subdirs"; then
5805 echo "AM_PROG_CC_C_O"
5808 for module in $modules; do
5810 if test -n "$module"; then
5812 gnumakefile | maintainer-makefile)
5813 # These modules are meant to be used only in the top-level directory.
5816 func_get_autoconf_early_snippet "$module"
5821 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5822 if test "$libtool" = true; then
5823 echo "LT_INIT([win32-dll])"
5824 echo "LT_LANG([C++])"
5825 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5826 echo "gl_cond_libtool=true"
5828 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5829 echo "gl_cond_libtool=false"
5831 echo "gl_ltlibdeps="
5833 # Wrap the set of autoconf snippets into an autoconf macro that is then
5834 # invoked. This is needed because autoconf does not support AC_REQUIRE
5836 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5837 # but we want the AC_REQUIRE to have its normal meaning (provide one
5838 # expansion of the required macro before the current point, and only one
5840 echo "AC_DEFUN([gl_INIT], ["
5841 sed_replace_build_aux='
5843 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5844 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5847 echo "gl_m4_base='../$m4base'"
5848 func_emit_initmacro_start $macro_prefix
5849 # We don't have explicit ordering constraints between the various
5850 # autoconf snippets. It's cleanest to put those of the library before
5851 # those of the tests.
5852 echo "gl_source_base='../$sourcebase'"
5853 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
5854 echo "gl_source_base='.'"
5855 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
5856 func_emit_initmacro_end $macro_prefix
5857 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5858 # created using libtool, because libtool already handles the dependencies.
5859 if test "$libtool" != true; then
5860 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5861 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5862 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5863 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5864 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5867 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5871 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5872 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5873 echo "AH_TOP([#include \"../config.h\"])"
5875 echo "AC_CONFIG_FILES([Makefile])"
5877 ) > "$testdir/$testsbase/configure.ac"
5878 auxdir="$saved_auxdir"
5879 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5881 func_append subdirs " $testsbase"
5884 # Create Makefile.am.
5885 (echo "## Process this file with automake to produce Makefile.in."
5887 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5889 echo "SUBDIRS = $subdirs"
5891 echo "ACLOCAL_AMFLAGS = -I $m4base"
5892 ) > "$testdir/Makefile.am"
5894 # Create configure.ac.
5895 (echo "# Process this file with autoconf to produce a configure script."
5896 echo "AC_INIT([dummy], [0])"
5897 if test "$auxdir" != "."; then
5898 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5900 echo "AM_INIT_AUTOMAKE"
5902 echo "AC_CONFIG_HEADERS([config.h])"
5905 echo "AC_PROG_INSTALL"
5906 echo "AC_PROG_MAKE_SET"
5908 echo "# For autobuild."
5909 echo "AC_CANONICAL_BUILD"
5910 echo "AC_CANONICAL_HOST"
5912 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5913 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5914 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5915 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5917 echo "gl_PROG_AR_RANLIB"
5919 if test -n "$any_uses_subdirs"; then
5920 echo "AM_PROG_CC_C_O"
5923 for module in $final_modules; do
5924 if $single_configure; then
5927 func_verify_nontests_module
5929 if test -n "$module"; then
5930 func_get_autoconf_early_snippet "$module"
5933 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5934 if test "$libtool" = true; then
5935 echo "LT_INIT([win32-dll])"
5936 echo "LT_LANG([C++])"
5937 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5938 echo "gl_cond_libtool=true"
5940 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5941 echo "gl_cond_libtool=false"
5943 echo "gl_ltlibdeps="
5945 # Wrap the set of autoconf snippets into an autoconf macro that is then
5946 # invoked. This is needed because autoconf does not support AC_REQUIRE
5948 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5949 # but we want the AC_REQUIRE to have its normal meaning (provide one
5950 # expansion of the required macro before the current point, and only one
5952 echo "AC_DEFUN([gl_INIT], ["
5953 if test "$auxdir" != "build-aux"; then
5954 sed_replace_build_aux='
5956 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5957 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5961 sed_replace_build_aux="$sed_noop"
5963 echo "gl_m4_base='$m4base'"
5964 func_emit_initmacro_start $macro_prefix
5965 echo "gl_source_base='$sourcebase'"
5966 if $single_configure; then
5967 func_emit_autoconf_snippets "$main_modules" func_verify_module true false false
5969 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
5971 func_emit_initmacro_end $macro_prefix
5972 if $single_configure; then
5973 echo " gltests_libdeps="
5974 echo " gltests_ltlibdeps="
5975 func_emit_initmacro_start ${macro_prefix}tests
5976 echo " gl_source_base='$testsbase'"
5977 # Define a tests witness macro.
5978 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
5979 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5980 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5981 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5982 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true false false
5983 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5984 func_emit_initmacro_end ${macro_prefix}tests
5986 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5987 # created using libtool, because libtool already handles the dependencies.
5988 if test "$libtool" != true; then
5989 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5990 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5991 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5992 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5993 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5995 if $single_configure; then
5996 if $use_libtests; then
5997 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5998 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6002 func_emit_initmacro_done $macro_prefix $sourcebase
6003 if $single_configure; then
6004 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6009 if test -n "$subdirs_with_configure_ac"; then
6010 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6012 makefiles="Makefile"
6013 for d in $subdirs; do
6014 # For subdirs that have a configure.ac by their own, it's the subdir's
6015 # configure.ac which creates the subdir's Makefile.am, not this one.
6016 case " $subdirs_with_configure_ac " in
6018 *) func_append makefiles " $d/Makefile" ;;
6021 echo "AC_CONFIG_FILES([$makefiles])"
6023 ) > "$testdir/configure.ac"
6025 # Create autogenerated files.
6027 # Do not use "${AUTORECONF} --force --install", because it may invoke
6028 # autopoint, which brings in older versions of some of our .m4 files.
6029 if test -f $m4base/gettext.m4; then
6030 func_execute_command ${AUTOPOINT} --force || func_exit 1
6031 for f in $m4base/*.m4~; do
6033 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6037 if test "$libtool" = true; then
6038 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6040 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6041 if ! test -d build-aux; then
6042 func_execute_command mkdir build-aux || func_exit 1
6044 func_execute_command ${AUTOCONF} || func_exit 1
6045 func_execute_command ${AUTOHEADER} || func_exit 1
6046 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6048 if test -n "$inctests" && ! $single_configure; then
6049 # Create autogenerated files.
6050 (cd "$testdir/$testsbase" || func_exit 1
6051 # Do not use "${AUTORECONF} --force --install", because it may invoke
6052 # autopoint, which brings in older versions of some of our .m4 files.
6053 if test -f ../$m4base/gettext.m4; then
6054 func_execute_command ${AUTOPOINT} --force || func_exit 1
6055 for f in ../$m4base/*.m4~; do
6057 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6061 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6062 if ! test -d ../build-aux; then
6063 func_execute_command mkdir ../build-aux
6065 func_execute_command ${AUTOCONF} || func_exit 1
6066 func_execute_command ${AUTOHEADER} || func_exit 1
6067 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6070 # Need to run configure and make once, to create built files that are to be
6071 # distributed (such as parse-datetime.c).
6072 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6073 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6074 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6075 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6076 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6077 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6078 # such $(FOO_H) because they don't refer to distributed files.
6079 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6080 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6081 | sed -e "$sed_remove_make_variables"`
6082 distributed_built_sources=`for file in $built_sources; do
6083 case "$cleaned_files" in
6088 tests_distributed_built_sources=
6089 if test -n "$inctests"; then
6090 # Likewise for built files in the $testsbase directory.
6091 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6092 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6093 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6094 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6095 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6096 | sed -e "$sed_remove_make_variables"`
6097 tests_distributed_built_sources=`for file in $tests_built_sources; do
6098 case "$tests_cleaned_files" in
6104 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6106 ./configure || func_exit 1
6107 if test -n "$distributed_built_sources"; then
6109 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6110 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6115 if test -n "$tests_distributed_built_sources"; then
6117 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6118 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6123 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6130 # func_create_megatestdir megatestdir allmodules
6132 # - local_gnulib_dir from --local-dir
6133 # - modcache true or false, from --cache-modules/--no-cache-modules
6134 # - auxdir directory relative to destdir where to place build aux files
6135 func_create_megatestdir ()
6139 if test -z "$allmodules"; then
6140 allmodules=`func_all_modules`
6144 # First, all modules one by one.
6145 for onemodule in $allmodules; do
6146 func_create_testdir "$megatestdir/$onemodule" $onemodule
6147 func_append megasubdirs "$onemodule "
6149 # Then, all modules all together.
6150 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6151 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6152 func_create_testdir "$megatestdir/ALL" "$allmodules"
6153 func_append megasubdirs "ALL"
6156 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
6157 vc_witness="$gnulib_dir/CVS/Entries"; \
6159 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6161 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6162 | sed -e 's,January,01,' -e 's,Jan,01,' \
6163 -e 's,February,02,' -e 's,Feb,02,' \
6164 -e 's,March,03,' -e 's,Mar,03,' \
6165 -e 's,April,04,' -e 's,Apr,04,' \
6167 -e 's,June,06,' -e 's,Jun,06,' \
6168 -e 's,July,07,' -e 's,Jul,07,' \
6169 -e 's,August,08,' -e 's,Aug,08,' \
6170 -e 's,September,09,' -e 's,Sep,09,' \
6171 -e 's,October,10,' -e 's,Oct,10,' \
6172 -e 's,November,11,' -e 's,Nov,11,' \
6173 -e 's,December,12,' -e 's,Dec,12,' \
6174 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6175 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6177 echo "CVSDATE=$cvsdate"
6178 echo ": \${MAKE=make}"
6179 echo "test -d logs || mkdir logs"
6180 echo "for module in $megasubdirs; do"
6181 echo " echo \"Working on module \$module...\""
6182 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6183 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6186 echo " : autobuild project... \$module"
6187 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6188 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6189 echo " : autobuild hostname... \`hostname\`"
6190 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6192 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6194 ) > "$megatestdir/do-autobuild"
6195 chmod a+x "$megatestdir/do-autobuild"
6197 # Create Makefile.am.
6198 (echo "## Process this file with automake to produce Makefile.in."
6200 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
6202 echo "SUBDIRS = $megasubdirs"
6204 echo "EXTRA_DIST = do-autobuild"
6205 ) > "$megatestdir/Makefile.am"
6207 # Create configure.ac.
6208 (echo "# Process this file with autoconf to produce a configure script."
6209 echo "AC_INIT([dummy], [0])"
6210 if test "$auxdir" != "."; then
6211 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6213 echo "AM_INIT_AUTOMAKE"
6215 echo "AC_PROG_MAKE_SET"
6217 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6218 echo "AC_CONFIG_FILES([Makefile])"
6220 ) > "$megatestdir/configure.ac"
6222 # Create autogenerated files.
6224 # Do not use "${AUTORECONF} --install", because autoreconf operates
6225 # recursively, but the subdirectories are already finished, therefore
6226 # calling autoreconf here would only waste lots of CPU time.
6227 func_execute_command ${ACLOCAL} || func_exit 1
6228 func_execute_command mkdir build-aux
6229 func_execute_command ${AUTOCONF} || func_exit 1
6230 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6236 func_fatal_error "no mode specified" ;;
6243 # sed expression that converts a literal to a basic regular expression.
6244 # Needs to handle . [ \ * ^ $.
6245 sed_literal_to_basic_regex='s/\\/\\\\/g
6251 if test -f "$gnulib_dir/$filename" \
6252 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
6253 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6254 filename_line_regex='^'"$filename_anywhere_regex"'$'
6257 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6258 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
6259 (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$,,')
6262 | func_sanitize_modulelist \
6265 for module in $module_candidates; do
6266 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6271 func_warning "file $filename does not exist"
6276 import | add-import | remove-import | update )
6279 if test -z "$destdir"; then
6282 test -d "$destdir" \
6283 || func_fatal_error "destination directory does not exist: $destdir"
6285 # Prefer configure.ac to configure.in.
6286 if test -f "$destdir"/configure.ac; then
6287 configure_ac="$destdir/configure.ac"
6289 if test -f "$destdir"/configure.in; then
6290 configure_ac="$destdir/configure.in"
6292 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6296 # Analyze configure.ac.
6298 guessed_libtool=false
6303 /AC_CONFIG_AUX_DIR/ {
6304 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6306 /A[CM]_PROG_LIBTOOL/ {
6307 s,^.*$,guessed_libtool=true,p
6309 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6311 if test -z "$auxdir"; then
6312 auxdir="$guessed_auxdir"
6315 # Determine where to apply func_import.
6316 if test "$mode" = import; then
6317 # Apply func_import to a particular gnulib directory.
6318 # The command line contains the complete specification; don't look at
6319 # the contents of gnulib-cache.m4.
6320 test -n "$supplied_libname" || supplied_libname=true
6321 test -n "$sourcebase" || sourcebase="lib"
6322 test -n "$m4base" || m4base="m4"
6323 test -n "$docbase" || docbase="doc"
6324 test -n "$testsbase" || testsbase="tests"
6325 test -n "$macro_prefix" || macro_prefix="gl"
6328 if test -n "$m4base"; then
6329 # Apply func_import to a particular gnulib directory.
6330 # Any number of additional modules can be given.
6331 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6332 # First use of gnulib in the given m4base.
6333 test -n "$supplied_libname" || supplied_libname=true
6334 test -n "$sourcebase" || sourcebase="lib"
6335 test -n "$docbase" || docbase="doc"
6336 test -n "$testsbase" || testsbase="tests"
6337 test -n "$macro_prefix" || macro_prefix="gl"
6341 # Apply func_import to all gnulib directories.
6342 # To get this list of directories, look at Makefile.am. (Not at
6343 # configure, because it may be omitted from version control. Also,
6344 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6348 if test -f "$destdir"/Makefile.am; then
6349 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6351 for arg in $aclocal_amflags; do
6352 if test -n "$m4dir_is_next"; then
6353 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6357 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6358 func_append m4dirs " $arg"
6359 m4dirs_count=`expr $m4dirs_count + 1`
6365 if test "X$arg" = "X-I"; then
6373 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6374 if test -f "$destdir"/aclocal.m4; then
6375 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6376 sedexpr2='s,^[^/]*$,.,'
6377 sedexpr3='s,/[^/]*$,,'
6378 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6379 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6380 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6383 if test $m4dirs_count = 0; then
6384 # First use of gnulib in a package.
6385 # Any number of additional modules can be given.
6386 test -n "$supplied_libname" || supplied_libname=true
6387 test -n "$sourcebase" || sourcebase="lib"
6389 test -n "$docbase" || docbase="doc"
6390 test -n "$testsbase" || testsbase="tests"
6391 test -n "$macro_prefix" || macro_prefix="gl"
6394 if test $m4dirs_count = 1; then
6395 # There's only one use of gnulib here. Assume the user means it.
6396 # Any number of additional modules can be given.
6397 for m4base in $m4dirs; do
6401 # Ambiguous - guess what the user meant.
6402 if test $# = 0; then
6403 # No further arguments. Guess the user wants to update all of them.
6404 for m4base in $m4dirs; do
6405 # Perform func_import in a subshell, so that variable values
6407 # local_gnulib_dir, incobsolete, inc_cxx_tests,
6408 # inc_longrunning_tests, inc_privileged_tests,
6409 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6410 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6411 # makefile_name, libtool, macro_prefix, po_domain,
6412 # witness_c_macro, vc_files
6413 # don't propagate from one directory to another.
6414 (func_import) || func_exit 1
6418 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6427 if test -z "$destdir"; then
6428 func_fatal_error "please specify --dir option"
6431 test -d "$destdir" \
6432 || func_fatal_error "could not create destination directory"
6433 test -n "$auxdir" || auxdir="build-aux"
6434 func_create_testdir "$destdir" "$*"
6437 create-megatestdir )
6438 if test -z "$destdir"; then
6439 func_fatal_error "please specify --dir option"
6441 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6442 test -n "$auxdir" || auxdir="build-aux"
6443 func_create_megatestdir "$destdir" "$*"
6447 test -n "$destdir" || destdir=testdir$$
6448 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6449 test -n "$auxdir" || auxdir="build-aux"
6450 func_create_testdir "$destdir" "$*"
6454 ../configure || func_exit 1
6455 $MAKE || func_exit 1
6456 $MAKE check || func_exit 1
6457 $MAKE distclean || func_exit 1
6458 remaining=`find . -type f -print`
6459 if test -n "$remaining"; then
6460 echo "Remaining files:" $remaining 1>&2
6461 echo "gnulib-tool: *** Stop." 1>&2
6470 test -n "$destdir" || destdir=testdir$$
6471 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6472 test -n "$auxdir" || auxdir="build-aux"
6473 func_create_megatestdir "$destdir" "$*"
6481 remaining=`find . -type f -print`
6482 if test -n "$remaining"; then
6483 echo "Remaining files:" $remaining 1>&2
6484 echo "gnulib-tool: *** Stop." 1>&2
6492 extract-description )
6496 if test -n "$module"; then
6497 func_get_description "$module"
6506 if test -n "$module"; then
6507 func_get_comment "$module"
6516 if test -n "$module"; then
6517 func_get_status "$module"
6526 if test -n "$module"; then
6527 func_get_notice "$module"
6532 extract-applicability )
6536 if test -n "$module"; then
6537 func_get_applicability "$module"
6546 if test -n "$module"; then
6547 func_get_filelist "$module"
6552 extract-dependencies )
6553 if test -n "$avoidlist"; then
6554 func_fatal_error "cannot combine --avoid and --extract-dependencies"
6559 if test -n "$module"; then
6560 func_get_dependencies "$module"
6565 extract-autoconf-snippet )
6569 if test -n "$module"; then
6570 func_get_autoconf_snippet "$module"
6575 extract-automake-snippet )
6579 if test -n "$module"; then
6580 func_get_automake_snippet "$module"
6585 extract-include-directive )
6589 if test -n "$module"; then
6590 func_get_include_directive "$module"
6595 extract-link-directive )
6599 if test -n "$module"; then
6600 func_get_link_directive "$module"
6609 if test -n "$module"; then
6610 func_get_license "$module"
6615 extract-maintainer )
6619 if test -n "$module"; then
6620 func_get_maintainer "$module"
6625 extract-tests-module )
6629 if test -n "$module"; then
6630 func_get_tests_module "$module"
6636 # Verify the number of arguments.
6637 if test $# -lt 1 || test $# -gt 2; then
6638 func_fatal_error "invalid number of arguments for --$mode"
6641 # The first argument is the file to be copied.
6643 # Verify the file exists.
6644 func_lookup_file "$f"
6646 # The second argument is the destination; either a directory ot a file.
6647 # It defaults to the current directory.
6649 test -n "$dest" || dest='.'
6650 test -n "$sourcebase" || sourcebase="lib"
6651 test -n "$m4base" || m4base="m4"
6652 test -n "$docbase" || docbase="doc"
6653 test -n "$testsbase" || testsbase="tests"
6654 test -n "$auxdir" || auxdir="build-aux"
6655 rewritten='%REWRITTEN%'
6656 sed_rewrite_files="\
6657 s,^build-aux/,$rewritten$auxdir/,
6658 s,^doc/,$rewritten$docbase/,
6659 s,^lib/,$rewritten$sourcebase/,
6660 s,^m4/,$rewritten$m4base/,
6661 s,^tests/,$rewritten$testsbase/,
6664 if test -d "$dest"; then
6666 g=`echo "$f" | sed -e "$sed_rewrite_files"`
6668 destdir=`dirname "$dest"`
6669 g=`basename "$dest"`
6672 # Create the directory for destfile.
6673 d=`dirname "$destdir/$g"`
6675 if test -n "$d" && test ! -d "$d"; then
6676 mkdir -p "$d" || func_fatal_error "failed"
6680 func_dest_tmpfilename "$g"
6681 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
6682 already_present=true
6683 if test -f "$destdir/$g"; then
6684 # The file already exists.
6688 # Don't protest if the file should be there but isn't: it happens
6689 # frequently that developers don't put autogenerated files under version
6697 func_fatal_error "unknown operation mode --$mode" ;;
6701 # Undo the effect of the previous 'trap' command. Some shellology:
6702 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6703 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6704 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6705 # 128 + signal number and is set before the trap-registered command is run.
6707 trap 'func_exit $?' 1 2 3 13 15
6712 # indent-tabs-mode: nil
6713 # whitespace-check-buffer-indent: nil