3 # Copyright (C) 2002-2011 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
75 if test -z "${MAKE}"; then
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # AIX 5.3 sed barfs over indented comments.
113 if echo fo | sed -e 's/f/g/
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
123 # outputs to stdout the --help usage message.
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
130 gnulib-tool --add-import [module1 ... moduleN]
131 gnulib-tool --remove-import [module1 ... moduleN]
133 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
134 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
135 gnulib-tool --test --dir=directory module1 ... moduleN
136 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
137 gnulib-tool --extract-description module
138 gnulib-tool --extract-comment module
139 gnulib-tool --extract-status module
140 gnulib-tool --extract-notice module
141 gnulib-tool --extract-applicability module
142 gnulib-tool --extract-filelist module
143 gnulib-tool --extract-dependencies module
144 gnulib-tool --extract-autoconf-snippet module
145 gnulib-tool --extract-automake-snippet module
146 gnulib-tool --extract-include-directive module
147 gnulib-tool --extract-link-directive module
148 gnulib-tool --extract-license module
149 gnulib-tool --extract-maintainer module
150 gnulib-tool --extract-tests-module module
151 gnulib-tool --copy-file file [destination]
155 --list print the available module names
156 --find find the modules which contain the specified file
157 --import import the given modules into the current package
158 --add-import augment the list of imports from gnulib into the
159 current package, by adding the given modules;
160 if no modules are specified, update the current
161 package from the current gnulib
162 --remove-import reduce the list of imports from gnulib into the
163 current package, by removing the given modules
164 --update update the current package, restore files omitted
166 --create-testdir create a scratch package with the given modules
167 --create-megatestdir create a mega scratch package with the given modules
168 one by one and all together
169 --test test the combination of the given modules
170 (recommended to use CC=\"gcc -Wall\" here)
171 --megatest test the given modules one by one and all together
172 (recommended to use CC=\"gcc -Wall\" here)
173 --extract-description extract the description
174 --extract-comment extract the comment
175 --extract-status extract the status (obsolete etc.)
176 --extract-notice extract the notice or banner
177 --extract-applicability extract the applicability
178 --extract-filelist extract the list of files
179 --extract-dependencies extract the dependencies
180 --extract-autoconf-snippet extract the snippet for configure.ac
181 --extract-automake-snippet extract the snippet for library makefile
182 --extract-include-directive extract the #include directive
183 --extract-link-directive extract the linker directive
184 --extract-license report the license terms of the source files
186 --extract-maintainer report the maintainer(s) inside gnulib
187 --extract-tests-module report the unit test module, if it exists
188 --copy-file copy a file that is not part of any module
192 --dir=DIRECTORY Specify the target directory.
193 For --import, this specifies where your
194 configure.ac can be found. Defaults to current
196 --local-dir=DIRECTORY Specify a local override directory where to look
197 up files before looking in gnulib's directory.
198 --cache-modules Enable module caching optimization.
199 --no-cache-modules Disable module caching optimization.
200 --verbose Increase verbosity. May be repeated.
201 --quiet Decrease verbosity. May be repeated.
203 Options for --import, --add/remove-import, --update:
205 --dry-run Only print what would have been done.
207 Options for --import, --add/remove-import,
208 --create-[mega]testdir, --[mega]test:
210 --with-tests Include unit tests for the included modules.
211 --with-obsolete Include obsolete modules when they occur among the
212 dependencies. By default, dependencies to obsolete
214 --with-c++-tests Include even unit tests for C++ interoperability.
215 --with-longrunning-tests
216 Include even unit tests that are long-runners.
217 --with-privileged-tests
218 Include even unit tests that require root
220 --with-unportable-tests
221 Include even unit tests that fail on some platforms.
222 --with-all-tests Include all kinds of problematic unit tests.
223 --avoid=MODULE Avoid including the given MODULE. Useful if you
224 have code that provides equivalent functionality.
225 This option can be repeated.
226 --conditional-dependencies
227 Support conditional dependencies (may save configure
228 time and object code).
229 --no-conditional-dependencies
230 Don't use conditional dependencies.
231 --libtool Use libtool rules.
232 --no-libtool Don't use libtool rules.
234 Options for --import, --add/remove-import:
236 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
237 --source-base=DIRECTORY
238 Directory relative to --dir where source code is
239 placed (default \"lib\").
240 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
241 placed (default \"m4\").
242 --po-base=DIRECTORY Directory relative to --dir where *.po files are
243 placed (default \"po\").
244 --doc-base=DIRECTORY Directory relative to --dir where doc files are
245 placed (default \"doc\").
246 --tests-base=DIRECTORY
247 Directory relative to --dir where unit tests are
248 placed (default \"tests\").
249 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
250 tools are placed (default comes from configure.ac).
251 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
252 Also modify license template from GPL to LGPL.
253 The version number of the LGPL can be specified;
254 the default is currently LGPLv3.
255 --makefile-name=NAME Name of makefile in automake syntax in the
256 source-base and tests-base directories
257 (default \"Makefile.am\").
258 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
259 'gl_INIT'. Default is 'gl'.
260 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
261 the package name. A suffix '-gnulib' is appended.
262 --witness-c-macro=NAME Specify the C macro that is defined when the
263 sources in this directory are compiled or used.
264 --vc-files Update version control related files.
265 --no-vc-files Don't update version control related files
266 (.gitignore and/or .cvsignore).
267 --no-changelog Don't update or create ChangeLog files.
269 Options for --create-[mega]testdir, --[mega]test:
271 --without-c++-tests Exclude unit tests for C++ interoperability.
272 --without-longrunning-tests
273 Exclude unit tests that are long-runners.
274 --without-privileged-tests
275 Exclude unit tests that require root privileges.
276 --without-unportable-tests
277 Exclude unit tests that fail on some platforms.
278 --single-configure Generate a single configure file, not a separate
279 configure file for the tests directory.
281 Options for --import, --add/remove-import, --update,
282 --create-[mega]testdir, --[mega]test:
284 -s, --symbolic, --symlink Make symbolic links instead of copying files.
285 --local-symlink Make symbolic links instead of copying files, only
286 for files from the local override directory.
288 Options for --import, --add/remove-import, --update:
290 -S, --more-symlinks Make symbolic links instead of copying files, and
291 don't replace copyright notices.
293 Report bugs to <bug-gnulib@gnu.org>."
297 # outputs to stdout the --version message.
301 if test -d "$gnulib_dir"/.git \
302 && (git --version) >/dev/null 2>/dev/null \
303 && (date --version) >/dev/null 2>/dev/null; then
304 # gnulib checked out from git.
305 sed_extract_first_date='/^Date/{
309 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
310 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
311 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
312 date=`echo "$date" | sed -e "$sed_year_before_time"`
313 # Use GNU date to compute the time in GMT.
314 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
315 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
317 if test -d "$gnulib_dir"/CVS \
318 && (cvs --version) >/dev/null 2>/dev/null; then
319 # gnulib checked out from CVS.
320 sed_extract_first_date='/^date: /{
321 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
324 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
326 # gnulib copy without versioning information.
327 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
331 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
333 gnulib-tool (GNU $package $date)$version
334 Copyright (C) $year Free Software Foundation, Inc.
335 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
336 This is free software: you are free to change and redistribute it.
337 There is NO WARRANTY, to the extent permitted by law.
339 Written by" "Bruno Haible" "and" "Simon Josefsson"
342 # func_emit_copyright_notice
343 # outputs to stdout a header for a generated file.
344 func_emit_copyright_notice ()
346 sed -n -e '/Copyright/ {
349 }' < "$self_abspathname"
351 echo "# This file is free software, distributed under the terms of the GNU"
352 echo "# General Public License. As a special exception to the GNU General"
353 echo "# Public License, this file may be distributed as part of a program"
354 echo "# that contains a configuration script generated by Autoconf, under"
355 echo "# the same distribution terms as the rest of that program."
357 echo "# Generated by gnulib-tool."
361 # exits with a given status.
362 # This function needs to be used, rather than 'exit', when a 'trap' handler is
363 # in effect that refers to $?.
370 # locates the directory where the gnulib repository lives
372 # - progname name of this program
374 # - self_abspathname absolute pathname of gnulib-tool
375 # - gnulib_dir absolute pathname of gnulib repository
379 /*) self_abspathname="$progname" ;;
380 */*) self_abspathname=`pwd`/"$progname" ;;
383 # Iterate through the elements of $PATH.
384 # We use IFS=: instead of
385 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
386 # because the latter does not work when some PATH element contains spaces.
387 # We use a canonicalized $pathx instead of $PATH, because empty PATH
388 # elements are by definition equivalent to '.', however field splitting
389 # according to IFS=: loses empty fields in many shells:
390 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
391 # beginning, at the end, and in the middle),
392 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
393 # at the beginning and at the end,
394 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
395 # Solaris lose empty fields at the end.
396 # The 'case' statement is an optimization, to avoid evaluating the
397 # explicit canonicalization command when $PATH contains no empty fields.
399 if test "${PATH_SEPARATOR+set}" != set; then
400 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
401 # contains only /bin. Note that ksh looks also at the FPATH variable,
402 # so we have to set that as well for the test.
404 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
405 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
406 || PATH_SEPARATOR=';'
409 if test "$PATH_SEPARATOR" = ";"; then
410 # On Windows, programs are searched in "." before $PATH.
413 # On Unix, we have to convert empty PATH elements to ".".
417 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
422 IFS="$PATH_SEPARATOR"
426 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
427 self_abspathname="$d/$progname"
432 if test -z "$self_abspathname"; then
433 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
437 while test -h "$self_abspathname"; do
438 # Resolve symbolic link.
439 linkval=`func_readlink "$self_abspathname"`
440 test -n "$linkval" || break
442 /* ) self_abspathname="$linkval" ;;
443 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
446 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
450 # creates a temporary directory.
452 # - progname name of this program
454 # - tmp pathname of freshly created temporary directory
457 # Use the environment variable TMPDIR, falling back to /tmp. This allows
458 # users to specify a different temporary directory, for example, if their
459 # /tmp is filled up or too small.
462 # Use the mktemp program if available. If not available, hide the error
464 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
465 test -n "$tmp" && test -d "$tmp"
468 # Use a simple mkdir command. It is guaranteed to fail if the directory
469 # already exists. $RANDOM is bash specific and expands to empty in shells
470 # other than bash, ksh and zsh. Its use does not increase security;
471 # rather, it minimizes the probability of failure in a very cluttered /tmp
473 tmp=$TMPDIR/gl$$-$RANDOM
474 (umask 077 && mkdir "$tmp")
477 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
482 # func_append var value
483 # appends the given value to the shell variable var.
484 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
485 # Use bash's += operator. It reduces complexity of appending repeatedly to
486 # a single variable from O(n^2) to O(n).
491 fast_func_append=true
495 eval "$1=\"\$$1\$2\""
497 fast_func_append=false
500 # func_remove_prefix var prefix
501 # removes the given prefix from the value of the shell variable var.
502 # var should be the name of a shell variable.
503 # Its value should not contain a newline and not start or end with whitespace.
504 # prefix should not contain the characters "$`\{}[]^|.
505 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
506 func_remove_prefix ()
510 fast_func_remove_prefix=true
512 func_remove_prefix ()
514 eval "value=\"\$$1\""
518 sed_escape_dots='s/\([.]\)/\\\1/g'
519 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
522 value=`echo "$value" | sed -e "s|^${prefix}||"`
523 eval "$1=\"\$value\""
525 fast_func_remove_prefix=false
528 # func_remove_suffix var suffix
529 # removes the given suffix from the value of the shell variable var.
530 # var should be the name of a shell variable.
531 # Its value should not contain a newline and not start or end with whitespace.
532 # suffix should not contain the characters "$`\{}[]^|.
533 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
534 func_remove_suffix ()
538 fast_func_remove_suffix=true
540 func_remove_suffix ()
542 eval "value=\"\$$1\""
546 sed_escape_dots='s/\([.]\)/\\\1/g'
547 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
550 value=`echo "$value" | sed -e "s|${suffix}\$||"`
551 eval "$1=\"\$value\""
553 fast_func_remove_suffix=false
556 # func_fatal_error message
557 # outputs to stderr a fatal error message, and terminates the program.
559 # - progname name of this program
562 echo "$progname: *** $1" 1>&2
563 echo "$progname: *** Stop." 1>&2
567 # func_warning message
568 # Outputs to stderr a warning message,
571 echo "gnulib-tool: warning: $1" 1>&2
574 # func_readlink SYMLINK
575 # outputs the target of the given symlink.
576 if (type -p readlink) > /dev/null 2>&1; then
579 # Use the readlink program from GNU coreutils.
585 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
586 # would do the wrong thing if the link target contains " -> ".
587 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
591 # func_relativize DIR1 DIR2
592 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
594 # - DIR1 relative pathname, relative to the current directory
595 # - DIR2 relative pathname, relative to the current directory
597 # - reldir relative pathname of DIR2, relative to DIR1
603 sed_first='s,^\([^/]*\)/.*$,\1,'
604 sed_rest='s,^[^/]*/*,,'
605 sed_last='s,^.*/\([^/]*\)$,\1,'
606 sed_butlast='s,/*[^/]*$,,'
607 while test -n "$dir1"; do
608 first=`echo "$dir1" | sed -e "$sed_first"`
609 if test "$first" != "."; then
610 if test "$first" = ".."; then
611 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
612 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
614 first2=`echo "$dir2" | sed -e "$sed_first"`
615 if test "$first2" = "$first"; then
616 dir2=`echo "$dir2" | sed -e "$sed_rest"`
620 dir0="$dir0"/"$first"
623 dir1=`echo "$dir1" | sed -e "$sed_rest"`
628 # func_relconcat DIR1 DIR2
629 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
631 # - DIR1 relative pathname, relative to the current directory
632 # - DIR2 relative pathname, relative to DIR1
634 # - relconcat DIR1/DIR2, relative to the current directory
639 sed_first='s,^\([^/]*\)/.*$,\1,'
640 sed_rest='s,^[^/]*/*,,'
641 sed_last='s,^.*/\([^/]*\)$,\1,'
642 sed_butlast='s,/*[^/]*$,,'
644 first=`echo "$dir2" | sed -e "$sed_first"`
645 if test "$first" = "."; then
646 dir2=`echo "$dir2" | sed -e "$sed_rest"`
647 if test -z "$dir2"; then
652 last=`echo "$dir1" | sed -e "$sed_last"`
653 while test "$last" = "."; do
654 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
655 last=`echo "$dir1" | sed -e "$sed_last"`
657 if test -z "$dir1"; then
661 if test "$first" = ".."; then
662 if test "$last" = ".."; then
663 relconcat="$dir1/$dir2"
666 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
667 dir2=`echo "$dir2" | sed -e "$sed_rest"`
668 if test -z "$dir1"; then
672 if test -z "$dir2"; then
677 relconcat="$dir1/$dir2"
685 # Like ln -s, except that SRC is given relative to the current directory (or
686 # absolute), not given relative to the directory of DEST.
692 *) # SRC is relative.
695 ln -s "`pwd`/$1" "$2" ;;
696 *) # DEST is relative too.
697 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
698 test -n "$ln_destdir" || ln_destdir="."
699 func_relativize "$ln_destdir" "$1"
707 # func_ln_if_changed SRC DEST
708 # Like func_ln, but avoids munging timestamps if the link is correct.
709 func_ln_if_changed ()
711 if test $# -ne 2; then
712 echo "usage: func_ln_if_changed SRC DEST" >&2
714 ln_target=`func_readlink "$2"`
715 if test -h "$2" && test "$1" = "$ln_target"; then
723 # Ensure an 'echo' command that
724 # 1. does not interpret backslashes and
725 # 2. does not print an error message "broken pipe" when writing into a pipe
728 # Test cases for problem 1:
729 # echo '\n' | wc -l prints 1 when OK, 2 when KO
730 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
731 # Test cases for problem 2:
732 # echo hi | true frequently prints
733 # "bash: echo: write error: Broken pipe"
734 # to standard error in bash 3.2.
736 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
737 # BSD echo interprets '-n' as an option, which is also not desirable).
738 # Nowadays the problem occurs in 4 situations:
739 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
740 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
741 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
742 # - in zsh, when sh-emulation is not set,
743 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
744 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
745 # - in Solaris /bin/sh and OSF/1 /bin/sh.
746 # We try the following workarounds:
747 # - for all: respawn using $CONFIG_SHELL if that is set and works.
748 # - for bash >= 2.04: unset the shell option xpg_echo.
749 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
750 # - for bash < 2.0: define echo to a function that uses cat of a here document.
751 # - for zsh: turn sh-emulation on.
752 # - for ksh: alias echo to 'print -r'.
753 # - for ksh: alias echo to a function that uses cat of a here document.
754 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
755 # the ksh workaround.
756 # - otherwise: respawn using /bin/sh and rely on the workarounds.
757 # When respawning, we pass --no-reexec as first argument, so as to avoid
758 # turning this script into a fork bomb in unlucky situations.
760 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
761 # the 'printf' built-in. See
762 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
763 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
764 # The workaround is: define echo to a function that uses the printf built-in.
766 if echo '\t' | grep t > /dev/null; then
767 have_echo=yes # Lucky!
769 # Try the workarounds.
770 # Respawn using $CONFIG_SHELL if that is set and works.
771 if test -z "$have_echo" \
772 && test "X$1" != "X--no-reexec" \
773 && test -n "$CONFIG_SHELL" \
774 && test -f "$CONFIG_SHELL" \
775 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
776 exec $CONFIG_SHELL "$0" --no-reexec "$@"
779 # For bash >= 2.04: unset the shell option xpg_echo.
780 if test -z "$have_echo" \
781 && test -n "$BASH_VERSION" \
782 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
786 # For bash >= 2.0: define echo to a function that uses the printf built-in.
787 # For bash < 2.0: define echo to a function that uses cat of a here document.
788 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
789 # Also handle problem 2, specific to bash 3.2, here.
790 if { test -z "$have_echo" \
791 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
793 && test -n "$BASH_VERSION"; then \
794 if type printf 2>/dev/null | grep / > /dev/null; then
795 # 'printf' is not a shell built-in.
803 # 'printf' is a shell built-in.
809 if echo '\t' | grep t > /dev/null; then
813 # For zsh: turn sh-emulation on.
814 if test -z "$have_echo" \
815 && test -n "$ZSH_VERSION" \
816 && (emulate sh) >/dev/null 2>&1; then
819 # For ksh: alias echo to 'print -r'.
820 if test -z "$have_echo" \
821 && (type print) >/dev/null 2>&1; then
822 # A 'print' command exists.
823 if type print 2>/dev/null | grep / > /dev/null; then
826 # 'print' is a shell built-in.
827 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
828 # 'print' is the ksh shell built-in.
829 alias echo='print -r'
833 if test -z "$have_echo" \
834 && echo '\t' | grep t > /dev/null; then
837 # For ksh: alias echo to a function that uses cat of a here document.
838 # The ksh manual page says:
839 # "Aliasing is performed when scripts are read, not while they are executed.
840 # Therefore, for an alias to take effect, the alias definition command has
841 # to be executed before the command which references the alias is read."
842 # Because of this, we have to play strange tricks with have_echo, to ensure
843 # that the top-level statement containing the test starts after the 'alias'
845 if test -z "$have_echo"; then
852 if (alias echo=bsd_echo) 2>/dev/null; then
853 alias echo=bsd_echo 2>/dev/null
856 if test -z "$have_echo" \
857 && echo '\t' | grep t > /dev/null; then
860 if test -z "$have_echo"; then
861 if (alias echo=bsd_echo) 2>/dev/null; then
862 unalias echo 2>/dev/null
865 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
866 if test -z "$have_echo" \
867 && test "X$1" != "X--no-reexec" \
868 && test -f /bin/ksh; then
869 exec /bin/ksh "$0" --no-reexec "$@"
872 # Otherwise: respawn using /bin/sh.
873 if test -z "$have_echo" \
874 && test "X$1" != "X--no-reexec" \
875 && test -f /bin/sh; then
876 exec /bin/sh "$0" --no-reexec "$@"
879 if test -z "$have_echo"; then
880 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
882 if echo '\t' | grep t > /dev/null; then
885 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
887 if test "X$1" = "X--no-reexec"; then
891 # Command-line option processing.
892 # Removes the OPTIONS from the arguments. Sets the variables:
893 # - mode list or import or add-import or remove-import or update
894 # or create-testdir or create-megatestdir
895 # - destdir from --dir
896 # - local_gnulib_dir from --local-dir
897 # - modcache true or false, from --cache-modules/--no-cache-modules
898 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
899 # - libname, supplied_libname from --lib
900 # - sourcebase from --source-base
901 # - m4base from --m4-base
902 # - pobase from --po-base
903 # - docbase from --doc-base
904 # - testsbase from --tests-base
905 # - auxdir from --aux-dir
906 # - inctests true if --with-tests was given, blank otherwise
907 # - incobsolete true if --with-obsolete was given, blank otherwise
908 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
909 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
911 # - inc_privileged_tests true if --with-privileged-tests was given, blank
913 # - inc_unportable_tests true if --with-unportable-tests was given, blank
915 # - inc_all_tests true if --with-all-tests was given, blank otherwise
916 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
917 # - excl_longrunning_tests true if --without-longrunning-tests was given,
919 # - excl_privileged_tests true if --without-privileged-tests was given, blank
921 # - excl_unportable_tests true if --without-unportable-tests was given, blank
923 # - single_configure true if --single-configure was given, false otherwise
924 # - avoidlist list of modules to avoid, from --avoid
925 # - cond_dependencies true if --conditional-dependencies was given, false if
926 # --no-conditional-dependencies was given, blank otherwise
927 # - lgpl yes or a number if --lgpl was given, blank otherwise
928 # - makefile_name from --makefile-name
929 # - libtool true if --libtool was given, false if --no-libtool was
930 # given, blank otherwise
931 # - macro_prefix from --macro-prefix
932 # - po_domain from --po-domain
933 # - witness_c_macro from --witness-c-macro
934 # - vc_files true if --vc-files was given, false if --no-vc-files was
935 # given, blank otherwise
936 # - autoconf_minversion minimum supported autoconf version
937 # - do_changelog false if --no-changelog was given, : otherwise
938 # - doit : if actions shall be executed, false if only to be printed
939 # - symbolic true if --symlink or --more-symlinks was given, blank
941 # - lsymbolic true if --local-symlink was given, blank otherwise
942 # - do_copyrights blank if --more-symlinks was given, true otherwise
960 inc_longrunning_tests=
961 inc_privileged_tests=
962 inc_unportable_tests=
965 excl_longrunning_tests=
966 excl_privileged_tests=
967 excl_unportable_tests=
968 single_configure=false
986 while test $# -gt 0; do
991 --find | --fin | --fi | --f )
994 --import | --impor | --impo | --imp | --im | --i )
997 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1000 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1003 --update | --updat | --upda | --upd | --up | --u )
1006 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1009 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1010 mode=create-megatestdir
1012 --test | --tes | --te | --t )
1015 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1019 mode=`echo "X$1" | sed -e 's/^X--//'`
1021 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1026 if test $# = 0; then
1027 func_fatal_error "missing argument for --dir"
1032 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1036 if test $# = 0; then
1037 func_fatal_error "missing argument for --local-dir"
1042 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1044 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1047 --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 )
1050 --verbose | --verbos | --verbo | --verb )
1051 verbose=`expr $verbose + 1`
1053 --quiet | --quie | --qui | --qu | --q )
1054 verbose=`expr $verbose - 1`
1058 if test $# = 0; then
1059 func_fatal_error "missing argument for --lib"
1062 supplied_libname=true
1065 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1066 supplied_libname=true
1070 if test $# = 0; then
1071 func_fatal_error "missing argument for --source-base"
1076 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1080 if test $# = 0; then
1081 func_fatal_error "missing argument for --m4-base"
1086 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1090 if test $# = 0; then
1091 func_fatal_error "missing argument for --po-base"
1096 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1100 if test $# = 0; then
1101 func_fatal_error "missing argument for --doc-base"
1106 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1110 if test $# = 0; then
1111 func_fatal_error "missing argument for --tests-base"
1116 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1120 if test $# = 0; then
1121 func_fatal_error "missing argument for --aux-dir"
1126 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1128 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1131 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1134 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1137 --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)
1138 inc_longrunning_tests=true
1140 --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)
1141 inc_privileged_tests=true
1143 --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)
1144 inc_unportable_tests=true
1146 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1149 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1152 --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)
1153 excl_longrunning_tests=true
1155 --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)
1156 excl_privileged_tests=true
1158 --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)
1159 excl_unportable_tests=true
1161 --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)
1162 single_configure=true
1166 if test $# = 0; then
1167 func_fatal_error "missing argument for --avoid"
1169 func_append avoidlist " $1"
1172 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1173 func_append avoidlist " $arg"
1175 --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)
1176 cond_dependencies=true
1178 --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)
1179 cond_dependencies=false
1185 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1188 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1194 if test $# = 0; then
1195 func_fatal_error "missing argument for --makefile-name"
1200 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1210 if test $# = 0; then
1211 func_fatal_error "missing argument for --macro-prefix"
1216 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1220 if test $# = 0; then
1221 func_fatal_error "missing argument for --po-domain"
1226 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1230 if test $# = 0; then
1231 func_fatal_error "missing argument for --witness-c-macro"
1233 witness_c_macro="$1"
1235 --witness-c-macro=* )
1236 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1244 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1250 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1253 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1256 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1260 --help | --hel | --he | --h )
1263 --version | --versio | --versi | --vers )
1267 # Stop option processing
1271 echo "gnulib-tool: unknown option $1" 1>&2
1272 echo "Try 'gnulib-tool --help' for more information." 1>&2
1279 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1280 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1281 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1282 || test "$single_configure" != false; then
1283 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1284 echo "Try 'gnulib-tool --help' for more information." 1>&2
1288 # This code helps migrating from --import to --add-import or --update. It can
1289 # be removed on 2012-01-01.
1290 if test "$mode" = import && test $# = 0; then
1291 echo "gnulib-tool: cowardly refusing to erase the module list." 1>&2
1292 echo "The meaning of the option '--import' has changed." 1>&2
1293 echo "See the documentation at" 1>&2
1294 echo "<http://www.gnu.org/software/gnulib/manual/html_node/Modified-imports.html>." 1>&2
1295 echo "For updating to a newer version of gnulib, use" 1>&2
1296 echo " gnulib-tool --add-import" 1>&2
1297 echo "For restoring files that were omitted from version control, use" 1>&2
1298 echo " gnulib-tool --update" 1>&2
1301 if test "$mode" = update; then
1302 if test $# != 0; then
1303 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1304 echo "Try 'gnulib-tool --help' for more information." 1>&2
1305 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1306 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1309 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1310 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1311 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1312 || test -n "$inctests" || test -n "$incobsolete" \
1313 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1314 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1315 || test -n "$inc_all_tests" \
1316 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1317 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1318 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1319 || test -n "$macro_prefix" || test -n "$po_domain" \
1320 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1321 echo "gnulib-tool: invalid options for '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
1329 if test -n "$pobase" && test -z "$po_domain"; then
1330 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1331 echo "Try 'gnulib-tool --help' for more information." 1>&2
1334 if test -z "$pobase" && test -n "$po_domain"; then
1335 func_warning "--po-domain has no effect without a --po-base option"
1337 if test "$cond_dependencies" = true && test -n "$inctests"; then
1338 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1342 # Determine the minimum supported autoconf version from the project's
1344 DEFAULT_AUTOCONF_MINVERSION="2.59"
1345 autoconf_minversion=
1347 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1348 && test -n "$destdir"; then
1349 if test -f "$destdir"/configure.ac; then
1350 configure_ac="$destdir/configure.ac"
1352 if test -f "$destdir"/configure.in; then
1353 configure_ac="$destdir/configure.in"
1357 if test -f configure.ac; then
1358 configure_ac="configure.ac"
1360 if test -f configure.in; then
1361 configure_ac="configure.in"
1365 if test -n "$configure_ac"; then
1366 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1367 # because when some m4 files are omitted from a version control repository,
1368 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1369 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1370 # autom4te: m4 failed with exit status: 1
1377 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1379 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1380 if test -n "$prereqs"; then
1381 autoconf_minversion=`
1382 for version in $prereqs; do echo $version; done |
1383 LC_ALL=C sort -nru | sed -e 1q
1387 if test -z "$autoconf_minversion"; then
1388 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1390 case "$autoconf_minversion" in
1391 1.* | 2.[0-4]* | 2.5[0-8]*)
1392 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1395 # Remove trailing slashes from the directory names. This is necessary for
1396 # m4base (to avoid an error in func_import) and optional for the others.
1397 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1398 case "$local_gnulib_dir" in
1399 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1401 case "$sourcebase" in
1402 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1405 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1408 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1411 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1413 case "$testsbase" in
1414 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1417 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1423 trap 'exit_status=$?
1424 if test "$signal" != 0; then
1425 echo "caught signal $signal" >&2
1428 exit $exit_status' 0
1429 for signal in 1 2 3 13 15; do
1430 trap '{ signal='$signal'; func_exit 1; }' $signal
1434 # Note: The 'eval' silences stderr output in dash.
1435 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1436 # Zsh 4 and Bash 4 have associative arrays.
1437 have_associative=true
1439 # For other shells, use 'eval' with computed shell variable names.
1440 have_associative=false
1443 # func_lookup_file file
1444 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1447 # - local_gnulib_dir from --local-dir
1449 # - lookedup_file name of the merged (combined) file
1450 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1454 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1455 lookedup_file="$local_gnulib_dir/$lkfile"
1458 if test -f "$gnulib_dir/$lkfile"; then
1459 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1460 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1461 rm -f "$tmp/$lkbase"
1462 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1463 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1464 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1465 lookedup_file="$tmp/$lkbase"
1468 lookedup_file="$gnulib_dir/$lkfile"
1472 func_fatal_error "file $gnulib_dir/$lkfile not found"
1477 # func_sanitize_modulelist
1478 # receives a list of possible module names on standard input, one per line.
1479 # It removes those which are just file names unrelated to modules, and outputs
1480 # the resulting list to standard output, one per line.
1481 func_sanitize_modulelist ()
1483 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1484 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1485 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1486 -e '/^README$/d' -e '/\/README$/d' \
1487 -e '/^TEMPLATE$/d' \
1488 -e '/^TEMPLATE-EXTENDED$/d' \
1489 -e '/^TEMPLATE-TESTS$/d' \
1496 # - local_gnulib_dir from --local-dir
1499 # Filter out metainformation files like README, which are not modules.
1500 # Filter out unit test modules; they can be retrieved through
1501 # --extract-tests-module if desired.
1503 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1504 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1505 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1508 | func_sanitize_modulelist \
1509 | sed -e '/-tests$/d' \
1513 # func_exists_module module
1514 # tests whether a module, given by name, exists
1516 # - local_gnulib_dir from --local-dir
1517 func_exists_module ()
1519 { test -f "$gnulib_dir/modules/$1" \
1520 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1521 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1522 && test "CVS" != "$1" \
1523 && test "ChangeLog" != "$1" \
1524 && test "COPYING" != "$1" \
1525 && test "README" != "$1" \
1526 && test "TEMPLATE" != "$1" \
1527 && test "TEMPLATE-EXTENDED" != "$1" \
1528 && test "TEMPLATE-TESTS" != "$1"
1531 # func_verify_module
1532 # verifies a module name
1534 # - local_gnulib_dir from --local-dir
1535 # - module module name argument
1536 func_verify_module ()
1538 if func_exists_module "$module"; then
1539 # OK, $module is a correct module name.
1540 # Verify that building the module description with 'patch' succeeds.
1541 func_lookup_file "modules/$module"
1543 func_warning "module $module doesn't exist"
1548 # func_verify_nontests_module
1549 # verifies a module name, excluding tests modules
1551 # - local_gnulib_dir from --local-dir
1552 # - module module name argument
1553 func_verify_nontests_module ()
1556 *-tests ) module= ;;
1557 * ) func_verify_module ;;
1561 # func_verify_tests_module
1562 # verifies a module name, considering only tests modules
1564 # - local_gnulib_dir from --local-dir
1565 # - module module name argument
1566 func_verify_tests_module ()
1569 *-tests ) func_verify_module ;;
1574 # Suffix of a sed expression that extracts a particular field from a
1575 # module description.
1576 # A field starts with a line that contains a keyword, such as 'Description',
1577 # followed by a colon and optional whitespace. All following lines, up to
1578 # the next field (or end of file if there is none) form the contents of the
1580 # An absent field is equivalent to a field with empty contents.
1581 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1582 sed_extract_prog=':[ ]*$/ {
1585 s/^Description:[ ]*$//
1589 s/^Applicability:[ ]*$//
1591 s/^Depends-on:[ ]*$//
1592 s/^configure\.ac-early:[ ]*$//
1593 s/^configure\.ac:[ ]*$//
1594 s/^Makefile\.am:[ ]*$//
1598 s/^Maintainer:[ ]*$//
1605 # Piece of a sed expression that converts a field header line to a shell
1607 # NOTE: Keep this in sync with sed_extract_prog above!
1608 sed_extract_field_header='
1609 s/^Description:[ ]*$/description/
1610 s/^Comment:[ ]*$/comment/
1611 s/^Status:[ ]*$/status/
1612 s/^Notice:[ ]*$/notice/
1613 s/^Applicability:[ ]*$/applicability/
1614 s/^Files:[ ]*$/files/
1615 s/^Depends-on:[ ]*$/dependson/
1616 s/^configure\.ac-early:[ ]*$/configureac_early/
1617 s/^configure\.ac:[ ]*$/configureac/
1618 s/^Makefile\.am:[ ]*$/makefile/
1619 s/^Include:[ ]*$/include/
1621 s/^License:[ ]*$/license/
1622 s/^Maintainer:[ ]*$/maintainer/'
1626 if $have_associative; then
1628 # Declare the associative arrays.
1629 declare -A modcache_cached
1630 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1631 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1632 eval "$declare_script"
1636 # func_cache_var module
1637 # computes the cache variable name corresponding to $module.
1638 # Note: This computation can map different module names to the same
1639 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1640 # to protect against this case.
1642 # - cachevar a shell variable name
1643 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1644 # Bash 2.0 and newer, ksh, and zsh support the syntax
1645 # ${param//pattern/replacement}
1646 # as a shorthand for
1647 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1648 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1649 eval 'func_cache_var ()
1651 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1658 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1667 # func_init_sed_convert_to_cache_statements
1669 # - modcachevar_assignment
1671 # - sed_convert_to_cache_statements
1672 func_init_sed_convert_to_cache_statements ()
1674 # 'sed' script that turns a module description into shell script
1675 # assignments, suitable to be eval'ed. All active characters are escaped.
1678 # Some module's description
1683 # modcache_description[$1]=\
1684 # 'Some module'"'"'s description
1686 # modcache_files[$1]=\
1689 # c_MODULE_description_set=set; c_MODULE_description=\
1690 # 'Some module'"'"'s description
1692 # c_MODULE_files_set=set; c_MODULE_files=\
1694 # The script consists of two parts:
1695 # 1) Ignore the lines before the first field header.
1696 # 2) A loop, treating non-field-header lines by escaping single quotes
1697 # and adding a closing quote in the last line,
1698 sed_convert_to_cache_statements="
1700 # Here we have not yet seen a field header.
1702 # See if the current line contains a field header.
1705 ${sed_extract_field_header}
1708 # No field header. Ignore the line.
1710 # Read the next line. Upon EOF, just exit.
1715 # The current line contains a field header.
1717 # Turn it into the beginning of an assignment.
1718 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1720 # Move it to the hold space. Don't print it yet,
1721 # because we want no assignment if the field is empty.
1724 # Read the next line.
1725 # Upon EOF, the field was empty. Print no assignment. Just exit.
1728 # See if the current line contains a field header.
1731 ${sed_extract_field_header}
1732 # If it is, the previous field was empty. Print no assignment.
1735 # Not a field header.
1737 # Print the previous line, held in the hold space.
1742 # Transform single quotes.
1745 # Prepend a single quote.
1750 # Move it to the hold space.
1753 # Read the next line.
1760 # See if the current line contains a field header.
1763 ${sed_extract_field_header}
1766 # Print the previous line, held in the hold space.
1771 # Transform single quotes.
1778 # Print the previous line, held in the hold space, with a single quote
1779 # to end the assignment.
1789 # Print the previous line, held in the hold space, with a single quote
1790 # to end the assignment.
1797 if ! $sed_comments; then
1799 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1800 | sed -e 's/^ *//' -e 's/^#.*//'`
1804 if $have_associative; then
1805 # sed_convert_to_cache_statements does not depend on the module.
1806 modcachevar_assignment='modcache_\1[$1]='
1807 func_init_sed_convert_to_cache_statements
1810 # func_cache_lookup_module module
1812 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1813 # of its relevant data in a cache in the memory of the processing shell. If
1814 # already cached, it does not look it up again, thus saving file access time.
1816 # - module non-empty string
1817 # Output if $have_associative:
1818 # - modcache_cached[$module] set to yes
1819 # - modcache_description[$module] ==
1820 # - modcache_status[$module] \ set to the field's value, minus the
1821 # - ... / final newline,
1822 # - modcache_maintainer[$module] == or unset if the field's value is empty
1823 # Output if ! $have_associative:
1824 # - cachevar a shell variable name
1825 # - ${cachevar}_cached set to $module
1826 # - ${cachevar}_description ==
1827 # - ${cachevar}_status \ set to the field's value, minus the
1828 # - ... / final newline,
1829 # - ${cachevar}_maintainer == or unset if the field's value is empty
1830 # - ${cachevar}_description_set ==
1831 # - ${cachevar}_status_set \ set to non-empty if the field's value
1832 # - ... / is non-empty,
1833 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1834 func_cache_lookup_module ()
1836 if $have_associative; then
1837 eval 'cached=${modcache_cached[$1]}'
1840 eval "cached=\"\$${cachevar}_cached\""
1842 if test -z "$cached"; then
1843 # Not found in cache. Look it up on the file system.
1844 func_lookup_file "modules/$1"
1845 if $have_associative; then
1846 eval 'modcache_cached[$1]=yes'
1848 eval "${cachevar}_cached=\"\$1\""
1850 if ! $have_associative; then
1851 # sed_convert_to_cache_statements depends on the module.
1852 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1853 func_init_sed_convert_to_cache_statements
1855 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1856 eval "$cache_statements"
1858 if ! $have_associative; then
1859 if test "$1" != "$cached"; then
1860 func_fatal_error "cache variable collision between $1 and $cached"
1868 # func_get_description module
1870 # - local_gnulib_dir from --local-dir
1871 # - modcache true or false, from --cache-modules/--no-cache-modules
1872 func_get_description ()
1874 if ! $modcache; then
1875 func_lookup_file "modules/$1"
1876 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1878 func_cache_lookup_module "$1"
1879 # Output the field's value, including the final newline (if any).
1880 if $have_associative; then
1881 if eval 'test -n "${modcache_description[$1]+set}"'; then
1882 eval 'echo "${modcache_description[$1]}"'
1885 eval "field_set=\"\$${cachevar}_description_set\""
1886 if test -n "$field_set"; then
1887 eval "field_value=\"\$${cachevar}_description\""
1888 echo "${field_value}"
1894 # func_get_comment module
1896 # - local_gnulib_dir from --local-dir
1897 # - modcache true or false, from --cache-modules/--no-cache-modules
1900 if ! $modcache; then
1901 func_lookup_file "modules/$1"
1902 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1904 func_cache_lookup_module "$1"
1905 # Output the field's value, including the final newline (if any).
1906 if $have_associative; then
1907 if eval 'test -n "${modcache_comment[$1]+set}"'; then
1908 eval 'echo "${modcache_comment[$1]}"'
1911 eval "field_set=\"\$${cachevar}_comment_set\""
1912 if test -n "$field_set"; then
1913 eval "field_value=\"\$${cachevar}_comment\""
1914 echo "${field_value}"
1920 # func_get_status module
1922 # - local_gnulib_dir from --local-dir
1923 # - modcache true or false, from --cache-modules/--no-cache-modules
1926 if ! $modcache; then
1927 func_lookup_file "modules/$1"
1928 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1930 func_cache_lookup_module "$1"
1931 # Output the field's value, including the final newline (if any).
1932 if $have_associative; then
1933 if eval 'test -n "${modcache_status[$1]+set}"'; then
1934 eval 'echo "${modcache_status[$1]}"'
1937 eval "field_set=\"\$${cachevar}_status_set\""
1938 if test -n "$field_set"; then
1939 eval "field_value=\"\$${cachevar}_status\""
1940 echo "${field_value}"
1946 # func_get_notice module
1948 # - local_gnulib_dir from --local-dir
1949 # - modcache true or false, from --cache-modules/--no-cache-modules
1952 if ! $modcache; then
1953 func_lookup_file "modules/$1"
1954 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1956 func_cache_lookup_module "$1"
1957 # Output the field's value, including the final newline (if any).
1958 if $have_associative; then
1959 if eval 'test -n "${modcache_notice[$1]+set}"'; then
1960 eval 'echo "${modcache_notice[$1]}"'
1963 eval "field_set=\"\$${cachevar}_notice_set\""
1964 if test -n "$field_set"; then
1965 eval "field_value=\"\$${cachevar}_notice\""
1966 echo "${field_value}"
1972 # func_get_applicability module
1974 # - local_gnulib_dir from --local-dir
1975 # - modcache true or false, from --cache-modules/--no-cache-modules
1976 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1977 func_get_applicability ()
1979 if ! $modcache; then
1980 func_lookup_file "modules/$1"
1981 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1983 func_cache_lookup_module "$1"
1984 # Get the field's value, without the final newline.
1985 if $have_associative; then
1986 eval 'my_applicability="${modcache_applicability[$1]}"'
1988 eval "my_applicability=\"\$${cachevar}_applicability\""
1991 if test -n "$my_applicability"; then
1992 echo $my_applicability
1994 # The default is 'main' or 'tests', depending on the module's name.
1996 *-tests) echo "tests";;
2002 # func_get_filelist module
2004 # - local_gnulib_dir from --local-dir
2005 # - modcache true or false, from --cache-modules/--no-cache-modules
2006 func_get_filelist ()
2008 if ! $modcache; then
2009 func_lookup_file "modules/$1"
2010 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2012 func_cache_lookup_module "$1"
2013 # Output the field's value, including the final newline (if any).
2014 if $have_associative; then
2015 if eval 'test -n "${modcache_files[$1]+set}"'; then
2016 eval 'echo "${modcache_files[$1]}"'
2019 eval "field_set=\"\$${cachevar}_files_set\""
2020 if test -n "$field_set"; then
2021 eval "field_value=\"\$${cachevar}_files\""
2022 echo "${field_value}"
2027 echo m4/gnulib-common.m4
2028 case "$autoconf_minversion" in
2035 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2036 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2037 # elements starting with prefix and ending with suffix are considered.
2038 # Processing: removed_prefix and removed_suffix are removed from each element,
2039 # added_prefix and added_suffix are added to each element.
2040 # prefix, suffix should not contain shell-special characters.
2041 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2042 # added_prefix, added_suffix should not contain the characters \|&.
2043 func_filter_filelist ()
2045 if test "$2" != "$nl" \
2046 || { $fast_func_append \
2047 && { test -z "$6" || $fast_func_remove_prefix; } \
2048 && { test -z "$7" || $fast_func_remove_suffix; }; \
2052 # Do not quote possibly-empty parameters in case patterns,
2053 # AIX and HP-UX ksh won't match them if they are empty.
2056 if test -n "$6"; then
2057 func_remove_prefix fff "$6"
2059 if test -n "$7"; then
2060 func_remove_suffix fff "$7"
2063 if test -z "$ffflist"; then
2066 func_append ffflist "$2${fff}"
2072 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2073 ffflist=`for fff in $3; do
2075 $4*$5) echo "$fff" ;;
2077 done | sed -e "$sed_fff_filter"`
2079 eval "$1=\"\$ffflist\""
2082 # func_get_dependencies module
2084 # - local_gnulib_dir from --local-dir
2085 # - modcache true or false, from --cache-modules/--no-cache-modules
2086 func_get_dependencies ()
2088 # ${module}-tests implicitly depends on ${module}, if that module exists.
2092 func_remove_suffix fgd1 '-tests'
2093 if func_exists_module "$fgd1"; then
2098 # Then the explicit dependencies listed in the module description.
2099 if ! $modcache; then
2100 func_lookup_file "modules/$1"
2101 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2103 func_cache_lookup_module "$1"
2104 # Output the field's value, including the final newline (if any).
2105 if $have_associative; then
2106 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2107 eval 'echo "${modcache_dependson[$1]}"'
2110 eval "field_set=\"\$${cachevar}_dependson_set\""
2111 if test -n "$field_set"; then
2112 eval "field_value=\"\$${cachevar}_dependson\""
2113 echo "${field_value}"
2119 # func_get_autoconf_early_snippet module
2121 # - local_gnulib_dir from --local-dir
2122 # - modcache true or false, from --cache-modules/--no-cache-modules
2123 func_get_autoconf_early_snippet ()
2125 if ! $modcache; then
2126 func_lookup_file "modules/$1"
2127 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2129 func_cache_lookup_module "$1"
2130 # Output the field's value, including the final newline (if any).
2131 if $have_associative; then
2132 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2133 eval 'echo "${modcache_configureac_early[$1]}"'
2136 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2137 if test -n "$field_set"; then
2138 eval "field_value=\"\$${cachevar}_configureac_early\""
2139 echo "${field_value}"
2145 # func_get_autoconf_snippet module
2147 # - local_gnulib_dir from --local-dir
2148 # - modcache true or false, from --cache-modules/--no-cache-modules
2149 func_get_autoconf_snippet ()
2151 if ! $modcache; then
2152 func_lookup_file "modules/$1"
2153 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2155 func_cache_lookup_module "$1"
2156 # Output the field's value, including the final newline (if any).
2157 if $have_associative; then
2158 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2159 eval 'echo "${modcache_configureac[$1]}"'
2162 eval "field_set=\"\$${cachevar}_configureac_set\""
2163 if test -n "$field_set"; then
2164 eval "field_value=\"\$${cachevar}_configureac\""
2165 echo "${field_value}"
2171 # func_get_automake_snippet_conditional module
2172 # returns the part of the Makefile.am snippet that can be put inside Automake
2175 # - local_gnulib_dir from --local-dir
2176 # - modcache true or false, from --cache-modules/--no-cache-modules
2177 func_get_automake_snippet_conditional ()
2179 if ! $modcache; then
2180 func_lookup_file "modules/$1"
2181 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2183 func_cache_lookup_module "$1"
2184 # Output the field's value, including the final newline (if any).
2185 if $have_associative; then
2186 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2187 eval 'echo "${modcache_makefile[$1]}"'
2190 eval "field_set=\"\$${cachevar}_makefile_set\""
2191 if test -n "$field_set"; then
2192 eval "field_value=\"\$${cachevar}_makefile\""
2193 echo "${field_value}"
2199 # func_get_automake_snippet_unconditional module
2200 # returns the part of the Makefile.am snippet that must stay outside of
2201 # Automake conditionals.
2203 # - local_gnulib_dir from --local-dir
2204 # - modcache true or false, from --cache-modules/--no-cache-modules
2205 func_get_automake_snippet_unconditional ()
2209 # *-tests module live in tests/, not lib/.
2210 # Synthesize an EXTRA_DIST augmentation.
2211 all_files=`func_get_filelist $1`
2212 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2213 extra_files="$tests_files"
2214 if test -n "$extra_files"; then
2215 echo "EXTRA_DIST +=" $extra_files
2220 # Synthesize an EXTRA_DIST augmentation.
2221 sed_combine_lines='/\\$/{
2228 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2229 already_mentioned_files=` \
2230 { if ! $modcache; then
2231 func_lookup_file "modules/$1"
2232 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2234 func_cache_lookup_module "$1"
2235 if $have_associative; then
2236 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2237 eval 'echo "${modcache_makefile[$1]}"'
2240 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2241 if test -n "$field_set"; then
2242 eval 'field_value="$'"${cachevar}"'_makefile"'
2243 echo "${field_value}"
2248 | sed -e "$sed_combine_lines" \
2249 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2250 all_files=`func_get_filelist $1`
2251 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2252 # Remove $already_mentioned_files from $lib_files.
2253 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2254 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2255 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2256 if test -n "$extra_files"; then
2257 echo "EXTRA_DIST +=" $extra_files
2260 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2261 # This is necessary so that automake can generate the right list of
2263 # A possible approach would be to use autom4te --trace of the redefined
2264 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2265 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2266 # inside autoconf's built-in macros are not missed).
2267 # But it's simpler and more robust to do it here, based on the file list.
2268 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2269 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2270 # automake will generate a useless dependency; this is harmless.
2272 relocatable-prog-wrapper) ;;
2275 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2276 if test -n "$extra_files"; then
2277 echo "EXTRA_lib_SOURCES +=" $extra_files
2282 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2283 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2284 if test -n "$buildaux_files"; then
2285 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2286 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2289 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2290 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2291 if test -n "$top_files"; then
2292 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2293 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2300 # func_get_automake_snippet module
2302 # - local_gnulib_dir from --local-dir
2303 # - modcache true or false, from --cache-modules/--no-cache-modules
2304 func_get_automake_snippet ()
2306 func_get_automake_snippet_conditional "$1"
2307 func_get_automake_snippet_unconditional "$1"
2310 # func_get_include_directive module
2312 # - local_gnulib_dir from --local-dir
2313 # - modcache true or false, from --cache-modules/--no-cache-modules
2314 func_get_include_directive ()
2317 if ! $modcache; then
2318 func_lookup_file "modules/$1"
2319 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2321 func_cache_lookup_module "$1"
2322 # Output the field's value, including the final newline (if any).
2323 if $have_associative; then
2324 if eval 'test -n "${modcache_include[$1]+set}"'; then
2325 eval 'echo "${modcache_include[$1]}"'
2328 eval "field_set=\"\$${cachevar}_include_set\""
2329 if test -n "$field_set"; then
2330 eval "field_value=\"\$${cachevar}_include\""
2331 echo "${field_value}"
2335 } | sed -e 's/^\(["<]\)/#include \1/'
2338 # func_get_link_directive module
2340 # - local_gnulib_dir from --local-dir
2341 # - modcache true or false, from --cache-modules/--no-cache-modules
2342 func_get_link_directive ()
2344 if ! $modcache; then
2345 func_lookup_file "modules/$1"
2346 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2348 func_cache_lookup_module "$1"
2349 # Output the field's value, including the final newline (if any).
2350 if $have_associative; then
2351 if eval 'test -n "${modcache_link[$1]+set}"'; then
2352 eval 'echo "${modcache_link[$1]}"'
2355 eval "field_set=\"\$${cachevar}_link_set\""
2356 if test -n "$field_set"; then
2357 eval "field_value=\"\$${cachevar}_link\""
2358 echo "${field_value}"
2364 # func_get_license module
2366 # - local_gnulib_dir from --local-dir
2367 # - modcache true or false, from --cache-modules/--no-cache-modules
2371 if ! $modcache; then
2372 func_lookup_file "modules/$1"
2373 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2375 func_cache_lookup_module "$1"
2376 # Output the field's value, including the final newline (if any).
2377 if $have_associative; then
2378 if eval 'test -n "${modcache_license[$1]+set}"'; then
2379 eval 'echo "${modcache_license[$1]}"'
2382 eval "field_set=\"\$${cachevar}_license_set\""
2383 if test -n "$field_set"; then
2384 eval "field_value=\"\$${cachevar}_license\""
2385 echo "${field_value}"
2389 # The default is GPL.
2391 } | sed -e 's,^ *$,,' | sed -e 1q
2394 # func_get_maintainer module
2396 # - local_gnulib_dir from --local-dir
2397 # - modcache true or false, from --cache-modules/--no-cache-modules
2398 func_get_maintainer ()
2400 if ! $modcache; then
2401 func_lookup_file "modules/$1"
2402 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2404 func_cache_lookup_module "$1"
2405 # Output the field's value, including the final newline (if any).
2406 if $have_associative; then
2407 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2408 eval 'echo "${modcache_maintainer[$1]}"'
2411 eval "field_set=\"\$${cachevar}_maintainer_set\""
2412 if test -n "$field_set"; then
2413 eval "field_value=\"\$${cachevar}_maintainer\""
2414 echo "${field_value}"
2420 # func_get_tests_module module
2422 # - local_gnulib_dir from --local-dir
2423 func_get_tests_module ()
2425 # The naming convention for tests modules is hardwired: ${module}-tests.
2426 if test -f "$gnulib_dir/modules/$1"-tests \
2427 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2428 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2433 # func_acceptable module
2434 # tests whether a module is acceptable.
2436 # - avoidlist list of modules to avoid
2439 for avoid in $avoidlist; do
2440 if test "$avoid" = "$1"; then
2447 # sed expression to keep the first 32 characters of each line.
2448 sed_first_32_chars='s/^\(................................\).*/\1/'
2450 # func_module_shellfunc_name module
2451 # computes the shell function name that will contain the m4 macros for the module.
2453 # - macro_prefix prefix to use
2455 # - shellfunc shell function name
2456 func_module_shellfunc_name ()
2460 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2462 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2466 # func_module_shellvar_name module
2467 # computes the shell variable name the will be set to true once the m4 macros
2468 # for the module have been executed.
2470 # - shellvar shell variable name
2471 func_module_shellvar_name ()
2475 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2477 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2481 # func_module_conditional_name module
2482 # computes the automake conditional name for the module.
2484 # - conditional name of automake conditional
2485 func_module_conditional_name ()
2489 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2491 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2495 # func_uncond_add_module B
2496 # notes the presence of B as an unconditional module.
2498 # func_conddep_add_module A B cond
2499 # notes the presence of a conditional dependency from module A to module B,
2500 # subject to the condition that A is enabled and cond is true.
2502 # func_cond_module_p B
2503 # tests whether module B is conditional.
2505 # func_cond_module_condition A B
2506 # returns the condition when B should be enabled as a dependency of A, once the
2507 # m4 code for A has been executed.
2508 # Output: - condition
2510 if $have_associative; then
2511 declare -A conddep_isuncond
2512 declare -A conddep_dependers
2513 declare -A conddep_condition
2514 func_uncond_add_module ()
2516 eval 'conddep_isuncond[$1]=true'
2517 eval 'unset conddep_dependers[$1]'
2519 func_conddep_add_module ()
2521 eval 'isuncond="${conddep_isuncond[$2]}"'
2522 if test -z "$isuncond"; then
2523 # No unconditional dependency to B known at this point.
2524 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2525 eval 'conddep_condition[$1---$2]="$3"'
2528 func_cond_module_p ()
2530 eval 'previous_dependers="${conddep_dependers[$1]}"'
2531 test -n "$previous_dependers"
2533 func_cond_module_condition ()
2535 eval 'condition="${conddep_condition[$1---$2]}"'
2538 func_uncond_add_module ()
2542 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2546 eval 'conddep_isuncond_'"$suffix"'=true'
2547 eval 'unset conddep_dependers_'"$suffix"
2549 func_conddep_add_module ()
2553 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2557 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2558 if test -z "$isuncond"; then
2559 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2560 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2561 eval 'conddep_condition_'"$suffix"'="$3"'
2564 func_cond_module_p ()
2568 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2572 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2573 test -n "$previous_dependers"
2575 func_cond_module_condition ()
2577 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2578 eval 'condition="${conddep_condition_'"$suffix"'}"'
2582 sed_dependencies_without_conditions='s/ *\[.*//'
2584 # func_modules_transitive_closure
2586 # - local_gnulib_dir from --local-dir
2587 # - modcache true or false, from --cache-modules/--no-cache-modules
2588 # - modules list of specified modules
2589 # - inctests true if tests should be included, blank otherwise
2590 # - incobsolete true if obsolete modules among dependencies should be
2591 # included, blank otherwise
2592 # - inc_cxx_tests true if C++ interoperability tests should be included,
2594 # - inc_longrunning_tests true if long-runnings tests should be included,
2596 # - inc_privileged_tests true if tests that require root privileges should be
2597 # included, blank otherwise
2598 # - inc_unportable_tests true if tests that fail on some platforms should be
2599 # included, blank otherwise
2600 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2601 # the unit tests of the specified modules should be
2602 # included, blank otherwise
2603 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2604 # the unit tests of the dependencies should be
2605 # included, blank otherwise
2606 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2608 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2610 # - excl_privileged_tests true if tests that require root privileges should be
2611 # excluded, blank otherwise
2612 # - excl_unportable_tests true if tests that fail on some platforms should be
2613 # excluded, blank otherwise
2614 # - avoidlist list of modules to avoid
2615 # - cond_dependencies true if conditional dependencies shall be supported,
2617 # - tmp pathname of a temporary directory
2619 # - modules list of modules, including dependencies
2620 # - conddep_dependers, conddep_condition information about conditionally
2622 func_modules_transitive_closure ()
2624 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2625 # In order to process every module only once (for speed), process an "input
2626 # list" of modules, producing an "output list" of modules. During each round,
2627 # more modules can be queued in the input list. Once a module on the input
2628 # list has been processed, it is added to the "handled list", so we can avoid
2629 # to process it again.
2631 inmodules="$modules"
2633 fmtc_inc_all_tests="$inc_all_direct_tests"
2634 if test "$cond_dependencies" = true; then
2635 for module in $inmodules; do
2637 if test -n "$module"; then
2638 if func_acceptable $module; then
2639 func_uncond_add_module $module
2644 while test -n "$inmodules"; do
2645 inmodules_this_round="$inmodules"
2646 inmodules= # Accumulator, queue for next round
2647 for module in $inmodules_this_round; do
2649 if test -n "$module"; then
2650 if func_acceptable $module; then
2651 func_append outmodules " $module"
2652 if test "$cond_dependencies" = true; then
2653 if func_get_automake_snippet_conditional $module | grep '^if ' > /dev/null; then
2654 # A module whose Makefile.am snippet contains a reference to an
2655 # automake conditional. If we were to use it conditionally, we
2656 # would get an error
2657 # configure: error: conditional "..." was never defined.
2658 # because automake 1.11.1 does not handle nested conditionals
2659 # correctly. As a workaround, make the module unconditional.
2660 func_uncond_add_module $module
2662 if func_cond_module_p $module; then
2668 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2669 # Duplicate dependencies are harmless, but Jim wants a warning.
2670 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2671 if test -n "$duplicated_deps"; then
2672 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2674 if test -n "$inctests"; then
2675 testsmodule=`func_get_tests_module $module`
2676 if test -n "$testsmodule"; then
2677 deps="$deps $testsmodule"
2680 for dep in $deps; do
2681 # Determine whether to include the dependency or tests module.
2683 for word in `func_get_status $dep`; do
2686 test -n "$incobsolete" \
2690 test -z "$excl_cxx_tests" \
2692 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2696 test -z "$excl_longrunning_tests" \
2698 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2702 test -z "$excl_privileged_tests" \
2704 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2708 test -z "$excl_unportable_tests" \
2710 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2714 test -n "$fmtc_inc_all_tests" \
2720 func_append inmodules " $dep"
2721 if test "$cond_dependencies" = true; then
2722 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2723 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2726 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2727 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2729 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2730 if test "$condition" = true; then
2733 if test -n "$condition"; then
2734 func_conddep_add_module "$module" "$dep" "$condition"
2736 if $conditional; then
2737 func_conddep_add_module "$module" "$dep" true
2739 func_uncond_add_module "$dep"
2748 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2749 # Remove $handledmodules from $inmodules.
2750 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2751 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2752 fmtc_inc_all_tests="$inc_all_indirect_tests"
2754 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2755 rm -f "$tmp"/queued-modules
2758 # func_show_module_list
2760 # - specified_modules list of specified modules (one per line, sorted)
2761 # - modules complete list of modules (one per line, sorted)
2762 # - tmp pathname of a temporary directory
2763 func_show_module_list ()
2769 # Assume xterm compatible escape sequences.
2770 bold_on=`printf '\x1b[1m'`
2771 bold_off=`printf '\x1b[0m'`
2776 echo "Module list with included dependencies (indented):"
2777 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2778 echo "$modules" | sed -e '/^$/d' \
2779 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2780 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2783 # func_modules_transitive_closure_separately
2784 # Determine main module list and tests-related module list separately.
2785 # The main module list is the transitive closure of the specified modules,
2786 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2787 # is specified, it will consist only of LGPLed source.
2788 # The tests-related module list is the transitive closure of the specified
2789 # modules, including tests modules, minus the main module list excluding
2790 # modules of applicability 'all'. Its lib/* sources (brought in through
2791 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2792 # source, even if --lgpl is specified.
2794 # - local_gnulib_dir from --local-dir
2795 # - modcache true or false, from --cache-modules/--no-cache-modules
2796 # - specified_modules list of specified modules
2797 # - inctests true if tests should be included, blank otherwise
2798 # - incobsolete true if obsolete modules among dependencies should be
2799 # included, blank otherwise
2800 # - inc_cxx_tests true if C++ interoperability tests should be included,
2802 # - inc_longrunning_tests true if long-runnings tests should be included,
2804 # - inc_privileged_tests true if tests that require root privileges should be
2805 # included, blank otherwise
2806 # - inc_unportable_tests true if tests that fail on some platforms should be
2807 # included, blank otherwise
2808 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2809 # the unit tests of the specified modules should be
2810 # included, blank otherwise
2811 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2812 # the unit tests of the dependencies should be
2813 # included, blank otherwise
2814 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2816 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2818 # - excl_privileged_tests true if tests that require root privileges should be
2819 # excluded, blank otherwise
2820 # - excl_unportable_tests true if tests that fail on some platforms should be
2821 # excluded, blank otherwise
2822 # - avoidlist list of modules to avoid
2823 # - cond_dependencies true if conditional dependencies shall be supported,
2825 # - tmp pathname of a temporary directory
2827 # - main_modules list of modules, including dependencies
2828 # - testsrelated_modules list of tests-related modules, including dependencies
2829 # - conddep_dependers, conddep_condition information about conditionally
2831 func_modules_transitive_closure_separately ()
2833 # Determine main module list.
2834 saved_inctests="$inctests"
2836 modules="$specified_modules"
2837 func_modules_transitive_closure
2838 main_modules="$modules"
2839 inctests="$saved_inctests"
2840 if test $verbose -ge 1; then
2841 echo "Main module list:"
2842 echo "$main_modules" | sed -e 's/^/ /'
2844 # Determine tests-related module list.
2845 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2846 testsrelated_modules=`for module in $main_modules; do
2847 if test \`func_get_applicability $module\` = main; then
2851 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2852 if test $verbose -ge 1; then
2853 echo "Tests-related module list:"
2854 echo "$testsrelated_modules" | sed -e 's/^/ /'
2858 # func_determine_use_libtests
2859 # Determines whether a $testsbase/libtests.a is needed.
2861 # - local_gnulib_dir from --local-dir
2862 # - modcache true or false, from --cache-modules/--no-cache-modules
2863 # - testsrelated_modules list of tests-related modules, including dependencies
2865 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2866 func_determine_use_libtests ()
2869 for module in $testsrelated_modules; do
2870 func_verify_nontests_module
2871 if test -n "$module"; then
2872 all_files=`func_get_filelist $module`
2873 # Test whether some file in $all_files lies in lib/.
2874 for f in $all_files; do
2886 # func_modules_add_dummy
2888 # - local_gnulib_dir from --local-dir
2889 # - modcache true or false, from --cache-modules/--no-cache-modules
2890 # - modules list of modules, including dependencies
2892 # - modules list of modules, including 'dummy' if needed
2893 func_modules_add_dummy ()
2895 # Determine whether any module provides a lib_SOURCES augmentation.
2897 sed_remove_backslash_newline=':a
2904 for module in $modules; do
2905 func_verify_nontests_module
2906 if test -n "$module"; then
2907 # Extract the value of "lib_SOURCES += ...".
2908 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2909 # Ignore .h files since they are not compiled.
2913 have_lib_SOURCES=yes
2920 # Add the dummy module, to make sure the library will be non-empty.
2921 if test -z "$have_lib_SOURCES"; then
2922 if func_acceptable "dummy"; then
2923 func_append modules " dummy"
2928 # func_modules_add_dummy_separately
2930 # - local_gnulib_dir from --local-dir
2931 # - modcache true or false, from --cache-modules/--no-cache-modules
2932 # - main_modules list of modules, including dependencies
2933 # - testsrelated_modules list of tests-related modules, including dependencies
2934 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2936 # - main_modules list of modules, including 'dummy' if needed
2937 # - testsrelated_modules list of tests-related modules, including 'dummy' if
2939 func_modules_add_dummy_separately ()
2941 # Add the dummy module to the main module list if needed.
2942 modules="$main_modules"
2943 func_modules_add_dummy
2944 main_modules="$modules"
2946 # Add the dummy module to the tests-related module list if needed.
2947 if $use_libtests; then
2948 modules="$testsrelated_modules"
2949 func_modules_add_dummy
2950 testsrelated_modules="$modules"
2954 # func_modules_notice
2956 # - local_gnulib_dir from --local-dir
2957 # - modcache true or false, from --cache-modules/--no-cache-modules
2958 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2959 # - modules list of modules, including dependencies
2960 func_modules_notice ()
2962 if test $verbose -ge -1; then
2963 for module in $modules; do
2965 if test -n "$module"; then
2966 msg=`func_get_notice $module`
2967 if test -n "$msg"; then
2968 echo "Notice from module $module:"
2969 echo "$msg" | sed -e 's/^/ /'
2976 # func_modules_to_filelist
2978 # - local_gnulib_dir from --local-dir
2979 # - modcache true or false, from --cache-modules/--no-cache-modules
2980 # - modules list of modules, including dependencies
2982 # - files list of files
2983 func_modules_to_filelist ()
2986 for module in $modules; do
2988 if test -n "$module"; then
2989 fs=`func_get_filelist $module`
2990 func_append files " $fs"
2993 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2996 # func_modules_to_filelist_separately
2997 # Determine the final file lists.
2998 # They must be computed separately, because files in lib/* go into
2999 # $sourcebase/ if they are in the main file list but into $testsbase/
3000 # if they are in the tests-related file list. Furthermore lib/dummy.c
3003 # - local_gnulib_dir from --local-dir
3004 # - modcache true or false, from --cache-modules/--no-cache-modules
3005 # - main_modules list of modules, including dependencies
3006 # - testsrelated_modules list of tests-related modules, including dependencies
3007 func_modules_to_filelist_separately ()
3009 # Determine final main file list.
3010 modules="$main_modules"
3011 func_modules_to_filelist
3013 # Determine final tests-related file list.
3014 modules="$testsrelated_modules"
3015 func_modules_to_filelist
3016 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3017 # Merge both file lists.
3018 sed_remove_empty_lines='/^$/d'
3019 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3020 if test $verbose -ge 0; then
3022 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3023 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3027 # func_compute_include_guard_prefix
3028 # Determine include_guard_prefix.
3030 # - macro_prefix prefix of gl_LIBOBJS macros to use
3032 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3033 # - sed_replace_include_guard_prefix
3034 # sed expression for resolving ${gl_include_guard_prefix}
3035 func_compute_include_guard_prefix ()
3037 if test "$macro_prefix" = gl; then
3038 include_guard_prefix='GL'
3040 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3042 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3045 # func_execute_command command [args...]
3046 # Executes a command.
3047 # Uses also the variables
3048 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3049 func_execute_command ()
3051 if test $verbose -ge 0; then
3055 # Commands like automake produce output to stderr even when they succeed.
3056 # Turn this output off if the command succeeds.
3057 "$@" > "$tmp"/cmdout 2>&1
3059 if test $cmdret = 0; then
3063 cat "$tmp"/cmdout 1>&2
3070 # func_dest_tmpfilename file
3071 # determines the name of a temporary file (file is relative to destdir).
3073 # - destdir target directory
3074 # - doit : if actions shall be executed, false if only to be printed
3075 # - tmp pathname of a temporary directory
3077 # - tmpfile absolute filename of the temporary file
3078 func_dest_tmpfilename ()
3081 # Put the new contents of $file in a file in the same directory (needed
3082 # to guarantee that an 'mv' to "$destdir/$file" works).
3083 tmpfile="$destdir/$1.tmp"
3085 # Put the new contents of $file in a file in a temporary directory
3086 # (because the directory of "$file" might not exist).
3087 tmpfile="$tmp"/`basename "$1"`.tmp
3092 # copies a file from gnulib into the destination directory. The destination
3093 # is known to not exist.
3095 # - destdir target directory
3096 # - local_gnulib_dir from --local-dir
3097 # - modcache true or false, from --cache-modules/--no-cache-modules
3098 # - f the original file name
3099 # - lookedup_file name of the merged (combined) file
3100 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3101 # - g the rewritten file name
3102 # - tmpfile absolute filename of the temporary file
3103 # - doit : if actions shall be executed, false if only to be printed
3104 # - symbolic true if files should be symlinked, copied otherwise
3105 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3110 echo "Copying file $g"
3111 if { test -n "$symbolic" \
3112 || { test -n "$lsymbolic" \
3113 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3114 && test -z "$lookedup_tmp" \
3115 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
3116 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3118 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3126 # copies a file from gnulib into the destination directory. The destination
3127 # is known to exist.
3129 # - destdir target directory
3130 # - local_gnulib_dir from --local-dir
3131 # - modcache true or false, from --cache-modules/--no-cache-modules
3132 # - f the original file name
3133 # - lookedup_file name of the merged (combined) file
3134 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3135 # - g the rewritten file name
3136 # - tmpfile absolute filename of the temporary file
3137 # - doit : if actions shall be executed, false if only to be printed
3138 # - symbolic true if files should be symlinked, copied otherwise
3139 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3141 # - already_present nonempty if the file should already exist, empty otherwise
3144 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
3145 : # The file has not changed.
3149 if test -n "$already_present"; then
3150 echo "Updating file $g (backup in ${g}~)"
3152 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3154 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3155 if { test -n "$symbolic" \
3156 || { test -n "$lsymbolic" \
3157 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3158 && test -z "$lookedup_tmp" \
3159 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
3160 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3162 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3165 if test -n "$already_present"; then
3166 echo "Update file $g (backup in ${g}~)"
3168 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3174 # func_emit_lib_Makefile_am
3175 # emits the contents of library makefile to standard output.
3177 # - local_gnulib_dir from --local-dir
3178 # - modcache true or false, from --cache-modules/--no-cache-modules
3179 # - modules list of modules, including dependencies
3180 # - libname library name
3181 # - pobase directory relative to destdir where to place *.po files
3182 # - auxdir directory relative to destdir where to place build aux files
3183 # - makefile_name from --makefile-name
3184 # - libtool true if libtool will be used, false or blank otherwise
3185 # - macro_prefix prefix of gl_LIBOBJS macros to use
3186 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3187 # - witness_c_macro from --witness-c-macro
3188 # - actioncmd (optional) command that will reproduce this invocation
3189 # - for_test true if creating a package for testing, false otherwise
3190 # - sed_replace_include_guard_prefix
3191 # sed expression for resolving ${gl_include_guard_prefix}
3192 # - destfile filename relative to destdir of makefile being generated
3194 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3195 # list of edits to be done to Makefile.am variables
3197 # - uses_subdirs nonempty if object files in subdirs exist
3198 func_emit_lib_Makefile_am ()
3200 # When creating an includable Makefile.am snippet, augment variables with
3201 # += instead of assigning them.
3202 if test -n "$makefile_name"; then
3207 if test "$libtool" = true; then
3210 sed_eliminate_LDFLAGS="$sed_noop"
3214 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3217 # When creating a package for testing: Attempt to provoke failures,
3218 # especially link errors, already during "make" rather than during
3219 # "make check", because "make check" is not possible in a cross-compiling
3220 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3221 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3223 sed_transform_check_PROGRAMS="$sed_noop"
3225 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3226 echo "## Process this file with automake to produce Makefile.in."
3227 func_emit_copyright_notice
3228 if test -n "$actioncmd"; then
3229 # The maximum line length (excluding the terminating newline) of any file
3230 # that is to be preprocessed by config.status is 3070. config.status uses
3231 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3232 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3233 len=`echo "$actioncmd" | wc -c`
3234 if test -n "$len" && test "$len" -le 3000; then
3235 echo "# Reproduce by: $actioncmd"
3241 for module in $modules; do
3242 func_verify_nontests_module
3243 if test -n "$module"; then
3245 func_get_automake_snippet_conditional "$module" |
3247 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3248 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3249 -e "$sed_eliminate_LDFLAGS" \
3250 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3251 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3252 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3253 -e "$sed_transform_check_PROGRAMS" \
3254 -e "$sed_replace_include_guard_prefix"
3255 if test "$module" = 'alloca'; then
3256 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3257 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3259 } > "$tmp"/amsnippet1
3261 func_get_automake_snippet_unconditional "$module" |
3262 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3263 } > "$tmp"/amsnippet2
3264 # Skip the contents if it's entirely empty.
3265 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3266 echo "## begin gnulib module $module"
3268 if test "$cond_dependencies" = true; then
3269 if func_cond_module_p "$module"; then
3270 func_module_conditional_name "$module"
3271 echo "if $conditional"
3274 cat "$tmp"/amsnippet1
3275 if test "$cond_dependencies" = true; then
3276 if func_cond_module_p "$module"; then
3280 cat "$tmp"/amsnippet2
3281 echo "## end gnulib module $module"
3284 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3285 # Test whether there are some source files in subdirectories.
3286 for f in `func_get_filelist "$module"`; do
3296 } > "$tmp"/allsnippets
3297 if test -z "$makefile_name"; then
3298 # If there are source files in subdirectories, prevent collision of the
3299 # object files (example: hash.c and libxml/hash.c).
3301 if test -n "$uses_subdirs"; then
3302 subdir_options=' subdir-objects'
3304 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
3307 if test -z "$makefile_name"; then
3309 echo "noinst_HEADERS ="
3310 echo "noinst_LIBRARIES ="
3311 echo "noinst_LTLIBRARIES ="
3312 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3313 # if you specify pkgdata_DATA to empty. This is a workaround.
3314 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3315 echo "pkgdata_DATA ="
3318 echo "BUILT_SOURCES ="
3321 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3322 if test -z "$makefile_name"; then
3323 echo "MOSTLYCLEANDIRS ="
3325 echo "DISTCLEANFILES ="
3326 echo "MAINTAINERCLEANFILES ="
3328 # Execute edits that apply to the Makefile.am being generated.
3330 while test $edit != $makefile_am_edits; do
3331 edit=`expr $edit + 1`
3332 eval dir=\"\$makefile_am_edit${edit}_dir\"
3333 eval var=\"\$makefile_am_edit${edit}_var\"
3334 eval val=\"\$makefile_am_edit${edit}_val\"
3335 if test -n "$var"; then
3336 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3337 echo "${var} += ${val}"
3338 eval "makefile_am_edit${edit}_var="
3342 if test -z "$makefile_name"; then
3345 cppflags_part1=" -DGNULIB_STRICT_CHECKING=1"
3349 if test -n "$witness_c_macro"; then
3350 cppflags_part2=" -D$witness_c_macro=1"
3354 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3358 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3359 || { test -n "$makefile_name" \
3360 && test -f "$sourcebase/Makefile.am" \
3361 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3363 # One of the snippets or the user's Makefile.am already specifies an
3364 # installation location for the library. Don't confuse automake by saying
3365 # it should not be installed.
3368 # By default, the generated library should not be installed.
3369 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3372 echo "${libname}_${libext}_SOURCES ="
3373 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3374 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3375 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3376 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3377 echo "EXTRA_${libname}_${libext}_SOURCES ="
3378 if test "$libtool" = true; then
3379 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3380 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3381 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3382 # the link dependencies of all modules.
3383 for module in $modules; do
3384 func_verify_nontests_module
3385 if test -n "$module"; then
3386 func_get_link_directive "$module"
3389 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3390 | LC_ALL=C sort -u \
3391 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3394 if test -n "$pobase"; then
3395 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3398 cat "$tmp"/allsnippets \
3399 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3401 echo "mostlyclean-local: mostlyclean-generic"
3402 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3403 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3404 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3408 rm -f "$tmp"/allsnippets
3411 # func_emit_po_Makevars
3412 # emits the contents of po/ makefile parameterization to standard output.
3414 # - local_gnulib_dir from --local-dir
3415 # - modcache true or false, from --cache-modules/--no-cache-modules
3416 # - sourcebase directory relative to destdir where to place source code
3417 # - pobase directory relative to destdir where to place *.po files
3418 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3419 func_emit_po_Makevars ()
3421 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3422 func_emit_copyright_notice
3424 echo "# Usually the message domain is the same as the package name."
3425 echo "# But here it has a '-gnulib' suffix."
3426 echo "DOMAIN = ${po_domain}-gnulib"
3428 echo "# These two variables depend on the location of this directory."
3429 echo "subdir = ${pobase}"
3430 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3433 # These options get passed to xgettext.
3434 XGETTEXT_OPTIONS = \
3435 --keyword=_ --flag=_:1:pass-c-format \
3436 --keyword=N_ --flag=N_:1:pass-c-format \
3437 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3438 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3439 --flag=error:3:c-format --flag=error_at_line:5:c-format
3441 # This is the copyright holder that gets inserted into the header of the
3442 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3443 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3445 # This is the email address or URL to which the translators shall report
3446 # bugs in the untranslated strings:
3447 # - Strings which are not entire sentences, see the maintainer guidelines
3448 # in the GNU gettext documentation, section 'Preparing Strings'.
3449 # - Strings which use unclear terms or require additional context to be
3451 # - Strings which make invalid assumptions about notation of date, time or
3453 # - Pluralisation problems.
3454 # - Incorrect English spelling.
3455 # - Incorrect formatting.
3456 # It can be your email address, or a mailing list address where translators
3457 # can write to without being subscribed, or the URL of a web page through
3458 # which the translators can contact you.
3459 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3461 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3462 # message catalogs shall be used. It is usually empty.
3463 EXTRA_LOCALE_CATEGORIES =
3465 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3466 # context. Possible values are "yes" and "no". Set this to yes if the
3467 # package uses functions taking also a message context, like pgettext(), or
3468 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3473 # func_emit_po_POTFILES_in
3474 # emits the file list to be passed to xgettext to standard output.
3476 # - local_gnulib_dir from --local-dir
3477 # - modcache true or false, from --cache-modules/--no-cache-modules
3478 # - sourcebase directory relative to destdir where to place source code
3479 # - files list of new files
3480 func_emit_po_POTFILES_in ()
3482 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3483 func_emit_copyright_notice
3485 echo "# List of files which contain translatable strings."
3486 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3489 # func_emit_tests_Makefile_am witness_macro
3490 # emits the contents of tests makefile to standard output.
3492 # - local_gnulib_dir from --local-dir
3493 # - modcache true or false, from --cache-modules/--no-cache-modules
3494 # - modules list of modules, including dependencies
3495 # - libname library name
3496 # - auxdir directory relative to destdir where to place build aux files
3497 # - makefile_name from --makefile-name
3498 # - libtool true if libtool will be used, false or blank otherwise
3499 # - sourcebase relative directory containing lib source code
3500 # - m4base relative directory containing autoconf macros
3501 # - testsbase relative directory containing unit test code
3502 # - macro_prefix prefix of gl_LIBOBJS macros to use
3503 # - witness_c_macro from --witness-c-macro
3504 # - for_test true if creating a package for testing, false otherwise
3505 # - single_configure true if a single configure file should be generated,
3506 # false for a separate configure file for the tests
3507 # - use_libtests true if a libtests.a should be built, false otherwise
3508 # - sed_replace_include_guard_prefix
3509 # sed expression for resolving ${gl_include_guard_prefix}
3510 # - destfile filename relative to destdir of makefile being generated
3512 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3513 # list of edits to be done to Makefile.am variables
3515 # - uses_subdirs nonempty if object files in subdirs exist
3516 func_emit_tests_Makefile_am ()
3519 if test "$libtool" = true; then
3521 sed_eliminate_LDFLAGS="$sed_noop"
3524 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3527 # When creating a package for testing: Attempt to provoke failures,
3528 # especially link errors, already during "make" rather than during
3529 # "make check", because "make check" is not possible in a cross-compiling
3530 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3531 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3533 sed_transform_check_PROGRAMS="$sed_noop"
3535 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3536 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3537 echo "## Process this file with automake to produce Makefile.in."
3538 func_emit_copyright_notice
3542 for module in $modules; do
3543 if $for_test && ! $single_configure; then
3544 func_verify_tests_module
3548 if test -n "$module"; then
3550 func_get_automake_snippet "$module" |
3552 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3553 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3554 -e "$sed_eliminate_LDFLAGS" \
3555 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3556 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3557 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3558 -e "$sed_transform_check_PROGRAMS" \
3559 -e "$sed_replace_include_guard_prefix"
3560 if $use_libtests && test "$module" = 'alloca'; then
3561 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3562 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3564 } > "$tmp"/amsnippet
3565 # Skip the contents if it's entirely empty.
3566 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3567 # Mention long-running tests at the end.
3569 for word in `func_get_status "$module"`; do
3570 if test "$word" = 'longrunning-test'; then
3575 { echo "## begin gnulib module $module"
3577 cat "$tmp"/amsnippet
3578 echo "## end gnulib module $module"
3582 rm -f "$tmp"/amsnippet
3583 # Test whether there are some source files in subdirectories.
3584 for f in `func_get_filelist "$module"`; do
3586 lib/*/*.c | tests/*/*.c)
3594 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3595 # Generate dependencies here, since it eases the debugging of test failures.
3596 # If there are source files in subdirectories, prevent collision of the
3597 # object files (example: hash.c and libxml/hash.c).
3599 if test -n "$uses_subdirs"; then
3600 subdir_options=' subdir-objects'
3602 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3604 if $for_test && ! $single_configure; then
3605 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3608 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3609 # variable is needed to avoid an error from automake:
3610 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3613 echo "XFAIL_TESTS ="
3614 echo "TESTS_ENVIRONMENT ="
3615 echo "noinst_PROGRAMS ="
3616 if ! $for_test; then
3617 echo "check_PROGRAMS ="
3619 echo "noinst_HEADERS ="
3620 echo "noinst_LIBRARIES ="
3621 if $use_libtests; then
3623 echo "noinst_LIBRARIES += libtests.a"
3625 echo "check_LIBRARIES = libtests.a"
3628 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3629 # if you specify pkgdata_DATA to empty. This is a workaround.
3630 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3631 echo "pkgdata_DATA ="
3634 echo "BUILT_SOURCES ="
3636 echo "MOSTLYCLEANFILES = core *.stackdump"
3637 echo "MOSTLYCLEANDIRS ="
3639 echo "DISTCLEANFILES ="
3640 echo "MAINTAINERCLEANFILES ="
3641 # Execute edits that apply to the Makefile.am being generated.
3643 while test $edit != $makefile_am_edits; do
3644 edit=`expr $edit + 1`
3645 eval dir=\"\$makefile_am_edit${edit}_dir\"
3646 eval var=\"\$makefile_am_edit${edit}_var\"
3647 eval val=\"\$makefile_am_edit${edit}_val\"
3648 if test -n "$var"; then
3649 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3650 echo "${var} += ${val}"
3651 eval "makefile_am_edit${edit}_var="
3656 echo "AM_CPPFLAGS = \\"
3658 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3660 if test -n "$witness_c_macro"; then
3661 echo " -D$witness_c_macro=1 \\"
3663 if test -n "${witness_macro}"; then
3664 echo " -D@${witness_macro}@=1 \\"
3666 echo " -I. -I\$(srcdir) \\"
3667 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3668 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3670 local_ldadd_before=''
3671 local_ldadd_after=''
3672 if $use_libtests; then
3673 # All test programs need to be linked with libtests.a.
3674 # It needs to be passed to the linker before ${libname}.${libext}, since
3675 # the tests-related modules depend on the main modules.
3676 # It also needs to be passed to the linker after ${libname}.${libext}
3677 # because the latter might contain incomplete modules (such as the 'error'
3678 # module whose dependency to 'progname' is voluntarily omitted).
3679 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3681 local_ldadd_before=' libtests.a'
3682 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3684 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3686 if $use_libtests; then
3687 echo "libtests_a_SOURCES ="
3688 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3689 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3690 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3691 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3692 echo "EXTRA_libtests_a_SOURCES ="
3693 # The circular dependency in LDADD requires this.
3694 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3697 # Many test scripts use ${EXEEXT} or ${srcdir}.
3698 # EXEEXT is defined by AC_PROG_CC through autoconf.
3699 # srcdir is defined by autoconf and automake.
3700 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3702 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3703 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3704 echo "# Clean up after Solaris cc."
3706 echo " rm -rf SunWS_cache"
3708 echo "mostlyclean-local: mostlyclean-generic"
3709 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3710 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3711 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3715 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3718 # func_emit_initmacro_start macro_prefix
3719 # emits the first few statements of the gl_INIT macro to standard output.
3720 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3721 func_emit_initmacro_start ()
3723 macro_prefix_arg="$1"
3724 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3725 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3726 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3727 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3729 # Furthermore it avoids an automake error like this when a Makefile.am
3730 # that uses pieces of gnulib also uses $(LIBOBJ):
3731 # automatically discovered file `error.c' should not be explicitly mentioned
3732 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3733 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3734 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3735 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3736 # automatically discovered file `error.c' should not be explicitly mentioned
3737 # We let automake know about the files to be distributed through the
3738 # EXTRA_lib_SOURCES variable.
3739 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3740 # Create data variables for checking the presence of files that are mentioned
3741 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3742 # because we want the check to happen when the configure file is created,
3743 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3744 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3745 # in which to expect them.
3746 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3747 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3751 # func_emit_initmacro_end macro_prefix
3752 # emits the last few statements of the gl_INIT macro to standard output.
3753 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3754 func_emit_initmacro_end ()
3756 macro_prefix_arg="$1"
3757 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3758 # The check is performed only when autoconf is run from the directory where
3759 # the configure.ac resides; if it is run from a different directory, the
3761 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3762 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3763 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3764 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3765 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3769 echo " m4_if(m4_sysval, [0], [],"
3770 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3772 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3773 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3774 echo " m4_popdef([AC_LIBSOURCES])"
3775 echo " m4_popdef([AC_REPLACE_FUNCS])"
3776 echo " m4_popdef([AC_LIBOBJ])"
3777 echo " AC_CONFIG_COMMANDS_PRE(["
3778 echo " ${macro_prefix_arg}_libobjs="
3779 echo " ${macro_prefix_arg}_ltlibobjs="
3780 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3781 echo " # Remove the extension."
3782 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3783 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3784 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3785 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3788 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3789 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3793 # func_emit_initmacro_done macro_prefix sourcebase
3794 # emits a few statements after the gl_INIT macro to standard output.
3795 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3796 # - sourcebase directory relative to destdir where to place source code
3797 func_emit_initmacro_done ()
3799 macro_prefix_arg="$1"
3802 echo "# Like AC_LIBOBJ, except that the module name goes"
3803 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3804 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3805 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3806 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3809 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3810 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3811 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3812 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3813 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3816 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3817 echo "# expected is derived from the gnulib-tool parameterization,"
3818 echo "# and alloca is special cased (for the alloca-opt module)."
3819 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3820 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3821 echo " m4_foreach([_gl_NAME], [\$1], ["
3822 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3823 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3824 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3830 # func_emit_autoconf_snippet indentation
3831 # emits the autoconf snippet of a module.
3833 # - local_gnulib_dir from --local-dir
3834 # - modcache true or false, from --cache-modules/--no-cache-modules
3835 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3836 # - module the module name
3837 # - toplevel true or false. 'false' means a subordinate use of
3839 # - disable_libtool true or false. It tells whether to disable libtool
3840 # handling even if it has been specified through the
3841 # command line options.
3842 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3844 # - indentation spaces to prepend on each line
3845 func_emit_autoconf_snippet ()
3847 if { case $module in
3848 gnumakefile | maintainer-makefile)
3849 # These modules are meant to be used only in the top-level directory.
3855 func_get_autoconf_snippet "$module" \
3856 | sed -e '/^$/d;' -e "s/^/$indentation/" \
3857 -e "$sed_replace_build_aux" \
3858 | { if $disable_libtool; then
3859 sed -e 's/\$gl_cond_libtool/false/g' \
3860 -e 's/gl_libdeps/gltests_libdeps/g' \
3861 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3866 | { if $disable_gettext; then
3867 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
3872 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
3873 echo 'changequote(,)dnl'
3874 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3875 echo 'changequote([, ])dnl'
3876 echo 'AC_SUBST([LTALLOCA])'
3881 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
3882 # collects and emit the autoconf snippets of a set of modules.
3884 # - local_gnulib_dir from --local-dir
3885 # - modcache true or false, from --cache-modules/--no-cache-modules
3886 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3887 # - modules the list of modules.
3888 # - verifier one of func_verify_module, func_verify_nontests_module,
3889 # func_verify_tests_module. It selects the subset of
3890 # $modules to consider.
3891 # - toplevel true or false. 'false' means a subordinate use of
3893 # - disable_libtool true or false. It tells whether to disable libtool
3894 # handling even if it has been specified through the
3895 # command line options.
3896 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3898 func_emit_autoconf_snippets ()
3902 disable_libtool="$4"
3903 disable_gettext="$5"
3904 if test "$cond_dependencies" = true; then
3905 # Emit the autoconf code for the unconditional modules.
3906 for module in $1; do
3908 if test -n "$module"; then
3909 if func_cond_module_p "$module"; then
3912 func_emit_autoconf_snippet " "
3916 # Initialize the shell variables indicating that the modules are enabled.
3917 for module in $1; do
3919 if test -n "$module"; then
3920 if func_cond_module_p "$module"; then
3921 func_module_shellvar_name "$module"
3922 echo " $shellvar=false"
3926 # Emit the autoconf code for the conditional modules, each in a separate
3927 # function. This makes it possible to support cycles among conditional
3929 for module in $1; do
3931 if test -n "$module"; then
3932 if func_cond_module_p "$module"; then
3933 func_module_shellfunc_name "$module"
3934 func_module_shellvar_name "$module"
3935 echo " $shellfunc ()"
3937 echo " if ! \$$shellvar; then"
3938 func_emit_autoconf_snippet " "
3939 echo " $shellvar=true"
3940 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3941 for dep in $deps; do
3942 if func_cond_module_p "$dep"; then
3943 func_module_shellfunc_name "$dep"
3944 func_cond_module_condition "$module" "$dep"
3945 if test "$condition" != true; then
3946 echo ' if $condition; then'
3953 # The autoconf code for $dep has already been emitted above and
3954 # therefore is already executed when this function is run.
3963 # Emit the dependencies from the unconditional to the conditional modules.
3964 for module in $1; do
3966 if test -n "$module"; then
3967 if func_cond_module_p "$module"; then
3970 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3971 for dep in $deps; do
3972 if func_cond_module_p "$dep"; then
3973 func_module_shellfunc_name "$dep"
3974 func_cond_module_condition "$module" "$dep"
3975 if test "$condition" != true; then
3976 echo " if $condition; then"
3983 # The autoconf code for $dep has already been emitted above and
3984 # therefore is already executed when this code is run.
3991 # Define the Automake conditionals.
3992 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
3993 for module in $1; do
3995 if test -n "$module"; then
3996 if func_cond_module_p "$module"; then
3997 func_module_conditional_name "$module"
3998 func_module_shellvar_name "$module"
3999 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4004 # Ignore the conditions, and enable all modules unconditionally.
4005 for module in $1; do
4007 if test -n "$module"; then
4008 func_emit_autoconf_snippet " "
4014 # func_import modules
4015 # Uses also the variables
4016 # - mode import or add-import or remove-import or update
4017 # - destdir target directory
4018 # - local_gnulib_dir from --local-dir
4019 # - modcache true or false, from --cache-modules/--no-cache-modules
4020 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4021 # - libname library name
4022 # - supplied_libname true if --lib was given, blank otherwise
4023 # - sourcebase directory relative to destdir where to place source code
4024 # - m4base directory relative to destdir where to place *.m4 macros
4025 # - pobase directory relative to destdir where to place *.po files
4026 # - docbase directory relative to destdir where to place doc files
4027 # - testsbase directory relative to destdir where to place unit test code
4028 # - auxdir directory relative to destdir where to place build aux files
4029 # - inctests true if --with-tests was given, blank otherwise
4030 # - incobsolete true if --with-obsolete was given, blank otherwise
4031 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4032 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4034 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4036 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4038 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4039 # - avoidlist list of modules to avoid, from --avoid
4040 # - cond_dependencies true if --conditional-dependencies was given, false if
4041 # --no-conditional-dependencies was given, blank otherwise
4042 # - lgpl yes or a number if library's license shall be LGPL,
4044 # - makefile_name from --makefile-name
4045 # - libtool true if --libtool was given, false if --no-libtool was
4046 # given, blank otherwise
4047 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4048 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4049 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4050 # - witness_c_macro from --witness-c-macro
4051 # - vc_files true if --vc-files was given, false if --no-vc-files was
4052 # given, blank otherwise
4053 # - autoconf_minversion minimum supported autoconf version
4054 # - doit : if actions shall be executed, false if only to be printed
4055 # - symbolic true if files should be symlinked, copied otherwise
4056 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4058 # - do_copyrights true if copyright notices in files should be replaced,
4062 # Get the cached settings.
4063 # In 'import' mode, we read them only for the purpose of knowing the old
4064 # installed file list, and don't use them as defaults.
4065 cached_local_gnulib_dir=
4066 cached_specified_modules=
4068 cached_inc_cxx_tests=
4069 cached_inc_longrunning_tests=
4070 cached_inc_privileged_tests=
4071 cached_inc_unportable_tests=
4072 cached_inc_all_tests=
4082 cached_makefile_name=
4083 cached_cond_dependencies=
4085 cached_macro_prefix=
4087 cached_witness_c_macro=
4090 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4091 cached_libtool=false
4097 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
4107 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4109 /gl_WITH_OBSOLETE/ {
4110 s,^.*$,cached_incobsolete=true,p
4112 /gl_WITH_CXX_TESTS/ {
4113 s,^.*$,cached_inc_cxx_tests=true,p
4115 /gl_WITH_LONGRUNNING_TESTS/ {
4116 s,^.*$,cached_inc_longrunning_tests=true,p
4118 /gl_WITH_PRIVILEGED_TESTS/ {
4119 s,^.*$,cached_inc_privileged_tests=true,p
4121 /gl_WITH_UNPORTABLE_TESTS/ {
4122 s,^.*$,cached_inc_unportable_tests=true,p
4124 /gl_WITH_ALL_TESTS/ {
4125 s,^.*$,cached_inc_all_tests=true,p
4128 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4131 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4134 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4137 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4140 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4143 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4146 s,^.*$,cached_inctests=true,p
4149 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4152 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4155 s,^.*$,cached_lgpl=yes,p
4157 /gl_MAKEFILE_NAME(/ {
4158 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4160 /gl_CONDITIONAL_DEPENDENCIES/ {
4161 s,^.*$,cached_cond_dependencies=true,p
4164 s,^.*$,cached_libtool=true,p
4166 /gl_MACRO_PREFIX(/ {
4167 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4170 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4172 /gl_WITNESS_C_MACRO(/ {
4173 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4176 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4178 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4179 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4184 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4185 s,^.*$,cached_files=",p
4198 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4202 if test "$mode" = import; then
4203 # In 'import' mode, the new set of specified modules overrides the cached
4204 # set of modules. Ignore the cached settings.
4205 specified_modules="$1"
4207 # Merge the cached settings with the specified ones.
4208 # The m4base must be the same as expected from the pathname.
4209 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4210 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4212 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
4213 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4214 if test -z "$local_gnulib_dir"; then
4215 if test -n "$cached_local_gnulib_dir"; then
4218 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4220 case "$cached_local_gnulib_dir" in
4222 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4224 func_relconcat "$destdir" "$cached_local_gnulib_dir"
4225 local_gnulib_dir="$relconcat" ;;
4232 # Append the cached and the specified module names. So that
4233 # "gnulib-tool --add-import foo" means to add the module foo.
4234 specified_modules="$cached_specified_modules $1"
4237 # Take the cached module names, minus the specified module names.
4239 if $have_associative; then
4240 # Use an associative array, for O(N) worst-case run time.
4241 declare -A to_remove
4243 eval 'to_remove[$m]=yes'
4245 for module in $cached_specified_modules; do
4246 if eval 'test -z "${to_remove[$module]}"'; then
4247 func_append specified_modules "$module "
4251 # This loop has O(N²) worst-case run time.
4252 for module in $cached_specified_modules; do
4255 if test "$m" = "$module"; then
4260 if test -z "$to_remove"; then
4261 func_append specified_modules "$module "
4267 # Take the cached module names. There are no specified module names.
4268 specified_modules="$cached_specified_modules"
4271 # Included obsolete modules among the dependencies if specified either way.
4272 if test -z "$incobsolete"; then
4273 incobsolete="$cached_incobsolete"
4275 # Included special kinds of tests modules among the dependencies if specified
4277 if test -z "$inc_cxx_tests"; then
4278 inc_cxx_tests="$cached_inc_cxx_tests"
4280 if test -z "$inc_longrunning_tests"; then
4281 inc_longrunning_tests="$cached_inc_longrunning_tests"
4283 if test -z "$inc_privileged_tests"; then
4284 inc_privileged_tests="$cached_inc_privileged_tests"
4286 if test -z "$inc_unportable_tests"; then
4287 inc_unportable_tests="$cached_inc_unportable_tests"
4289 if test -z "$inc_all_tests"; then
4290 inc_all_tests="$cached_inc_all_tests"
4292 # Append the cached and the specified avoidlist. This is probably better
4293 # than dropping the cached one when --avoid is specified at least once.
4294 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4295 avoidlist=`echo $avoidlist`
4297 # The sourcebase defaults to the cached one.
4298 if test -z "$sourcebase"; then
4299 sourcebase="$cached_sourcebase"
4300 if test -z "$sourcebase"; then
4301 func_fatal_error "missing --source-base option"
4304 # The pobase defaults to the cached one.
4305 if test -z "$pobase"; then
4306 pobase="$cached_pobase"
4308 # The docbase defaults to the cached one.
4309 if test -z "$docbase"; then
4310 docbase="$cached_docbase"
4311 if test -z "$docbase"; then
4312 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."
4315 # The testsbase defaults to the cached one.
4316 if test -z "$testsbase"; then
4317 testsbase="$cached_testsbase"
4318 if test -z "$testsbase"; then
4319 func_fatal_error "missing --tests-base option"
4322 # Require the tests if specified either way.
4323 if test -z "$inctests"; then
4324 inctests="$cached_inctests"
4326 # The libname defaults to the cached one.
4327 if test -z "$supplied_libname"; then
4328 libname="$cached_libname"
4329 if test -z "$libname"; then
4330 func_fatal_error "missing --lib option"
4333 # Require LGPL if specified either way.
4334 if test -z "$lgpl"; then
4337 # The makefile_name defaults to the cached one.
4338 if test -z "$makefile_name"; then
4339 makefile_name="$cached_makefile_name"
4341 # Use conditional dependencies if specified either way.
4342 if test -z "$cond_dependencies"; then
4343 cond_dependencies="$cached_cond_dependencies"
4345 # Use libtool if specified either way, or if guessed.
4346 if test -z "$libtool"; then
4347 if test -n "$cached_m4base"; then
4348 libtool="$cached_libtool"
4350 libtool="$guessed_libtool"
4353 # The macro_prefix defaults to the cached one.
4354 if test -z "$macro_prefix"; then
4355 macro_prefix="$cached_macro_prefix"
4356 if test -z "$macro_prefix"; then
4357 func_fatal_error "missing --macro-prefix option"
4360 # The po_domain defaults to the cached one.
4361 if test -z "$po_domain"; then
4362 po_domain="$cached_po_domain"
4364 # The witness_c_macro defaults to the cached one.
4365 if test -z "$witness_c_macro"; then
4366 witness_c_macro="$cached_witness_c_macro"
4368 # The vc_files defaults to the cached one.
4369 if test -z "$vc_files"; then
4370 vc_files="$cached_vc_files"
4372 # Ensure constraints.
4373 if test "$cond_dependencies" = true && test -n "$inctests"; then
4374 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4378 # --without-*-tests options are not supported here.
4380 excl_longrunning_tests=
4381 excl_privileged_tests=
4382 excl_unportable_tests=
4384 # Canonicalize the list of specified modules.
4385 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4387 # Include all kinds of tests modules if --with-all-tests was specified.
4388 inc_all_direct_tests="$inc_all_tests"
4389 inc_all_indirect_tests="$inc_all_tests"
4391 # Determine final module list.
4392 modules="$specified_modules"
4393 func_modules_transitive_closure
4394 if test $verbose -ge 0; then
4395 func_show_module_list
4397 final_modules="$modules"
4399 # Determine main module list and tests-related module list separately.
4400 func_modules_transitive_closure_separately
4402 # Determine whether a $testsbase/libtests.a is needed.
4403 func_determine_use_libtests
4405 # Add the dummy module to the main module list or to the tests-related module
4407 func_modules_add_dummy_separately
4409 # If --lgpl, verify that the licenses of modules are compatible.
4410 if test -n "$lgpl"; then
4411 license_incompatibilities=
4412 for module in $main_modules; do
4413 license=`func_get_license $module`
4415 'GPLed build tool') ;;
4416 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4421 LGPL | LGPLv2+ | LGPLv3+) ;;
4422 *) func_append license_incompatibilities "$module $license$nl" ;;
4428 *) func_append license_incompatibilities "$module $license$nl" ;;
4431 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4436 if test -n "$license_incompatibilities"; then
4437 # Format the license incompatibilities as a table.
4438 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4439 s,^\(.................................................[^ ]*\) *, \1 ,'
4440 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4441 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4445 # Show banner notice of every module.
4446 modules="$main_modules"
4449 # Determine script to apply to imported library files.
4450 sed_transform_lib_file=
4451 for module in $main_modules; do
4452 if test $module = config-h; then
4453 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4454 sed_transform_lib_file=$sed_transform_lib_file'
4455 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4460 sed_transform_main_lib_file="$sed_transform_lib_file"
4461 if test -n "$do_copyrights"; then
4462 if test -n "$lgpl"; then
4466 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4467 s/GNU General/GNU Lesser General/g
4468 s/General Public License/Lesser General Public License/g
4469 s/Lesser Lesser General Public License/Lesser General Public License/g
4473 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4474 s/GNU General/GNU Lesser General/g
4475 s/General Public License/Lesser General Public License/g
4476 s/Lesser Lesser General Public License/Lesser General Public License/g
4478 s/version [23]\([ ,]\)/version 2.1\1/g
4481 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4485 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4486 s/GNU Lesser General/GNU General/g
4487 s/Lesser General Public License/General Public License/g
4489 s/GNU Library General/GNU General/g
4490 s/Library General Public License/General Public License/g
4492 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4497 # Determine script to apply to auxiliary files that go into $auxdir/.
4498 sed_transform_build_aux_file=
4499 if test -n "$do_copyrights"; then
4501 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4502 s/GNU Lesser General/GNU General/g
4503 s/Lesser General Public License/General Public License/g
4505 s/GNU Library General/GNU General/g
4506 s/Library General Public License/General Public License/g
4508 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4512 # Determine script to apply to library files that go into $testsbase/.
4513 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4514 if test -n "$do_copyrights"; then
4516 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4517 s/GNU Lesser General/GNU General/g
4518 s/Lesser General Public License/General Public License/g
4520 s/GNU Library General/GNU General/g
4521 s/Library General Public License/General Public License/g
4523 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4527 # Determine the final file lists.
4528 func_modules_to_filelist_separately
4531 || func_fatal_error "refusing to do nothing"
4533 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4534 new_files="$files m4/gnulib-tool.m4"
4535 old_files="$cached_files"
4536 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4537 func_append old_files " m4/gnulib-tool.m4"
4540 rewritten='%REWRITTEN%'
4541 sed_rewrite_old_files="\
4542 s,^build-aux/,$rewritten$auxdir/,
4543 s,^doc/,$rewritten$cached_docbase/,
4544 s,^lib/,$rewritten$cached_sourcebase/,
4545 s,^m4/,$rewritten$cached_m4base/,
4546 s,^tests/,$rewritten$cached_testsbase/,
4547 s,^tests=lib/,$rewritten$cached_testsbase/,
4550 sed_rewrite_new_files="\
4551 s,^build-aux/,$rewritten$auxdir/,
4552 s,^doc/,$rewritten$docbase/,
4553 s,^lib/,$rewritten$sourcebase/,
4554 s,^m4/,$rewritten$m4base/,
4555 s,^tests/,$rewritten$testsbase/,
4556 s,^tests=lib/,$rewritten$testsbase/,
4560 # Create directories.
4561 { echo "$sourcebase"
4563 if test -n "$pobase"; then
4566 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4567 if test -n "$docfiles"; then
4570 if test -n "$inctests"; then
4574 for f in $files; do echo $f; done \
4575 | sed -e "$sed_rewrite_new_files" \
4576 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4579 { # Rearrange file descriptors. Needed because "while ... done < ..."
4580 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4581 exec 5<&0 < "$tmp"/dirs
4583 if test ! -d "$destdir/$d"; then
4585 echo "Creating directory $destdir/$d"
4586 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4588 echo "Create directory $destdir/$d"
4595 # Copy files or make symbolic links. Remove obsolete files.
4599 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4600 # representing the files according to the last gnulib-tool invocation.
4601 for f in $old_files; do echo $f; done \
4602 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4605 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4606 # representing the files after this gnulib-tool invocation.
4607 for f in $new_files; do echo $f; done \
4608 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4611 # First the files that are in old-files, but not in new-files:
4612 sed_take_first_column='s,'"$delimiter"'.*,,'
4613 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4614 # Remove the file. Do nothing if the user already removed it.
4615 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4617 echo "Removing file $g (backup in ${g}~)"
4618 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4620 echo "Remove file $g (backup in ${g}~)"
4622 func_append removed_files "$g$nl"
4625 # func_add_or_update handles a file that ought to be present afterwards.
4627 # - f the original file name
4628 # - g the rewritten file name
4629 # - already_present nonempty if the file should already exist, empty
4631 func_add_or_update ()
4635 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4637 func_dest_tmpfilename "$g"
4638 func_lookup_file "$f"
4639 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4640 if test -n "$sed_transform_main_lib_file"; then
4643 sed -e "$sed_transform_main_lib_file" \
4644 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4648 if test -n "$sed_transform_build_aux_file"; then
4651 sed -e "$sed_transform_build_aux_file" \
4652 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4656 if test -n "$sed_transform_testsrelated_lib_file"; then
4659 sed -e "$sed_transform_testsrelated_lib_file" \
4660 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4664 if test -f "$destdir/$g"; then
4665 # The file already exists.
4669 # Don't protest if the file should be there but isn't: it happens
4670 # frequently that developers don't put autogenerated files under version control.
4672 func_append added_files "$g$nl"
4676 # Then the files that are in new-files, but not in old-files:
4677 sed_take_last_column='s,^.*'"$delimiter"',,'
4679 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4680 | sed -e "$sed_take_last_column" \
4681 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4682 { # Rearrange file descriptors. Needed because "while ... done < ..."
4683 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4684 exec 5<&0 < "$tmp"/added-files
4690 # Then the files that are in new-files and in old-files:
4691 already_present=true
4692 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4693 | sed -e "$sed_take_last_column" \
4694 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4695 { # Rearrange file descriptors. Needed because "while ... done < ..."
4696 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4697 exec 5<&0 < "$tmp"/kept-files
4704 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4705 actioncmd="gnulib-tool --import"
4706 func_append actioncmd " --dir=$destdir"
4707 if test -n "$local_gnulib_dir"; then
4708 func_append actioncmd " --local-dir=$local_gnulib_dir"
4710 func_append actioncmd " --lib=$libname"
4711 func_append actioncmd " --source-base=$sourcebase"
4712 func_append actioncmd " --m4-base=$m4base"
4713 if test -n "$pobase"; then
4714 func_append actioncmd " --po-base=$pobase"
4716 func_append actioncmd " --doc-base=$docbase"
4717 func_append actioncmd " --tests-base=$testsbase"
4718 func_append actioncmd " --aux-dir=$auxdir"
4719 if test -n "$inctests"; then
4720 func_append actioncmd " --with-tests"
4722 if test -n "$incobsolete"; then
4723 func_append actioncmd " --with-obsolete"
4725 if test -n "$inc_cxx_tests"; then
4726 func_append actioncmd " --with-c++-tests"
4728 if test -n "$inc_longrunning_tests"; then
4729 func_append actioncmd " --with-longrunning-tests"
4731 if test -n "$inc_privileged_tests"; then
4732 func_append actioncmd " --with-privileged-tests"
4734 if test -n "$inc_unportable_tests"; then
4735 func_append actioncmd " --with-unportable-tests"
4737 if test -n "$inc_all_tests"; then
4738 func_append actioncmd " --with-all-tests"
4740 for module in $avoidlist; do
4741 func_append actioncmd " --avoid=$module"
4743 if test -n "$lgpl"; then
4744 if test "$lgpl" = yes; then
4745 func_append actioncmd " --lgpl"
4747 func_append actioncmd " --lgpl=$lgpl"
4750 if test -n "$makefile_name"; then
4751 func_append actioncmd " --makefile-name=$makefile_name"
4753 if test "$cond_dependencies" = true; then
4754 func_append actioncmd " --conditional-dependencies"
4756 func_append actioncmd " --no-conditional-dependencies"
4758 if test "$libtool" = true; then
4759 func_append actioncmd " --libtool"
4761 func_append actioncmd " --no-libtool"
4763 func_append actioncmd " --macro-prefix=$macro_prefix"
4764 if test -n "$po_domain"; then
4765 func_append actioncmd " --po-domain=$po_domain"
4767 if test -n "$witness_c_macro"; then
4768 func_append actioncmd " --witness-c-macro=$witness_c_macro"
4770 if test -n "$vc_files"; then
4771 if test "$vc_files" = true; then
4772 func_append actioncmd " --vc-files"
4774 func_append actioncmd " --no-vc-files"
4777 func_append actioncmd " `echo $specified_modules`"
4779 # Determine include_guard_prefix.
4780 func_compute_include_guard_prefix
4782 # Default the makefile name to Makefile.am.
4783 if test -n "$makefile_name"; then
4784 makefile_am=$makefile_name
4786 makefile_am=Makefile.am
4789 # Create normal Makefile.ams.
4792 # Setup list of Makefile.am edits that are to be performed afterwards.
4793 # Some of these edits apply to files that we will generate; others are
4794 # under the responsibility of the developer.
4796 # func_note_Makefile_am_edit dir var value
4797 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4799 func_note_Makefile_am_edit ()
4801 makefile_am_edits=`expr $makefile_am_edits + 1`
4802 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4803 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4804 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4806 if test "$makefile_am" = Makefile.am; then
4807 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4808 sourcebase_base=`basename "$sourcebase"`
4809 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4811 if test -n "$pobase"; then
4812 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4813 pobase_base=`basename "$pobase"`
4814 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4816 if test -n "$inctests"; then
4817 if test "$makefile_am" = Makefile.am; then
4818 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4819 testsbase_base=`basename "$testsbase"`
4820 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4823 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4825 # Find the first parent directory of $m4base that contains or will contain
4827 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4829 sed_butlast='s,[^/][^/]*//*$,,'
4830 dir1="${m4base}/"; dir2=""
4831 while test -n "$dir1" \
4832 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4833 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4834 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4835 || { test -n "$inctests" \
4836 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4837 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4838 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4839 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4841 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4844 # Create library makefile.
4845 func_dest_tmpfilename $sourcebase/$makefile_am
4846 destfile="$sourcebase/$makefile_am"
4847 modules="$main_modules"
4848 func_emit_lib_Makefile_am > "$tmpfile"
4849 if test -f "$destdir"/$sourcebase/$makefile_am; then
4850 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4854 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4855 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4856 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4858 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4864 echo "Creating $sourcebase/$makefile_am"
4865 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4867 echo "Create $sourcebase/$makefile_am"
4870 func_append added_files "$sourcebase/$makefile_am$nl"
4873 # Create po/ directory.
4874 if test -n "$pobase"; then
4875 # Create po makefile and auxiliary files.
4876 for file in Makefile.in.in remove-potcdate.sin; do
4877 func_dest_tmpfilename $pobase/$file
4878 func_lookup_file build-aux/po/$file
4879 cat "$lookedup_file" > "$tmpfile"
4880 if test -f "$destdir"/$pobase/$file; then
4881 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4885 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4886 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4887 mv -f "$tmpfile" "$destdir"/$pobase/$file
4889 echo "Update $pobase/$file (backup in $pobase/$file~)"
4895 echo "Creating $pobase/$file"
4896 mv -f "$tmpfile" "$destdir"/$pobase/$file
4898 echo "Create $pobase/$file"
4901 func_append added_files "$pobase/$file$nl"
4904 # Create po makefile parameterization, part 1.
4905 func_dest_tmpfilename $pobase/Makevars
4906 func_emit_po_Makevars > "$tmpfile"
4907 if test -f "$destdir"/$pobase/Makevars; then
4908 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4912 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4913 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4914 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4916 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4922 echo "Creating $pobase/Makevars"
4923 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4925 echo "Create $pobase/Makevars"
4928 func_append added_files "$pobase/Makevars$nl"
4930 # Create po makefile parameterization, part 2.
4931 func_dest_tmpfilename $pobase/POTFILES.in
4932 func_emit_po_POTFILES_in > "$tmpfile"
4933 if test -f "$destdir"/$pobase/POTFILES.in; then
4934 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4938 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4939 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4940 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4942 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4948 echo "Creating $pobase/POTFILES.in"
4949 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4951 echo "Create $pobase/POTFILES.in"
4954 func_append added_files "$pobase/POTFILES.in$nl"
4957 TP_URL="http://translationproject.org/latest/"
4958 TP_RSYNC_URI="translationproject.org::tp/latest/"
4960 echo "Fetching gnulib PO files from $TP_URL"
4961 (cd "$destdir"/$pobase \
4962 && { # Prefer rsync over wget if it is available, since it consumes
4963 # less network bandwidth, due to compression.
4964 if type rsync 2>/dev/null | grep / > /dev/null; then
4965 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4967 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4972 echo "Fetch gnulib PO files from $TP_URL"
4974 # Create po/LINGUAS.
4976 func_dest_tmpfilename $pobase/LINGUAS
4977 (cd "$destdir"/$pobase \
4978 && { echo '# Set of available languages.'
4979 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4982 if test -f "$destdir"/$pobase/LINGUAS; then
4983 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4986 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4987 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4988 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4991 echo "Creating $pobase/LINGUAS"
4992 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4993 func_append added_files "$pobase/LINGUAS$nl"
4996 if test -f "$destdir"/$pobase/LINGUAS; then
4997 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4999 echo "Create $pobase/LINGUAS"
5004 # Create m4/gnulib-cache.m4.
5005 func_dest_tmpfilename $m4base/gnulib-cache.m4
5007 func_emit_copyright_notice
5009 echo "# This file represents the specification of how gnulib-tool is used."
5010 echo "# It acts as a cache: It is written and read by gnulib-tool."
5011 echo "# In projects that use version control, this file is meant to be put under"
5012 echo "# version control, like the configure.ac and various Makefile.am files."
5015 echo "# Specification in the form of a command-line invocation:"
5018 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5019 # Store the local_gnulib_dir relative to destdir.
5020 case "$local_gnulib_dir" in
5022 relative_local_gnulib_dir="$local_gnulib_dir" ;;
5025 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
5027 # destdir, local_gnulib_dir are both relative.
5028 func_relativize "$destdir" "$local_gnulib_dir"
5029 relative_local_gnulib_dir="$reldir" ;;
5032 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
5034 echo "$specified_modules" | sed -e 's/^/ /g'
5036 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5037 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5038 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5039 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5040 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5041 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5042 echo "gl_AVOID([$avoidlist])"
5043 echo "gl_SOURCE_BASE([$sourcebase])"
5044 echo "gl_M4_BASE([$m4base])"
5045 echo "gl_PO_BASE([$pobase])"
5046 echo "gl_DOC_BASE([$docbase])"
5047 echo "gl_TESTS_BASE([$testsbase])"
5048 test -z "$inctests" || echo "gl_WITH_TESTS"
5049 echo "gl_LIB([$libname])"
5050 if test -n "$lgpl"; then
5051 if test "$lgpl" = yes; then
5054 echo "gl_LGPL([$lgpl])"
5057 echo "gl_MAKEFILE_NAME([$makefile_name])"
5058 if test "$cond_dependencies" = true; then
5059 echo "gl_CONDITIONAL_DEPENDENCIES"
5061 if test "$libtool" = true; then
5064 echo "gl_MACRO_PREFIX([$macro_prefix])"
5065 echo "gl_PO_DOMAIN([$po_domain])"
5066 echo "gl_WITNESS_C_DOMAIN([$witness_c_macro])"
5067 if test -n "$vc_files"; then
5068 echo "gl_VC_FILES([$vc_files])"
5071 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5072 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
5076 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5077 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5078 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5080 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5084 echo "# gnulib-cache.m4 ends here"
5091 echo "Creating $m4base/gnulib-cache.m4"
5092 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5094 echo "Create $m4base/gnulib-cache.m4"
5100 # Create m4/gnulib-comp.m4.
5101 func_dest_tmpfilename $m4base/gnulib-comp.m4
5103 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5104 func_emit_copyright_notice
5106 echo "# This file represents the compiled summary of the specification in"
5107 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5108 echo "# to be invoked from configure.ac."
5109 echo "# In projects that use version control, this file can be treated like"
5110 echo "# other built files."
5113 echo "# This macro should be invoked from $configure_ac, in the section"
5114 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5115 echo "# any checks for libraries, header files, types and library functions."
5116 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5118 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5119 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5120 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5121 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5122 echo " AC_REQUIRE([AC_PROG_RANLIB])"
5123 if test -n "$uses_subdirs"; then
5124 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5126 for module in $final_modules; do
5128 if test -n "$module"; then
5129 echo "# Code from module $module:"
5130 func_get_autoconf_early_snippet "$module"
5133 | sed -e '/^$/d;' -e 's/^/ /'
5136 echo "# This macro should be invoked from $configure_ac, in the section"
5137 echo "# \"Check for header files, types and library functions\"."
5138 echo "AC_DEFUN([${macro_prefix}_INIT],"
5140 if test "$libtool" = true; then
5141 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5142 echo " gl_cond_libtool=true"
5144 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5145 echo " gl_cond_libtool=false"
5147 echo " gl_ltlibdeps="
5149 if test "$auxdir" != "build-aux"; then
5150 sed_replace_build_aux='
5152 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5153 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5157 sed_replace_build_aux="$sed_noop"
5159 echo " gl_m4_base='$m4base'"
5160 func_emit_initmacro_start $macro_prefix
5161 echo " gl_source_base='$sourcebase'"
5162 if test -n "$witness_c_macro"; then
5163 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5165 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
5166 if test -n "$witness_c_macro"; then
5167 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5169 echo " # End of code from modules"
5170 func_emit_initmacro_end $macro_prefix
5171 echo " gltests_libdeps="
5172 echo " gltests_ltlibdeps="
5173 func_emit_initmacro_start ${macro_prefix}tests
5174 echo " gl_source_base='$testsbase'"
5175 # Define a tests witness macro that depends on the package.
5176 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5177 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5178 echo "changequote(,)dnl"
5179 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"
5180 echo "changequote([, ])dnl"
5181 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5182 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5183 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5184 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
5185 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5186 func_emit_initmacro_end ${macro_prefix}tests
5187 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5188 # created using libtool, because libtool already handles the dependencies.
5189 if test "$libtool" != true; then
5190 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5191 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5192 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5193 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5194 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5196 if $use_libtests; then
5197 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5198 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5201 func_emit_initmacro_done $macro_prefix $sourcebase
5202 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5204 echo "# This macro records the list of files which have been installed by"
5205 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5206 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5207 echo "$files" | sed -e 's,^, ,'
5210 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5211 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
5215 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5216 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5217 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5219 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5223 echo "# gnulib-comp.m4 ends here"
5230 echo "Creating $m4base/gnulib-comp.m4"
5231 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5233 echo "Create $m4base/gnulib-comp.m4"
5239 if test -n "$inctests"; then
5240 # Create tests makefile.
5241 func_dest_tmpfilename $testsbase/$makefile_am
5242 destfile="$testsbase/$makefile_am"
5243 modules="$testsrelated_modules"
5244 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5245 if test -f "$destdir"/$testsbase/$makefile_am; then
5246 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
5250 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5251 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5252 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5254 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5260 echo "Creating $testsbase/$makefile_am"
5261 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5263 echo "Create $testsbase/$makefile_am"
5266 func_append added_files "$testsbase/$makefile_am$nl"
5270 if test "$vc_files" != false; then
5271 # Update the .cvsignore and .gitignore files.
5272 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5273 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5274 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5275 echo "$m4base/|A|gnulib-comp.m4"
5276 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5277 { # Rearrange file descriptors. Needed because "while ... done < ..."
5278 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5279 exec 5<&0 < "$tmp"/fileset-changes
5280 func_update_ignorelist ()
5283 if test "$ignore" = .gitignore; then
5284 # In a .gitignore file, "foo" applies to the current directory and all
5285 # subdirectories, whereas "/foo" applies to the current directory only.
5288 doubly_escaped_anchor='\\/'
5292 doubly_escaped_anchor=''
5294 if test -f "$destdir/$dir$ignore"; then
5295 if test -n "$dir_added" || test -n "$dir_removed"; then
5296 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5297 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5298 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5299 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5300 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
5302 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5304 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5305 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5306 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5307 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5308 } > "$tmp"/sed-ignore-removed
5309 { cat "$destdir/$dir$ignore"~
5310 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5311 } | sed -f "$tmp"/sed-ignore-removed \
5312 > "$destdir/$dir$ignore"
5314 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5319 if test -n "$dir_added"; then
5321 echo "Creating $destdir/$dir$ignore"
5323 if test "$ignore" = .cvsignore; then
5325 # Automake generates Makefile rules that create .dirstamp files.
5328 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5329 } > "$destdir/$dir$ignore"
5331 echo "Create $destdir/$dir$ignore"
5341 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5342 func_update_ignorelist .cvsignore
5344 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5345 func_update_ignorelist .gitignore
5352 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5353 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5354 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5355 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5356 if test "$next_dir" != "$last_dir"; then
5357 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5358 last_dir="$next_dir"
5363 A) func_append last_dir_added "$file$nl";;
5364 R) func_append last_dir_removed "$file$nl";;
5367 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5374 echo "You may need to add #include directives for the following .h files."
5375 # Intersect $specified_modules and $main_modules
5376 # (since $specified_modules is not necessarily of subset of $main_modules
5377 # - some may have been skipped through --avoid, and since the elements of
5378 # $main_modules but not in $specified_modules can go away without explicit
5379 # notice - through changes in the module dependencies).
5380 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5381 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5382 # First the #include <...> directives without #ifs, sorted for convenience,
5383 # then the #include "..." directives without #ifs, sorted for convenience,
5384 # then the #include directives that are surrounded by #ifs. Not sorted.
5385 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5386 include_directive=`func_get_include_directive "$module"`
5387 case "$nl$include_directive" in
5389 echo "$include_directive" 1>&5
5392 echo "$include_directive" | grep -v 'include "' 1>&6
5393 echo "$include_directive" | grep 'include "' 1>&7
5396 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5398 LC_ALL=C sort -u "$tmp"/include-angles
5399 LC_ALL=C sort -u "$tmp"/include-quotes
5400 cat "$tmp"/include-if
5401 ) | sed -e '/^$/d' -e 's/^/ /'
5402 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5404 for module in $main_modules; do
5405 func_get_link_directive "$module"
5407 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5408 if test `wc -l < "$tmp"/link` != 0; then
5410 echo "You may need to use the following Makefile variables when linking."
5411 echo "Use them in <program>_LDADD when linking a program, or"
5412 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5418 echo "Don't forget to"
5419 if test "$makefile_am" = Makefile.am; then
5420 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5422 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5424 if test -n "$pobase"; then
5425 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5427 if test -n "$inctests"; then
5428 if test "$makefile_am" = Makefile.am; then
5429 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5431 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5435 while test $edit != $makefile_am_edits; do
5436 edit=`expr $edit + 1`
5437 eval dir=\"\$makefile_am_edit${edit}_dir\"
5438 eval var=\"\$makefile_am_edit${edit}_var\"
5439 eval val=\"\$makefile_am_edit${edit}_val\"
5440 if test -n "$var"; then
5441 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5444 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
5445 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5448 # func_create_testdir testdir modules
5450 # - local_gnulib_dir from --local-dir
5451 # - modcache true or false, from --cache-modules/--no-cache-modules
5452 # - auxdir directory relative to destdir where to place build aux files
5453 # - inctests true if tests should be included, blank otherwise
5454 # - incobsolete true if obsolete modules among dependencies should be
5455 # included, blank otherwise
5456 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5458 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5460 # - excl_privileged_tests true if tests that require root privileges should be
5461 # excluded, blank otherwise
5462 # - excl_unportable_tests true if tests that fail on some platforms should be
5463 # excluded, blank otherwise
5464 # - single_configure true if a single configure file should be generated,
5465 # false for a separate configure file for the tests
5466 # - avoidlist list of modules to avoid
5467 # - cond_dependencies true if --conditional-dependencies was given, false if
5468 # --no-conditional-dependencies was given, blank otherwise
5469 # - libtool true if --libtool was given, false if --no-libtool was
5470 # given, blank otherwise
5471 # - symbolic true if files should be symlinked, copied otherwise
5472 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
5474 func_create_testdir ()
5478 if test -z "$modules"; then
5479 # All modules together.
5480 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5481 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5482 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5483 modules=`func_all_modules`
5484 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5486 specified_modules="$modules"
5488 # Canonicalize the list of specified modules.
5489 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5491 # Unlike in func_import, here we want to include all kinds of tests for the
5492 # directly specified modules, but not for dependencies.
5493 inc_all_direct_tests=true
5494 inc_all_indirect_tests="$inc_all_tests"
5496 # Check that the license of every module is consistent with the license of
5498 saved_inctests="$inctests"
5499 # When computing transitive closures, don't consider $module to depend on
5500 # $module-tests. Need this becauses tests are implicitly GPL and may depend
5501 # on GPL modules - therefore we don't want a warning in this case.
5503 for requested_module in $specified_modules; do
5504 requested_license=`func_get_license "$requested_module"`
5505 if test "$requested_license" != GPL; then
5506 # Here we use func_modules_transitive_closure, not just
5507 # func_get_dependencies, so that we also detect weird situations like
5508 # an LGPL module which depends on a GPLed build tool module which depends
5510 modules="$requested_module"
5511 func_modules_transitive_closure
5512 for module in $modules; do
5513 license=`func_get_license "$module"`
5515 'GPLed build tool') ;;
5516 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5518 case "$requested_license" in
5521 GPLv2+ | LGPLv2+) ;;
5522 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5528 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5534 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5543 inctests="$saved_inctests"
5545 # Subdirectory names.
5556 # Determine final module list.
5557 modules="$specified_modules"
5558 func_modules_transitive_closure
5559 if test $verbose -ge 0; then
5560 func_show_module_list
5562 final_modules="$modules"
5564 if $single_configure; then
5565 # Determine main module list and tests-related module list separately.
5566 func_modules_transitive_closure_separately
5569 if $single_configure; then
5570 # Determine whether a $testsbase/libtests.a is needed.
5571 func_determine_use_libtests
5574 # Add the dummy module if needed.
5575 if $single_configure; then
5576 func_modules_add_dummy_separately
5578 func_modules_add_dummy
5581 # Show banner notice of every module.
5582 if $single_configure; then
5583 modules="$main_modules"
5589 # Determine final file list.
5590 if $single_configure; then
5591 func_modules_to_filelist_separately
5593 func_modules_to_filelist
5594 if test $verbose -ge 0; then
5596 echo "$files" | sed -e 's/^/ /'
5599 # Add files for which the copy in gnulib is newer than the one that
5600 # "automake --add-missing --copy" would provide.
5601 files="$files build-aux/config.guess"
5602 files="$files build-aux/config.sub"
5603 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5605 rewritten='%REWRITTEN%'
5606 sed_rewrite_files="\
5607 s,^build-aux/,$rewritten$auxdir/,
5608 s,^doc/,$rewritten$docbase/,
5609 s,^lib/,$rewritten$sourcebase/,
5610 s,^m4/,$rewritten$m4base/,
5611 s,^tests/,$rewritten$testsbase/,
5612 s,^tests=lib/,$rewritten$testsbase/,
5616 # Create directories.
5617 for f in $files; do echo $f; done \
5618 | sed -e "$sed_rewrite_files" \
5619 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5620 | LC_ALL=C sort -u \
5622 { # Rearrange file descriptors. Needed because "while ... done < ..."
5623 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5624 exec 5<&0 < "$tmp"/dirs
5626 mkdir -p "$testdir/$d"
5631 # Copy files or make symbolic links.
5633 for f in $files; do echo $f; done \
5634 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5637 { # Rearrange file descriptors. Needed because "while ... done < ..."
5638 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5639 exec 5<&0 < "$tmp"/files
5642 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5644 func_lookup_file "$f"
5645 if test -n "$lookedup_tmp"; then
5646 cp -p "$lookedup_file" "$testdir/$g"
5648 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5649 if { test -n "$symbolic" \
5650 || { test -n "$lsymbolic" \
5651 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5652 func_ln "$lookedup_file" "$testdir/$g"
5654 cp -p "$lookedup_file" "$testdir/$g"
5661 # Determine include_guard_prefix.
5662 func_compute_include_guard_prefix
5664 # Create Makefile.ams that are for testing.
5667 # No special edits are needed.
5670 # Create $sourcebase/Makefile.am.
5671 mkdir -p "$testdir/$sourcebase"
5672 destfile="$sourcebase/Makefile.am"
5673 if $single_configure; then
5674 modules="$main_modules"
5676 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5677 any_uses_subdirs="$uses_subdirs"
5679 # Create $m4base/Makefile.am.
5680 mkdir -p "$testdir/$m4base"
5681 (echo "## Process this file with automake to produce Makefile.in."
5687 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5690 ) > "$testdir/$m4base/Makefile.am"
5692 subdirs="$sourcebase $m4base"
5693 subdirs_with_configure_ac=""
5695 if false && test -f "$testdir"/$m4base/gettext.m4; then
5696 # Avoid stupid error message from automake:
5697 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5698 mkdir -p "$testdir/po"
5699 (echo "## Process this file with automake to produce Makefile.in."
5700 ) > "$testdir/po/Makefile.am"
5701 func_append subdirs " po"
5704 if test -n "$inctests"; then
5705 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5706 if $single_configure; then
5707 # Create $testsbase/Makefile.am.
5708 destfile="$testsbase/Makefile.am"
5709 modules="$testsrelated_modules"
5710 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
5712 # Viewed from the $testsbase subdirectory, $auxdir is different.
5713 saved_auxdir="$auxdir"
5714 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5715 # Create $testsbase/Makefile.am.
5717 destfile="$testsbase/Makefile.am"
5718 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5719 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5720 # Create $testsbase/configure.ac.
5721 (echo "# Process this file with autoconf to produce a configure script."
5722 echo "AC_INIT([dummy], [0])"
5723 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5724 echo "AM_INIT_AUTOMAKE"
5726 echo "AC_CONFIG_HEADERS([config.h])"
5729 echo "AC_PROG_INSTALL"
5730 echo "AC_PROG_MAKE_SET"
5731 echo "AC_PROG_RANLIB"
5733 if test -n "$uses_subdirs"; then
5734 echo "AM_PROG_CC_C_O"
5737 for module in $modules; do
5739 if test -n "$module"; then
5741 gnumakefile | maintainer-makefile)
5742 # These modules are meant to be used only in the top-level directory.
5745 func_get_autoconf_early_snippet "$module"
5750 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5751 if test "$libtool" = true; then
5752 echo "LT_INIT([win32-dll])"
5753 echo "LT_LANG([C++])"
5754 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5755 echo "gl_cond_libtool=true"
5757 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5758 echo "gl_cond_libtool=false"
5760 echo "gl_ltlibdeps="
5762 # Wrap the set of autoconf snippets into an autoconf macro that is then
5763 # invoked. This is needed because autoconf does not support AC_REQUIRE
5765 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5766 # but we want the AC_REQUIRE to have its normal meaning (provide one
5767 # expansion of the required macro before the current point, and only one
5769 echo "AC_DEFUN([gl_INIT], ["
5770 sed_replace_build_aux='
5772 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5773 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5776 echo "gl_m4_base='../$m4base'"
5777 func_emit_initmacro_start $macro_prefix
5778 # We don't have explicit ordering constraints between the various
5779 # autoconf snippets. It's cleanest to put those of the library before
5780 # those of the tests.
5781 echo "gl_source_base='../$sourcebase'"
5782 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
5783 echo "gl_source_base='.'"
5784 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
5785 func_emit_initmacro_end $macro_prefix
5786 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5787 # created using libtool, because libtool already handles the dependencies.
5788 if test "$libtool" != true; then
5789 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5790 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5791 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5792 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5793 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5796 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5800 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5801 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5802 echo "AH_TOP([#include \"../config.h\"])"
5804 echo "AC_CONFIG_FILES([Makefile])"
5806 ) > "$testdir/$testsbase/configure.ac"
5807 auxdir="$saved_auxdir"
5808 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5810 func_append subdirs " $testsbase"
5813 # Create Makefile.am.
5814 (echo "## Process this file with automake to produce Makefile.in."
5816 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5818 echo "SUBDIRS = $subdirs"
5820 echo "ACLOCAL_AMFLAGS = -I $m4base"
5821 ) > "$testdir/Makefile.am"
5823 # Create configure.ac.
5824 (echo "# Process this file with autoconf to produce a configure script."
5825 echo "AC_INIT([dummy], [0])"
5826 if test "$auxdir" != "."; then
5827 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5829 echo "AM_INIT_AUTOMAKE"
5831 echo "AC_CONFIG_HEADERS([config.h])"
5834 echo "AC_PROG_INSTALL"
5835 echo "AC_PROG_MAKE_SET"
5837 echo "# For autobuild."
5838 echo "AC_CANONICAL_BUILD"
5839 echo "AC_CANONICAL_HOST"
5841 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5842 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5843 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5844 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5846 echo "AC_PROG_RANLIB"
5848 if test -n "$any_uses_subdirs"; then
5849 echo "AM_PROG_CC_C_O"
5852 for module in $final_modules; do
5853 if $single_configure; then
5856 func_verify_nontests_module
5858 if test -n "$module"; then
5859 func_get_autoconf_early_snippet "$module"
5862 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5863 if test "$libtool" = true; then
5864 echo "LT_INIT([win32-dll])"
5865 echo "LT_LANG([C++])"
5866 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5867 echo "gl_cond_libtool=true"
5869 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5870 echo "gl_cond_libtool=false"
5872 echo "gl_ltlibdeps="
5874 # Wrap the set of autoconf snippets into an autoconf macro that is then
5875 # invoked. This is needed because autoconf does not support AC_REQUIRE
5877 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5878 # but we want the AC_REQUIRE to have its normal meaning (provide one
5879 # expansion of the required macro before the current point, and only one
5881 echo "AC_DEFUN([gl_INIT], ["
5882 if test "$auxdir" != "build-aux"; then
5883 sed_replace_build_aux='
5885 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5886 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5890 sed_replace_build_aux="$sed_noop"
5892 echo "gl_m4_base='$m4base'"
5893 func_emit_initmacro_start $macro_prefix
5894 echo "gl_source_base='$sourcebase'"
5895 if $single_configure; then
5896 func_emit_autoconf_snippets "$main_modules" func_verify_module true false false
5898 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
5900 func_emit_initmacro_end $macro_prefix
5901 if $single_configure; then
5902 echo " gltests_libdeps="
5903 echo " gltests_ltlibdeps="
5904 func_emit_initmacro_start ${macro_prefix}tests
5905 echo " gl_source_base='$testsbase'"
5906 # Define a tests witness macro.
5907 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
5908 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5909 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5910 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5911 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true false false
5912 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5913 func_emit_initmacro_end ${macro_prefix}tests
5915 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5916 # created using libtool, because libtool already handles the dependencies.
5917 if test "$libtool" != true; then
5918 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5919 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5920 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5921 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5922 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5924 if $single_configure; then
5925 if $use_libtests; then
5926 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5927 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5931 func_emit_initmacro_done $macro_prefix $sourcebase
5932 if $single_configure; then
5933 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5938 if test -n "$subdirs_with_configure_ac"; then
5939 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5941 makefiles="Makefile"
5942 for d in $subdirs; do
5943 # For subdirs that have a configure.ac by their own, it's the subdir's
5944 # configure.ac which creates the subdir's Makefile.am, not this one.
5945 case " $subdirs_with_configure_ac " in
5947 *) func_append makefiles " $d/Makefile" ;;
5950 echo "AC_CONFIG_FILES([$makefiles])"
5952 ) > "$testdir/configure.ac"
5954 # Create autogenerated files.
5956 # Do not use "${AUTORECONF} --force --install", because it may invoke
5957 # autopoint, which brings in older versions of some of our .m4 files.
5958 if test -f $m4base/gettext.m4; then
5959 func_execute_command ${AUTOPOINT} --force || func_exit 1
5960 for f in $m4base/*.m4~; do
5962 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5966 if test "$libtool" = true; then
5967 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5969 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5970 if ! test -d build-aux; then
5971 func_execute_command mkdir build-aux || func_exit 1
5973 func_execute_command ${AUTOCONF} || func_exit 1
5974 func_execute_command ${AUTOHEADER} || func_exit 1
5975 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5977 if test -n "$inctests" && ! $single_configure; then
5978 # Create autogenerated files.
5979 (cd "$testdir/$testsbase" || func_exit 1
5980 # Do not use "${AUTORECONF} --force --install", because it may invoke
5981 # autopoint, which brings in older versions of some of our .m4 files.
5982 if test -f ../$m4base/gettext.m4; then
5983 func_execute_command ${AUTOPOINT} --force || func_exit 1
5984 for f in ../$m4base/*.m4~; do
5986 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5990 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5991 if ! test -d ../build-aux; then
5992 func_execute_command mkdir ../build-aux
5994 func_execute_command ${AUTOCONF} || func_exit 1
5995 func_execute_command ${AUTOHEADER} || func_exit 1
5996 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5999 # Need to run configure and make once, to create built files that are to be
6000 # distributed (such as parse-datetime.c).
6001 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6002 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6003 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6004 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6005 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6006 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6007 # such $(FOO_H) because they don't refer to distributed files.
6008 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6009 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6010 | sed -e "$sed_remove_make_variables"`
6011 distributed_built_sources=`for file in $built_sources; do
6012 case "$cleaned_files" in
6017 tests_distributed_built_sources=
6018 if test -n "$inctests"; then
6019 # Likewise for built files in the $testsbase directory.
6020 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6021 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6022 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6023 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6024 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6025 | sed -e "$sed_remove_make_variables"`
6026 tests_distributed_built_sources=`for file in $tests_built_sources; do
6027 case "$tests_cleaned_files" in
6033 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6035 ./configure || func_exit 1
6036 if test -n "$distributed_built_sources"; then
6038 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6039 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6044 if test -n "$tests_distributed_built_sources"; then
6046 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6047 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6052 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6059 # func_create_megatestdir megatestdir allmodules
6061 # - local_gnulib_dir from --local-dir
6062 # - modcache true or false, from --cache-modules/--no-cache-modules
6063 # - auxdir directory relative to destdir where to place build aux files
6064 func_create_megatestdir ()
6068 if test -z "$allmodules"; then
6069 allmodules=`func_all_modules`
6073 # First, all modules one by one.
6074 for onemodule in $allmodules; do
6075 func_create_testdir "$megatestdir/$onemodule" $onemodule
6076 func_append megasubdirs "$onemodule "
6078 # Then, all modules all together.
6079 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6080 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6081 func_create_testdir "$megatestdir/ALL" "$allmodules"
6082 func_append megasubdirs "ALL"
6085 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
6086 vc_witness="$gnulib_dir/CVS/Entries"; \
6088 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6090 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6091 | sed -e 's,January,01,' -e 's,Jan,01,' \
6092 -e 's,February,02,' -e 's,Feb,02,' \
6093 -e 's,March,03,' -e 's,Mar,03,' \
6094 -e 's,April,04,' -e 's,Apr,04,' \
6096 -e 's,June,06,' -e 's,Jun,06,' \
6097 -e 's,July,07,' -e 's,Jul,07,' \
6098 -e 's,August,08,' -e 's,Aug,08,' \
6099 -e 's,September,09,' -e 's,Sep,09,' \
6100 -e 's,October,10,' -e 's,Oct,10,' \
6101 -e 's,November,11,' -e 's,Nov,11,' \
6102 -e 's,December,12,' -e 's,Dec,12,' \
6103 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6104 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6106 echo "CVSDATE=$cvsdate"
6107 echo ": \${MAKE=make}"
6108 echo "test -d logs || mkdir logs"
6109 echo "for module in $megasubdirs; do"
6110 echo " echo \"Working on module \$module...\""
6111 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6112 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6115 echo " : autobuild project... \$module"
6116 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6117 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6118 echo " : autobuild hostname... \`hostname\`"
6119 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6121 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6123 ) > "$megatestdir/do-autobuild"
6124 chmod a+x "$megatestdir/do-autobuild"
6126 # Create Makefile.am.
6127 (echo "## Process this file with automake to produce Makefile.in."
6129 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
6131 echo "SUBDIRS = $megasubdirs"
6133 echo "EXTRA_DIST = do-autobuild"
6134 ) > "$megatestdir/Makefile.am"
6136 # Create configure.ac.
6137 (echo "# Process this file with autoconf to produce a configure script."
6138 echo "AC_INIT([dummy], [0])"
6139 if test "$auxdir" != "."; then
6140 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6142 echo "AM_INIT_AUTOMAKE"
6144 echo "AC_PROG_MAKE_SET"
6146 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6147 echo "AC_CONFIG_FILES([Makefile])"
6149 ) > "$megatestdir/configure.ac"
6151 # Create autogenerated files.
6153 # Do not use "${AUTORECONF} --install", because autoreconf operates
6154 # recursively, but the subdirectories are already finished, therefore
6155 # calling autoreconf here would only waste lots of CPU time.
6156 func_execute_command ${ACLOCAL} || func_exit 1
6157 func_execute_command mkdir build-aux
6158 func_execute_command ${AUTOCONF} || func_exit 1
6159 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6165 func_fatal_error "no mode specified" ;;
6172 # sed expression that converts a literal to a basic regular expression.
6173 # Needs to handle . [ \ * ^ $.
6174 sed_literal_to_basic_regex='s/\\/\\\\/g
6180 if test -f "$gnulib_dir/$filename" \
6181 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
6182 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6183 filename_line_regex='^'"$filename_anywhere_regex"'$'
6186 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6187 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
6188 (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$,,')
6191 | func_sanitize_modulelist \
6194 for module in $module_candidates; do
6195 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6200 func_warning "file $filename does not exist"
6205 import | add-import | remove-import | update )
6208 if test -z "$destdir"; then
6211 test -d "$destdir" \
6212 || func_fatal_error "destination directory does not exist: $destdir"
6214 # Prefer configure.ac to configure.in.
6215 if test -f "$destdir"/configure.ac; then
6216 configure_ac="$destdir/configure.ac"
6218 if test -f "$destdir"/configure.in; then
6219 configure_ac="$destdir/configure.in"
6221 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6225 # Analyze configure.ac.
6227 guessed_libtool=false
6232 /AC_CONFIG_AUX_DIR/ {
6233 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6235 /A[CM]_PROG_LIBTOOL/ {
6236 s,^.*$,guessed_libtool=true,p
6238 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6240 if test -z "$auxdir"; then
6241 auxdir="$guessed_auxdir"
6244 # Determine where to apply func_import.
6245 if test "$mode" = import; then
6246 # Apply func_import to a particular gnulib directory.
6247 # The command line contains the complete specification; don't look at
6248 # the contents of gnulib-cache.m4.
6249 test -n "$supplied_libname" || supplied_libname=true
6250 test -n "$sourcebase" || sourcebase="lib"
6251 test -n "$m4base" || m4base="m4"
6252 test -n "$docbase" || docbase="doc"
6253 test -n "$testsbase" || testsbase="tests"
6254 test -n "$macro_prefix" || macro_prefix="gl"
6257 if test -n "$m4base"; then
6258 # Apply func_import to a particular gnulib directory.
6259 # Any number of additional modules can be given.
6260 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6261 # First use of gnulib in the given m4base.
6262 test -n "$supplied_libname" || supplied_libname=true
6263 test -n "$sourcebase" || sourcebase="lib"
6264 test -n "$docbase" || docbase="doc"
6265 test -n "$testsbase" || testsbase="tests"
6266 test -n "$macro_prefix" || macro_prefix="gl"
6270 # Apply func_import to all gnulib directories.
6271 # To get this list of directories, look at Makefile.am. (Not at
6272 # configure, because it may be omitted from version control. Also,
6273 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6277 if test -f "$destdir"/Makefile.am; then
6278 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6280 for arg in $aclocal_amflags; do
6281 if test -n "$m4dir_is_next"; then
6282 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6286 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6287 func_append m4dirs " $arg"
6288 m4dirs_count=`expr $m4dirs_count + 1`
6294 if test "X$arg" = "X-I"; then
6302 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6303 if test -f "$destdir"/aclocal.m4; then
6304 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6305 sedexpr2='s,^[^/]*$,.,'
6306 sedexpr3='s,/[^/]*$,,'
6307 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6308 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6309 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6312 if test $m4dirs_count = 0; then
6313 # First use of gnulib in a package.
6314 # Any number of additional modules can be given.
6315 test -n "$supplied_libname" || supplied_libname=true
6316 test -n "$sourcebase" || sourcebase="lib"
6318 test -n "$docbase" || docbase="doc"
6319 test -n "$testsbase" || testsbase="tests"
6320 test -n "$macro_prefix" || macro_prefix="gl"
6323 if test $m4dirs_count = 1; then
6324 # There's only one use of gnulib here. Assume the user means it.
6325 # Any number of additional modules can be given.
6326 for m4base in $m4dirs; do
6330 # Ambiguous - guess what the user meant.
6331 if test $# = 0; then
6332 # No further arguments. Guess the user wants to update all of them.
6333 for m4base in $m4dirs; do
6334 # Perform func_import in a subshell, so that variable values
6336 # local_gnulib_dir, incobsolete, inc_cxx_tests,
6337 # inc_longrunning_tests, inc_privileged_tests,
6338 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6339 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6340 # makefile_name, libtool, macro_prefix, po_domain,
6341 # witness_c_macro, vc_files
6342 # don't propagate from one directory to another.
6343 (func_import) || func_exit 1
6347 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6356 if test -z "$destdir"; then
6357 func_fatal_error "please specify --dir option"
6360 test -d "$destdir" \
6361 || func_fatal_error "could not create destination directory"
6362 test -n "$auxdir" || auxdir="build-aux"
6363 func_create_testdir "$destdir" "$*"
6366 create-megatestdir )
6367 if test -z "$destdir"; then
6368 func_fatal_error "please specify --dir option"
6370 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6371 test -n "$auxdir" || auxdir="build-aux"
6372 func_create_megatestdir "$destdir" "$*"
6376 test -n "$destdir" || destdir=testdir$$
6377 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6378 test -n "$auxdir" || auxdir="build-aux"
6379 func_create_testdir "$destdir" "$*"
6383 ../configure || func_exit 1
6384 $MAKE || func_exit 1
6385 $MAKE check || func_exit 1
6386 $MAKE distclean || func_exit 1
6387 remaining=`find . -type f -print`
6388 if test -n "$remaining"; then
6389 echo "Remaining files:" $remaining 1>&2
6390 echo "gnulib-tool: *** Stop." 1>&2
6399 test -n "$destdir" || destdir=testdir$$
6400 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6401 test -n "$auxdir" || auxdir="build-aux"
6402 func_create_megatestdir "$destdir" "$*"
6410 remaining=`find . -type f -print`
6411 if test -n "$remaining"; then
6412 echo "Remaining files:" $remaining 1>&2
6413 echo "gnulib-tool: *** Stop." 1>&2
6421 extract-description )
6425 if test -n "$module"; then
6426 func_get_description "$module"
6435 if test -n "$module"; then
6436 func_get_comment "$module"
6445 if test -n "$module"; then
6446 func_get_status "$module"
6455 if test -n "$module"; then
6456 func_get_notice "$module"
6461 extract-applicability )
6465 if test -n "$module"; then
6466 func_get_applicability "$module"
6475 if test -n "$module"; then
6476 func_get_filelist "$module"
6481 extract-dependencies )
6485 if test -n "$module"; then
6486 func_get_dependencies "$module"
6491 extract-autoconf-snippet )
6495 if test -n "$module"; then
6496 func_get_autoconf_snippet "$module"
6501 extract-automake-snippet )
6505 if test -n "$module"; then
6506 func_get_automake_snippet "$module"
6511 extract-include-directive )
6515 if test -n "$module"; then
6516 func_get_include_directive "$module"
6521 extract-link-directive )
6525 if test -n "$module"; then
6526 func_get_link_directive "$module"
6535 if test -n "$module"; then
6536 func_get_license "$module"
6541 extract-maintainer )
6545 if test -n "$module"; then
6546 func_get_maintainer "$module"
6551 extract-tests-module )
6555 if test -n "$module"; then
6556 func_get_tests_module "$module"
6562 # Verify the number of arguments.
6563 if test $# -lt 1 || test $# -gt 2; then
6564 func_fatal_error "invalid number of arguments for --$mode"
6567 # The first argument is the file to be copied.
6569 # Verify the file exists.
6570 func_lookup_file "$f"
6572 # The second argument is the destination; either a directory ot a file.
6573 # It defaults to the current directory.
6575 test -n "$dest" || dest='.'
6576 test -n "$sourcebase" || sourcebase="lib"
6577 test -n "$m4base" || m4base="m4"
6578 test -n "$docbase" || docbase="doc"
6579 test -n "$testsbase" || testsbase="tests"
6580 test -n "$auxdir" || auxdir="build-aux"
6581 rewritten='%REWRITTEN%'
6582 sed_rewrite_files="\
6583 s,^build-aux/,$rewritten$auxdir/,
6584 s,^doc/,$rewritten$docbase/,
6585 s,^lib/,$rewritten$sourcebase/,
6586 s,^m4/,$rewritten$m4base/,
6587 s,^tests/,$rewritten$testsbase/,
6590 if test -d "$dest"; then
6592 g=`echo "$f" | sed -e "$sed_rewrite_files"`
6594 destdir=`dirname "$dest"`
6595 g=`basename "$dest"`
6598 # Create the directory for destfile.
6599 d=`dirname "$destdir/$g"`
6601 if test -n "$d" && test ! -d "$d"; then
6602 mkdir -p "$d" || func_fatal_error "failed"
6606 func_dest_tmpfilename "$g"
6607 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
6608 already_present=true
6609 if test -f "$destdir/$g"; then
6610 # The file already exists.
6614 # Don't protest if the file should be there but isn't: it happens
6615 # frequently that developers don't put autogenerated files under version
6623 func_fatal_error "unknown operation mode --$mode" ;;
6627 # Undo the effect of the previous 'trap' command. Some shellology:
6628 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6629 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6630 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6631 # 128 + signal number and is set before the trap-registered command is run.
6633 trap 'func_exit $?' 1 2 3 13 15
6638 # indent-tabs-mode: nil
6639 # whitespace-check-buffer-indent: nil