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 Written by" "Bruno Haible" "and" "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 "$lookedup_file" "$tmpfile" > /dev/null; 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 "$destdir/$g" "$tmpfile" > /dev/null; 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 "$lookedup_file" "$tmpfile" > /dev/null; 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.9b create an empty pkgdatadir at installation time
3352 # if you specify pkgdata_DATA to empty. This is a workaround.
3353 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3354 echo "pkgdata_DATA ="
3357 echo "BUILT_SOURCES ="
3360 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3361 if test -z "$makefile_name"; then
3362 echo "MOSTLYCLEANDIRS ="
3364 echo "DISTCLEANFILES ="
3365 echo "MAINTAINERCLEANFILES ="
3367 # Execute edits that apply to the Makefile.am being generated.
3369 while test $edit != $makefile_am_edits; do
3370 edit=`expr $edit + 1`
3371 eval dir=\"\$makefile_am_edit${edit}_dir\"
3372 eval var=\"\$makefile_am_edit${edit}_var\"
3373 eval val=\"\$makefile_am_edit${edit}_val\"
3374 if test -n "$var"; then
3375 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3376 echo "${var} += ${val}"
3377 eval "makefile_am_edit${edit}_var="
3381 if test -n "$witness_c_macro"; then
3382 cppflags_part1=" -D$witness_c_macro=1"
3387 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3391 if test -z "$makefile_name"; then
3393 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3396 if test -n "$cppflags_part1$cppflags_part2"; then
3398 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3402 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3403 || { test -n "$makefile_name" \
3404 && test -f "$sourcebase/Makefile.am" \
3405 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3407 # One of the snippets or the user's Makefile.am already specifies an
3408 # installation location for the library. Don't confuse automake by saying
3409 # it should not be installed.
3412 # By default, the generated library should not be installed.
3413 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3416 echo "${libname}_${libext}_SOURCES ="
3417 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3418 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3419 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3420 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3421 echo "EXTRA_${libname}_${libext}_SOURCES ="
3422 if test "$libtool" = true; then
3423 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3424 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3425 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3426 # the link dependencies of all modules.
3427 for module in $modules; do
3428 func_verify_nontests_module
3429 if test -n "$module"; then
3430 func_get_link_directive "$module"
3433 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3434 | LC_ALL=C sort -u \
3435 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3438 if test -n "$pobase"; then
3439 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3442 cat "$tmp"/allsnippets \
3443 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3445 echo "mostlyclean-local: mostlyclean-generic"
3446 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3447 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3448 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3452 rm -f "$tmp"/allsnippets
3455 # func_emit_po_Makevars
3456 # emits the contents of po/ makefile parameterization to standard output.
3458 # - local_gnulib_dir from --local-dir
3459 # - modcache true or false, from --cache-modules/--no-cache-modules
3460 # - sourcebase directory relative to destdir where to place source code
3461 # - pobase directory relative to destdir where to place *.po files
3462 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3463 func_emit_po_Makevars ()
3465 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3466 func_emit_copyright_notice
3468 echo "# Usually the message domain is the same as the package name."
3469 echo "# But here it has a '-gnulib' suffix."
3470 echo "DOMAIN = ${po_domain}-gnulib"
3472 echo "# These two variables depend on the location of this directory."
3473 echo "subdir = ${pobase}"
3474 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3477 # These options get passed to xgettext.
3478 XGETTEXT_OPTIONS = \
3479 --keyword=_ --flag=_:1:pass-c-format \
3480 --keyword=N_ --flag=N_:1:pass-c-format \
3481 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3482 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3483 --flag=error:3:c-format --flag=error_at_line:5:c-format
3485 # This is the copyright holder that gets inserted into the header of the
3486 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3487 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3489 # This is the email address or URL to which the translators shall report
3490 # bugs in the untranslated strings:
3491 # - Strings which are not entire sentences, see the maintainer guidelines
3492 # in the GNU gettext documentation, section 'Preparing Strings'.
3493 # - Strings which use unclear terms or require additional context to be
3495 # - Strings which make invalid assumptions about notation of date, time or
3497 # - Pluralisation problems.
3498 # - Incorrect English spelling.
3499 # - Incorrect formatting.
3500 # It can be your email address, or a mailing list address where translators
3501 # can write to without being subscribed, or the URL of a web page through
3502 # which the translators can contact you.
3503 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3505 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3506 # message catalogs shall be used. It is usually empty.
3507 EXTRA_LOCALE_CATEGORIES =
3509 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3510 # context. Possible values are "yes" and "no". Set this to yes if the
3511 # package uses functions taking also a message context, like pgettext(), or
3512 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3517 # func_emit_po_POTFILES_in
3518 # emits the file list to be passed to xgettext to standard output.
3520 # - local_gnulib_dir from --local-dir
3521 # - modcache true or false, from --cache-modules/--no-cache-modules
3522 # - sourcebase directory relative to destdir where to place source code
3523 # - files list of new files
3524 func_emit_po_POTFILES_in ()
3526 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3527 func_emit_copyright_notice
3529 echo "# List of files which contain translatable strings."
3530 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3533 # func_emit_tests_Makefile_am witness_macro
3534 # emits the contents of tests makefile to standard output.
3536 # - local_gnulib_dir from --local-dir
3537 # - modcache true or false, from --cache-modules/--no-cache-modules
3538 # - modules list of modules, including dependencies
3539 # - libname library name
3540 # - auxdir directory relative to destdir where to place build aux files
3541 # - makefile_name from --makefile-name
3542 # - libtool true if libtool will be used, false or blank otherwise
3543 # - sourcebase relative directory containing lib source code
3544 # - m4base relative directory containing autoconf macros
3545 # - testsbase relative directory containing unit test code
3546 # - macro_prefix prefix of gl_LIBOBJS macros to use
3547 # - witness_c_macro from --witness-c-macro
3548 # - for_test true if creating a package for testing, false otherwise
3549 # - single_configure true if a single configure file should be generated,
3550 # false for a separate configure file for the tests
3551 # - use_libtests true if a libtests.a should be built, false otherwise
3552 # - sed_replace_include_guard_prefix
3553 # sed expression for resolving ${gl_include_guard_prefix}
3554 # - destfile filename relative to destdir of makefile being generated
3556 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3557 # list of edits to be done to Makefile.am variables
3559 # - uses_subdirs nonempty if object files in subdirs exist
3560 func_emit_tests_Makefile_am ()
3563 if test "$libtool" = true; then
3565 sed_eliminate_LDFLAGS="$sed_noop"
3568 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3571 # When creating a package for testing: Attempt to provoke failures,
3572 # especially link errors, already during "make" rather than during
3573 # "make check", because "make check" is not possible in a cross-compiling
3574 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3575 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3577 sed_transform_check_PROGRAMS="$sed_noop"
3579 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3580 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3581 echo "## Process this file with automake to produce Makefile.in."
3582 func_emit_copyright_notice
3586 for module in $modules; do
3587 if $for_test && ! $single_configure; then
3588 func_verify_tests_module
3592 if test -n "$module"; then
3594 func_get_automake_snippet "$module" |
3596 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3597 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3598 -e "$sed_eliminate_LDFLAGS" \
3599 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3600 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3601 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3602 -e "$sed_transform_check_PROGRAMS" \
3603 -e "$sed_replace_include_guard_prefix"
3604 if $use_libtests && test "$module" = 'alloca'; then
3605 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3606 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3608 } > "$tmp"/amsnippet
3609 # Skip the contents if it's entirely empty.
3610 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3611 # Mention long-running tests at the end.
3613 for word in `func_get_status "$module"`; do
3614 if test "$word" = 'longrunning-test'; then
3619 { echo "## begin gnulib module $module"
3621 cat "$tmp"/amsnippet
3622 echo "## end gnulib module $module"
3626 rm -f "$tmp"/amsnippet
3627 # Test whether there are some source files in subdirectories.
3628 for f in `func_get_filelist "$module"`; do
3630 lib/*/*.c | tests/*/*.c)
3638 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3639 # Generate dependencies here, since it eases the debugging of test failures.
3640 # If there are source files in subdirectories, prevent collision of the
3641 # object files (example: hash.c and libxml/hash.c).
3643 if test -n "$uses_subdirs"; then
3644 subdir_options=' subdir-objects'
3646 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3648 if $for_test && ! $single_configure; then
3649 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3652 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3653 # variable is needed to avoid an error from automake:
3654 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3657 echo "XFAIL_TESTS ="
3658 echo "TESTS_ENVIRONMENT ="
3659 echo "noinst_PROGRAMS ="
3660 if ! $for_test; then
3661 echo "check_PROGRAMS ="
3663 echo "noinst_HEADERS ="
3664 echo "noinst_LIBRARIES ="
3665 if $use_libtests; then
3667 echo "noinst_LIBRARIES += libtests.a"
3669 echo "check_LIBRARIES = libtests.a"
3672 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3673 # if you specify pkgdata_DATA to empty. This is a workaround.
3674 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3675 echo "pkgdata_DATA ="
3678 echo "BUILT_SOURCES ="
3680 echo "MOSTLYCLEANFILES = core *.stackdump"
3681 echo "MOSTLYCLEANDIRS ="
3683 echo "DISTCLEANFILES ="
3684 echo "MAINTAINERCLEANFILES ="
3685 # Execute edits that apply to the Makefile.am being generated.
3687 while test $edit != $makefile_am_edits; do
3688 edit=`expr $edit + 1`
3689 eval dir=\"\$makefile_am_edit${edit}_dir\"
3690 eval var=\"\$makefile_am_edit${edit}_var\"
3691 eval val=\"\$makefile_am_edit${edit}_val\"
3692 if test -n "$var"; then
3693 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3694 echo "${var} += ${val}"
3695 eval "makefile_am_edit${edit}_var="
3700 echo "AM_CPPFLAGS = \\"
3702 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3704 if test -n "$witness_c_macro"; then
3705 echo " -D$witness_c_macro=1 \\"
3707 if test -n "${witness_macro}"; then
3708 echo " -D@${witness_macro}@=1 \\"
3710 echo " -I. -I\$(srcdir) \\"
3711 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3712 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3714 local_ldadd_before=''
3715 local_ldadd_after=''
3716 if $use_libtests; then
3717 # All test programs need to be linked with libtests.a.
3718 # It needs to be passed to the linker before ${libname}.${libext}, since
3719 # the tests-related modules depend on the main modules.
3720 # It also needs to be passed to the linker after ${libname}.${libext}
3721 # because the latter might contain incomplete modules (such as the 'error'
3722 # module whose dependency to 'progname' is voluntarily omitted).
3723 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3725 local_ldadd_before=' libtests.a'
3726 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3728 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3730 if $use_libtests; then
3731 echo "libtests_a_SOURCES ="
3732 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3733 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3734 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3735 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3736 echo "EXTRA_libtests_a_SOURCES ="
3737 # The circular dependency in LDADD requires this.
3738 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3741 # Many test scripts use ${EXEEXT} or ${srcdir}.
3742 # EXEEXT is defined by AC_PROG_CC through autoconf.
3743 # srcdir is defined by autoconf and automake.
3744 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3746 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3747 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3748 echo "# Clean up after Solaris cc."
3750 echo " rm -rf SunWS_cache"
3752 echo "mostlyclean-local: mostlyclean-generic"
3753 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3754 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3755 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3759 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3762 # func_emit_initmacro_start macro_prefix
3763 # emits the first few statements of the gl_INIT macro to standard output.
3764 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3765 func_emit_initmacro_start ()
3767 macro_prefix_arg="$1"
3768 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3769 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3770 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3771 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3773 # Furthermore it avoids an automake error like this when a Makefile.am
3774 # that uses pieces of gnulib also uses $(LIBOBJ):
3775 # automatically discovered file `error.c' should not be explicitly mentioned
3776 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3777 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3778 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3779 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3780 # automatically discovered file `error.c' should not be explicitly mentioned
3781 # We let automake know about the files to be distributed through the
3782 # EXTRA_lib_SOURCES variable.
3783 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3784 # Create data variables for checking the presence of files that are mentioned
3785 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3786 # because we want the check to happen when the configure file is created,
3787 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3788 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3789 # in which to expect them.
3790 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3791 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3795 # func_emit_initmacro_end macro_prefix
3796 # emits the last few statements of the gl_INIT macro to standard output.
3797 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3798 func_emit_initmacro_end ()
3800 macro_prefix_arg="$1"
3801 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3802 # The check is performed only when autoconf is run from the directory where
3803 # the configure.ac resides; if it is run from a different directory, the
3805 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3806 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3807 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3808 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3809 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3813 echo " m4_if(m4_sysval, [0], [],"
3814 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3816 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3817 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3818 echo " m4_popdef([AC_LIBSOURCES])"
3819 echo " m4_popdef([AC_REPLACE_FUNCS])"
3820 echo " m4_popdef([AC_LIBOBJ])"
3821 echo " AC_CONFIG_COMMANDS_PRE(["
3822 echo " ${macro_prefix_arg}_libobjs="
3823 echo " ${macro_prefix_arg}_ltlibobjs="
3824 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3825 echo " # Remove the extension."
3826 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3827 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3828 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3829 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3832 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3833 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3837 # func_emit_initmacro_done macro_prefix sourcebase
3838 # emits a few statements after the gl_INIT macro to standard output.
3839 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3840 # - sourcebase directory relative to destdir where to place source code
3841 func_emit_initmacro_done ()
3843 macro_prefix_arg="$1"
3846 echo "# Like AC_LIBOBJ, except that the module name goes"
3847 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3848 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3849 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3850 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3853 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3854 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3855 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3856 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3857 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3860 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3861 echo "# expected is derived from the gnulib-tool parameterization,"
3862 echo "# and alloca is special cased (for the alloca-opt module)."
3863 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3864 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3865 echo " m4_foreach([_gl_NAME], [\$1], ["
3866 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3867 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3868 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3874 # func_emit_autoconf_snippet indentation
3875 # emits the autoconf snippet of a module.
3877 # - local_gnulib_dir from --local-dir
3878 # - modcache true or false, from --cache-modules/--no-cache-modules
3879 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3880 # - sed_replace_include_guard_prefix
3881 # sed expression for resolving ${gl_include_guard_prefix}
3882 # - module the module name
3883 # - toplevel true or false. 'false' means a subordinate use of
3885 # - disable_libtool true or false. It tells whether to disable libtool
3886 # handling even if it has been specified through the
3887 # command line options.
3888 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3890 # - indentation spaces to prepend on each line
3891 func_emit_autoconf_snippet ()
3893 if { case $module in
3894 gnumakefile | maintainer-makefile)
3895 # These modules are meant to be used only in the top-level directory.
3901 func_get_autoconf_snippet "$module" \
3902 | sed -e '/^$/d;' -e "s/^/$indentation/" \
3903 -e "$sed_replace_build_aux" \
3904 -e "$sed_replace_include_guard_prefix" \
3905 | { if $disable_libtool; then
3906 sed -e 's/\$gl_cond_libtool/false/g' \
3907 -e 's/gl_libdeps/gltests_libdeps/g' \
3908 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3913 | { if $disable_gettext; then
3914 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
3919 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
3920 echo 'changequote(,)dnl'
3921 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3922 echo 'changequote([, ])dnl'
3923 echo 'AC_SUBST([LTALLOCA])'
3928 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
3929 # collects and emit the autoconf snippets of a set of modules.
3931 # - local_gnulib_dir from --local-dir
3932 # - modcache true or false, from --cache-modules/--no-cache-modules
3933 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3934 # - sed_replace_include_guard_prefix
3935 # sed expression for resolving ${gl_include_guard_prefix}
3936 # - modules the list of modules.
3937 # - verifier one of func_verify_module, func_verify_nontests_module,
3938 # func_verify_tests_module. It selects the subset of
3939 # $modules to consider.
3940 # - toplevel true or false. 'false' means a subordinate use of
3942 # - disable_libtool true or false. It tells whether to disable libtool
3943 # handling even if it has been specified through the
3944 # command line options.
3945 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3947 func_emit_autoconf_snippets ()
3951 disable_libtool="$4"
3952 disable_gettext="$5"
3953 if test "$cond_dependencies" = true; then
3954 for m in $modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
3955 # Emit the autoconf code for the unconditional modules.
3956 for module in $1; do
3958 if test -n "$module"; then
3959 if func_cond_module_p "$module"; then
3962 func_emit_autoconf_snippet " "
3966 # Initialize the shell variables indicating that the modules are enabled.
3967 for module in $1; do
3969 if test -n "$module"; then
3970 if func_cond_module_p "$module"; then
3971 func_module_shellvar_name "$module"
3972 echo " $shellvar=false"
3976 # Emit the autoconf code for the conditional modules, each in a separate
3977 # function. This makes it possible to support cycles among conditional
3979 for module in $1; do
3981 if test -n "$module"; then
3982 if func_cond_module_p "$module"; then
3983 func_module_shellfunc_name "$module"
3984 func_module_shellvar_name "$module"
3985 echo " $shellfunc ()"
3987 echo " if ! \$$shellvar; then"
3988 func_emit_autoconf_snippet " "
3989 echo " $shellvar=true"
3990 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3991 # Intersect $deps with the modules list $1.
3992 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
3993 for dep in $deps; do
3994 if func_cond_module_p "$dep"; then
3995 func_module_shellfunc_name "$dep"
3996 func_cond_module_condition "$module" "$dep"
3997 if test "$condition" != true; then
3998 echo " if $condition; then"
4005 # The autoconf code for $dep has already been emitted above and
4006 # therefore is already executed when this function is run.
4015 # Emit the dependencies from the unconditional to the conditional modules.
4016 for module in $1; do
4018 if test -n "$module"; then
4019 if func_cond_module_p "$module"; then
4022 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4023 # Intersect $deps with the modules list $1.
4024 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4025 for dep in $deps; do
4026 if func_cond_module_p "$dep"; then
4027 func_module_shellfunc_name "$dep"
4028 func_cond_module_condition "$module" "$dep"
4029 if test "$condition" != true; then
4030 echo " if $condition; then"
4037 # The autoconf code for $dep has already been emitted above and
4038 # therefore is already executed when this code is run.
4045 # Define the Automake conditionals.
4046 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4047 for module in $1; do
4049 if test -n "$module"; then
4050 if func_cond_module_p "$module"; then
4051 func_module_conditional_name "$module"
4052 func_module_shellvar_name "$module"
4053 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4058 # Ignore the conditions, and enable all modules unconditionally.
4059 for module in $1; do
4061 if test -n "$module"; then
4062 func_emit_autoconf_snippet " "
4068 # func_import modules
4069 # Uses also the variables
4070 # - mode import or add-import or remove-import or update
4071 # - destdir target directory
4072 # - local_gnulib_dir from --local-dir
4073 # - modcache true or false, from --cache-modules/--no-cache-modules
4074 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4075 # - libname library name
4076 # - supplied_libname true if --lib was given, blank otherwise
4077 # - sourcebase directory relative to destdir where to place source code
4078 # - m4base directory relative to destdir where to place *.m4 macros
4079 # - pobase directory relative to destdir where to place *.po files
4080 # - docbase directory relative to destdir where to place doc files
4081 # - testsbase directory relative to destdir where to place unit test code
4082 # - auxdir directory relative to destdir where to place build aux files
4083 # - inctests true if --with-tests was given, blank otherwise
4084 # - incobsolete true if --with-obsolete was given, blank otherwise
4085 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4086 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4088 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4090 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4092 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4093 # - avoidlist list of modules to avoid, from --avoid
4094 # - cond_dependencies true if --conditional-dependencies was given, false if
4095 # --no-conditional-dependencies was given, blank otherwise
4096 # - lgpl yes or a number if library's license shall be LGPL,
4098 # - makefile_name from --makefile-name
4099 # - libtool true if --libtool was given, false if --no-libtool was
4100 # given, blank otherwise
4101 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4102 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4103 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4104 # - witness_c_macro from --witness-c-macro
4105 # - vc_files true if --vc-files was given, false if --no-vc-files was
4106 # given, blank otherwise
4107 # - autoconf_minversion minimum supported autoconf version
4108 # - doit : if actions shall be executed, false if only to be printed
4109 # - symbolic true if files should be symlinked, copied otherwise
4110 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4112 # - do_copyrights true if copyright notices in files should be replaced,
4116 # Get the cached settings.
4117 # In 'import' mode, we read them only for the purpose of knowing the old
4118 # installed file list, and don't use them as defaults.
4119 cached_local_gnulib_dir=
4120 cached_specified_modules=
4122 cached_inc_cxx_tests=
4123 cached_inc_longrunning_tests=
4124 cached_inc_privileged_tests=
4125 cached_inc_unportable_tests=
4126 cached_inc_all_tests=
4136 cached_makefile_name=
4137 cached_cond_dependencies=
4139 cached_macro_prefix=
4141 cached_witness_c_macro=
4144 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4145 cached_libtool=false
4151 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
4161 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4163 /gl_WITH_OBSOLETE/ {
4164 s,^.*$,cached_incobsolete=true,p
4166 /gl_WITH_CXX_TESTS/ {
4167 s,^.*$,cached_inc_cxx_tests=true,p
4169 /gl_WITH_LONGRUNNING_TESTS/ {
4170 s,^.*$,cached_inc_longrunning_tests=true,p
4172 /gl_WITH_PRIVILEGED_TESTS/ {
4173 s,^.*$,cached_inc_privileged_tests=true,p
4175 /gl_WITH_UNPORTABLE_TESTS/ {
4176 s,^.*$,cached_inc_unportable_tests=true,p
4178 /gl_WITH_ALL_TESTS/ {
4179 s,^.*$,cached_inc_all_tests=true,p
4182 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4185 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4188 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4191 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4194 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4197 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4200 s,^.*$,cached_inctests=true,p
4203 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4206 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4209 s,^.*$,cached_lgpl=yes,p
4211 /gl_MAKEFILE_NAME(/ {
4212 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4214 /gl_CONDITIONAL_DEPENDENCIES/ {
4215 s,^.*$,cached_cond_dependencies=true,p
4218 s,^.*$,cached_libtool=true,p
4220 /gl_MACRO_PREFIX(/ {
4221 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4224 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4226 /gl_WITNESS_C_MACRO(/ {
4227 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4230 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4232 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4233 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4238 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4239 s,^.*$,cached_files=",p
4252 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4256 if test "$mode" = import; then
4257 # In 'import' mode, the new set of specified modules overrides the cached
4258 # set of modules. Ignore the cached settings.
4259 specified_modules="$1"
4261 # Merge the cached settings with the specified ones.
4262 # The m4base must be the same as expected from the pathname.
4263 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4264 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4266 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
4267 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4268 if test -z "$local_gnulib_dir"; then
4269 if test -n "$cached_local_gnulib_dir"; then
4272 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4274 case "$cached_local_gnulib_dir" in
4276 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4278 func_relconcat "$destdir" "$cached_local_gnulib_dir"
4279 local_gnulib_dir="$relconcat" ;;
4286 # Append the cached and the specified module names. So that
4287 # "gnulib-tool --add-import foo" means to add the module foo.
4288 specified_modules="$cached_specified_modules $1"
4291 # Take the cached module names, minus the specified module names.
4293 if $have_associative; then
4294 # Use an associative array, for O(N) worst-case run time.
4295 declare -A to_remove
4297 eval 'to_remove[$m]=yes'
4299 for module in $cached_specified_modules; do
4300 if eval 'test -z "${to_remove[$module]}"'; then
4301 func_append specified_modules "$module "
4305 # This loop has O(N²) worst-case run time.
4306 for module in $cached_specified_modules; do
4309 if test "$m" = "$module"; then
4314 if test -z "$to_remove"; then
4315 func_append specified_modules "$module "
4321 # Take the cached module names. There are no specified module names.
4322 specified_modules="$cached_specified_modules"
4325 # Included obsolete modules among the dependencies if specified either way.
4326 if test -z "$incobsolete"; then
4327 incobsolete="$cached_incobsolete"
4329 # Included special kinds of tests modules among the dependencies if specified
4331 if test -z "$inc_cxx_tests"; then
4332 inc_cxx_tests="$cached_inc_cxx_tests"
4334 if test -z "$inc_longrunning_tests"; then
4335 inc_longrunning_tests="$cached_inc_longrunning_tests"
4337 if test -z "$inc_privileged_tests"; then
4338 inc_privileged_tests="$cached_inc_privileged_tests"
4340 if test -z "$inc_unportable_tests"; then
4341 inc_unportable_tests="$cached_inc_unportable_tests"
4343 if test -z "$inc_all_tests"; then
4344 inc_all_tests="$cached_inc_all_tests"
4346 # Append the cached and the specified avoidlist. This is probably better
4347 # than dropping the cached one when --avoid is specified at least once.
4348 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4349 avoidlist=`echo $avoidlist`
4351 # The sourcebase defaults to the cached one.
4352 if test -z "$sourcebase"; then
4353 sourcebase="$cached_sourcebase"
4354 if test -z "$sourcebase"; then
4355 func_fatal_error "missing --source-base option"
4358 # The pobase defaults to the cached one.
4359 if test -z "$pobase"; then
4360 pobase="$cached_pobase"
4362 # The docbase defaults to the cached one.
4363 if test -z "$docbase"; then
4364 docbase="$cached_docbase"
4365 if test -z "$docbase"; then
4366 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."
4369 # The testsbase defaults to the cached one.
4370 if test -z "$testsbase"; then
4371 testsbase="$cached_testsbase"
4372 if test -z "$testsbase"; then
4373 func_fatal_error "missing --tests-base option"
4376 # Require the tests if specified either way.
4377 if test -z "$inctests"; then
4378 inctests="$cached_inctests"
4380 # The libname defaults to the cached one.
4381 if test -z "$supplied_libname"; then
4382 libname="$cached_libname"
4383 if test -z "$libname"; then
4384 func_fatal_error "missing --lib option"
4387 # Require LGPL if specified either way.
4388 if test -z "$lgpl"; then
4391 # The makefile_name defaults to the cached one.
4392 if test -z "$makefile_name"; then
4393 makefile_name="$cached_makefile_name"
4395 # Use conditional dependencies if specified either way.
4396 if test -z "$cond_dependencies"; then
4397 cond_dependencies="$cached_cond_dependencies"
4399 # Use libtool if specified either way, or if guessed.
4400 if test -z "$libtool"; then
4401 if test -n "$cached_m4base"; then
4402 libtool="$cached_libtool"
4404 libtool="$guessed_libtool"
4407 # The macro_prefix defaults to the cached one.
4408 if test -z "$macro_prefix"; then
4409 macro_prefix="$cached_macro_prefix"
4410 if test -z "$macro_prefix"; then
4411 func_fatal_error "missing --macro-prefix option"
4414 # The po_domain defaults to the cached one.
4415 if test -z "$po_domain"; then
4416 po_domain="$cached_po_domain"
4418 # The witness_c_macro defaults to the cached one.
4419 if test -z "$witness_c_macro"; then
4420 witness_c_macro="$cached_witness_c_macro"
4422 # The vc_files defaults to the cached one.
4423 if test -z "$vc_files"; then
4424 vc_files="$cached_vc_files"
4426 # Ensure constraints.
4427 if test "$cond_dependencies" = true && test -n "$inctests"; then
4428 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4432 # --without-*-tests options are not supported here.
4434 excl_longrunning_tests=
4435 excl_privileged_tests=
4436 excl_unportable_tests=
4438 # Canonicalize the list of specified modules.
4439 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4441 # Include all kinds of tests modules if --with-all-tests was specified.
4442 inc_all_direct_tests="$inc_all_tests"
4443 inc_all_indirect_tests="$inc_all_tests"
4445 # Determine final module list.
4446 modules="$specified_modules"
4447 func_modules_transitive_closure
4448 if test $verbose -ge 0; then
4449 func_show_module_list
4451 final_modules="$modules"
4453 # Determine main module list and tests-related module list separately.
4454 func_modules_transitive_closure_separately
4456 # Determine whether a $testsbase/libtests.a is needed.
4457 func_determine_use_libtests
4459 # Add the dummy module to the main module list or to the tests-related module
4461 func_modules_add_dummy_separately
4463 # If --lgpl, verify that the licenses of modules are compatible.
4464 if test -n "$lgpl"; then
4465 license_incompatibilities=
4466 for module in $main_modules; do
4467 license=`func_get_license $module`
4469 'GPLed build tool') ;;
4470 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4475 LGPL | LGPLv2+ | LGPLv3+) ;;
4476 *) func_append license_incompatibilities "$module $license$nl" ;;
4482 *) func_append license_incompatibilities "$module $license$nl" ;;
4485 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4490 if test -n "$license_incompatibilities"; then
4491 # Format the license incompatibilities as a table.
4492 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4493 s,^\(.................................................[^ ]*\) *, \1 ,'
4494 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4495 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4499 # Show banner notice of every module.
4500 modules="$main_modules"
4503 # Determine script to apply to imported library files.
4504 sed_transform_lib_file=
4505 for module in $main_modules; do
4506 if test $module = config-h; then
4507 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4508 sed_transform_lib_file=$sed_transform_lib_file'
4509 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4514 sed_transform_main_lib_file="$sed_transform_lib_file"
4515 if test -n "$do_copyrights"; then
4516 if test -n "$lgpl"; then
4520 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4521 s/GNU General/GNU Lesser General/g
4522 s/General Public License/Lesser General Public License/g
4523 s/Lesser Lesser General Public License/Lesser General Public License/g
4527 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4528 s/GNU General/GNU Lesser General/g
4529 s/General Public License/Lesser General Public License/g
4530 s/Lesser Lesser General Public License/Lesser General Public License/g
4532 s/version [23]\([ ,]\)/version 2.1\1/g
4535 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4539 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4540 s/GNU Lesser General/GNU General/g
4541 s/Lesser General Public License/General Public License/g
4543 s/GNU Library General/GNU General/g
4544 s/Library General Public License/General Public License/g
4546 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4551 # Determine script to apply to auxiliary files that go into $auxdir/.
4552 sed_transform_build_aux_file=
4553 if test -n "$do_copyrights"; then
4555 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4556 s/GNU Lesser General/GNU General/g
4557 s/Lesser General Public License/General Public License/g
4559 s/GNU Library General/GNU General/g
4560 s/Library General Public License/General Public License/g
4562 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4566 # Determine script to apply to library files that go into $testsbase/.
4567 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4568 if test -n "$do_copyrights"; then
4570 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4571 s/GNU Lesser General/GNU General/g
4572 s/Lesser General Public License/General Public License/g
4574 s/GNU Library General/GNU General/g
4575 s/Library General Public License/General Public License/g
4577 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4581 # Determine the final file lists.
4582 func_modules_to_filelist_separately
4585 || func_fatal_error "refusing to do nothing"
4587 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4588 new_files="$files m4/gnulib-tool.m4"
4589 old_files="$cached_files"
4590 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4591 func_append old_files " m4/gnulib-tool.m4"
4594 rewritten='%REWRITTEN%'
4595 sed_rewrite_old_files="\
4596 s,^build-aux/,$rewritten$auxdir/,
4597 s,^doc/,$rewritten$cached_docbase/,
4598 s,^lib/,$rewritten$cached_sourcebase/,
4599 s,^m4/,$rewritten$cached_m4base/,
4600 s,^tests/,$rewritten$cached_testsbase/,
4601 s,^tests=lib/,$rewritten$cached_testsbase/,
4604 sed_rewrite_new_files="\
4605 s,^build-aux/,$rewritten$auxdir/,
4606 s,^doc/,$rewritten$docbase/,
4607 s,^lib/,$rewritten$sourcebase/,
4608 s,^m4/,$rewritten$m4base/,
4609 s,^tests/,$rewritten$testsbase/,
4610 s,^tests=lib/,$rewritten$testsbase/,
4614 # Create directories.
4615 { echo "$sourcebase"
4617 if test -n "$pobase"; then
4620 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4621 if test -n "$docfiles"; then
4624 if test -n "$inctests"; then
4628 for f in $files; do echo $f; done \
4629 | sed -e "$sed_rewrite_new_files" \
4630 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4633 { # Rearrange file descriptors. Needed because "while ... done < ..."
4634 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4635 exec 5<&0 < "$tmp"/dirs
4637 if test ! -d "$destdir/$d"; then
4639 echo "Creating directory $destdir/$d"
4640 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4642 echo "Create directory $destdir/$d"
4649 # Copy files or make symbolic links. Remove obsolete files.
4653 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4654 # representing the files according to the last gnulib-tool invocation.
4655 for f in $old_files; do echo $f; done \
4656 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4659 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4660 # representing the files after this gnulib-tool invocation.
4661 for f in $new_files; do echo $f; done \
4662 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4665 # First the files that are in old-files, but not in new-files:
4666 sed_take_first_column='s,'"$delimiter"'.*,,'
4667 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4668 # Remove the file. Do nothing if the user already removed it.
4669 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4671 echo "Removing file $g (backup in ${g}~)"
4672 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4674 echo "Remove file $g (backup in ${g}~)"
4676 func_append removed_files "$g$nl"
4679 # func_add_or_update handles a file that ought to be present afterwards.
4681 # - f the original file name
4682 # - g the rewritten file name
4683 # - already_present nonempty if the file should already exist, empty
4685 func_add_or_update ()
4689 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4691 func_dest_tmpfilename "$g"
4692 func_lookup_file "$f"
4693 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4694 if test -n "$sed_transform_main_lib_file"; then
4697 sed -e "$sed_transform_main_lib_file" \
4698 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4702 if test -n "$sed_transform_build_aux_file"; then
4705 sed -e "$sed_transform_build_aux_file" \
4706 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4710 if test -n "$sed_transform_testsrelated_lib_file"; then
4713 sed -e "$sed_transform_testsrelated_lib_file" \
4714 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4718 if test -f "$destdir/$g"; then
4719 # The file already exists.
4723 # Don't protest if the file should be there but isn't: it happens
4724 # frequently that developers don't put autogenerated files under version control.
4726 func_append added_files "$g$nl"
4730 # Then the files that are in new-files, but not in old-files:
4731 sed_take_last_column='s,^.*'"$delimiter"',,'
4733 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4734 | sed -e "$sed_take_last_column" \
4735 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4736 { # Rearrange file descriptors. Needed because "while ... done < ..."
4737 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4738 exec 5<&0 < "$tmp"/added-files
4744 # Then the files that are in new-files and in old-files:
4745 already_present=true
4746 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4747 | sed -e "$sed_take_last_column" \
4748 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4749 { # Rearrange file descriptors. Needed because "while ... done < ..."
4750 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4751 exec 5<&0 < "$tmp"/kept-files
4758 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4759 actioncmd="gnulib-tool --import"
4760 func_append actioncmd " --dir=$destdir"
4761 if test -n "$local_gnulib_dir"; then
4762 func_append actioncmd " --local-dir=$local_gnulib_dir"
4764 func_append actioncmd " --lib=$libname"
4765 func_append actioncmd " --source-base=$sourcebase"
4766 func_append actioncmd " --m4-base=$m4base"
4767 if test -n "$pobase"; then
4768 func_append actioncmd " --po-base=$pobase"
4770 func_append actioncmd " --doc-base=$docbase"
4771 func_append actioncmd " --tests-base=$testsbase"
4772 func_append actioncmd " --aux-dir=$auxdir"
4773 if test -n "$inctests"; then
4774 func_append actioncmd " --with-tests"
4776 if test -n "$incobsolete"; then
4777 func_append actioncmd " --with-obsolete"
4779 if test -n "$inc_cxx_tests"; then
4780 func_append actioncmd " --with-c++-tests"
4782 if test -n "$inc_longrunning_tests"; then
4783 func_append actioncmd " --with-longrunning-tests"
4785 if test -n "$inc_privileged_tests"; then
4786 func_append actioncmd " --with-privileged-tests"
4788 if test -n "$inc_unportable_tests"; then
4789 func_append actioncmd " --with-unportable-tests"
4791 if test -n "$inc_all_tests"; then
4792 func_append actioncmd " --with-all-tests"
4794 for module in $avoidlist; do
4795 func_append actioncmd " --avoid=$module"
4797 if test -n "$lgpl"; then
4798 if test "$lgpl" = yes; then
4799 func_append actioncmd " --lgpl"
4801 func_append actioncmd " --lgpl=$lgpl"
4804 if test -n "$makefile_name"; then
4805 func_append actioncmd " --makefile-name=$makefile_name"
4807 if test "$cond_dependencies" = true; then
4808 func_append actioncmd " --conditional-dependencies"
4810 func_append actioncmd " --no-conditional-dependencies"
4812 if test "$libtool" = true; then
4813 func_append actioncmd " --libtool"
4815 func_append actioncmd " --no-libtool"
4817 func_append actioncmd " --macro-prefix=$macro_prefix"
4818 if test -n "$po_domain"; then
4819 func_append actioncmd " --po-domain=$po_domain"
4821 if test -n "$witness_c_macro"; then
4822 func_append actioncmd " --witness-c-macro=$witness_c_macro"
4824 if test -n "$vc_files"; then
4825 if test "$vc_files" = true; then
4826 func_append actioncmd " --vc-files"
4828 func_append actioncmd " --no-vc-files"
4831 func_append actioncmd " `echo $specified_modules`"
4833 # Determine include_guard_prefix.
4834 func_compute_include_guard_prefix
4836 # Default the makefile name to Makefile.am.
4837 if test -n "$makefile_name"; then
4838 makefile_am=$makefile_name
4840 makefile_am=Makefile.am
4843 # Create normal Makefile.ams.
4846 # Setup list of Makefile.am edits that are to be performed afterwards.
4847 # Some of these edits apply to files that we will generate; others are
4848 # under the responsibility of the developer.
4850 # func_note_Makefile_am_edit dir var value
4851 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4853 func_note_Makefile_am_edit ()
4855 makefile_am_edits=`expr $makefile_am_edits + 1`
4856 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4857 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4858 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4860 if test "$makefile_am" = Makefile.am; then
4861 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4862 sourcebase_base=`basename "$sourcebase"`
4863 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4865 if test -n "$pobase"; then
4866 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4867 pobase_base=`basename "$pobase"`
4868 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4870 if test -n "$inctests"; then
4871 if test "$makefile_am" = Makefile.am; then
4872 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4873 testsbase_base=`basename "$testsbase"`
4874 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4877 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4879 # Find the first parent directory of $m4base that contains or will contain
4881 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4883 sed_butlast='s,[^/][^/]*//*$,,'
4884 dir1="${m4base}/"; dir2=""
4885 while test -n "$dir1" \
4886 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4887 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4888 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4889 || { test -n "$inctests" \
4890 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4891 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4892 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4893 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4895 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4898 # Create library makefile.
4899 func_dest_tmpfilename $sourcebase/$makefile_am
4900 destfile="$sourcebase/$makefile_am"
4901 modules="$main_modules"
4902 func_emit_lib_Makefile_am > "$tmpfile"
4903 if test -f "$destdir"/$sourcebase/$makefile_am; then
4904 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4908 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4909 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4910 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4912 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4918 echo "Creating $sourcebase/$makefile_am"
4919 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4921 echo "Create $sourcebase/$makefile_am"
4924 func_append added_files "$sourcebase/$makefile_am$nl"
4927 # Create po/ directory.
4928 if test -n "$pobase"; then
4929 # Create po makefile and auxiliary files.
4930 for file in Makefile.in.in remove-potcdate.sin; do
4931 func_dest_tmpfilename $pobase/$file
4932 func_lookup_file build-aux/po/$file
4933 cat "$lookedup_file" > "$tmpfile"
4934 if test -f "$destdir"/$pobase/$file; then
4935 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4939 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4940 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4941 mv -f "$tmpfile" "$destdir"/$pobase/$file
4943 echo "Update $pobase/$file (backup in $pobase/$file~)"
4949 echo "Creating $pobase/$file"
4950 mv -f "$tmpfile" "$destdir"/$pobase/$file
4952 echo "Create $pobase/$file"
4955 func_append added_files "$pobase/$file$nl"
4958 # Create po makefile parameterization, part 1.
4959 func_dest_tmpfilename $pobase/Makevars
4960 func_emit_po_Makevars > "$tmpfile"
4961 if test -f "$destdir"/$pobase/Makevars; then
4962 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4966 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4967 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4968 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4970 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4976 echo "Creating $pobase/Makevars"
4977 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4979 echo "Create $pobase/Makevars"
4982 func_append added_files "$pobase/Makevars$nl"
4984 # Create po makefile parameterization, part 2.
4985 func_dest_tmpfilename $pobase/POTFILES.in
4986 func_emit_po_POTFILES_in > "$tmpfile"
4987 if test -f "$destdir"/$pobase/POTFILES.in; then
4988 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4992 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4993 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4994 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4996 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5002 echo "Creating $pobase/POTFILES.in"
5003 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5005 echo "Create $pobase/POTFILES.in"
5008 func_append added_files "$pobase/POTFILES.in$nl"
5011 TP_URL="http://translationproject.org/latest/"
5012 TP_RSYNC_URI="translationproject.org::tp/latest/"
5014 echo "Fetching gnulib PO files from $TP_URL"
5015 (cd "$destdir"/$pobase \
5016 && { # Prefer rsync over wget if it is available, since it consumes
5017 # less network bandwidth, due to compression.
5018 if type rsync 2>/dev/null | grep / > /dev/null; then
5019 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
5021 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
5026 echo "Fetch gnulib PO files from $TP_URL"
5028 # Create po/LINGUAS.
5030 func_dest_tmpfilename $pobase/LINGUAS
5031 (cd "$destdir"/$pobase \
5032 && { echo '# Set of available languages.'
5033 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5036 if test -f "$destdir"/$pobase/LINGUAS; then
5037 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
5040 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5041 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5042 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5045 echo "Creating $pobase/LINGUAS"
5046 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5047 func_append added_files "$pobase/LINGUAS$nl"
5050 if test -f "$destdir"/$pobase/LINGUAS; then
5051 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5053 echo "Create $pobase/LINGUAS"
5058 # Create m4/gnulib-cache.m4.
5059 func_dest_tmpfilename $m4base/gnulib-cache.m4
5061 func_emit_copyright_notice
5063 echo "# This file represents the specification of how gnulib-tool is used."
5064 echo "# It acts as a cache: It is written and read by gnulib-tool."
5065 echo "# In projects that use version control, this file is meant to be put under"
5066 echo "# version control, like the configure.ac and various Makefile.am files."
5069 echo "# Specification in the form of a command-line invocation:"
5072 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5073 # Store the local_gnulib_dir relative to destdir.
5074 case "$local_gnulib_dir" in
5076 relative_local_gnulib_dir="$local_gnulib_dir" ;;
5079 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
5081 # destdir, local_gnulib_dir are both relative.
5082 func_relativize "$destdir" "$local_gnulib_dir"
5083 relative_local_gnulib_dir="$reldir" ;;
5086 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
5088 echo "$specified_modules" | sed -e 's/^/ /g'
5090 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5091 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5092 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5093 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5094 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5095 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5096 echo "gl_AVOID([$avoidlist])"
5097 echo "gl_SOURCE_BASE([$sourcebase])"
5098 echo "gl_M4_BASE([$m4base])"
5099 echo "gl_PO_BASE([$pobase])"
5100 echo "gl_DOC_BASE([$docbase])"
5101 echo "gl_TESTS_BASE([$testsbase])"
5102 test -z "$inctests" || echo "gl_WITH_TESTS"
5103 echo "gl_LIB([$libname])"
5104 if test -n "$lgpl"; then
5105 if test "$lgpl" = yes; then
5108 echo "gl_LGPL([$lgpl])"
5111 echo "gl_MAKEFILE_NAME([$makefile_name])"
5112 if test "$cond_dependencies" = true; then
5113 echo "gl_CONDITIONAL_DEPENDENCIES"
5115 if test "$libtool" = true; then
5118 echo "gl_MACRO_PREFIX([$macro_prefix])"
5119 echo "gl_PO_DOMAIN([$po_domain])"
5120 echo "gl_WITNESS_C_DOMAIN([$witness_c_macro])"
5121 if test -n "$vc_files"; then
5122 echo "gl_VC_FILES([$vc_files])"
5125 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5126 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
5130 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5131 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5132 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5134 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5138 echo "# gnulib-cache.m4 ends here"
5145 echo "Creating $m4base/gnulib-cache.m4"
5146 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5148 echo "Create $m4base/gnulib-cache.m4"
5154 # Create m4/gnulib-comp.m4.
5155 func_dest_tmpfilename $m4base/gnulib-comp.m4
5157 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5158 func_emit_copyright_notice
5160 echo "# This file represents the compiled summary of the specification in"
5161 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5162 echo "# to be invoked from configure.ac."
5163 echo "# In projects that use version control, this file can be treated like"
5164 echo "# other built files."
5167 echo "# This macro should be invoked from $configure_ac, in the section"
5168 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5169 echo "# any checks for libraries, header files, types and library functions."
5170 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5172 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5173 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5174 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5175 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5176 echo " AC_REQUIRE([gl_PROG_AR_RANLIB])"
5177 if test -n "$uses_subdirs"; then
5178 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5180 for module in $final_modules; do
5182 if test -n "$module"; then
5183 echo "# Code from module $module:"
5184 func_get_autoconf_early_snippet "$module"
5187 | sed -e '/^$/d;' -e 's/^/ /'
5190 echo "# This macro should be invoked from $configure_ac, in the section"
5191 echo "# \"Check for header files, types and library functions\"."
5192 echo "AC_DEFUN([${macro_prefix}_INIT],"
5194 if test "$libtool" = true; then
5195 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5196 echo " gl_cond_libtool=true"
5198 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5199 echo " gl_cond_libtool=false"
5201 echo " gl_ltlibdeps="
5203 if test "$auxdir" != "build-aux"; then
5204 sed_replace_build_aux='
5206 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5207 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5211 sed_replace_build_aux="$sed_noop"
5213 echo " gl_m4_base='$m4base'"
5214 func_emit_initmacro_start $macro_prefix
5215 echo " gl_source_base='$sourcebase'"
5216 if test -n "$witness_c_macro"; then
5217 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5219 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
5220 if test -n "$witness_c_macro"; then
5221 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5223 echo " # End of code from modules"
5224 func_emit_initmacro_end $macro_prefix
5225 echo " gltests_libdeps="
5226 echo " gltests_ltlibdeps="
5227 func_emit_initmacro_start ${macro_prefix}tests
5228 echo " gl_source_base='$testsbase'"
5229 # Define a tests witness macro that depends on the package.
5230 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5231 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5232 echo "changequote(,)dnl"
5233 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"
5234 echo "changequote([, ])dnl"
5235 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5236 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5237 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5238 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
5239 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5240 func_emit_initmacro_end ${macro_prefix}tests
5241 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5242 # created using libtool, because libtool already handles the dependencies.
5243 if test "$libtool" != true; then
5244 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5245 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5246 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5247 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5248 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5250 if $use_libtests; then
5251 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5252 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5255 func_emit_initmacro_done $macro_prefix $sourcebase
5256 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5258 echo "# This macro records the list of files which have been installed by"
5259 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5260 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5261 echo "$files" | sed -e 's,^, ,'
5264 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5265 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
5269 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5270 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5271 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5273 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5277 echo "# gnulib-comp.m4 ends here"
5284 echo "Creating $m4base/gnulib-comp.m4"
5285 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5287 echo "Create $m4base/gnulib-comp.m4"
5293 if test -n "$inctests"; then
5294 # Create tests makefile.
5295 func_dest_tmpfilename $testsbase/$makefile_am
5296 destfile="$testsbase/$makefile_am"
5297 modules="$testsrelated_modules"
5298 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5299 if test -f "$destdir"/$testsbase/$makefile_am; then
5300 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
5304 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5305 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5306 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5308 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5314 echo "Creating $testsbase/$makefile_am"
5315 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5317 echo "Create $testsbase/$makefile_am"
5320 func_append added_files "$testsbase/$makefile_am$nl"
5324 if test "$vc_files" != false; then
5325 # Update the .cvsignore and .gitignore files.
5326 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5327 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5328 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5329 echo "$m4base/|A|gnulib-comp.m4"
5330 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5331 { # Rearrange file descriptors. Needed because "while ... done < ..."
5332 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5333 exec 5<&0 < "$tmp"/fileset-changes
5334 func_update_ignorelist ()
5337 if test "$ignore" = .gitignore; then
5338 # In a .gitignore file, "foo" applies to the current directory and all
5339 # subdirectories, whereas "/foo" applies to the current directory only.
5342 doubly_escaped_anchor='\\/'
5346 doubly_escaped_anchor=''
5348 if test -f "$destdir/$dir$ignore"; then
5349 if test -n "$dir_added" || test -n "$dir_removed"; then
5350 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5351 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5352 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5353 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5354 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
5356 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5358 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5359 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5360 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5361 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5362 } > "$tmp"/sed-ignore-removed
5363 { cat "$destdir/$dir$ignore"~
5364 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5365 } | sed -f "$tmp"/sed-ignore-removed \
5366 > "$destdir/$dir$ignore"
5368 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5373 if test -n "$dir_added"; then
5375 echo "Creating $destdir/$dir$ignore"
5377 if test "$ignore" = .cvsignore; then
5379 # Automake generates Makefile rules that create .dirstamp files.
5382 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5383 } > "$destdir/$dir$ignore"
5385 echo "Create $destdir/$dir$ignore"
5395 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5396 func_update_ignorelist .cvsignore
5398 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5399 func_update_ignorelist .gitignore
5406 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5407 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5408 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5409 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5410 if test "$next_dir" != "$last_dir"; then
5411 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5412 last_dir="$next_dir"
5417 A) func_append last_dir_added "$file$nl";;
5418 R) func_append last_dir_removed "$file$nl";;
5421 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5428 echo "You may need to add #include directives for the following .h files."
5429 # Intersect $specified_modules and $main_modules
5430 # (since $specified_modules is not necessarily of subset of $main_modules
5431 # - some may have been skipped through --avoid, and since the elements of
5432 # $main_modules but not in $specified_modules can go away without explicit
5433 # notice - through changes in the module dependencies).
5434 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5435 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5436 # First the #include <...> directives without #ifs, sorted for convenience,
5437 # then the #include "..." directives without #ifs, sorted for convenience,
5438 # then the #include directives that are surrounded by #ifs. Not sorted.
5439 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5440 include_directive=`func_get_include_directive "$module"`
5441 case "$nl$include_directive" in
5443 echo "$include_directive" 1>&5
5446 echo "$include_directive" | grep -v 'include "' 1>&6
5447 echo "$include_directive" | grep 'include "' 1>&7
5450 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5452 LC_ALL=C sort -u "$tmp"/include-angles
5453 LC_ALL=C sort -u "$tmp"/include-quotes
5454 cat "$tmp"/include-if
5455 ) | sed -e '/^$/d' -e 's/^/ /'
5456 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5458 for module in $main_modules; do
5459 func_get_link_directive "$module"
5461 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5462 if test `wc -l < "$tmp"/link` != 0; then
5464 echo "You may need to use the following Makefile variables when linking."
5465 echo "Use them in <program>_LDADD when linking a program, or"
5466 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5472 echo "Don't forget to"
5473 if test "$makefile_am" = Makefile.am; then
5474 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5476 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5478 if test -n "$pobase"; then
5479 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5481 if test -n "$inctests"; then
5482 if test "$makefile_am" = Makefile.am; then
5483 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5485 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5489 while test $edit != $makefile_am_edits; do
5490 edit=`expr $edit + 1`
5491 eval dir=\"\$makefile_am_edit${edit}_dir\"
5492 eval var=\"\$makefile_am_edit${edit}_var\"
5493 eval val=\"\$makefile_am_edit${edit}_val\"
5494 if test -n "$var"; then
5495 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5498 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
5499 position_early_after=AC_PROG_CC_STDC
5501 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
5502 position_early_after=AC_PROG_CC_C99
5504 position_early_after=AC_PROG_CC
5507 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
5508 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5511 # func_create_testdir testdir modules
5513 # - local_gnulib_dir from --local-dir
5514 # - modcache true or false, from --cache-modules/--no-cache-modules
5515 # - auxdir directory relative to destdir where to place build aux files
5516 # - inctests true if tests should be included, blank otherwise
5517 # - incobsolete true if obsolete modules among dependencies should be
5518 # included, blank otherwise
5519 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5521 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5523 # - excl_privileged_tests true if tests that require root privileges should be
5524 # excluded, blank otherwise
5525 # - excl_unportable_tests true if tests that fail on some platforms should be
5526 # excluded, blank otherwise
5527 # - single_configure true if a single configure file should be generated,
5528 # false for a separate configure file for the tests
5529 # - avoidlist list of modules to avoid
5530 # - cond_dependencies true if --conditional-dependencies was given, false if
5531 # --no-conditional-dependencies was given, blank otherwise
5532 # - libtool true if --libtool was given, false if --no-libtool was
5533 # given, blank otherwise
5534 # - symbolic true if files should be symlinked, copied otherwise
5535 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
5537 func_create_testdir ()
5541 if test -z "$modules"; then
5542 # All modules together.
5543 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5544 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5545 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5546 modules=`func_all_modules`
5547 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5549 specified_modules="$modules"
5551 # Canonicalize the list of specified modules.
5552 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5554 # Unlike in func_import, here we want to include all kinds of tests for the
5555 # directly specified modules, but not for dependencies.
5556 inc_all_direct_tests=true
5557 inc_all_indirect_tests="$inc_all_tests"
5559 # Check that the license of every module is consistent with the license of
5561 saved_inctests="$inctests"
5562 # When computing transitive closures, don't consider $module to depend on
5563 # $module-tests. Need this because tests are implicitly GPL and may depend
5564 # on GPL modules - therefore we don't want a warning in this case.
5566 for requested_module in $specified_modules; do
5567 requested_license=`func_get_license "$requested_module"`
5568 if test "$requested_license" != GPL; then
5569 # Here we use func_modules_transitive_closure, not just
5570 # func_get_dependencies, so that we also detect weird situations like
5571 # an LGPL module which depends on a GPLed build tool module which depends
5573 modules="$requested_module"
5574 func_modules_transitive_closure
5575 for module in $modules; do
5576 license=`func_get_license "$module"`
5578 'GPLed build tool') ;;
5579 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5581 case "$requested_license" in
5584 GPLv2+ | LGPLv2+) ;;
5585 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5591 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5597 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5606 inctests="$saved_inctests"
5608 # Subdirectory names.
5619 # Determine final module list.
5620 modules="$specified_modules"
5621 func_modules_transitive_closure
5622 if test $verbose -ge 0; then
5623 func_show_module_list
5625 final_modules="$modules"
5627 if $single_configure; then
5628 # Determine main module list and tests-related module list separately.
5629 func_modules_transitive_closure_separately
5632 if $single_configure; then
5633 # Determine whether a $testsbase/libtests.a is needed.
5634 func_determine_use_libtests
5637 # Add the dummy module if needed.
5638 if $single_configure; then
5639 func_modules_add_dummy_separately
5641 func_modules_add_dummy
5644 # Show banner notice of every module.
5645 if $single_configure; then
5646 modules="$main_modules"
5652 # Determine final file list.
5653 if $single_configure; then
5654 func_modules_to_filelist_separately
5656 func_modules_to_filelist
5657 if test $verbose -ge 0; then
5659 echo "$files" | sed -e 's/^/ /'
5662 # Add files for which the copy in gnulib is newer than the one that
5663 # "automake --add-missing --copy" would provide.
5664 files="$files build-aux/config.guess"
5665 files="$files build-aux/config.sub"
5666 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5668 rewritten='%REWRITTEN%'
5669 sed_rewrite_files="\
5670 s,^build-aux/,$rewritten$auxdir/,
5671 s,^doc/,$rewritten$docbase/,
5672 s,^lib/,$rewritten$sourcebase/,
5673 s,^m4/,$rewritten$m4base/,
5674 s,^tests/,$rewritten$testsbase/,
5675 s,^tests=lib/,$rewritten$testsbase/,
5679 # Create directories.
5680 for f in $files; do echo $f; done \
5681 | sed -e "$sed_rewrite_files" \
5682 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5683 | LC_ALL=C sort -u \
5685 { # Rearrange file descriptors. Needed because "while ... done < ..."
5686 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5687 exec 5<&0 < "$tmp"/dirs
5689 mkdir -p "$testdir/$d"
5694 # Copy files or make symbolic links.
5696 for f in $files; do echo $f; done \
5697 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5700 { # Rearrange file descriptors. Needed because "while ... done < ..."
5701 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5702 exec 5<&0 < "$tmp"/files
5705 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5707 func_lookup_file "$f"
5708 if test -n "$lookedup_tmp"; then
5709 cp -p "$lookedup_file" "$testdir/$g"
5711 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5712 if { test -n "$symbolic" \
5713 || { test -n "$lsymbolic" \
5714 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5715 func_ln "$lookedup_file" "$testdir/$g"
5717 cp -p "$lookedup_file" "$testdir/$g"
5724 # Determine include_guard_prefix.
5725 func_compute_include_guard_prefix
5727 # Create Makefile.ams that are for testing.
5730 # No special edits are needed.
5733 # Create $sourcebase/Makefile.am.
5734 mkdir -p "$testdir/$sourcebase"
5735 destfile="$sourcebase/Makefile.am"
5736 if $single_configure; then
5737 modules="$main_modules"
5739 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5740 any_uses_subdirs="$uses_subdirs"
5742 # Create $m4base/Makefile.am.
5743 mkdir -p "$testdir/$m4base"
5744 (echo "## Process this file with automake to produce Makefile.in."
5750 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5753 ) > "$testdir/$m4base/Makefile.am"
5755 subdirs="$sourcebase $m4base"
5756 subdirs_with_configure_ac=""
5758 if false && test -f "$testdir"/$m4base/gettext.m4; then
5759 # Avoid stupid error message from automake:
5760 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5761 mkdir -p "$testdir/po"
5762 (echo "## Process this file with automake to produce Makefile.in."
5763 ) > "$testdir/po/Makefile.am"
5764 func_append subdirs " po"
5767 if test -n "$inctests"; then
5768 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5769 if $single_configure; then
5770 # Create $testsbase/Makefile.am.
5771 destfile="$testsbase/Makefile.am"
5772 modules="$testsrelated_modules"
5773 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
5775 # Viewed from the $testsbase subdirectory, $auxdir is different.
5776 saved_auxdir="$auxdir"
5777 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5778 # Create $testsbase/Makefile.am.
5780 destfile="$testsbase/Makefile.am"
5781 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5782 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5783 # Create $testsbase/configure.ac.
5784 (echo "# Process this file with autoconf to produce a configure script."
5785 echo "AC_INIT([dummy], [0])"
5786 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5787 echo "AM_INIT_AUTOMAKE"
5789 echo "AC_CONFIG_HEADERS([config.h])"
5792 echo "AC_PROG_INSTALL"
5793 echo "AC_PROG_MAKE_SET"
5794 echo "gl_PROG_AR_RANLIB"
5796 if test -n "$uses_subdirs"; then
5797 echo "AM_PROG_CC_C_O"
5800 for module in $modules; do
5802 if test -n "$module"; then
5804 gnumakefile | maintainer-makefile)
5805 # These modules are meant to be used only in the top-level directory.
5808 func_get_autoconf_early_snippet "$module"
5813 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5814 if test "$libtool" = true; then
5815 echo "LT_INIT([win32-dll])"
5816 echo "LT_LANG([C++])"
5817 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5818 echo "gl_cond_libtool=true"
5820 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5821 echo "gl_cond_libtool=false"
5823 echo "gl_ltlibdeps="
5825 # Wrap the set of autoconf snippets into an autoconf macro that is then
5826 # invoked. This is needed because autoconf does not support AC_REQUIRE
5828 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5829 # but we want the AC_REQUIRE to have its normal meaning (provide one
5830 # expansion of the required macro before the current point, and only one
5832 echo "AC_DEFUN([gl_INIT], ["
5833 sed_replace_build_aux='
5835 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5836 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5839 echo "gl_m4_base='../$m4base'"
5840 func_emit_initmacro_start $macro_prefix
5841 # We don't have explicit ordering constraints between the various
5842 # autoconf snippets. It's cleanest to put those of the library before
5843 # those of the tests.
5844 echo "gl_source_base='../$sourcebase'"
5845 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
5846 echo "gl_source_base='.'"
5847 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
5848 func_emit_initmacro_end $macro_prefix
5849 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5850 # created using libtool, because libtool already handles the dependencies.
5851 if test "$libtool" != true; then
5852 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5853 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5854 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5855 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5856 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5859 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5863 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5864 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5865 echo "AH_TOP([#include \"../config.h\"])"
5867 echo "AC_CONFIG_FILES([Makefile])"
5869 ) > "$testdir/$testsbase/configure.ac"
5870 auxdir="$saved_auxdir"
5871 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5873 func_append subdirs " $testsbase"
5876 # Create Makefile.am.
5877 (echo "## Process this file with automake to produce Makefile.in."
5879 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5881 echo "SUBDIRS = $subdirs"
5883 echo "ACLOCAL_AMFLAGS = -I $m4base"
5884 ) > "$testdir/Makefile.am"
5886 # Create configure.ac.
5887 (echo "# Process this file with autoconf to produce a configure script."
5888 echo "AC_INIT([dummy], [0])"
5889 if test "$auxdir" != "."; then
5890 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5892 echo "AM_INIT_AUTOMAKE"
5894 echo "AC_CONFIG_HEADERS([config.h])"
5897 echo "AC_PROG_INSTALL"
5898 echo "AC_PROG_MAKE_SET"
5900 echo "# For autobuild."
5901 echo "AC_CANONICAL_BUILD"
5902 echo "AC_CANONICAL_HOST"
5904 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5905 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5906 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5907 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5909 echo "gl_PROG_AR_RANLIB"
5911 if test -n "$any_uses_subdirs"; then
5912 echo "AM_PROG_CC_C_O"
5915 for module in $final_modules; do
5916 if $single_configure; then
5919 func_verify_nontests_module
5921 if test -n "$module"; then
5922 func_get_autoconf_early_snippet "$module"
5925 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5926 if test "$libtool" = true; then
5927 echo "LT_INIT([win32-dll])"
5928 echo "LT_LANG([C++])"
5929 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5930 echo "gl_cond_libtool=true"
5932 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5933 echo "gl_cond_libtool=false"
5935 echo "gl_ltlibdeps="
5937 # Wrap the set of autoconf snippets into an autoconf macro that is then
5938 # invoked. This is needed because autoconf does not support AC_REQUIRE
5940 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5941 # but we want the AC_REQUIRE to have its normal meaning (provide one
5942 # expansion of the required macro before the current point, and only one
5944 echo "AC_DEFUN([gl_INIT], ["
5945 if test "$auxdir" != "build-aux"; then
5946 sed_replace_build_aux='
5948 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5949 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5953 sed_replace_build_aux="$sed_noop"
5955 echo "gl_m4_base='$m4base'"
5956 func_emit_initmacro_start $macro_prefix
5957 echo "gl_source_base='$sourcebase'"
5958 if $single_configure; then
5959 func_emit_autoconf_snippets "$main_modules" func_verify_module true false false
5961 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
5963 func_emit_initmacro_end $macro_prefix
5964 if $single_configure; then
5965 echo " gltests_libdeps="
5966 echo " gltests_ltlibdeps="
5967 func_emit_initmacro_start ${macro_prefix}tests
5968 echo " gl_source_base='$testsbase'"
5969 # Define a tests witness macro.
5970 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
5971 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5972 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5973 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5974 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true false false
5975 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5976 func_emit_initmacro_end ${macro_prefix}tests
5978 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5979 # created using libtool, because libtool already handles the dependencies.
5980 if test "$libtool" != true; then
5981 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5982 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5983 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5984 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5985 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5987 if $single_configure; then
5988 if $use_libtests; then
5989 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5990 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5994 func_emit_initmacro_done $macro_prefix $sourcebase
5995 if $single_configure; then
5996 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6001 if test -n "$subdirs_with_configure_ac"; then
6002 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6004 makefiles="Makefile"
6005 for d in $subdirs; do
6006 # For subdirs that have a configure.ac by their own, it's the subdir's
6007 # configure.ac which creates the subdir's Makefile.am, not this one.
6008 case " $subdirs_with_configure_ac " in
6010 *) func_append makefiles " $d/Makefile" ;;
6013 echo "AC_CONFIG_FILES([$makefiles])"
6015 ) > "$testdir/configure.ac"
6017 # Create autogenerated files.
6019 # Do not use "${AUTORECONF} --force --install", because it may invoke
6020 # autopoint, which brings in older versions of some of our .m4 files.
6021 if test -f $m4base/gettext.m4; then
6022 func_execute_command ${AUTOPOINT} --force || func_exit 1
6023 for f in $m4base/*.m4~; do
6025 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6029 if test "$libtool" = true; then
6030 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6032 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6033 if ! test -d build-aux; then
6034 func_execute_command mkdir build-aux || func_exit 1
6036 func_execute_command ${AUTOCONF} || func_exit 1
6037 func_execute_command ${AUTOHEADER} || func_exit 1
6038 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6040 if test -n "$inctests" && ! $single_configure; then
6041 # Create autogenerated files.
6042 (cd "$testdir/$testsbase" || func_exit 1
6043 # Do not use "${AUTORECONF} --force --install", because it may invoke
6044 # autopoint, which brings in older versions of some of our .m4 files.
6045 if test -f ../$m4base/gettext.m4; then
6046 func_execute_command ${AUTOPOINT} --force || func_exit 1
6047 for f in ../$m4base/*.m4~; do
6049 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6053 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6054 if ! test -d ../build-aux; then
6055 func_execute_command mkdir ../build-aux
6057 func_execute_command ${AUTOCONF} || func_exit 1
6058 func_execute_command ${AUTOHEADER} || func_exit 1
6059 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6062 # Need to run configure and make once, to create built files that are to be
6063 # distributed (such as parse-datetime.c).
6064 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6065 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6066 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6067 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6068 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6069 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6070 # such $(FOO_H) because they don't refer to distributed files.
6071 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6072 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6073 | sed -e "$sed_remove_make_variables"`
6074 distributed_built_sources=`for file in $built_sources; do
6075 case "$cleaned_files" in
6080 tests_distributed_built_sources=
6081 if test -n "$inctests"; then
6082 # Likewise for built files in the $testsbase directory.
6083 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6084 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6085 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6086 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6087 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6088 | sed -e "$sed_remove_make_variables"`
6089 tests_distributed_built_sources=`for file in $tests_built_sources; do
6090 case "$tests_cleaned_files" in
6096 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6098 ./configure || func_exit 1
6099 if test -n "$distributed_built_sources"; then
6101 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6102 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6107 if test -n "$tests_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 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6122 # func_create_megatestdir megatestdir allmodules
6124 # - local_gnulib_dir from --local-dir
6125 # - modcache true or false, from --cache-modules/--no-cache-modules
6126 # - auxdir directory relative to destdir where to place build aux files
6127 func_create_megatestdir ()
6131 if test -z "$allmodules"; then
6132 allmodules=`func_all_modules`
6136 # First, all modules one by one.
6137 for onemodule in $allmodules; do
6138 func_create_testdir "$megatestdir/$onemodule" $onemodule
6139 func_append megasubdirs "$onemodule "
6141 # Then, all modules all together.
6142 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6143 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6144 func_create_testdir "$megatestdir/ALL" "$allmodules"
6145 func_append megasubdirs "ALL"
6148 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
6149 vc_witness="$gnulib_dir/CVS/Entries"; \
6151 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6153 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6154 | sed -e 's,January,01,' -e 's,Jan,01,' \
6155 -e 's,February,02,' -e 's,Feb,02,' \
6156 -e 's,March,03,' -e 's,Mar,03,' \
6157 -e 's,April,04,' -e 's,Apr,04,' \
6159 -e 's,June,06,' -e 's,Jun,06,' \
6160 -e 's,July,07,' -e 's,Jul,07,' \
6161 -e 's,August,08,' -e 's,Aug,08,' \
6162 -e 's,September,09,' -e 's,Sep,09,' \
6163 -e 's,October,10,' -e 's,Oct,10,' \
6164 -e 's,November,11,' -e 's,Nov,11,' \
6165 -e 's,December,12,' -e 's,Dec,12,' \
6166 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6167 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6169 echo "CVSDATE=$cvsdate"
6170 echo ": \${MAKE=make}"
6171 echo "test -d logs || mkdir logs"
6172 echo "for module in $megasubdirs; do"
6173 echo " echo \"Working on module \$module...\""
6174 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6175 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6178 echo " : autobuild project... \$module"
6179 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6180 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6181 echo " : autobuild hostname... \`hostname\`"
6182 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6184 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6186 ) > "$megatestdir/do-autobuild"
6187 chmod a+x "$megatestdir/do-autobuild"
6189 # Create Makefile.am.
6190 (echo "## Process this file with automake to produce Makefile.in."
6192 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
6194 echo "SUBDIRS = $megasubdirs"
6196 echo "EXTRA_DIST = do-autobuild"
6197 ) > "$megatestdir/Makefile.am"
6199 # Create configure.ac.
6200 (echo "# Process this file with autoconf to produce a configure script."
6201 echo "AC_INIT([dummy], [0])"
6202 if test "$auxdir" != "."; then
6203 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6205 echo "AM_INIT_AUTOMAKE"
6207 echo "AC_PROG_MAKE_SET"
6209 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6210 echo "AC_CONFIG_FILES([Makefile])"
6212 ) > "$megatestdir/configure.ac"
6214 # Create autogenerated files.
6216 # Do not use "${AUTORECONF} --install", because autoreconf operates
6217 # recursively, but the subdirectories are already finished, therefore
6218 # calling autoreconf here would only waste lots of CPU time.
6219 func_execute_command ${ACLOCAL} || func_exit 1
6220 func_execute_command mkdir build-aux
6221 func_execute_command ${AUTOCONF} || func_exit 1
6222 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6228 func_fatal_error "no mode specified" ;;
6235 # sed expression that converts a literal to a basic regular expression.
6236 # Needs to handle . [ \ * ^ $.
6237 sed_literal_to_basic_regex='s/\\/\\\\/g
6243 if test -f "$gnulib_dir/$filename" \
6244 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
6245 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6246 filename_line_regex='^'"$filename_anywhere_regex"'$'
6249 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6250 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
6251 (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$,,')
6254 | func_sanitize_modulelist \
6257 for module in $module_candidates; do
6258 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6263 func_warning "file $filename does not exist"
6268 import | add-import | remove-import | update )
6271 if test -z "$destdir"; then
6274 test -d "$destdir" \
6275 || func_fatal_error "destination directory does not exist: $destdir"
6277 # Prefer configure.ac to configure.in.
6278 if test -f "$destdir"/configure.ac; then
6279 configure_ac="$destdir/configure.ac"
6281 if test -f "$destdir"/configure.in; then
6282 configure_ac="$destdir/configure.in"
6284 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6288 # Analyze configure.ac.
6290 guessed_libtool=false
6295 /AC_CONFIG_AUX_DIR/ {
6296 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6298 /A[CM]_PROG_LIBTOOL/ {
6299 s,^.*$,guessed_libtool=true,p
6301 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6303 if test -z "$auxdir"; then
6304 auxdir="$guessed_auxdir"
6307 # Determine where to apply func_import.
6308 if test "$mode" = import; then
6309 # Apply func_import to a particular gnulib directory.
6310 # The command line contains the complete specification; don't look at
6311 # the contents of gnulib-cache.m4.
6312 test -n "$supplied_libname" || supplied_libname=true
6313 test -n "$sourcebase" || sourcebase="lib"
6314 test -n "$m4base" || m4base="m4"
6315 test -n "$docbase" || docbase="doc"
6316 test -n "$testsbase" || testsbase="tests"
6317 test -n "$macro_prefix" || macro_prefix="gl"
6320 if test -n "$m4base"; then
6321 # Apply func_import to a particular gnulib directory.
6322 # Any number of additional modules can be given.
6323 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6324 # First use of gnulib in the given m4base.
6325 test -n "$supplied_libname" || supplied_libname=true
6326 test -n "$sourcebase" || sourcebase="lib"
6327 test -n "$docbase" || docbase="doc"
6328 test -n "$testsbase" || testsbase="tests"
6329 test -n "$macro_prefix" || macro_prefix="gl"
6333 # Apply func_import to all gnulib directories.
6334 # To get this list of directories, look at Makefile.am. (Not at
6335 # configure, because it may be omitted from version control. Also,
6336 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6340 if test -f "$destdir"/Makefile.am; then
6341 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6343 for arg in $aclocal_amflags; do
6344 if test -n "$m4dir_is_next"; then
6345 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6349 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6350 func_append m4dirs " $arg"
6351 m4dirs_count=`expr $m4dirs_count + 1`
6357 if test "X$arg" = "X-I"; then
6365 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6366 if test -f "$destdir"/aclocal.m4; then
6367 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6368 sedexpr2='s,^[^/]*$,.,'
6369 sedexpr3='s,/[^/]*$,,'
6370 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6371 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6372 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6375 if test $m4dirs_count = 0; then
6376 # First use of gnulib in a package.
6377 # Any number of additional modules can be given.
6378 test -n "$supplied_libname" || supplied_libname=true
6379 test -n "$sourcebase" || sourcebase="lib"
6381 test -n "$docbase" || docbase="doc"
6382 test -n "$testsbase" || testsbase="tests"
6383 test -n "$macro_prefix" || macro_prefix="gl"
6386 if test $m4dirs_count = 1; then
6387 # There's only one use of gnulib here. Assume the user means it.
6388 # Any number of additional modules can be given.
6389 for m4base in $m4dirs; do
6393 # Ambiguous - guess what the user meant.
6394 if test $# = 0; then
6395 # No further arguments. Guess the user wants to update all of them.
6396 for m4base in $m4dirs; do
6397 # Perform func_import in a subshell, so that variable values
6399 # local_gnulib_dir, incobsolete, inc_cxx_tests,
6400 # inc_longrunning_tests, inc_privileged_tests,
6401 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6402 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6403 # makefile_name, libtool, macro_prefix, po_domain,
6404 # witness_c_macro, vc_files
6405 # don't propagate from one directory to another.
6406 (func_import) || func_exit 1
6410 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6419 if test -z "$destdir"; then
6420 func_fatal_error "please specify --dir option"
6423 test -d "$destdir" \
6424 || func_fatal_error "could not create destination directory"
6425 test -n "$auxdir" || auxdir="build-aux"
6426 func_create_testdir "$destdir" "$*"
6429 create-megatestdir )
6430 if test -z "$destdir"; then
6431 func_fatal_error "please specify --dir option"
6433 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6434 test -n "$auxdir" || auxdir="build-aux"
6435 func_create_megatestdir "$destdir" "$*"
6439 test -n "$destdir" || destdir=testdir$$
6440 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6441 test -n "$auxdir" || auxdir="build-aux"
6442 func_create_testdir "$destdir" "$*"
6446 ../configure || func_exit 1
6447 $MAKE || func_exit 1
6448 $MAKE check || func_exit 1
6449 $MAKE distclean || func_exit 1
6450 remaining=`find . -type f -print`
6451 if test -n "$remaining"; then
6452 echo "Remaining files:" $remaining 1>&2
6453 echo "gnulib-tool: *** Stop." 1>&2
6462 test -n "$destdir" || destdir=testdir$$
6463 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6464 test -n "$auxdir" || auxdir="build-aux"
6465 func_create_megatestdir "$destdir" "$*"
6473 remaining=`find . -type f -print`
6474 if test -n "$remaining"; then
6475 echo "Remaining files:" $remaining 1>&2
6476 echo "gnulib-tool: *** Stop." 1>&2
6484 extract-description )
6488 if test -n "$module"; then
6489 func_get_description "$module"
6498 if test -n "$module"; then
6499 func_get_comment "$module"
6508 if test -n "$module"; then
6509 func_get_status "$module"
6518 if test -n "$module"; then
6519 func_get_notice "$module"
6524 extract-applicability )
6528 if test -n "$module"; then
6529 func_get_applicability "$module"
6538 if test -n "$module"; then
6539 func_get_filelist "$module"
6544 extract-dependencies )
6545 if test -n "$avoidlist"; then
6546 func_fatal_error "cannot combine --avoid and --extract-dependencies"
6551 if test -n "$module"; then
6552 func_get_dependencies "$module"
6557 extract-autoconf-snippet )
6561 if test -n "$module"; then
6562 func_get_autoconf_snippet "$module"
6567 extract-automake-snippet )
6571 if test -n "$module"; then
6572 func_get_automake_snippet "$module"
6577 extract-include-directive )
6581 if test -n "$module"; then
6582 func_get_include_directive "$module"
6587 extract-link-directive )
6591 if test -n "$module"; then
6592 func_get_link_directive "$module"
6601 if test -n "$module"; then
6602 func_get_license "$module"
6607 extract-maintainer )
6611 if test -n "$module"; then
6612 func_get_maintainer "$module"
6617 extract-tests-module )
6621 if test -n "$module"; then
6622 func_get_tests_module "$module"
6628 # Verify the number of arguments.
6629 if test $# -lt 1 || test $# -gt 2; then
6630 func_fatal_error "invalid number of arguments for --$mode"
6633 # The first argument is the file to be copied.
6635 # Verify the file exists.
6636 func_lookup_file "$f"
6638 # The second argument is the destination; either a directory ot a file.
6639 # It defaults to the current directory.
6641 test -n "$dest" || dest='.'
6642 test -n "$sourcebase" || sourcebase="lib"
6643 test -n "$m4base" || m4base="m4"
6644 test -n "$docbase" || docbase="doc"
6645 test -n "$testsbase" || testsbase="tests"
6646 test -n "$auxdir" || auxdir="build-aux"
6647 rewritten='%REWRITTEN%'
6648 sed_rewrite_files="\
6649 s,^build-aux/,$rewritten$auxdir/,
6650 s,^doc/,$rewritten$docbase/,
6651 s,^lib/,$rewritten$sourcebase/,
6652 s,^m4/,$rewritten$m4base/,
6653 s,^tests/,$rewritten$testsbase/,
6656 if test -d "$dest"; then
6658 g=`echo "$f" | sed -e "$sed_rewrite_files"`
6660 destdir=`dirname "$dest"`
6661 g=`basename "$dest"`
6664 # Create the directory for destfile.
6665 d=`dirname "$destdir/$g"`
6667 if test -n "$d" && test ! -d "$d"; then
6668 mkdir -p "$d" || func_fatal_error "failed"
6672 func_dest_tmpfilename "$g"
6673 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
6674 already_present=true
6675 if test -f "$destdir/$g"; then
6676 # The file already exists.
6680 # Don't protest if the file should be there but isn't: it happens
6681 # frequently that developers don't put autogenerated files under version
6689 func_fatal_error "unknown operation mode --$mode" ;;
6693 # Undo the effect of the previous 'trap' command. Some shellology:
6694 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6695 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6696 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6697 # 128 + signal number and is set before the trap-registered command is run.
6699 trap 'func_exit $?' 1 2 3 13 15
6704 # indent-tabs-mode: nil
6705 # whitespace-check-buffer-indent: nil