3 # Copyright (C) 2002-2014 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
189 --help Show this help text.
190 --version Show version and authorship information.
194 --dir=DIRECTORY Specify the target directory.
195 For --import, this specifies where your
196 configure.ac can be found. Defaults to current
198 --local-dir=DIRECTORY Specify a local override directory where to look
199 up files before looking in gnulib's directory.
200 --cache-modules Enable module caching optimization.
201 --no-cache-modules Disable module caching optimization.
202 --verbose Increase verbosity. May be repeated.
203 --quiet Decrease verbosity. May be repeated.
205 Options for --import, --add/remove-import, --update:
207 --dry-run Only print what would have been done.
209 Options for --import, --add/remove-import:
211 --with-tests Include unit tests for the included modules.
213 Options for --create-[mega]testdir, --[mega]test:
215 --without-tests Don't include unit tests for the included modules.
217 Options for --import, --add/remove-import,
218 --create-[mega]testdir, --[mega]test:
220 --with-obsolete Include obsolete modules when they occur among the
221 dependencies. By default, dependencies to obsolete
223 --with-c++-tests Include even unit tests for C++ interoperability.
224 --without-c++-tests Exclude unit tests for C++ interoperability.
225 --with-longrunning-tests
226 Include even unit tests that are long-runners.
227 --without-longrunning-tests
228 Exclude unit tests that are long-runners.
229 --with-privileged-tests
230 Include even unit tests that require root
232 --without-privileged-tests
233 Exclude unit tests that require root privileges.
234 --with-unportable-tests
235 Include even unit tests that fail on some platforms.
236 --without-unportable-tests
237 Exclude unit tests that fail on some platforms.
238 --with-all-tests Include all kinds of problematic unit tests.
239 --avoid=MODULE Avoid including the given MODULE. Useful if you
240 have code that provides equivalent functionality.
241 This option can be repeated.
242 --conditional-dependencies
243 Support conditional dependencies (may save configure
244 time and object code).
245 --no-conditional-dependencies
246 Don't use conditional dependencies.
247 --libtool Use libtool rules.
248 --no-libtool Don't use libtool rules.
250 Options for --import, --add/remove-import:
252 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
253 --source-base=DIRECTORY
254 Directory relative to --dir where source code is
255 placed (default \"lib\").
256 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
257 placed (default \"m4\").
258 --po-base=DIRECTORY Directory relative to --dir where *.po files are
259 placed (default \"po\").
260 --doc-base=DIRECTORY Directory relative to --dir where doc files are
261 placed (default \"doc\").
262 --tests-base=DIRECTORY
263 Directory relative to --dir where unit tests are
264 placed (default \"tests\").
265 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
266 tools are placed (default comes from configure.ac).
267 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
268 Also modify license template from GPL to LGPL.
269 The version number of the LGPL can be specified;
270 the default is currently LGPLv3.
271 --makefile-name=NAME Name of makefile in automake syntax in the
272 source-base and tests-base directories
273 (default \"Makefile.am\").
274 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
275 'gl_INIT'. Default is 'gl'.
276 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
277 the package name. A suffix '-gnulib' is appended.
278 --witness-c-macro=NAME Specify the C macro that is defined when the
279 sources in this directory are compiled or used.
280 --vc-files Update version control related files.
281 --no-vc-files Don't update version control related files
282 (.gitignore and/or .cvsignore).
284 Options for --create-[mega]testdir, --[mega]test:
286 --single-configure Generate a single configure file, not a separate
287 configure file for the tests directory.
289 Options for --import, --add/remove-import, --update,
290 --create-[mega]testdir, --[mega]test:
292 -s, --symbolic, --symlink Make symbolic links instead of copying files.
293 --local-symlink Make symbolic links instead of copying files, only
294 for files from the local override directory.
296 Options for --import, --add/remove-import, --update:
298 -S, --more-symlinks Make symbolic links instead of copying files, and
299 don't replace copyright notices.
301 Report bugs to <bug-gnulib@gnu.org>."
305 # outputs to stdout the --version message.
309 if test -d "$gnulib_dir"/.git \
310 && (git --version) >/dev/null 2>/dev/null \
311 && (date --version) >/dev/null 2>/dev/null; then
312 # gnulib checked out from git.
313 sed_extract_first_date='/^Date/{
317 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
318 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
319 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
320 date=`echo "$date" | sed -e "$sed_year_before_time"`
321 # Use GNU date to compute the time in GMT.
322 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
323 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
325 # gnulib copy without versioning information.
326 date=`zcat /usr/share/doc/gnulib/changelog.gz | sed -e 's/ .*//;q'`
327 version=`zcat /usr/share/doc/gnulib/NEWS.stable.gz | grep -o -m 1 ' [0-9]\+-stable'`
328 debversion=`dpkg-query --show --showformat '${Version}' gnulib`
330 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
332 gnulib-tool (GNU $package $date)$version Debian: $debversion
333 Copyright (C) $year Free Software Foundation, Inc.
334 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
335 This is free software: you are free to change and redistribute it.
336 There is NO WARRANTY, to the extent permitted by law.
338 printf "Written by %s, %s, and %s.\n" "Bruno Haible" "Paul Eggert" "Simon Josefsson"
341 # func_emit_copyright_notice
342 # outputs to stdout a header for a generated file.
343 func_emit_copyright_notice ()
345 sed -n -e '/Copyright/ {
348 }' < "$self_abspathname"
350 echo "# This file is free software; you can redistribute it and/or modify"
351 echo "# it under the terms of the GNU General Public License as published by"
352 echo "# the Free Software Foundation; either version 3 of the License, or"
353 echo "# (at your option) any later version."
355 echo "# This file is distributed in the hope that it will be useful,"
356 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
357 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
358 echo "# GNU General Public License for more details."
360 echo "# You should have received a copy of the GNU General Public License"
361 echo "# along with this file. If not, see <http://www.gnu.org/licenses/>."
363 echo "# As a special exception to the GNU General Public License,"
364 echo "# this file may be distributed as part of a program that"
365 echo "# contains a configuration script generated by Autoconf, under"
366 echo "# the same distribution terms as the rest of that program."
368 echo "# Generated by gnulib-tool."
372 # exits with a given status.
373 # This function needs to be used, rather than 'exit', when a 'trap' handler is
374 # in effect that refers to $?.
381 # locates the directory where the gnulib repository lives
383 # - progname name of this program
385 # - self_abspathname absolute pathname of gnulib-tool
386 # - gnulib_dir absolute pathname of gnulib repository
390 /*) self_abspathname="$progname" ;;
391 */*) self_abspathname=`pwd`/"$progname" ;;
394 # Iterate through the elements of $PATH.
395 # We use IFS=: instead of
396 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
397 # because the latter does not work when some PATH element contains spaces.
398 # We use a canonicalized $pathx instead of $PATH, because empty PATH
399 # elements are by definition equivalent to '.', however field splitting
400 # according to IFS=: loses empty fields in many shells:
401 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
402 # beginning, at the end, and in the middle),
403 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
404 # at the beginning and at the end,
405 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
406 # Solaris lose empty fields at the end.
407 # The 'case' statement is an optimization, to avoid evaluating the
408 # explicit canonicalization command when $PATH contains no empty fields.
410 if test "${PATH_SEPARATOR+set}" != set; then
411 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
412 # contains only /bin. Note that ksh looks also at the FPATH variable,
413 # so we have to set that as well for the test.
415 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
416 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
417 || PATH_SEPARATOR=';'
420 if test "$PATH_SEPARATOR" = ";"; then
421 # On Windows, programs are searched in "." before $PATH.
424 # On Unix, we have to convert empty PATH elements to ".".
428 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
433 IFS="$PATH_SEPARATOR"
437 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
438 self_abspathname="$d/$progname"
443 if test -z "$self_abspathname"; then
444 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
448 while test -h "$self_abspathname"; do
449 # Resolve symbolic link.
450 linkval=`func_readlink "$self_abspathname"`
451 test -n "$linkval" || break
453 /* ) self_abspathname="$linkval" ;;
454 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
457 gnulib_dir=/usr/share/gnulib
461 # creates a temporary directory.
463 # - progname name of this program
465 # - tmp pathname of freshly created temporary directory
468 # Use the environment variable TMPDIR, falling back to /tmp. This allows
469 # users to specify a different temporary directory, for example, if their
470 # /tmp is filled up or too small.
473 # Use the mktemp program if available. If not available, hide the error
475 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
476 test -n "$tmp" && test -d "$tmp"
479 # Use a simple mkdir command. It is guaranteed to fail if the directory
480 # already exists. $RANDOM is bash specific and expands to empty in shells
481 # other than bash, ksh and zsh. Its use does not increase security;
482 # rather, it minimizes the probability of failure in a very cluttered /tmp
484 tmp=$TMPDIR/gl$$-$RANDOM
485 (umask 077 && mkdir "$tmp")
488 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
493 # func_append var value
494 # appends the given value to the shell variable var.
495 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
496 # Use bash's += operator. It reduces complexity of appending repeatedly to
497 # a single variable from O(n^2) to O(n).
502 fast_func_append=true
506 eval "$1=\"\$$1\$2\""
508 fast_func_append=false
511 # func_remove_prefix var prefix
512 # removes the given prefix from the value of the shell variable var.
513 # var should be the name of a shell variable.
514 # Its value should not contain a newline and not start or end with whitespace.
515 # prefix should not contain the characters "$`\{}[]^|.
516 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
517 func_remove_prefix ()
521 fast_func_remove_prefix=true
523 func_remove_prefix ()
525 eval "value=\"\$$1\""
529 sed_escape_dots='s/\([.]\)/\\\1/g'
530 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
533 value=`echo "$value" | sed -e "s|^${prefix}||"`
534 eval "$1=\"\$value\""
536 fast_func_remove_prefix=false
539 # func_remove_suffix var suffix
540 # removes the given suffix from the value of the shell variable var.
541 # var should be the name of a shell variable.
542 # Its value should not contain a newline and not start or end with whitespace.
543 # suffix should not contain the characters "$`\{}[]^|.
544 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
545 func_remove_suffix ()
549 fast_func_remove_suffix=true
551 func_remove_suffix ()
553 eval "value=\"\$$1\""
557 sed_escape_dots='s/\([.]\)/\\\1/g'
558 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
561 value=`echo "$value" | sed -e "s|${suffix}\$||"`
562 eval "$1=\"\$value\""
564 fast_func_remove_suffix=false
567 # func_fatal_error message
568 # outputs to stderr a fatal error message, and terminates the program.
570 # - progname name of this program
573 echo "$progname: *** $1" 1>&2
574 echo "$progname: *** Stop." 1>&2
578 # func_warning message
579 # Outputs to stderr a warning message,
582 echo "gnulib-tool: warning: $1" 1>&2
585 # func_readlink SYMLINK
586 # outputs the target of the given symlink.
587 if (type readlink) > /dev/null 2>&1; then
590 # Use the readlink program from GNU coreutils.
596 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
597 # would do the wrong thing if the link target contains " -> ".
598 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
602 # func_relativize DIR1 DIR2
603 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
605 # - DIR1 relative pathname, relative to the current directory
606 # - DIR2 relative pathname, relative to the current directory
608 # - reldir relative pathname of DIR2, relative to DIR1
614 sed_first='s,^\([^/]*\)/.*$,\1,'
615 sed_rest='s,^[^/]*/*,,'
616 sed_last='s,^.*/\([^/]*\)$,\1,'
617 sed_butlast='s,/*[^/]*$,,'
618 while test -n "$dir1"; do
619 first=`echo "$dir1" | sed -e "$sed_first"`
620 if test "$first" != "."; then
621 if test "$first" = ".."; then
622 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
623 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
625 first2=`echo "$dir2" | sed -e "$sed_first"`
626 if test "$first2" = "$first"; then
627 dir2=`echo "$dir2" | sed -e "$sed_rest"`
631 dir0="$dir0"/"$first"
634 dir1=`echo "$dir1" | sed -e "$sed_rest"`
639 # func_relconcat DIR1 DIR2
640 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
642 # - DIR1 relative pathname, relative to the current directory
643 # - DIR2 relative pathname, relative to DIR1
645 # - relconcat DIR1/DIR2, relative to the current directory
650 sed_first='s,^\([^/]*\)/.*$,\1,'
651 sed_rest='s,^[^/]*/*,,'
652 sed_last='s,^.*/\([^/]*\)$,\1,'
653 sed_butlast='s,/*[^/]*$,,'
655 first=`echo "$dir2" | sed -e "$sed_first"`
656 if test "$first" = "."; then
657 dir2=`echo "$dir2" | sed -e "$sed_rest"`
658 if test -z "$dir2"; then
663 last=`echo "$dir1" | sed -e "$sed_last"`
664 while test "$last" = "."; do
665 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
666 last=`echo "$dir1" | sed -e "$sed_last"`
668 if test -z "$dir1"; then
672 if test "$first" = ".."; then
673 if test "$last" = ".."; then
674 relconcat="$dir1/$dir2"
677 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
678 dir2=`echo "$dir2" | sed -e "$sed_rest"`
679 if test -z "$dir1"; then
683 if test -z "$dir2"; then
688 relconcat="$dir1/$dir2"
696 # Like ln -s, except that SRC is given relative to the current directory (or
697 # absolute), not given relative to the directory of DEST.
703 *) # SRC is relative.
706 ln -s "`pwd`/$1" "$2" ;;
707 *) # DEST is relative too.
708 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
709 test -n "$ln_destdir" || ln_destdir="."
710 func_relativize "$ln_destdir" "$1"
718 # func_ln_if_changed SRC DEST
719 # Like func_ln, but avoids munging timestamps if the link is correct.
720 func_ln_if_changed ()
722 if test $# -ne 2; then
723 echo "usage: func_ln_if_changed SRC DEST" >&2
725 ln_target=`func_readlink "$2"`
726 if test -h "$2" && test "$1" = "$ln_target"; then
734 # Ensure an 'echo' command that
735 # 1. does not interpret backslashes and
736 # 2. does not print an error message "broken pipe" when writing into a pipe
739 # Test cases for problem 1:
740 # echo '\n' | wc -l prints 1 when OK, 2 when KO
741 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
742 # Test cases for problem 2:
743 # echo hi | true frequently prints
744 # "bash: echo: write error: Broken pipe"
745 # to standard error in bash 3.2.
747 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
748 # BSD echo interprets '-n' as an option, which is also not desirable).
749 # Nowadays the problem occurs in 4 situations:
750 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
751 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
752 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
753 # - in zsh, when sh-emulation is not set,
754 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
755 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
756 # - in Solaris /bin/sh and OSF/1 /bin/sh.
757 # We try the following workarounds:
758 # - for all: respawn using $CONFIG_SHELL if that is set and works.
759 # - for bash >= 2.04: unset the shell option xpg_echo.
760 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
761 # - for bash < 2.0: define echo to a function that uses cat of a here document.
762 # - for zsh: turn sh-emulation on.
763 # - for ksh: alias echo to 'print -r'.
764 # - for ksh: alias echo to a function that uses cat of a here document.
765 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
766 # the ksh workaround.
767 # - otherwise: respawn using /bin/sh and rely on the workarounds.
768 # When respawning, we pass --no-reexec as first argument, so as to avoid
769 # turning this script into a fork bomb in unlucky situations.
771 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
772 # the 'printf' built-in. See
773 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
774 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
775 # The workaround is: define echo to a function that uses the printf built-in.
777 if echo '\t' | grep t > /dev/null; then
778 have_echo=yes # Lucky!
780 # Try the workarounds.
781 # Respawn using $CONFIG_SHELL if that is set and works.
782 if test -z "$have_echo" \
783 && test "X$1" != "X--no-reexec" \
784 && test -n "$CONFIG_SHELL" \
785 && test -f "$CONFIG_SHELL" \
786 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
787 exec $CONFIG_SHELL "$0" --no-reexec "$@"
790 # For bash >= 2.04: unset the shell option xpg_echo.
791 if test -z "$have_echo" \
792 && test -n "$BASH_VERSION" \
793 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
797 # For bash >= 2.0: define echo to a function that uses the printf built-in.
798 # For bash < 2.0: define echo to a function that uses cat of a here document.
799 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
800 # Also handle problem 2, specific to bash 3.2, here.
801 if { test -z "$have_echo" \
802 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
804 && test -n "$BASH_VERSION"; then \
805 if type printf 2>/dev/null | grep / > /dev/null; then
806 # 'printf' is not a shell built-in.
814 # 'printf' is a shell built-in.
820 if echo '\t' | grep t > /dev/null; then
824 # For zsh: turn sh-emulation on.
825 if test -z "$have_echo" \
826 && test -n "$ZSH_VERSION" \
827 && (emulate sh) >/dev/null 2>&1; then
830 # For ksh: alias echo to 'print -r'.
831 if test -z "$have_echo" \
832 && (type print) >/dev/null 2>&1; then
833 # A 'print' command exists.
834 if type print 2>/dev/null | grep / > /dev/null; then
837 # 'print' is a shell built-in.
838 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
839 # 'print' is the ksh shell built-in.
840 alias echo='print -r'
844 if test -z "$have_echo" \
845 && echo '\t' | grep t > /dev/null; then
848 # For ksh: alias echo to a function that uses cat of a here document.
849 # The ksh manual page says:
850 # "Aliasing is performed when scripts are read, not while they are executed.
851 # Therefore, for an alias to take effect, the alias definition command has
852 # to be executed before the command which references the alias is read."
853 # Because of this, we have to play strange tricks with have_echo, to ensure
854 # that the top-level statement containing the test starts after the 'alias'
856 if test -z "$have_echo"; then
863 if (alias echo=bsd_echo) 2>/dev/null; then
864 alias echo=bsd_echo 2>/dev/null
867 if test -z "$have_echo" \
868 && echo '\t' | grep t > /dev/null; then
871 if test -z "$have_echo"; then
872 if (alias echo=bsd_echo) 2>/dev/null; then
873 unalias echo 2>/dev/null
876 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
877 if test -z "$have_echo" \
878 && test "X$1" != "X--no-reexec" \
879 && test -f /bin/ksh; then
880 exec /bin/ksh "$0" --no-reexec "$@"
883 # Otherwise: respawn using /bin/sh.
884 if test -z "$have_echo" \
885 && test "X$1" != "X--no-reexec" \
886 && test -f /bin/sh; then
887 exec /bin/sh "$0" --no-reexec "$@"
890 if test -z "$have_echo"; then
891 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
893 if echo '\t' | grep t > /dev/null; then
896 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
898 if test "X$1" = "X--no-reexec"; then
902 # Unset CDPATH. Otherwise, output from 'cd dir' can surprise callers.
903 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
905 # Command-line option processing.
906 # Removes the OPTIONS from the arguments. Sets the variables:
907 # - mode one of: list, find, import, add-import, remove-import,
908 # update, create-testdir, create-megatestdir, test, megatest,
910 # - destdir from --dir
911 # - local_gnulib_dir from --local-dir
912 # - modcache true or false, from --cache-modules/--no-cache-modules
913 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
914 # - libname, supplied_libname from --lib
915 # - sourcebase from --source-base
916 # - m4base from --m4-base
917 # - pobase from --po-base
918 # - docbase from --doc-base
919 # - testsbase from --tests-base
920 # - auxdir from --aux-dir
921 # - inctests true if --with-tests was given, false if --without-tests
922 # was given, blank otherwise
923 # - incobsolete true if --with-obsolete was given, blank otherwise
924 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
925 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
927 # - inc_privileged_tests true if --with-privileged-tests was given, blank
929 # - inc_unportable_tests true if --with-unportable-tests was given, blank
931 # - inc_all_tests true if --with-all-tests was given, blank otherwise
932 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
933 # - excl_longrunning_tests true if --without-longrunning-tests was given,
935 # - excl_privileged_tests true if --without-privileged-tests was given, blank
937 # - excl_unportable_tests true if --without-unportable-tests was given, blank
939 # - single_configure true if --single-configure was given, false otherwise
940 # - avoidlist list of modules to avoid, from --avoid
941 # - cond_dependencies true if --conditional-dependencies was given, false if
942 # --no-conditional-dependencies was given, blank otherwise
943 # - lgpl yes or a number if --lgpl was given, blank otherwise
944 # - makefile_name from --makefile-name
945 # - libtool true if --libtool was given, false if --no-libtool was
946 # given, blank otherwise
947 # - macro_prefix from --macro-prefix
948 # - po_domain from --po-domain
949 # - witness_c_macro from --witness-c-macro
950 # - vc_files true if --vc-files was given, false if --no-vc-files was
951 # given, blank otherwise
952 # - autoconf_minversion minimum supported autoconf version
953 # - doit : if actions shall be executed, false if only to be printed
954 # - symbolic true if --symlink or --more-symlinks was given, blank
956 # - lsymbolic true if --local-symlink was given, blank otherwise
957 # - do_copyrights blank if --more-symlinks was given, true otherwise
975 inc_longrunning_tests=
976 inc_privileged_tests=
977 inc_unportable_tests=
980 excl_longrunning_tests=
981 excl_privileged_tests=
982 excl_unportable_tests=
983 single_configure=false
1000 while test $# -gt 0; do
1005 --find | --fin | --fi | --f )
1008 --import | --impor | --impo | --imp | --im | --i )
1011 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1014 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1017 --update | --updat | --upda | --upd | --up | --u )
1020 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1023 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1024 mode=create-megatestdir
1026 --test | --tes | --te | --t )
1029 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1033 mode=`echo "X$1" | sed -e 's/^X--//'`
1035 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1040 if test $# = 0; then
1041 func_fatal_error "missing argument for --dir"
1046 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1050 if test $# = 0; then
1051 func_fatal_error "missing argument for --local-dir"
1056 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1058 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1061 --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 )
1064 --verbose | --verbos | --verbo | --verb )
1065 verbose=`expr $verbose + 1`
1067 --quiet | --quie | --qui | --qu | --q )
1068 verbose=`expr $verbose - 1`
1072 if test $# = 0; then
1073 func_fatal_error "missing argument for --lib"
1076 supplied_libname=true
1079 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1080 supplied_libname=true
1084 if test $# = 0; then
1085 func_fatal_error "missing argument for --source-base"
1090 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1094 if test $# = 0; then
1095 func_fatal_error "missing argument for --m4-base"
1100 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1104 if test $# = 0; then
1105 func_fatal_error "missing argument for --po-base"
1110 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1114 if test $# = 0; then
1115 func_fatal_error "missing argument for --doc-base"
1120 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1124 if test $# = 0; then
1125 func_fatal_error "missing argument for --tests-base"
1130 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1134 if test $# = 0; then
1135 func_fatal_error "missing argument for --aux-dir"
1140 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1142 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1145 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1148 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1151 --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)
1152 inc_longrunning_tests=true
1154 --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)
1155 inc_privileged_tests=true
1157 --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)
1158 inc_unportable_tests=true
1160 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1163 --without-tests | --without-test | --without-tes | --without-te | --without-t)
1166 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1169 --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)
1170 excl_longrunning_tests=true
1172 --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)
1173 excl_privileged_tests=true
1175 --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)
1176 excl_unportable_tests=true
1178 --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)
1179 single_configure=true
1183 if test $# = 0; then
1184 func_fatal_error "missing argument for --avoid"
1186 func_append avoidlist " $1"
1189 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1190 func_append avoidlist " $arg"
1192 --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)
1193 cond_dependencies=true
1195 --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)
1196 cond_dependencies=false
1202 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1205 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1211 if test $# = 0; then
1212 func_fatal_error "missing argument for --makefile-name"
1217 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1227 if test $# = 0; then
1228 func_fatal_error "missing argument for --macro-prefix"
1233 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1237 if test $# = 0; then
1238 func_fatal_error "missing argument for --po-domain"
1243 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1247 if test $# = 0; then
1248 func_fatal_error "missing argument for --witness-c-macro"
1250 witness_c_macro="$1"
1252 --witness-c-macro=* )
1253 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1261 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1262 # A no-op for backward compatibility.
1267 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1270 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1273 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1277 --help | --hel | --he | --h )
1280 --version | --versio | --versi | --vers )
1284 # Stop option processing
1288 echo "gnulib-tool: unknown option $1" 1>&2
1289 echo "Try 'gnulib-tool --help' for more information." 1>&2
1296 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1297 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1298 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1299 || test "$single_configure" != false; then
1300 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1301 echo "Try 'gnulib-tool --help' for more information." 1>&2
1305 if test "$mode" = update; then
1306 if test $# != 0; then
1307 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1308 echo "Try 'gnulib-tool --help' for more information." 1>&2
1309 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1310 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1313 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1314 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1315 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1316 || test -n "$inctests" || test -n "$incobsolete" \
1317 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1318 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1319 || test -n "$inc_all_tests" \
1320 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1321 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1322 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1323 || test -n "$macro_prefix" || test -n "$po_domain" \
1324 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1325 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1326 echo "Try 'gnulib-tool --help' for more information." 1>&2
1327 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1328 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1332 if test -n "$pobase" && test -z "$po_domain"; then
1333 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1334 echo "Try 'gnulib-tool --help' for more information." 1>&2
1337 if test -z "$pobase" && test -n "$po_domain"; then
1338 func_warning "--po-domain has no effect without a --po-base option"
1340 # Canonicalize the inctests variable.
1342 import | add-import | remove-import | update)
1343 if test -z "$inctests"; then
1347 create-testdir | create-megatestdir | test | megatest)
1348 if test -z "$inctests"; then
1353 # Now the only possible values of "$inctests" are true and false
1354 # (or blank but then it is irrelevant).
1355 if test "$cond_dependencies" = true && test "$inctests" = true; then
1356 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1360 # Determine the minimum supported autoconf version from the project's
1362 DEFAULT_AUTOCONF_MINVERSION="2.59"
1363 autoconf_minversion=
1365 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1366 && test -n "$destdir"; then
1367 if test -f "$destdir"/configure.ac; then
1368 configure_ac="$destdir/configure.ac"
1370 if test -f "$destdir"/configure.in; then
1371 configure_ac="$destdir/configure.in"
1375 if test -f configure.ac; then
1376 configure_ac="configure.ac"
1378 if test -f configure.in; then
1379 configure_ac="configure.in"
1383 if test -n "$configure_ac"; then
1384 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1385 # because when some m4 files are omitted from a version control repository,
1386 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1387 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1388 # autom4te: m4 failed with exit status: 1
1395 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1397 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1398 if test -n "$prereqs"; then
1399 autoconf_minversion=`
1400 for version in $prereqs; do echo $version; done |
1401 LC_ALL=C sort -nru | sed -e 1q
1405 if test -z "$autoconf_minversion"; then
1406 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1408 case "$autoconf_minversion" in
1409 1.* | 2.[0-4]* | 2.5[0-8]*)
1410 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1413 # Remove trailing slashes from the directory names. This is necessary for
1414 # m4base (to avoid an error in func_import) and optional for the others.
1415 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1416 case "$local_gnulib_dir" in
1417 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1419 case "$sourcebase" in
1420 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1423 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1426 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1429 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1431 case "$testsbase" in
1432 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1435 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1441 trap 'exit_status=$?
1442 if test "$signal" != 0; then
1443 echo "caught signal $signal" >&2
1446 exit $exit_status' 0
1447 for signal in 1 2 3 13 15; do
1448 trap '{ signal='$signal'; func_exit 1; }' $signal
1452 # Note: The 'eval' silences stderr output in dash.
1453 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1454 # Zsh 4 and Bash 4 have associative arrays.
1455 have_associative=true
1457 # For other shells, use 'eval' with computed shell variable names.
1458 have_associative=false
1461 # func_lookup_file file
1462 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1465 # - local_gnulib_dir from --local-dir
1467 # - lookedup_file name of the merged (combined) file
1468 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1472 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1473 lookedup_file="$local_gnulib_dir/$lkfile"
1476 if test -f "$gnulib_dir/$lkfile"; then
1477 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1478 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1479 rm -f "$tmp/$lkbase"
1480 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1481 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1482 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1483 lookedup_file="$tmp/$lkbase"
1486 lookedup_file="$gnulib_dir/$lkfile"
1490 func_fatal_error "file $gnulib_dir/$lkfile not found"
1495 # func_sanitize_modulelist
1496 # receives a list of possible module names on standard input, one per line.
1497 # It removes those which are just file names unrelated to modules, and outputs
1498 # the resulting list to standard output, one per line.
1499 func_sanitize_modulelist ()
1501 sed -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1502 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1503 -e '/^README$/d' -e '/\/README$/d' \
1504 -e '/^TEMPLATE$/d' \
1505 -e '/^TEMPLATE-EXTENDED$/d' \
1506 -e '/^TEMPLATE-TESTS$/d' \
1513 # - local_gnulib_dir from --local-dir
1516 # Filter out metainformation files like README, which are not modules.
1517 # Filter out unit test modules; they can be retrieved through
1518 # --extract-tests-module if desired.
1520 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1521 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1522 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1525 | func_sanitize_modulelist \
1526 | sed -e '/-tests$/d' \
1530 # func_exists_module module
1531 # tests whether a module, given by name, exists
1533 # - local_gnulib_dir from --local-dir
1534 func_exists_module ()
1536 { test -f "$gnulib_dir/modules/$1" \
1537 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1538 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1539 && test "ChangeLog" != "$1" \
1540 && test "COPYING" != "$1" \
1541 && test "README" != "$1" \
1542 && test "TEMPLATE" != "$1" \
1543 && test "TEMPLATE-EXTENDED" != "$1" \
1544 && test "TEMPLATE-TESTS" != "$1"
1547 # func_verify_module
1548 # verifies a module name
1550 # - local_gnulib_dir from --local-dir
1551 # - module module name argument
1552 func_verify_module ()
1554 if func_exists_module "$module"; then
1555 # OK, $module is a correct module name.
1556 # Verify that building the module description with 'patch' succeeds.
1557 func_lookup_file "modules/$module"
1559 func_warning "module $module doesn't exist"
1564 # func_verify_nontests_module
1565 # verifies a module name, excluding tests modules
1567 # - local_gnulib_dir from --local-dir
1568 # - module module name argument
1569 func_verify_nontests_module ()
1572 *-tests ) module= ;;
1573 * ) func_verify_module ;;
1577 # func_verify_tests_module
1578 # verifies a module name, considering only tests modules
1580 # - local_gnulib_dir from --local-dir
1581 # - module module name argument
1582 func_verify_tests_module ()
1585 *-tests ) func_verify_module ;;
1590 # Suffix of a sed expression that extracts a particular field from a
1591 # module description.
1592 # A field starts with a line that contains a keyword, such as 'Description',
1593 # followed by a colon and optional whitespace. All following lines, up to
1594 # the next field (or end of file if there is none) form the contents of the
1596 # An absent field is equivalent to a field with empty contents.
1597 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1598 sed_extract_prog=':[ ]*$/ {
1601 s/^Description:[ ]*$//
1605 s/^Applicability:[ ]*$//
1607 s/^Depends-on:[ ]*$//
1608 s/^configure\.ac-early:[ ]*$//
1609 s/^configure\.ac:[ ]*$//
1610 s/^Makefile\.am:[ ]*$//
1614 s/^Maintainer:[ ]*$//
1621 # Piece of a sed expression that converts a field header line to a shell
1623 # NOTE: Keep this in sync with sed_extract_prog above!
1624 sed_extract_field_header='
1625 s/^Description:[ ]*$/description/
1626 s/^Comment:[ ]*$/comment/
1627 s/^Status:[ ]*$/status/
1628 s/^Notice:[ ]*$/notice/
1629 s/^Applicability:[ ]*$/applicability/
1630 s/^Files:[ ]*$/files/
1631 s/^Depends-on:[ ]*$/dependson/
1632 s/^configure\.ac-early:[ ]*$/configureac_early/
1633 s/^configure\.ac:[ ]*$/configureac/
1634 s/^Makefile\.am:[ ]*$/makefile/
1635 s/^Include:[ ]*$/include/
1637 s/^License:[ ]*$/license/
1638 s/^Maintainer:[ ]*$/maintainer/'
1642 if $have_associative; then
1644 # Declare the associative arrays.
1645 declare -A modcache_cached
1646 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1647 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1648 eval "$declare_script"
1652 # func_cache_var module
1653 # computes the cache variable name corresponding to $module.
1654 # Note: This computation can map different module names to the same
1655 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1656 # to protect against this case.
1658 # - cachevar a shell variable name
1659 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1660 # Bash 2.0 and newer, ksh, and zsh support the syntax
1661 # ${param//pattern/replacement}
1662 # as a shorthand for
1663 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1664 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1665 eval 'func_cache_var ()
1667 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1674 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1683 # func_init_sed_convert_to_cache_statements
1685 # - modcachevar_assignment
1687 # - sed_convert_to_cache_statements
1688 func_init_sed_convert_to_cache_statements ()
1690 # 'sed' script that turns a module description into shell script
1691 # assignments, suitable to be eval'ed. All active characters are escaped.
1694 # Some module's description
1699 # modcache_description[$1]=\
1700 # 'Some module'"'"'s description
1702 # modcache_files[$1]=\
1705 # c_MODULE_description_set=set; c_MODULE_description=\
1706 # 'Some module'"'"'s description
1708 # c_MODULE_files_set=set; c_MODULE_files=\
1710 # The script consists of two parts:
1711 # 1) Ignore the lines before the first field header.
1712 # 2) A loop, treating non-field-header lines by escaping single quotes
1713 # and adding a closing quote in the last line,
1714 sed_convert_to_cache_statements="
1716 # Here we have not yet seen a field header.
1718 # See if the current line contains a field header.
1721 ${sed_extract_field_header}
1724 # No field header. Ignore the line.
1726 # Read the next line. Upon EOF, just exit.
1731 # The current line contains a field header.
1733 # Turn it into the beginning of an assignment.
1734 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1736 # Move it to the hold space. Don't print it yet,
1737 # because we want no assignment if the field is empty.
1740 # Read the next line.
1741 # Upon EOF, the field was empty. Print no assignment. Just exit.
1744 # See if the current line contains a field header.
1747 ${sed_extract_field_header}
1748 # If it is, the previous field was empty. Print no assignment.
1751 # Not a field header.
1753 # Print the previous line, held in the hold space.
1758 # Transform single quotes.
1761 # Prepend a single quote.
1766 # Move it to the hold space.
1769 # Read the next line.
1776 # See if the current line contains a field header.
1779 ${sed_extract_field_header}
1782 # Print the previous line, held in the hold space.
1787 # Transform single quotes.
1794 # Print the previous line, held in the hold space, with a single quote
1795 # to end the assignment.
1805 # Print the previous line, held in the hold space, with a single quote
1806 # to end the assignment.
1813 if ! $sed_comments; then
1815 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1816 | sed -e 's/^ *//' -e 's/^#.*//'`
1820 if $have_associative; then
1821 # sed_convert_to_cache_statements does not depend on the module.
1822 modcachevar_assignment='modcache_\1[$1]='
1823 func_init_sed_convert_to_cache_statements
1826 # func_cache_lookup_module module
1828 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1829 # of its relevant data in a cache in the memory of the processing shell. If
1830 # already cached, it does not look it up again, thus saving file access time.
1832 # - module non-empty string
1833 # Output if $have_associative:
1834 # - modcache_cached[$module] set to yes
1835 # - modcache_description[$module] ==
1836 # - modcache_status[$module] \ set to the field's value, minus the
1837 # - ... / final newline,
1838 # - modcache_maintainer[$module] == or unset if the field's value is empty
1839 # Output if ! $have_associative:
1840 # - cachevar a shell variable name
1841 # - ${cachevar}_cached set to $module
1842 # - ${cachevar}_description ==
1843 # - ${cachevar}_status \ set to the field's value, minus the
1844 # - ... / final newline,
1845 # - ${cachevar}_maintainer == or unset if the field's value is empty
1846 # - ${cachevar}_description_set ==
1847 # - ${cachevar}_status_set \ set to non-empty if the field's value
1848 # - ... / is non-empty,
1849 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1850 func_cache_lookup_module ()
1852 if $have_associative; then
1853 eval 'cached=${modcache_cached[$1]}'
1856 eval "cached=\"\$${cachevar}_cached\""
1858 if test -z "$cached"; then
1859 # Not found in cache. Look it up on the file system.
1860 func_lookup_file "modules/$1"
1861 if $have_associative; then
1862 eval 'modcache_cached[$1]=yes'
1864 eval "${cachevar}_cached=\"\$1\""
1866 if ! $have_associative; then
1867 # sed_convert_to_cache_statements depends on the module.
1868 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1869 func_init_sed_convert_to_cache_statements
1871 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1872 eval "$cache_statements"
1874 if ! $have_associative; then
1875 if test "$1" != "$cached"; then
1876 func_fatal_error "cache variable collision between $1 and $cached"
1884 # func_get_description module
1886 # - local_gnulib_dir from --local-dir
1887 # - modcache true or false, from --cache-modules/--no-cache-modules
1888 func_get_description ()
1890 if ! $modcache; then
1891 func_lookup_file "modules/$1"
1892 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1894 func_cache_lookup_module "$1"
1895 # Output the field's value, including the final newline (if any).
1896 if $have_associative; then
1897 if eval 'test -n "${modcache_description[$1]+set}"'; then
1898 eval 'echo "${modcache_description[$1]}"'
1901 eval "field_set=\"\$${cachevar}_description_set\""
1902 if test -n "$field_set"; then
1903 eval "field_value=\"\$${cachevar}_description\""
1904 echo "${field_value}"
1910 # func_get_comment module
1912 # - local_gnulib_dir from --local-dir
1913 # - modcache true or false, from --cache-modules/--no-cache-modules
1916 if ! $modcache; then
1917 func_lookup_file "modules/$1"
1918 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1920 func_cache_lookup_module "$1"
1921 # Output the field's value, including the final newline (if any).
1922 if $have_associative; then
1923 if eval 'test -n "${modcache_comment[$1]+set}"'; then
1924 eval 'echo "${modcache_comment[$1]}"'
1927 eval "field_set=\"\$${cachevar}_comment_set\""
1928 if test -n "$field_set"; then
1929 eval "field_value=\"\$${cachevar}_comment\""
1930 echo "${field_value}"
1936 # func_get_status module
1938 # - local_gnulib_dir from --local-dir
1939 # - modcache true or false, from --cache-modules/--no-cache-modules
1942 if ! $modcache; then
1943 func_lookup_file "modules/$1"
1944 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1946 func_cache_lookup_module "$1"
1947 # Output the field's value, including the final newline (if any).
1948 if $have_associative; then
1949 if eval 'test -n "${modcache_status[$1]+set}"'; then
1950 eval 'echo "${modcache_status[$1]}"'
1953 eval "field_set=\"\$${cachevar}_status_set\""
1954 if test -n "$field_set"; then
1955 eval "field_value=\"\$${cachevar}_status\""
1956 echo "${field_value}"
1962 # func_get_notice module
1964 # - local_gnulib_dir from --local-dir
1965 # - modcache true or false, from --cache-modules/--no-cache-modules
1968 if ! $modcache; then
1969 func_lookup_file "modules/$1"
1970 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1972 func_cache_lookup_module "$1"
1973 # Output the field's value, including the final newline (if any).
1974 if $have_associative; then
1975 if eval 'test -n "${modcache_notice[$1]+set}"'; then
1976 eval 'echo "${modcache_notice[$1]}"'
1979 eval "field_set=\"\$${cachevar}_notice_set\""
1980 if test -n "$field_set"; then
1981 eval "field_value=\"\$${cachevar}_notice\""
1982 echo "${field_value}"
1988 # func_get_applicability module
1990 # - local_gnulib_dir from --local-dir
1991 # - modcache true or false, from --cache-modules/--no-cache-modules
1992 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1993 func_get_applicability ()
1995 if ! $modcache; then
1996 func_lookup_file "modules/$1"
1997 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1999 func_cache_lookup_module "$1"
2000 # Get the field's value, without the final newline.
2001 if $have_associative; then
2002 eval 'my_applicability="${modcache_applicability[$1]}"'
2004 eval "my_applicability=\"\$${cachevar}_applicability\""
2007 if test -n "$my_applicability"; then
2008 echo $my_applicability
2010 # The default is 'main' or 'tests', depending on the module's name.
2012 *-tests) echo "tests";;
2018 # func_get_filelist module
2020 # - local_gnulib_dir from --local-dir
2021 # - modcache true or false, from --cache-modules/--no-cache-modules
2022 func_get_filelist ()
2024 if ! $modcache; then
2025 func_lookup_file "modules/$1"
2026 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2028 func_cache_lookup_module "$1"
2029 # Output the field's value, including the final newline (if any).
2030 if $have_associative; then
2031 if eval 'test -n "${modcache_files[$1]+set}"'; then
2032 eval 'echo "${modcache_files[$1]}"'
2035 eval "field_set=\"\$${cachevar}_files_set\""
2036 if test -n "$field_set"; then
2037 eval "field_value=\"\$${cachevar}_files\""
2038 echo "${field_value}"
2043 echo m4/gnulib-common.m4
2044 case "$autoconf_minversion" in
2051 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2052 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2053 # elements starting with prefix and ending with suffix are considered.
2054 # Processing: removed_prefix and removed_suffix are removed from each element,
2055 # added_prefix and added_suffix are added to each element.
2056 # prefix, suffix should not contain shell-special characters.
2057 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2058 # added_prefix, added_suffix should not contain the characters \|&.
2059 func_filter_filelist ()
2061 if test "$2" != "$nl" \
2062 || { $fast_func_append \
2063 && { test -z "$6" || $fast_func_remove_prefix; } \
2064 && { test -z "$7" || $fast_func_remove_suffix; }; \
2068 # Do not quote possibly-empty parameters in case patterns,
2069 # AIX and HP-UX ksh won't match them if they are empty.
2072 if test -n "$6"; then
2073 func_remove_prefix fff "$6"
2075 if test -n "$7"; then
2076 func_remove_suffix fff "$7"
2079 if test -z "$ffflist"; then
2082 func_append ffflist "$2${fff}"
2088 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2089 ffflist=`for fff in $3; do
2091 $4*$5) echo "$fff" ;;
2093 done | sed -e "$sed_fff_filter"`
2095 eval "$1=\"\$ffflist\""
2098 # func_get_dependencies module
2100 # - local_gnulib_dir from --local-dir
2101 # - modcache true or false, from --cache-modules/--no-cache-modules
2102 func_get_dependencies ()
2104 # ${module}-tests implicitly depends on ${module}, if that module exists.
2108 func_remove_suffix fgd1 '-tests'
2109 if func_exists_module "$fgd1"; then
2114 # Then the explicit dependencies listed in the module description.
2115 { if ! $modcache; then
2116 func_lookup_file "modules/$1"
2117 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2119 func_cache_lookup_module "$1"
2120 # Output the field's value, including the final newline (if any).
2121 if $have_associative; then
2122 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2123 eval 'echo "${modcache_dependson[$1]}"'
2126 eval "field_set=\"\$${cachevar}_dependson_set\""
2127 if test -n "$field_set"; then
2128 eval "field_value=\"\$${cachevar}_dependson\""
2129 echo "${field_value}"
2137 # func_get_autoconf_early_snippet module
2139 # - local_gnulib_dir from --local-dir
2140 # - modcache true or false, from --cache-modules/--no-cache-modules
2141 func_get_autoconf_early_snippet ()
2143 if ! $modcache; then
2144 func_lookup_file "modules/$1"
2145 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2147 func_cache_lookup_module "$1"
2148 # Output the field's value, including the final newline (if any).
2149 if $have_associative; then
2150 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2151 eval 'echo "${modcache_configureac_early[$1]}"'
2154 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2155 if test -n "$field_set"; then
2156 eval "field_value=\"\$${cachevar}_configureac_early\""
2157 echo "${field_value}"
2163 # func_get_autoconf_snippet module
2165 # - local_gnulib_dir from --local-dir
2166 # - modcache true or false, from --cache-modules/--no-cache-modules
2167 func_get_autoconf_snippet ()
2169 if ! $modcache; then
2170 func_lookup_file "modules/$1"
2171 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2173 func_cache_lookup_module "$1"
2174 # Output the field's value, including the final newline (if any).
2175 if $have_associative; then
2176 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2177 eval 'echo "${modcache_configureac[$1]}"'
2180 eval "field_set=\"\$${cachevar}_configureac_set\""
2181 if test -n "$field_set"; then
2182 eval "field_value=\"\$${cachevar}_configureac\""
2183 echo "${field_value}"
2189 # func_get_automake_snippet_conditional module
2190 # returns the part of the Makefile.am snippet that can be put inside Automake
2193 # - local_gnulib_dir from --local-dir
2194 # - modcache true or false, from --cache-modules/--no-cache-modules
2195 func_get_automake_snippet_conditional ()
2197 if ! $modcache; then
2198 func_lookup_file "modules/$1"
2199 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2201 func_cache_lookup_module "$1"
2202 # Output the field's value, including the final newline (if any).
2203 if $have_associative; then
2204 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2205 eval 'echo "${modcache_makefile[$1]}"'
2208 eval "field_set=\"\$${cachevar}_makefile_set\""
2209 if test -n "$field_set"; then
2210 eval "field_value=\"\$${cachevar}_makefile\""
2211 echo "${field_value}"
2217 # func_get_automake_snippet_unconditional module
2218 # returns the part of the Makefile.am snippet that must stay outside of
2219 # Automake conditionals.
2221 # - local_gnulib_dir from --local-dir
2222 # - modcache true or false, from --cache-modules/--no-cache-modules
2223 func_get_automake_snippet_unconditional ()
2227 # *-tests module live in tests/, not lib/.
2228 # Synthesize an EXTRA_DIST augmentation.
2229 all_files=`func_get_filelist $1`
2230 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2231 extra_files="$tests_files"
2232 if test -n "$extra_files"; then
2233 echo "EXTRA_DIST +=" $extra_files
2238 # Synthesize an EXTRA_DIST augmentation.
2239 sed_combine_lines='/\\$/{
2246 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2247 already_mentioned_files=` \
2248 { if ! $modcache; then
2249 func_lookup_file "modules/$1"
2250 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2252 func_cache_lookup_module "$1"
2253 if $have_associative; then
2254 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2255 eval 'echo "${modcache_makefile[$1]}"'
2258 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2259 if test -n "$field_set"; then
2260 eval 'field_value="$'"${cachevar}"'_makefile"'
2261 echo "${field_value}"
2266 | sed -e "$sed_combine_lines" \
2267 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2268 all_files=`func_get_filelist $1`
2269 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2270 # Remove $already_mentioned_files from $lib_files.
2271 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2272 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2273 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2274 if test -n "$extra_files"; then
2275 echo "EXTRA_DIST +=" $extra_files
2278 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2279 # This is necessary so that automake can generate the right list of
2281 # A possible approach would be to use autom4te --trace of the redefined
2282 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2283 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2284 # inside autoconf's built-in macros are not missed).
2285 # But it's simpler and more robust to do it here, based on the file list.
2286 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2287 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2288 # automake will generate a useless dependency; this is harmless.
2290 relocatable-prog-wrapper) ;;
2293 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2294 if test -n "$extra_files"; then
2295 echo "EXTRA_lib_SOURCES +=" $extra_files
2300 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2301 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2302 if test -n "$buildaux_files"; then
2303 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2304 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2307 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2308 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2309 if test -n "$top_files"; then
2310 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2311 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2318 # func_get_automake_snippet module
2320 # - local_gnulib_dir from --local-dir
2321 # - modcache true or false, from --cache-modules/--no-cache-modules
2322 func_get_automake_snippet ()
2324 func_get_automake_snippet_conditional "$1"
2325 func_get_automake_snippet_unconditional "$1"
2328 # func_get_include_directive module
2330 # - local_gnulib_dir from --local-dir
2331 # - modcache true or false, from --cache-modules/--no-cache-modules
2332 func_get_include_directive ()
2335 if ! $modcache; then
2336 func_lookup_file "modules/$1"
2337 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2339 func_cache_lookup_module "$1"
2340 # Output the field's value, including the final newline (if any).
2341 if $have_associative; then
2342 if eval 'test -n "${modcache_include[$1]+set}"'; then
2343 eval 'echo "${modcache_include[$1]}"'
2346 eval "field_set=\"\$${cachevar}_include_set\""
2347 if test -n "$field_set"; then
2348 eval "field_value=\"\$${cachevar}_include\""
2349 echo "${field_value}"
2353 } | sed -e 's/^\(["<]\)/#include \1/'
2356 # func_get_link_directive module
2358 # - local_gnulib_dir from --local-dir
2359 # - modcache true or false, from --cache-modules/--no-cache-modules
2360 func_get_link_directive ()
2362 if ! $modcache; then
2363 func_lookup_file "modules/$1"
2364 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2366 func_cache_lookup_module "$1"
2367 # Output the field's value, including the final newline (if any).
2368 if $have_associative; then
2369 if eval 'test -n "${modcache_link[$1]+set}"'; then
2370 eval 'echo "${modcache_link[$1]}"'
2373 eval "field_set=\"\$${cachevar}_link_set\""
2374 if test -n "$field_set"; then
2375 eval "field_value=\"\$${cachevar}_link\""
2376 echo "${field_value}"
2382 # func_get_license_raw module
2384 # - local_gnulib_dir from --local-dir
2385 # - modcache true or false, from --cache-modules/--no-cache-modules
2386 func_get_license_raw ()
2388 if ! $modcache; then
2389 func_lookup_file "modules/$1"
2390 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2392 func_cache_lookup_module "$1"
2393 # Output the field's value, including the final newline (if any).
2394 if $have_associative; then
2395 if eval 'test -n "${modcache_license[$1]+set}"'; then
2396 eval 'echo "${modcache_license[$1]}"'
2399 eval "field_set=\"\$${cachevar}_license_set\""
2400 if test -n "$field_set"; then
2401 eval "field_value=\"\$${cachevar}_license\""
2402 echo "${field_value}"
2408 # func_get_license module
2410 # - local_gnulib_dir from --local-dir
2411 # - modcache true or false, from --cache-modules/--no-cache-modules
2414 # Warn if the License field is missing.
2418 license=`func_get_license_raw "$1"`
2419 if test -z "$license"; then
2420 func_warning "module $1 lacks a License"
2425 func_get_license_raw "$1"
2426 # The default is GPL.
2428 } | sed -e 's,^ *$,,' | sed -e 1q
2431 # func_get_maintainer module
2433 # - local_gnulib_dir from --local-dir
2434 # - modcache true or false, from --cache-modules/--no-cache-modules
2435 func_get_maintainer ()
2437 if ! $modcache; then
2438 func_lookup_file "modules/$1"
2439 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2441 func_cache_lookup_module "$1"
2442 # Output the field's value, including the final newline (if any).
2443 if $have_associative; then
2444 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2445 eval 'echo "${modcache_maintainer[$1]}"'
2448 eval "field_set=\"\$${cachevar}_maintainer_set\""
2449 if test -n "$field_set"; then
2450 eval "field_value=\"\$${cachevar}_maintainer\""
2451 echo "${field_value}"
2457 # func_get_tests_module module
2459 # - local_gnulib_dir from --local-dir
2460 func_get_tests_module ()
2462 # The naming convention for tests modules is hardwired: ${module}-tests.
2463 if test -f "$gnulib_dir/modules/$1"-tests \
2464 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2465 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2470 # func_acceptable module
2471 # tests whether a module is acceptable.
2473 # - avoidlist list of modules to avoid
2476 for avoid in $avoidlist; do
2477 if test "$avoid" = "$1"; then
2484 # sed expression to keep the first 32 characters of each line.
2485 sed_first_32_chars='s/^\(................................\).*/\1/'
2487 # func_module_shellfunc_name module
2488 # computes the shell function name that will contain the m4 macros for the module.
2490 # - macro_prefix prefix to use
2492 # - shellfunc shell function name
2493 func_module_shellfunc_name ()
2497 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2499 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2503 # func_module_shellvar_name module
2504 # computes the shell variable name the will be set to true once the m4 macros
2505 # for the module have been executed.
2507 # - shellvar shell variable name
2508 func_module_shellvar_name ()
2512 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2514 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2518 # func_module_conditional_name module
2519 # computes the automake conditional name for the module.
2521 # - conditional name of automake conditional
2522 func_module_conditional_name ()
2526 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2528 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2532 # func_uncond_add_module B
2533 # notes the presence of B as an unconditional module.
2535 # func_conddep_add_module A B cond
2536 # notes the presence of a conditional dependency from module A to module B,
2537 # subject to the condition that A is enabled and cond is true.
2539 # func_cond_module_p B
2540 # tests whether module B is conditional.
2542 # func_cond_module_condition A B
2543 # returns the condition when B should be enabled as a dependency of A, once the
2544 # m4 code for A has been executed.
2545 # Output: - condition
2547 if $have_associative; then
2548 declare -A conddep_isuncond
2549 declare -A conddep_dependers
2550 declare -A conddep_condition
2551 func_uncond_add_module ()
2553 eval 'conddep_isuncond[$1]=true'
2554 eval 'unset conddep_dependers[$1]'
2556 func_conddep_add_module ()
2558 eval 'isuncond="${conddep_isuncond[$2]}"'
2559 if test -z "$isuncond"; then
2560 # No unconditional dependency to B known at this point.
2561 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2562 eval 'conddep_condition[$1---$2]="$3"'
2565 func_cond_module_p ()
2567 eval 'previous_dependers="${conddep_dependers[$1]}"'
2568 test -n "$previous_dependers"
2570 func_cond_module_condition ()
2572 eval 'condition="${conddep_condition[$1---$2]}"'
2575 func_uncond_add_module ()
2579 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2583 eval 'conddep_isuncond_'"$suffix"'=true'
2584 eval 'unset conddep_dependers_'"$suffix"
2586 func_conddep_add_module ()
2590 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2594 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2595 if test -z "$isuncond"; then
2596 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2597 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2598 eval 'conddep_condition_'"$suffix"'="$3"'
2601 func_cond_module_p ()
2605 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2609 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2610 test -n "$previous_dependers"
2612 func_cond_module_condition ()
2614 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2615 eval 'condition="${conddep_condition_'"$suffix"'}"'
2619 sed_dependencies_without_conditions='s/ *\[.*//'
2621 # func_modules_transitive_closure
2623 # - local_gnulib_dir from --local-dir
2624 # - modcache true or false, from --cache-modules/--no-cache-modules
2625 # - modules list of specified modules
2626 # - inctests true if tests should be included, false otherwise
2627 # - incobsolete true if obsolete modules among dependencies should be
2628 # included, blank otherwise
2629 # - inc_cxx_tests true if C++ interoperability tests should be included,
2631 # - inc_longrunning_tests true if long-runnings tests should be included,
2633 # - inc_privileged_tests true if tests that require root privileges should be
2634 # included, blank otherwise
2635 # - inc_unportable_tests true if tests that fail on some platforms should be
2636 # included, blank otherwise
2637 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2638 # the unit tests of the specified modules should be
2639 # included, blank otherwise
2640 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2641 # the unit tests of the dependencies should be
2642 # included, blank otherwise
2643 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2645 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2647 # - excl_privileged_tests true if tests that require root privileges should be
2648 # excluded, blank otherwise
2649 # - excl_unportable_tests true if tests that fail on some platforms should be
2650 # excluded, blank otherwise
2651 # - avoidlist list of modules to avoid
2652 # - cond_dependencies true if conditional dependencies shall be supported,
2654 # - tmp pathname of a temporary directory
2656 # - modules list of modules, including dependencies
2657 # - conddep_dependers, conddep_condition information about conditionally
2659 func_modules_transitive_closure ()
2661 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2662 # In order to process every module only once (for speed), process an "input
2663 # list" of modules, producing an "output list" of modules. During each round,
2664 # more modules can be queued in the input list. Once a module on the input
2665 # list has been processed, it is added to the "handled list", so we can avoid
2666 # to process it again.
2668 inmodules="$modules"
2670 fmtc_inc_all_tests="$inc_all_direct_tests"
2671 if test "$cond_dependencies" = true; then
2672 for module in $inmodules; do
2674 if test -n "$module"; then
2675 if func_acceptable $module; then
2676 func_uncond_add_module $module
2681 while test -n "$inmodules"; do
2682 inmodules_this_round="$inmodules"
2683 inmodules= # Accumulator, queue for next round
2684 for module in $inmodules_this_round; do
2686 if test -n "$module"; then
2687 if func_acceptable $module; then
2688 func_append outmodules " $module"
2689 if test "$cond_dependencies" = true; then
2690 if func_get_automake_snippet_conditional $module | grep '^if ' > /dev/null; then
2691 # A module whose Makefile.am snippet contains a reference to an
2692 # automake conditional. If we were to use it conditionally, we
2693 # would get an error
2694 # configure: error: conditional "..." was never defined.
2695 # because automake 1.11.1 does not handle nested conditionals
2696 # correctly. As a workaround, make the module unconditional.
2697 func_uncond_add_module $module
2699 if func_cond_module_p $module; then
2705 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2706 # Duplicate dependencies are harmless, but Jim wants a warning.
2707 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2708 if test -n "$duplicated_deps"; then
2709 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2712 testsmodule=`func_get_tests_module $module`
2713 if test -n "$testsmodule"; then
2714 deps="$deps $testsmodule"
2717 for dep in $deps; do
2718 # Determine whether to include the dependency or tests module.
2720 for word in `func_get_status $dep`; do
2723 test -n "$incobsolete" \
2727 test -z "$excl_cxx_tests" \
2729 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2733 test -z "$excl_longrunning_tests" \
2735 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2739 test -z "$excl_privileged_tests" \
2741 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2745 test -z "$excl_unportable_tests" \
2747 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2751 test -n "$fmtc_inc_all_tests" \
2756 if $inc && func_acceptable "$dep"; then
2757 func_append inmodules " $dep"
2758 if test "$cond_dependencies" = true; then
2759 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2760 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2763 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2764 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2766 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2767 if test "$condition" = true; then
2770 if test -n "$condition"; then
2771 func_conddep_add_module "$module" "$dep" "$condition"
2773 if $conditional; then
2774 func_conddep_add_module "$module" "$dep" true
2776 func_uncond_add_module "$dep"
2785 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2786 # Remove $handledmodules from $inmodules.
2787 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2788 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2789 fmtc_inc_all_tests="$inc_all_indirect_tests"
2791 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2792 rm -f "$tmp"/queued-modules
2795 # func_show_module_list
2797 # - specified_modules list of specified modules (one per line, sorted)
2798 # - modules complete list of modules (one per line, sorted)
2799 # - tmp pathname of a temporary directory
2800 func_show_module_list ()
2806 # Assume xterm compatible escape sequences.
2807 bold_on=`printf '\x1b[1m'`
2808 bold_off=`printf '\x1b[0m'`
2813 echo "Module list with included dependencies (indented):"
2814 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2815 echo "$modules" | sed -e '/^$/d' \
2816 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2817 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2820 # func_modules_transitive_closure_separately
2821 # Determine main module list and tests-related module list separately.
2822 # The main module list is the transitive closure of the specified modules,
2823 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2824 # is specified, it will consist only of LGPLed source.
2825 # The tests-related module list is the transitive closure of the specified
2826 # modules, including tests modules, minus the main module list excluding
2827 # modules of applicability 'all'. Its lib/* sources (brought in through
2828 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2829 # source, even if --lgpl is specified.
2831 # - local_gnulib_dir from --local-dir
2832 # - modcache true or false, from --cache-modules/--no-cache-modules
2833 # - specified_modules list of specified modules
2834 # - inctests true if tests should be included, false otherwise
2835 # - incobsolete true if obsolete modules among dependencies should be
2836 # included, blank otherwise
2837 # - inc_cxx_tests true if C++ interoperability tests should be included,
2839 # - inc_longrunning_tests true if long-runnings tests should be included,
2841 # - inc_privileged_tests true if tests that require root privileges should be
2842 # included, blank otherwise
2843 # - inc_unportable_tests true if tests that fail on some platforms should be
2844 # included, blank otherwise
2845 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2846 # the unit tests of the specified modules should be
2847 # included, blank otherwise
2848 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2849 # the unit tests of the dependencies should be
2850 # included, blank otherwise
2851 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2853 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2855 # - excl_privileged_tests true if tests that require root privileges should be
2856 # excluded, blank otherwise
2857 # - excl_unportable_tests true if tests that fail on some platforms should be
2858 # excluded, blank otherwise
2859 # - avoidlist list of modules to avoid
2860 # - cond_dependencies true if conditional dependencies shall be supported,
2862 # - tmp pathname of a temporary directory
2864 # - main_modules list of modules, including dependencies
2865 # - testsrelated_modules list of tests-related modules, including dependencies
2866 # - conddep_dependers, conddep_condition information about conditionally
2868 func_modules_transitive_closure_separately ()
2870 # Determine main module list.
2871 saved_inctests="$inctests"
2873 modules="$specified_modules"
2874 func_modules_transitive_closure
2875 main_modules="$modules"
2876 inctests="$saved_inctests"
2877 if test $verbose -ge 1; then
2878 echo "Main module list:"
2879 echo "$main_modules" | sed -e 's/^/ /'
2881 # Determine tests-related module list.
2882 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2883 testsrelated_modules=`for module in $main_modules; do
2884 if test \`func_get_applicability $module\` = main; then
2888 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2889 if test $verbose -ge 1; then
2890 echo "Tests-related module list:"
2891 echo "$testsrelated_modules" | sed -e 's/^/ /'
2895 # func_determine_use_libtests
2896 # Determines whether a $testsbase/libtests.a is needed.
2898 # - local_gnulib_dir from --local-dir
2899 # - modcache true or false, from --cache-modules/--no-cache-modules
2900 # - testsrelated_modules list of tests-related modules, including dependencies
2902 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2903 func_determine_use_libtests ()
2906 for module in $testsrelated_modules; do
2907 func_verify_nontests_module
2908 if test -n "$module"; then
2909 all_files=`func_get_filelist $module`
2910 # Test whether some file in $all_files lies in lib/.
2911 for f in $all_files; do
2923 # func_modules_add_dummy
2925 # - local_gnulib_dir from --local-dir
2926 # - modcache true or false, from --cache-modules/--no-cache-modules
2927 # - modules list of modules, including dependencies
2929 # - modules list of modules, including 'dummy' if needed
2930 func_modules_add_dummy ()
2932 # Determine whether any module provides a lib_SOURCES augmentation.
2934 sed_remove_backslash_newline=':a
2941 for module in $modules; do
2942 func_verify_nontests_module
2943 if test -n "$module"; then
2944 # Extract the value of "lib_SOURCES += ...".
2945 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2946 # Ignore .h files since they are not compiled.
2950 have_lib_SOURCES=yes
2957 # Add the dummy module, to make sure the library will be non-empty.
2958 if test -z "$have_lib_SOURCES"; then
2959 if func_acceptable "dummy"; then
2960 func_append modules " dummy"
2965 # func_modules_add_dummy_separately
2967 # - local_gnulib_dir from --local-dir
2968 # - modcache true or false, from --cache-modules/--no-cache-modules
2969 # - main_modules list of modules, including dependencies
2970 # - testsrelated_modules list of tests-related modules, including dependencies
2971 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2973 # - main_modules list of modules, including 'dummy' if needed
2974 # - testsrelated_modules list of tests-related modules, including 'dummy' if
2976 func_modules_add_dummy_separately ()
2978 # Add the dummy module to the main module list if needed.
2979 modules="$main_modules"
2980 func_modules_add_dummy
2981 main_modules="$modules"
2983 # Add the dummy module to the tests-related module list if needed.
2984 if $use_libtests; then
2985 modules="$testsrelated_modules"
2986 func_modules_add_dummy
2987 testsrelated_modules="$modules"
2991 # func_modules_notice
2993 # - local_gnulib_dir from --local-dir
2994 # - modcache true or false, from --cache-modules/--no-cache-modules
2995 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2996 # - modules list of modules, including dependencies
2997 func_modules_notice ()
2999 if test $verbose -ge -1; then
3000 for module in $modules; do
3002 if test -n "$module"; then
3003 msg=`func_get_notice $module`
3004 if test -n "$msg"; then
3005 echo "Notice from module $module:"
3006 echo "$msg" | sed -e 's/^/ /'
3013 # func_modules_to_filelist
3015 # - local_gnulib_dir from --local-dir
3016 # - modcache true or false, from --cache-modules/--no-cache-modules
3017 # - modules list of modules, including dependencies
3019 # - files list of files
3020 func_modules_to_filelist ()
3023 for module in $modules; do
3025 if test -n "$module"; then
3026 fs=`func_get_filelist $module`
3027 func_append files " $fs"
3030 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3033 # func_modules_to_filelist_separately
3034 # Determine the final file lists.
3035 # They must be computed separately, because files in lib/* go into
3036 # $sourcebase/ if they are in the main file list but into $testsbase/
3037 # if they are in the tests-related file list. Furthermore lib/dummy.c
3040 # - local_gnulib_dir from --local-dir
3041 # - modcache true or false, from --cache-modules/--no-cache-modules
3042 # - main_modules list of modules, including dependencies
3043 # - testsrelated_modules list of tests-related modules, including dependencies
3044 func_modules_to_filelist_separately ()
3046 # Determine final main file list.
3047 modules="$main_modules"
3048 func_modules_to_filelist
3050 # Determine final tests-related file list.
3051 modules="$testsrelated_modules"
3052 func_modules_to_filelist
3053 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3054 # Merge both file lists.
3055 sed_remove_empty_lines='/^$/d'
3056 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3057 if test $verbose -ge 0; then
3059 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3060 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3064 # func_compute_include_guard_prefix
3065 # Determine include_guard_prefix.
3067 # - macro_prefix prefix of gl_LIBOBJS macros to use
3069 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3070 # - sed_replace_include_guard_prefix
3071 # sed expression for resolving ${gl_include_guard_prefix}
3072 func_compute_include_guard_prefix ()
3074 if test "$macro_prefix" = gl; then
3075 include_guard_prefix='GL'
3077 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3079 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3082 # func_execute_command command [args...]
3083 # Executes a command.
3084 # Uses also the variables
3085 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3086 func_execute_command ()
3088 if test $verbose -ge 0; then
3092 # Commands like automake produce output to stderr even when they succeed.
3093 # Turn this output off if the command succeeds.
3094 "$@" > "$tmp"/cmdout 2>&1
3096 if test $cmdret = 0; then
3100 cat "$tmp"/cmdout 1>&2
3107 # func_dest_tmpfilename file
3108 # determines the name of a temporary file (file is relative to destdir).
3110 # - destdir target directory
3111 # - doit : if actions shall be executed, false if only to be printed
3112 # - tmp pathname of a temporary directory
3114 # - tmpfile absolute filename of the temporary file
3115 func_dest_tmpfilename ()
3118 # Put the new contents of $file in a file in the same directory (needed
3119 # to guarantee that an 'mv' to "$destdir/$file" works).
3120 tmpfile="$destdir/$1.tmp"
3122 # Put the new contents of $file in a file in a temporary directory
3123 # (because the directory of "$file" might not exist).
3124 tmpfile="$tmp"/`basename "$1"`.tmp
3129 # copies a file from gnulib into the destination directory. The destination
3130 # is known to not exist.
3132 # - destdir target directory
3133 # - local_gnulib_dir from --local-dir
3134 # - modcache true or false, from --cache-modules/--no-cache-modules
3135 # - f the original file name
3136 # - lookedup_file name of the merged (combined) file
3137 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3138 # - g the rewritten file name
3139 # - tmpfile absolute filename of the temporary file
3140 # - doit : if actions shall be executed, false if only to be printed
3141 # - symbolic true if files should be symlinked, copied otherwise
3142 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3147 echo "Copying file $g"
3148 if { test -n "$symbolic" \
3149 || { test -n "$lsymbolic" \
3150 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3151 && test -z "$lookedup_tmp" \
3152 && cmp -s "$lookedup_file" "$tmpfile"; then
3153 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3155 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3163 # copies a file from gnulib into the destination directory. The destination
3164 # is known to exist.
3166 # - destdir target directory
3167 # - local_gnulib_dir from --local-dir
3168 # - modcache true or false, from --cache-modules/--no-cache-modules
3169 # - f the original file name
3170 # - lookedup_file name of the merged (combined) file
3171 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3172 # - g the rewritten file name
3173 # - tmpfile absolute filename of the temporary file
3174 # - doit : if actions shall be executed, false if only to be printed
3175 # - symbolic true if files should be symlinked, copied otherwise
3176 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3178 # - already_present nonempty if the file should already exist, empty otherwise
3181 if cmp -s "$destdir/$g" "$tmpfile"; then
3182 : # The file has not changed.
3186 if test -n "$already_present"; then
3187 echo "Updating file $g (backup in ${g}~)"
3189 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3191 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3192 if { test -n "$symbolic" \
3193 || { test -n "$lsymbolic" \
3194 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3195 && test -z "$lookedup_tmp" \
3196 && cmp -s "$lookedup_file" "$tmpfile"; then
3197 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3199 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3202 if test -n "$already_present"; then
3203 echo "Update file $g (backup in ${g}~)"
3205 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3211 # func_emit_lib_Makefile_am
3212 # emits the contents of library makefile to standard output.
3214 # - local_gnulib_dir from --local-dir
3215 # - modcache true or false, from --cache-modules/--no-cache-modules
3216 # - modules list of modules, including dependencies
3217 # - libname library name
3218 # - pobase directory relative to destdir where to place *.po files
3219 # - auxdir directory relative to destdir where to place build aux files
3220 # - makefile_name from --makefile-name
3221 # - libtool true if libtool will be used, false or blank otherwise
3222 # - macro_prefix prefix of gl_LIBOBJS macros to use
3223 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3224 # - witness_c_macro from --witness-c-macro
3225 # - actioncmd (optional) command that will reproduce this invocation
3226 # - for_test true if creating a package for testing, false otherwise
3227 # - sed_replace_include_guard_prefix
3228 # sed expression for resolving ${gl_include_guard_prefix}
3229 # - destfile filename relative to destdir of makefile being generated
3231 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3232 # list of edits to be done to Makefile.am variables
3234 # - uses_subdirs nonempty if object files in subdirs exist
3235 func_emit_lib_Makefile_am ()
3237 # When creating an includable Makefile.am snippet, augment variables with
3238 # += instead of assigning them.
3239 if test -n "$makefile_name"; then
3244 if test "$libtool" = true; then
3247 sed_eliminate_LDFLAGS="$sed_noop"
3251 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3254 # When creating a package for testing: Attempt to provoke failures,
3255 # especially link errors, already during "make" rather than during
3256 # "make check", because "make check" is not possible in a cross-compiling
3257 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3258 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3260 sed_transform_check_PROGRAMS="$sed_noop"
3262 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3263 echo "## Process this file with automake to produce Makefile.in."
3264 func_emit_copyright_notice
3265 if test -n "$actioncmd"; then
3266 # The maximum line length (excluding the terminating newline) of any file
3267 # that is to be preprocessed by config.status is 3070. config.status uses
3268 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3269 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3270 len=`echo "$actioncmd" | wc -c`
3271 if test -n "$len" && test "$len" -le 3000; then
3272 echo "# Reproduce by: $actioncmd"
3278 for module in $modules; do
3279 func_verify_nontests_module
3280 if test -n "$module"; then
3282 func_get_automake_snippet_conditional "$module" |
3284 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3285 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3286 -e "$sed_eliminate_LDFLAGS" \
3287 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3288 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3289 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3290 -e "$sed_transform_check_PROGRAMS" \
3291 -e "$sed_replace_include_guard_prefix"
3292 if test "$module" = 'alloca'; then
3293 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3294 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3296 } > "$tmp"/amsnippet1
3298 func_get_automake_snippet_unconditional "$module" |
3299 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3300 } > "$tmp"/amsnippet2
3301 # Skip the contents if it's entirely empty.
3302 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3303 echo "## begin gnulib module $module"
3305 if test "$cond_dependencies" = true; then
3306 if func_cond_module_p "$module"; then
3307 func_module_conditional_name "$module"
3308 echo "if $conditional"
3311 cat "$tmp"/amsnippet1
3312 if test "$cond_dependencies" = true; then
3313 if func_cond_module_p "$module"; then
3317 cat "$tmp"/amsnippet2
3318 echo "## end gnulib module $module"
3321 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3322 # Test whether there are some source files in subdirectories.
3323 for f in `func_get_filelist "$module"`; do
3333 } > "$tmp"/allsnippets
3334 if test -z "$makefile_name"; then
3335 # If there are source files in subdirectories, prevent collision of the
3336 # object files (example: hash.c and libxml/hash.c).
3338 if test -n "$uses_subdirs"; then
3339 subdir_options=' subdir-objects'
3341 echo "AUTOMAKE_OPTIONS = 1.9.6 gnits${subdir_options}"
3344 if test -z "$makefile_name"; then
3346 echo "noinst_HEADERS ="
3347 echo "noinst_LIBRARIES ="
3348 echo "noinst_LTLIBRARIES ="
3349 # Automake versions < 1.11.4 create an empty pkgdatadir at
3350 # installation time if you specify pkgdata_DATA to empty.
3351 # See automake bugs #10997 and #11030:
3352 # * http://debbugs.gnu.org/10997
3353 # * http://debbugs.gnu.org/11030
3354 # So we need this workaround.
3355 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3356 echo "pkgdata_DATA ="
3359 echo "BUILT_SOURCES ="
3362 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3363 if test -z "$makefile_name"; then
3364 echo "MOSTLYCLEANDIRS ="
3366 echo "DISTCLEANFILES ="
3367 echo "MAINTAINERCLEANFILES ="
3369 # Execute edits that apply to the Makefile.am being generated.
3371 while test $edit != $makefile_am_edits; do
3372 edit=`expr $edit + 1`
3373 eval dir=\"\$makefile_am_edit${edit}_dir\"
3374 eval var=\"\$makefile_am_edit${edit}_var\"
3375 eval val=\"\$makefile_am_edit${edit}_val\"
3376 if test -n "$var"; then
3377 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3378 echo "${var} += ${val}"
3379 eval "makefile_am_edit${edit}_var="
3383 if test -n "$witness_c_macro"; then
3384 cppflags_part1=" -D$witness_c_macro=1"
3389 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3393 if test -z "$makefile_name"; then
3395 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3398 if test -n "$cppflags_part1$cppflags_part2"; then
3400 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3404 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3405 || { test -n "$makefile_name" \
3406 && test -f "$sourcebase/Makefile.am" \
3407 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3409 # One of the snippets or the user's Makefile.am already specifies an
3410 # installation location for the library. Don't confuse automake by saying
3411 # it should not be installed.
3414 # By default, the generated library should not be installed.
3415 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3418 echo "${libname}_${libext}_SOURCES ="
3419 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3420 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3421 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3422 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3423 echo "EXTRA_${libname}_${libext}_SOURCES ="
3424 if test "$libtool" = true; then
3425 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3426 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3427 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3428 # the link dependencies of all modules.
3429 for module in $modules; do
3430 func_verify_nontests_module
3431 if test -n "$module"; then
3432 func_get_link_directive "$module"
3435 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3436 | LC_ALL=C sort -u \
3437 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3440 if test -n "$pobase"; then
3441 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3444 cat "$tmp"/allsnippets \
3445 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3447 echo "mostlyclean-local: mostlyclean-generic"
3448 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3449 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3450 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3454 rm -f "$tmp"/allsnippets
3457 # func_emit_po_Makevars
3458 # emits the contents of po/ makefile parameterization to standard output.
3460 # - local_gnulib_dir from --local-dir
3461 # - modcache true or false, from --cache-modules/--no-cache-modules
3462 # - sourcebase directory relative to destdir where to place source code
3463 # - pobase directory relative to destdir where to place *.po files
3464 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3465 func_emit_po_Makevars ()
3467 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3468 func_emit_copyright_notice
3470 echo "# Usually the message domain is the same as the package name."
3471 echo "# But here it has a '-gnulib' suffix."
3472 echo "DOMAIN = ${po_domain}-gnulib"
3474 echo "# These two variables depend on the location of this directory."
3475 echo "subdir = ${pobase}"
3476 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3479 # These options get passed to xgettext.
3480 XGETTEXT_OPTIONS = \
3481 --keyword=_ --flag=_:1:pass-c-format \
3482 --keyword=N_ --flag=N_:1:pass-c-format \
3483 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3484 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3485 --flag=error:3:c-format --flag=error_at_line:5:c-format
3487 # This is the copyright holder that gets inserted into the header of the
3488 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3489 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3491 # This is the email address or URL to which the translators shall report
3492 # bugs in the untranslated strings:
3493 # - Strings which are not entire sentences, see the maintainer guidelines
3494 # in the GNU gettext documentation, section 'Preparing Strings'.
3495 # - Strings which use unclear terms or require additional context to be
3497 # - Strings which make invalid assumptions about notation of date, time or
3499 # - Pluralisation problems.
3500 # - Incorrect English spelling.
3501 # - Incorrect formatting.
3502 # It can be your email address, or a mailing list address where translators
3503 # can write to without being subscribed, or the URL of a web page through
3504 # which the translators can contact you.
3505 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3507 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3508 # message catalogs shall be used. It is usually empty.
3509 EXTRA_LOCALE_CATEGORIES =
3511 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3512 # context. Possible values are "yes" and "no". Set this to yes if the
3513 # package uses functions taking also a message context, like pgettext(), or
3514 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3519 # func_emit_po_POTFILES_in
3520 # emits the file list to be passed to xgettext to standard output.
3522 # - local_gnulib_dir from --local-dir
3523 # - modcache true or false, from --cache-modules/--no-cache-modules
3524 # - sourcebase directory relative to destdir where to place source code
3525 # - files list of new files
3526 func_emit_po_POTFILES_in ()
3528 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3529 func_emit_copyright_notice
3531 echo "# List of files which contain translatable strings."
3532 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3535 # func_emit_tests_Makefile_am witness_macro
3536 # emits the contents of tests makefile to standard output.
3538 # - local_gnulib_dir from --local-dir
3539 # - modcache true or false, from --cache-modules/--no-cache-modules
3540 # - modules list of modules, including dependencies
3541 # - libname library name
3542 # - auxdir directory relative to destdir where to place build aux files
3543 # - makefile_name from --makefile-name
3544 # - libtool true if libtool will be used, false or blank otherwise
3545 # - sourcebase relative directory containing lib source code
3546 # - m4base relative directory containing autoconf macros
3547 # - testsbase relative directory containing unit test code
3548 # - macro_prefix prefix of gl_LIBOBJS macros to use
3549 # - witness_c_macro from --witness-c-macro
3550 # - for_test true if creating a package for testing, false otherwise
3551 # - single_configure true if a single configure file should be generated,
3552 # false for a separate configure file for the tests
3553 # - use_libtests true if a libtests.a should be built, false otherwise
3554 # - sed_replace_include_guard_prefix
3555 # sed expression for resolving ${gl_include_guard_prefix}
3556 # - destfile filename relative to destdir of makefile being generated
3558 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3559 # list of edits to be done to Makefile.am variables
3561 # - uses_subdirs nonempty if object files in subdirs exist
3562 func_emit_tests_Makefile_am ()
3565 if test "$libtool" = true; then
3568 sed_eliminate_LDFLAGS="$sed_noop"
3572 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3575 # When creating a package for testing: Attempt to provoke failures,
3576 # especially link errors, already during "make" rather than during
3577 # "make check", because "make check" is not possible in a cross-compiling
3578 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3579 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3581 sed_transform_check_PROGRAMS="$sed_noop"
3583 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3584 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3585 echo "## Process this file with automake to produce Makefile.in."
3586 func_emit_copyright_notice
3590 for module in $modules; do
3591 if $for_test && ! $single_configure; then
3592 func_verify_tests_module
3596 if test -n "$module"; then
3598 func_get_automake_snippet "$module" |
3600 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3601 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3602 -e "$sed_eliminate_LDFLAGS" \
3603 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3604 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3605 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3606 -e "$sed_transform_check_PROGRAMS" \
3607 -e "$sed_replace_include_guard_prefix"
3608 if $use_libtests && test "$module" = 'alloca'; then
3609 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3610 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3612 } > "$tmp"/amsnippet
3613 # Skip the contents if it's entirely empty.
3614 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3615 # Mention long-running tests at the end.
3617 for word in `func_get_status "$module"`; do
3618 if test "$word" = 'longrunning-test'; then
3623 { echo "## begin gnulib module $module"
3625 cat "$tmp"/amsnippet
3626 echo "## end gnulib module $module"
3630 rm -f "$tmp"/amsnippet
3631 # Test whether there are some source files in subdirectories.
3632 for f in `func_get_filelist "$module"`; do
3634 lib/*/*.c | tests/*/*.c)
3642 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3643 # Generate dependencies here, since it eases the debugging of test failures.
3644 # If there are source files in subdirectories, prevent collision of the
3645 # object files (example: hash.c and libxml/hash.c).
3647 if test -n "$uses_subdirs"; then
3648 subdir_options=' subdir-objects'
3650 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign${subdir_options}"
3652 if $for_test && ! $single_configure; then
3653 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3656 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3657 # variable is needed to avoid an error from automake:
3658 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3661 echo "XFAIL_TESTS ="
3662 echo "TESTS_ENVIRONMENT ="
3663 echo "noinst_PROGRAMS ="
3664 if ! $for_test; then
3665 echo "check_PROGRAMS ="
3667 echo "noinst_HEADERS ="
3668 echo "noinst_LIBRARIES ="
3669 if $use_libtests; then
3671 echo "noinst_LIBRARIES += libtests.a"
3673 echo "check_LIBRARIES = libtests.a"
3676 # Automake versions < 1.11.4 create an empty pkgdatadir at
3677 # installation time if you specify pkgdata_DATA to empty.
3678 # See automake bugs #10997 and #11030:
3679 # * http://debbugs.gnu.org/10997
3680 # * http://debbugs.gnu.org/11030
3681 # So we need this workaround.
3682 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3683 echo "pkgdata_DATA ="
3686 echo "BUILT_SOURCES ="
3688 echo "MOSTLYCLEANFILES = core *.stackdump"
3689 echo "MOSTLYCLEANDIRS ="
3691 echo "DISTCLEANFILES ="
3692 echo "MAINTAINERCLEANFILES ="
3693 # Execute edits that apply to the Makefile.am being generated.
3695 while test $edit != $makefile_am_edits; do
3696 edit=`expr $edit + 1`
3697 eval dir=\"\$makefile_am_edit${edit}_dir\"
3698 eval var=\"\$makefile_am_edit${edit}_var\"
3699 eval val=\"\$makefile_am_edit${edit}_val\"
3700 if test -n "$var"; then
3701 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3702 echo "${var} += ${val}"
3703 eval "makefile_am_edit${edit}_var="
3708 echo "AM_CPPFLAGS = \\"
3710 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3712 if test -n "$witness_c_macro"; then
3713 echo " -D$witness_c_macro=1 \\"
3715 if test -n "${witness_macro}"; then
3716 echo " -D@${witness_macro}@=1 \\"
3718 echo " -I. -I\$(srcdir) \\"
3719 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3720 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3722 local_ldadd_before=''
3723 local_ldadd_after=''
3724 if $use_libtests; then
3725 # All test programs need to be linked with libtests.a.
3726 # It needs to be passed to the linker before ${libname}.${libext}, since
3727 # the tests-related modules depend on the main modules.
3728 # It also needs to be passed to the linker after ${libname}.${libext}
3729 # because the latter might contain incomplete modules (such as the 'error'
3730 # module whose dependency to 'progname' is voluntarily omitted).
3731 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3733 local_ldadd_before=' libtests.a'
3734 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3736 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3738 if $use_libtests; then
3739 echo "libtests_a_SOURCES ="
3740 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3741 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3742 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3743 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3744 echo "EXTRA_libtests_a_SOURCES ="
3745 # The circular dependency in LDADD requires this.
3746 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3749 # Many test scripts use ${EXEEXT} or ${srcdir}.
3750 # EXEEXT is defined by AC_PROG_CC through autoconf.
3751 # srcdir is defined by autoconf and automake.
3752 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3754 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3755 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3756 echo "# Clean up after Solaris cc."
3758 echo " rm -rf SunWS_cache"
3760 echo "mostlyclean-local: mostlyclean-generic"
3761 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3762 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3763 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3767 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3770 # func_emit_initmacro_start macro_prefix
3771 # emits the first few statements of the gl_INIT macro to standard output.
3772 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3773 func_emit_initmacro_start ()
3775 macro_prefix_arg="$1"
3776 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3777 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3778 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3779 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3781 # Furthermore it avoids an automake error like this when a Makefile.am
3782 # that uses pieces of gnulib also uses $(LIBOBJ):
3783 # automatically discovered file `error.c' should not be explicitly mentioned
3784 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3785 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3786 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3787 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3788 # automatically discovered file `error.c' should not be explicitly mentioned
3789 # We let automake know about the files to be distributed through the
3790 # EXTRA_lib_SOURCES variable.
3791 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3792 # Create data variables for checking the presence of files that are mentioned
3793 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3794 # because we want the check to happen when the configure file is created,
3795 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3796 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3797 # in which to expect them.
3798 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3799 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3803 # func_emit_initmacro_end macro_prefix
3804 # emits the last few statements of the gl_INIT macro to standard output.
3805 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3806 func_emit_initmacro_end ()
3808 macro_prefix_arg="$1"
3809 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3810 # The check is performed only when autoconf is run from the directory where
3811 # the configure.ac resides; if it is run from a different directory, the
3813 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3814 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3815 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3816 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3817 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3821 echo " m4_if(m4_sysval, [0], [],"
3822 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3824 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3825 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3826 echo " m4_popdef([AC_LIBSOURCES])"
3827 echo " m4_popdef([AC_REPLACE_FUNCS])"
3828 echo " m4_popdef([AC_LIBOBJ])"
3829 echo " AC_CONFIG_COMMANDS_PRE(["
3830 echo " ${macro_prefix_arg}_libobjs="
3831 echo " ${macro_prefix_arg}_ltlibobjs="
3832 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3833 echo " # Remove the extension."
3834 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3835 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3836 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3837 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3840 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3841 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3845 # func_emit_initmacro_done macro_prefix sourcebase
3846 # emits a few statements after the gl_INIT macro to standard output.
3847 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3848 # - sourcebase directory relative to destdir where to place source code
3849 func_emit_initmacro_done ()
3851 macro_prefix_arg="$1"
3854 echo "# Like AC_LIBOBJ, except that the module name goes"
3855 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3856 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3857 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3858 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3861 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3862 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3863 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3864 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3865 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3868 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3869 echo "# expected is derived from the gnulib-tool parameterization,"
3870 echo "# and alloca is special cased (for the alloca-opt module)."
3871 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3872 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3873 echo " m4_foreach([_gl_NAME], [\$1], ["
3874 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3875 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3876 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3882 # func_emit_autoconf_snippet indentation
3883 # emits the autoconf snippet of a module.
3885 # - indentation spaces to prepend on each line
3886 # - local_gnulib_dir from --local-dir
3887 # - modcache true or false, from --cache-modules/--no-cache-modules
3888 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3889 # - sed_replace_include_guard_prefix
3890 # sed expression for resolving ${gl_include_guard_prefix}
3891 # - module the module name
3892 # - toplevel true or false. 'false' means a subordinate use of
3894 # - disable_libtool true or false. It tells whether to disable libtool
3895 # handling even if it has been specified through the
3896 # command line options.
3897 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3899 func_emit_autoconf_snippet ()
3902 if { case $module in
3903 gnumakefile | maintainer-makefile)
3904 # These modules are meant to be used only in the top-level directory.
3910 func_get_autoconf_snippet "$module" \
3911 | sed -e '/^$/d;' -e "s/^/$indentation/" \
3912 -e "$sed_replace_build_aux" \
3913 -e "$sed_replace_include_guard_prefix" \
3914 | { if $disable_libtool; then
3915 sed -e 's/\$gl_cond_libtool/false/g' \
3916 -e 's/gl_libdeps/gltests_libdeps/g' \
3917 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3922 | { if $disable_gettext; then
3923 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
3925 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
3926 # autopoint through at least GNU gettext version 0.18.2.
3927 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
3930 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
3931 echo 'changequote(,)dnl'
3932 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3933 echo 'changequote([, ])dnl'
3934 echo 'AC_SUBST([LTALLOCA])'
3939 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
3940 # collects and emit the autoconf snippets of a set of modules.
3942 # - local_gnulib_dir from --local-dir
3943 # - modcache true or false, from --cache-modules/--no-cache-modules
3944 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3945 # - sed_replace_include_guard_prefix
3946 # sed expression for resolving ${gl_include_guard_prefix}
3947 # - modules the list of modules.
3948 # - verifier one of func_verify_module, func_verify_nontests_module,
3949 # func_verify_tests_module. It selects the subset of
3950 # $modules to consider.
3951 # - toplevel true or false. 'false' means a subordinate use of
3953 # - disable_libtool true or false. It tells whether to disable libtool
3954 # handling even if it has been specified through the
3955 # command line options.
3956 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3958 func_emit_autoconf_snippets ()
3962 disable_libtool="$4"
3963 disable_gettext="$5"
3964 if test "$cond_dependencies" = true; then
3965 for m in $modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
3966 # Emit the autoconf code for the unconditional modules.
3967 for module in $1; do
3969 if test -n "$module"; then
3970 if func_cond_module_p "$module"; then
3973 func_emit_autoconf_snippet " "
3977 # Initialize the shell variables indicating that the modules are enabled.
3978 for module in $1; do
3980 if test -n "$module"; then
3981 if func_cond_module_p "$module"; then
3982 func_module_shellvar_name "$module"
3983 echo " $shellvar=false"
3987 # Emit the autoconf code for the conditional modules, each in a separate
3988 # function. This makes it possible to support cycles among conditional
3990 for module in $1; do
3992 if test -n "$module"; then
3993 if func_cond_module_p "$module"; then
3994 func_module_shellfunc_name "$module"
3995 func_module_shellvar_name "$module"
3996 echo " $shellfunc ()"
3998 echo " if ! \$$shellvar; then"
3999 func_emit_autoconf_snippet " "
4000 echo " $shellvar=true"
4001 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4002 # Intersect $deps with the modules list $1.
4003 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4004 for dep in $deps; do
4005 if func_cond_module_p "$dep"; then
4006 func_module_shellfunc_name "$dep"
4007 func_cond_module_condition "$module" "$dep"
4008 if test "$condition" != true; then
4009 echo " if $condition; then"
4016 # The autoconf code for $dep has already been emitted above and
4017 # therefore is already executed when this function is run.
4026 # Emit the dependencies from the unconditional to the conditional modules.
4027 for module in $1; do
4029 if test -n "$module"; then
4030 if func_cond_module_p "$module"; then
4033 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4034 # Intersect $deps with the modules list $1.
4035 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4036 for dep in $deps; do
4037 if func_cond_module_p "$dep"; then
4038 func_module_shellfunc_name "$dep"
4039 func_cond_module_condition "$module" "$dep"
4040 if test "$condition" != true; then
4041 echo " if $condition; then"
4048 # The autoconf code for $dep has already been emitted above and
4049 # therefore is already executed when this code is run.
4056 # Define the Automake conditionals.
4057 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4058 for module in $1; do
4060 if test -n "$module"; then
4061 if func_cond_module_p "$module"; then
4062 func_module_conditional_name "$module"
4063 func_module_shellvar_name "$module"
4064 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4069 # Ignore the conditions, and enable all modules unconditionally.
4070 for module in $1; do
4072 if test -n "$module"; then
4073 func_emit_autoconf_snippet " "
4079 # func_import modules
4080 # Uses also the variables
4081 # - mode import or add-import or remove-import or update
4082 # - destdir target directory
4083 # - local_gnulib_dir from --local-dir
4084 # - modcache true or false, from --cache-modules/--no-cache-modules
4085 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4086 # - libname library name
4087 # - supplied_libname true if --lib was given, blank otherwise
4088 # - sourcebase directory relative to destdir where to place source code
4089 # - m4base directory relative to destdir where to place *.m4 macros
4090 # - pobase directory relative to destdir where to place *.po files
4091 # - docbase directory relative to destdir where to place doc files
4092 # - testsbase directory relative to destdir where to place unit test code
4093 # - auxdir directory relative to destdir where to place build aux files
4094 # - inctests true if --with-tests was given, false otherwise
4095 # - incobsolete true if --with-obsolete was given, blank otherwise
4096 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4097 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4099 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4101 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4103 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4104 # - avoidlist list of modules to avoid, from --avoid
4105 # - cond_dependencies true if --conditional-dependencies was given, false if
4106 # --no-conditional-dependencies was given, blank otherwise
4107 # - lgpl yes or a number if library's license shall be LGPL,
4109 # - makefile_name from --makefile-name
4110 # - libtool true if --libtool was given, false if --no-libtool was
4111 # given, blank otherwise
4112 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4113 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4114 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4115 # - witness_c_macro from --witness-c-macro
4116 # - vc_files true if --vc-files was given, false if --no-vc-files was
4117 # given, blank otherwise
4118 # - autoconf_minversion minimum supported autoconf version
4119 # - doit : if actions shall be executed, false if only to be printed
4120 # - symbolic true if files should be symlinked, copied otherwise
4121 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4123 # - do_copyrights true if copyright notices in files should be replaced,
4127 # Get the cached settings.
4128 # In 'import' mode, we read them only for the purpose of knowing the old
4129 # installed file list, and don't use them as defaults.
4130 cached_local_gnulib_dir=
4131 cached_specified_modules=
4133 cached_inc_cxx_tests=
4134 cached_inc_longrunning_tests=
4135 cached_inc_privileged_tests=
4136 cached_inc_unportable_tests=
4137 cached_inc_all_tests=
4147 cached_makefile_name=
4148 cached_cond_dependencies=
4150 cached_macro_prefix=
4152 cached_witness_c_macro=
4155 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4156 cached_libtool=false
4162 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
4172 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4174 /gl_WITH_OBSOLETE/ {
4175 s,^.*$,cached_incobsolete=true,p
4177 /gl_WITH_CXX_TESTS/ {
4178 s,^.*$,cached_inc_cxx_tests=true,p
4180 /gl_WITH_LONGRUNNING_TESTS/ {
4181 s,^.*$,cached_inc_longrunning_tests=true,p
4183 /gl_WITH_PRIVILEGED_TESTS/ {
4184 s,^.*$,cached_inc_privileged_tests=true,p
4186 /gl_WITH_UNPORTABLE_TESTS/ {
4187 s,^.*$,cached_inc_unportable_tests=true,p
4189 /gl_WITH_ALL_TESTS/ {
4190 s,^.*$,cached_inc_all_tests=true,p
4193 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4196 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4199 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4202 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4205 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4208 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4211 s,^.*$,cached_inctests=true,p
4214 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4217 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4220 s,^.*$,cached_lgpl=yes,p
4222 /gl_MAKEFILE_NAME(/ {
4223 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4225 /gl_CONDITIONAL_DEPENDENCIES/ {
4226 s,^.*$,cached_cond_dependencies=true,p
4229 s,^.*$,cached_libtool=true,p
4231 /gl_MACRO_PREFIX(/ {
4232 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4235 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4237 /gl_WITNESS_C_MACRO(/ {
4238 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4241 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4243 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4244 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4249 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4250 s,^.*$,cached_files=",p
4263 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4267 if test "$mode" = import; then
4268 # In 'import' mode, the new set of specified modules overrides the cached
4269 # set of modules. Ignore the cached settings.
4270 specified_modules="$1"
4272 # Merge the cached settings with the specified ones.
4273 # The m4base must be the same as expected from the pathname.
4274 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4275 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4277 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
4278 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4279 if test -z "$local_gnulib_dir"; then
4280 if test -n "$cached_local_gnulib_dir"; then
4283 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4285 case "$cached_local_gnulib_dir" in
4287 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4289 func_relconcat "$destdir" "$cached_local_gnulib_dir"
4290 local_gnulib_dir="$relconcat" ;;
4297 # Append the cached and the specified module names. So that
4298 # "gnulib-tool --add-import foo" means to add the module foo.
4299 specified_modules="$cached_specified_modules $1"
4302 # Take the cached module names, minus the specified module names.
4304 if $have_associative; then
4305 # Use an associative array, for O(N) worst-case run time.
4306 declare -A to_remove
4308 eval 'to_remove[$m]=yes'
4310 for module in $cached_specified_modules; do
4311 if eval 'test -z "${to_remove[$module]}"'; then
4312 func_append specified_modules "$module "
4316 # This loop has O(N²) worst-case run time.
4317 for module in $cached_specified_modules; do
4320 if test "$m" = "$module"; then
4325 if test -z "$to_remove"; then
4326 func_append specified_modules "$module "
4332 # Take the cached module names. There are no specified module names.
4333 specified_modules="$cached_specified_modules"
4336 # Included obsolete modules among the dependencies if specified either way.
4337 if test -z "$incobsolete"; then
4338 incobsolete="$cached_incobsolete"
4340 # Included special kinds of tests modules among the dependencies if specified
4342 if test -z "$inc_cxx_tests"; then
4343 inc_cxx_tests="$cached_inc_cxx_tests"
4345 if test -z "$inc_longrunning_tests"; then
4346 inc_longrunning_tests="$cached_inc_longrunning_tests"
4348 if test -z "$inc_privileged_tests"; then
4349 inc_privileged_tests="$cached_inc_privileged_tests"
4351 if test -z "$inc_unportable_tests"; then
4352 inc_unportable_tests="$cached_inc_unportable_tests"
4354 if test -z "$inc_all_tests"; then
4355 inc_all_tests="$cached_inc_all_tests"
4357 # Append the cached and the specified avoidlist. This is probably better
4358 # than dropping the cached one when --avoid is specified at least once.
4359 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4360 avoidlist=`echo $avoidlist`
4362 # The sourcebase defaults to the cached one.
4363 if test -z "$sourcebase"; then
4364 sourcebase="$cached_sourcebase"
4365 if test -z "$sourcebase"; then
4366 func_fatal_error "missing --source-base option"
4369 # The pobase defaults to the cached one.
4370 if test -z "$pobase"; then
4371 pobase="$cached_pobase"
4373 # The docbase defaults to the cached one.
4374 if test -z "$docbase"; then
4375 docbase="$cached_docbase"
4376 if test -z "$docbase"; then
4377 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."
4380 # The testsbase defaults to the cached one.
4381 if test -z "$testsbase"; then
4382 testsbase="$cached_testsbase"
4383 if test -z "$testsbase"; then
4384 func_fatal_error "missing --tests-base option"
4387 # Require the tests if specified either way.
4388 if ! $inctests; then
4389 inctests="$cached_inctests"
4390 if test -z "$inctests"; then
4394 # The libname defaults to the cached one.
4395 if test -z "$supplied_libname"; then
4396 libname="$cached_libname"
4397 if test -z "$libname"; then
4398 func_fatal_error "missing --lib option"
4401 # Require LGPL if specified either way.
4402 if test -z "$lgpl"; then
4405 # The makefile_name defaults to the cached one.
4406 if test -z "$makefile_name"; then
4407 makefile_name="$cached_makefile_name"
4409 # Use conditional dependencies if specified either way.
4410 if test -z "$cond_dependencies"; then
4411 cond_dependencies="$cached_cond_dependencies"
4413 # Use libtool if specified either way, or if guessed.
4414 if test -z "$libtool"; then
4415 if test -n "$cached_m4base"; then
4416 libtool="$cached_libtool"
4418 libtool="$guessed_libtool"
4421 # The macro_prefix defaults to the cached one.
4422 if test -z "$macro_prefix"; then
4423 macro_prefix="$cached_macro_prefix"
4424 if test -z "$macro_prefix"; then
4425 func_fatal_error "missing --macro-prefix option"
4428 # The po_domain defaults to the cached one.
4429 if test -z "$po_domain"; then
4430 po_domain="$cached_po_domain"
4432 # The witness_c_macro defaults to the cached one.
4433 if test -z "$witness_c_macro"; then
4434 witness_c_macro="$cached_witness_c_macro"
4436 # The vc_files defaults to the cached one.
4437 if test -z "$vc_files"; then
4438 vc_files="$cached_vc_files"
4440 # Ensure constraints.
4441 if test "$cond_dependencies" = true && $inctests; then
4442 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4446 # --without-*-tests options are not supported here.
4448 excl_longrunning_tests=
4449 excl_privileged_tests=
4450 excl_unportable_tests=
4452 # Canonicalize the list of specified modules.
4453 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4455 # Include all kinds of tests modules if --with-all-tests was specified.
4456 inc_all_direct_tests="$inc_all_tests"
4457 inc_all_indirect_tests="$inc_all_tests"
4459 # Determine final module list.
4460 modules="$specified_modules"
4461 func_modules_transitive_closure
4462 if test $verbose -ge 0; then
4463 func_show_module_list
4465 final_modules="$modules"
4467 # Determine main module list and tests-related module list separately.
4468 func_modules_transitive_closure_separately
4470 # Determine whether a $testsbase/libtests.a is needed.
4471 func_determine_use_libtests
4473 # Add the dummy module to the main module list or to the tests-related module
4475 func_modules_add_dummy_separately
4477 # If --lgpl, verify that the licenses of modules are compatible.
4478 if test -n "$lgpl"; then
4479 license_incompatibilities=
4480 for module in $main_modules; do
4481 license=`func_get_license $module`
4483 'GPLed build tool') ;;
4484 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4489 LGPL | LGPLv2+ | LGPLv3+) ;;
4490 *) func_append license_incompatibilities "$module $license$nl" ;;
4496 *) func_append license_incompatibilities "$module $license$nl" ;;
4499 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4504 if test -n "$license_incompatibilities"; then
4505 # Format the license incompatibilities as a table.
4506 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4507 s,^\(.................................................[^ ]*\) *, \1 ,'
4508 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4509 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4513 # Show banner notice of every module.
4514 modules="$main_modules"
4517 # Determine script to apply to imported library files.
4518 sed_transform_lib_file=
4519 for module in $main_modules; do
4520 if test $module = config-h; then
4521 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4522 sed_transform_lib_file=$sed_transform_lib_file'
4523 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4528 sed_transform_main_lib_file="$sed_transform_lib_file"
4529 if test -n "$do_copyrights"; then
4530 if test -n "$lgpl"; then
4534 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4535 s/GNU General/GNU Lesser General/g
4536 s/General Public License/Lesser General Public License/g
4537 s/Lesser Lesser General Public License/Lesser General Public License/g
4541 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4542 s/GNU General/GNU Lesser General/g
4543 s/General Public License/Lesser General Public License/g
4544 s/Lesser Lesser General Public License/Lesser General Public License/g
4546 s/version [23]\([ ,]\)/version 2.1\1/g
4549 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4553 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4554 s/GNU Lesser General/GNU General/g
4555 s/Lesser General Public License/General Public License/g
4557 s/GNU Library General/GNU General/g
4558 s/Library General Public License/General Public License/g
4560 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4565 # Determine script to apply to auxiliary files that go into $auxdir/.
4566 sed_transform_build_aux_file=
4567 if test -n "$do_copyrights"; then
4569 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4570 s/GNU Lesser General/GNU General/g
4571 s/Lesser General Public License/General Public License/g
4573 s/GNU Library General/GNU General/g
4574 s/Library General Public License/General Public License/g
4576 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4580 # Determine script to apply to library files that go into $testsbase/.
4581 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4582 if test -n "$do_copyrights"; then
4584 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4585 s/GNU Lesser General/GNU General/g
4586 s/Lesser General Public License/General Public License/g
4588 s/GNU Library General/GNU General/g
4589 s/Library General Public License/General Public License/g
4591 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4595 # Determine the final file lists.
4596 func_modules_to_filelist_separately
4599 || func_fatal_error "refusing to do nothing"
4601 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4602 new_files="$files m4/gnulib-tool.m4"
4603 old_files="$cached_files"
4604 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4605 func_append old_files " m4/gnulib-tool.m4"
4608 rewritten='%REWRITTEN%'
4609 sed_rewrite_old_files="\
4610 s,^build-aux/,$rewritten$auxdir/,
4611 s,^doc/,$rewritten$cached_docbase/,
4612 s,^lib/,$rewritten$cached_sourcebase/,
4613 s,^m4/,$rewritten$cached_m4base/,
4614 s,^tests/,$rewritten$cached_testsbase/,
4615 s,^tests=lib/,$rewritten$cached_testsbase/,
4618 sed_rewrite_new_files="\
4619 s,^build-aux/,$rewritten$auxdir/,
4620 s,^doc/,$rewritten$docbase/,
4621 s,^lib/,$rewritten$sourcebase/,
4622 s,^m4/,$rewritten$m4base/,
4623 s,^tests/,$rewritten$testsbase/,
4624 s,^tests=lib/,$rewritten$testsbase/,
4628 # Create directories.
4629 { echo "$sourcebase"
4631 if test -n "$pobase"; then
4634 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4635 if test -n "$docfiles"; then
4642 for f in $files; do echo $f; done \
4643 | sed -e "$sed_rewrite_new_files" \
4644 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4647 { # Rearrange file descriptors. Needed because "while ... done < ..."
4648 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4649 exec 5<&0 < "$tmp"/dirs
4651 if test ! -d "$destdir/$d"; then
4653 echo "Creating directory $destdir/$d"
4654 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4656 echo "Create directory $destdir/$d"
4663 # Copy files or make symbolic links. Remove obsolete files.
4667 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4668 # representing the files according to the last gnulib-tool invocation.
4669 for f in $old_files; do echo $f; done \
4670 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4673 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4674 # representing the files after this gnulib-tool invocation.
4675 for f in $new_files; do echo $f; done \
4676 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4679 # First the files that are in old-files, but not in new-files:
4680 sed_take_first_column='s,'"$delimiter"'.*,,'
4681 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4682 # Remove the file. Do nothing if the user already removed it.
4683 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4685 echo "Removing file $g (backup in ${g}~)"
4686 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4688 echo "Remove file $g (backup in ${g}~)"
4690 func_append removed_files "$g$nl"
4693 # func_add_or_update handles a file that ought to be present afterwards.
4695 # - f the original file name
4696 # - g the rewritten file name
4697 # - already_present nonempty if the file should already exist, empty
4699 func_add_or_update ()
4703 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4705 func_dest_tmpfilename "$g"
4706 func_lookup_file "$f"
4707 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4708 if test -n "$sed_transform_main_lib_file"; then
4711 sed -e "$sed_transform_main_lib_file" \
4712 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4716 if test -n "$sed_transform_build_aux_file"; then
4719 sed -e "$sed_transform_build_aux_file" \
4720 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4724 if test -n "$sed_transform_testsrelated_lib_file"; then
4727 sed -e "$sed_transform_testsrelated_lib_file" \
4728 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4732 if test -f "$destdir/$g"; then
4733 # The file already exists.
4737 # Don't protest if the file should be there but isn't: it happens
4738 # frequently that developers don't put autogenerated files under version control.
4740 func_append added_files "$g$nl"
4744 # Then the files that are in new-files, but not in old-files:
4745 sed_take_last_column='s,^.*'"$delimiter"',,'
4747 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4748 | sed -e "$sed_take_last_column" \
4749 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4750 { # Rearrange file descriptors. Needed because "while ... done < ..."
4751 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4752 exec 5<&0 < "$tmp"/added-files
4758 # Then the files that are in new-files and in old-files:
4759 already_present=true
4760 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4761 | sed -e "$sed_take_last_column" \
4762 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4763 { # Rearrange file descriptors. Needed because "while ... done < ..."
4764 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4765 exec 5<&0 < "$tmp"/kept-files
4772 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4773 actioncmd="gnulib-tool --import"
4774 func_append actioncmd " --dir=$destdir"
4775 if test -n "$local_gnulib_dir"; then
4776 func_append actioncmd " --local-dir=$local_gnulib_dir"
4778 func_append actioncmd " --lib=$libname"
4779 func_append actioncmd " --source-base=$sourcebase"
4780 func_append actioncmd " --m4-base=$m4base"
4781 if test -n "$pobase"; then
4782 func_append actioncmd " --po-base=$pobase"
4784 func_append actioncmd " --doc-base=$docbase"
4785 func_append actioncmd " --tests-base=$testsbase"
4786 func_append actioncmd " --aux-dir=$auxdir"
4788 func_append actioncmd " --with-tests"
4790 if test -n "$incobsolete"; then
4791 func_append actioncmd " --with-obsolete"
4793 if test -n "$inc_cxx_tests"; then
4794 func_append actioncmd " --with-c++-tests"
4796 if test -n "$inc_longrunning_tests"; then
4797 func_append actioncmd " --with-longrunning-tests"
4799 if test -n "$inc_privileged_tests"; then
4800 func_append actioncmd " --with-privileged-tests"
4802 if test -n "$inc_unportable_tests"; then
4803 func_append actioncmd " --with-unportable-tests"
4805 if test -n "$inc_all_tests"; then
4806 func_append actioncmd " --with-all-tests"
4808 for module in $avoidlist; do
4809 func_append actioncmd " --avoid=$module"
4811 if test -n "$lgpl"; then
4812 if test "$lgpl" = yes; then
4813 func_append actioncmd " --lgpl"
4815 func_append actioncmd " --lgpl=$lgpl"
4818 if test -n "$makefile_name"; then
4819 func_append actioncmd " --makefile-name=$makefile_name"
4821 if test "$cond_dependencies" = true; then
4822 func_append actioncmd " --conditional-dependencies"
4824 func_append actioncmd " --no-conditional-dependencies"
4826 if test "$libtool" = true; then
4827 func_append actioncmd " --libtool"
4829 func_append actioncmd " --no-libtool"
4831 func_append actioncmd " --macro-prefix=$macro_prefix"
4832 if test -n "$po_domain"; then
4833 func_append actioncmd " --po-domain=$po_domain"
4835 if test -n "$witness_c_macro"; then
4836 func_append actioncmd " --witness-c-macro=$witness_c_macro"
4838 if test -n "$vc_files"; then
4839 if test "$vc_files" = true; then
4840 func_append actioncmd " --vc-files"
4842 func_append actioncmd " --no-vc-files"
4845 func_append actioncmd " `echo $specified_modules`"
4847 # Determine include_guard_prefix.
4848 func_compute_include_guard_prefix
4850 # Default the makefile name to Makefile.am.
4851 if test -n "$makefile_name"; then
4852 makefile_am=$makefile_name
4854 makefile_am=Makefile.am
4857 # Create normal Makefile.ams.
4860 # Setup list of Makefile.am edits that are to be performed afterwards.
4861 # Some of these edits apply to files that we will generate; others are
4862 # under the responsibility of the developer.
4864 # func_note_Makefile_am_edit dir var value
4865 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4867 func_note_Makefile_am_edit ()
4869 makefile_am_edits=`expr $makefile_am_edits + 1`
4870 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4871 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4872 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4874 if test "$makefile_am" = Makefile.am; then
4875 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4876 sourcebase_base=`basename "$sourcebase"`
4877 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4879 if test -n "$pobase"; then
4880 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4881 pobase_base=`basename "$pobase"`
4882 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4885 if test "$makefile_am" = Makefile.am; then
4886 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4887 testsbase_base=`basename "$testsbase"`
4888 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4891 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4893 # Find the first parent directory of $m4base that contains or will contain
4895 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4897 sed_butlast='s,[^/][^/]*//*$,,'
4898 dir1="${m4base}/"; dir2=""
4899 while test -n "$dir1" \
4900 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4901 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4902 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4904 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4905 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4906 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4907 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4909 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4912 # Create library makefile.
4913 func_dest_tmpfilename $sourcebase/$makefile_am
4914 destfile="$sourcebase/$makefile_am"
4915 modules="$main_modules"
4916 func_emit_lib_Makefile_am > "$tmpfile"
4917 if test -f "$destdir"/$sourcebase/$makefile_am; then
4918 if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
4922 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4923 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4924 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4926 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4932 echo "Creating $sourcebase/$makefile_am"
4933 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4935 echo "Create $sourcebase/$makefile_am"
4938 func_append added_files "$sourcebase/$makefile_am$nl"
4941 # Create po/ directory.
4942 if test -n "$pobase"; then
4943 # Create po makefile and auxiliary files.
4944 for file in Makefile.in.in remove-potcdate.sin; do
4945 func_dest_tmpfilename $pobase/$file
4946 func_lookup_file build-aux/po/$file
4947 cat "$lookedup_file" > "$tmpfile"
4948 if test -f "$destdir"/$pobase/$file; then
4949 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
4953 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4954 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4955 mv -f "$tmpfile" "$destdir"/$pobase/$file
4957 echo "Update $pobase/$file (backup in $pobase/$file~)"
4963 echo "Creating $pobase/$file"
4964 mv -f "$tmpfile" "$destdir"/$pobase/$file
4966 echo "Create $pobase/$file"
4969 func_append added_files "$pobase/$file$nl"
4972 # Create po makefile parameterization, part 1.
4973 func_dest_tmpfilename $pobase/Makevars
4974 func_emit_po_Makevars > "$tmpfile"
4975 if test -f "$destdir"/$pobase/Makevars; then
4976 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
4980 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4981 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4982 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4984 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4990 echo "Creating $pobase/Makevars"
4991 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4993 echo "Create $pobase/Makevars"
4996 func_append added_files "$pobase/Makevars$nl"
4998 # Create po makefile parameterization, part 2.
4999 func_dest_tmpfilename $pobase/POTFILES.in
5000 func_emit_po_POTFILES_in > "$tmpfile"
5001 if test -f "$destdir"/$pobase/POTFILES.in; then
5002 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5006 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5007 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5008 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5010 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5016 echo "Creating $pobase/POTFILES.in"
5017 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5019 echo "Create $pobase/POTFILES.in"
5022 func_append added_files "$pobase/POTFILES.in$nl"
5025 TP_URL="http://translationproject.org/latest/"
5026 TP_RSYNC_URI="translationproject.org::tp/latest/"
5028 echo "Fetching gnulib PO files from $TP_URL"
5029 (cd "$destdir"/$pobase \
5030 && { # Prefer rsync over wget if it is available, since it consumes
5031 # less network bandwidth, due to compression.
5032 if type rsync 2>/dev/null | grep / > /dev/null; then
5033 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
5035 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
5040 echo "Fetch gnulib PO files from $TP_URL"
5042 # Create po/LINGUAS.
5044 func_dest_tmpfilename $pobase/LINGUAS
5045 (cd "$destdir"/$pobase \
5046 && { echo '# Set of available languages.'
5047 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5050 if test -f "$destdir"/$pobase/LINGUAS; then
5051 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5054 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5055 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5056 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5059 echo "Creating $pobase/LINGUAS"
5060 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5061 func_append added_files "$pobase/LINGUAS$nl"
5064 if test -f "$destdir"/$pobase/LINGUAS; then
5065 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5067 echo "Create $pobase/LINGUAS"
5072 # Create m4/gnulib-cache.m4.
5073 func_dest_tmpfilename $m4base/gnulib-cache.m4
5075 func_emit_copyright_notice
5077 echo "# This file represents the specification of how gnulib-tool is used."
5078 echo "# It acts as a cache: It is written and read by gnulib-tool."
5079 echo "# In projects that use version control, this file is meant to be put under"
5080 echo "# version control, like the configure.ac and various Makefile.am files."
5083 echo "# Specification in the form of a command-line invocation:"
5086 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5087 # Store the local_gnulib_dir relative to destdir.
5088 case "$local_gnulib_dir" in
5090 relative_local_gnulib_dir="$local_gnulib_dir" ;;
5093 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
5095 # destdir, local_gnulib_dir are both relative.
5096 func_relativize "$destdir" "$local_gnulib_dir"
5097 relative_local_gnulib_dir="$reldir" ;;
5100 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
5102 echo "$specified_modules" | sed -e 's/^/ /g'
5104 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5105 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5106 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5107 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5108 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5109 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5110 echo "gl_AVOID([$avoidlist])"
5111 echo "gl_SOURCE_BASE([$sourcebase])"
5112 echo "gl_M4_BASE([$m4base])"
5113 echo "gl_PO_BASE([$pobase])"
5114 echo "gl_DOC_BASE([$docbase])"
5115 echo "gl_TESTS_BASE([$testsbase])"
5117 echo "gl_WITH_TESTS"
5119 echo "gl_LIB([$libname])"
5120 if test -n "$lgpl"; then
5121 if test "$lgpl" = yes; then
5124 echo "gl_LGPL([$lgpl])"
5127 echo "gl_MAKEFILE_NAME([$makefile_name])"
5128 if test "$cond_dependencies" = true; then
5129 echo "gl_CONDITIONAL_DEPENDENCIES"
5131 if test "$libtool" = true; then
5134 echo "gl_MACRO_PREFIX([$macro_prefix])"
5135 echo "gl_PO_DOMAIN([$po_domain])"
5136 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5137 if test -n "$vc_files"; then
5138 echo "gl_VC_FILES([$vc_files])"
5141 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5142 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
5146 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5147 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5148 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5150 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5154 echo "# gnulib-cache.m4 ends here"
5161 echo "Creating $m4base/gnulib-cache.m4"
5162 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5164 echo "Create $m4base/gnulib-cache.m4"
5170 # Create m4/gnulib-comp.m4.
5171 func_dest_tmpfilename $m4base/gnulib-comp.m4
5173 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5174 func_emit_copyright_notice
5176 echo "# This file represents the compiled summary of the specification in"
5177 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5178 echo "# to be invoked from configure.ac."
5179 echo "# In projects that use version control, this file can be treated like"
5180 echo "# other built files."
5183 echo "# This macro should be invoked from $configure_ac, in the section"
5184 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5185 echo "# any checks for libraries, header files, types and library functions."
5186 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5188 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5189 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5190 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5191 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5192 echo " AC_REQUIRE([gl_PROG_AR_RANLIB])"
5193 if test -n "$uses_subdirs"; then
5194 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5196 for module in $final_modules; do
5198 if test -n "$module"; then
5199 echo "# Code from module $module:"
5200 func_get_autoconf_early_snippet "$module"
5203 | sed -e '/^$/d;' -e 's/^/ /'
5206 echo "# This macro should be invoked from $configure_ac, in the section"
5207 echo "# \"Check for header files, types and library functions\"."
5208 echo "AC_DEFUN([${macro_prefix}_INIT],"
5210 if test "$libtool" = true; then
5211 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5212 echo " gl_cond_libtool=true"
5214 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5215 echo " gl_cond_libtool=false"
5217 echo " gl_ltlibdeps="
5219 if test "$auxdir" != "build-aux"; then
5220 sed_replace_build_aux='
5222 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5223 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5227 sed_replace_build_aux="$sed_noop"
5229 echo " gl_m4_base='$m4base'"
5230 func_emit_initmacro_start $macro_prefix
5231 echo " gl_source_base='$sourcebase'"
5232 if test -n "$witness_c_macro"; then
5233 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5235 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
5236 if test -n "$witness_c_macro"; then
5237 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5239 echo " # End of code from modules"
5240 func_emit_initmacro_end $macro_prefix
5241 echo " gltests_libdeps="
5242 echo " gltests_ltlibdeps="
5243 func_emit_initmacro_start ${macro_prefix}tests
5244 echo " gl_source_base='$testsbase'"
5245 # Define a tests witness macro that depends on the package.
5246 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5247 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5248 echo "changequote(,)dnl"
5249 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"
5250 echo "changequote([, ])dnl"
5251 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5252 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5253 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5254 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
5255 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5256 func_emit_initmacro_end ${macro_prefix}tests
5257 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5258 # created using libtool, because libtool already handles the dependencies.
5259 if test "$libtool" != true; then
5260 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5261 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5262 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5263 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5264 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5266 if $use_libtests; then
5267 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5268 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5271 func_emit_initmacro_done $macro_prefix $sourcebase
5272 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5274 echo "# This macro records the list of files which have been installed by"
5275 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5276 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5277 echo "$files" | sed -e 's,^, ,'
5280 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5281 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
5285 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5286 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5287 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5289 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5293 echo "# gnulib-comp.m4 ends here"
5300 echo "Creating $m4base/gnulib-comp.m4"
5301 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5303 echo "Create $m4base/gnulib-comp.m4"
5310 # Create tests makefile.
5311 func_dest_tmpfilename $testsbase/$makefile_am
5312 destfile="$testsbase/$makefile_am"
5313 modules="$testsrelated_modules"
5314 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5315 if test -f "$destdir"/$testsbase/$makefile_am; then
5316 if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
5320 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5321 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5322 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5324 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5330 echo "Creating $testsbase/$makefile_am"
5331 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5333 echo "Create $testsbase/$makefile_am"
5336 func_append added_files "$testsbase/$makefile_am$nl"
5340 if test "$vc_files" != false; then
5341 # Update the .cvsignore and .gitignore files.
5342 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5343 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5344 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5345 echo "$m4base/|A|gnulib-comp.m4"
5346 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5347 { # Rearrange file descriptors. Needed because "while ... done < ..."
5348 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5349 exec 5<&0 < "$tmp"/fileset-changes
5350 func_update_ignorelist ()
5353 if test "$ignore" = .gitignore; then
5354 # In a .gitignore file, "foo" applies to the current directory and all
5355 # subdirectories, whereas "/foo" applies to the current directory only.
5358 doubly_escaped_anchor='\\/'
5362 doubly_escaped_anchor=''
5364 if test -f "$destdir/$dir$ignore"; then
5365 if test -n "$dir_added" || test -n "$dir_removed"; then
5366 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5367 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5368 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5369 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5370 > "$tmp"/ignore-removed
5372 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5374 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5375 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5376 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5377 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5378 } > "$tmp"/sed-ignore-removed
5379 { cat "$destdir/$dir$ignore"~
5380 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5381 } | sed -f "$tmp"/sed-ignore-removed \
5382 > "$destdir/$dir$ignore"
5384 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5389 if test -n "$dir_added"; then
5391 echo "Creating $destdir/$dir$ignore"
5393 if test "$ignore" = .cvsignore; then
5395 # Automake generates Makefile rules that create .dirstamp files.
5398 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5399 } > "$destdir/$dir$ignore"
5401 echo "Create $destdir/$dir$ignore"
5411 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5412 func_update_ignorelist .cvsignore
5414 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5415 func_update_ignorelist .gitignore
5422 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5423 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5424 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5425 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5426 if test "$next_dir" != "$last_dir"; then
5427 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5428 last_dir="$next_dir"
5433 A) func_append last_dir_added "$file$nl";;
5434 R) func_append last_dir_removed "$file$nl";;
5437 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5444 echo "You may need to add #include directives for the following .h files."
5445 # Intersect $specified_modules and $main_modules
5446 # (since $specified_modules is not necessarily of subset of $main_modules
5447 # - some may have been skipped through --avoid, and since the elements of
5448 # $main_modules but not in $specified_modules can go away without explicit
5449 # notice - through changes in the module dependencies).
5450 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5451 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5452 # First the #include <...> directives without #ifs, sorted for convenience,
5453 # then the #include "..." directives without #ifs, sorted for convenience,
5454 # then the #include directives that are surrounded by #ifs. Not sorted.
5455 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5456 include_directive=`func_get_include_directive "$module"`
5457 case "$nl$include_directive" in
5459 echo "$include_directive" 1>&5
5462 echo "$include_directive" | grep -v 'include "' 1>&6
5463 echo "$include_directive" | grep 'include "' 1>&7
5466 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5468 LC_ALL=C sort -u "$tmp"/include-angles
5469 LC_ALL=C sort -u "$tmp"/include-quotes
5470 cat "$tmp"/include-if
5471 ) | sed -e '/^$/d' -e 's/^/ /'
5472 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5474 for module in $main_modules; do
5475 func_get_link_directive "$module"
5477 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5478 if test `wc -l < "$tmp"/link` != 0; then
5480 echo "You may need to use the following Makefile variables when linking."
5481 echo "Use them in <program>_LDADD when linking a program, or"
5482 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5488 echo "Don't forget to"
5489 if test "$makefile_am" = Makefile.am; then
5490 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5492 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5494 if test -n "$pobase"; then
5495 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5498 if test "$makefile_am" = Makefile.am; then
5499 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5501 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5505 while test $edit != $makefile_am_edits; do
5506 edit=`expr $edit + 1`
5507 eval dir=\"\$makefile_am_edit${edit}_dir\"
5508 eval var=\"\$makefile_am_edit${edit}_var\"
5509 eval val=\"\$makefile_am_edit${edit}_val\"
5510 if test -n "$var"; then
5511 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5514 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
5515 position_early_after=AC_PROG_CC_STDC
5517 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
5518 position_early_after=AC_PROG_CC_C99
5520 position_early_after=AC_PROG_CC
5523 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
5524 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5527 # func_create_testdir testdir modules
5529 # - local_gnulib_dir from --local-dir
5530 # - modcache true or false, from --cache-modules/--no-cache-modules
5531 # - auxdir directory relative to destdir where to place build aux files
5532 # - inctests true if tests should be included, false otherwise
5533 # - incobsolete true if obsolete modules among dependencies should be
5534 # included, blank otherwise
5535 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5537 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5539 # - excl_privileged_tests true if tests that require root privileges should be
5540 # excluded, blank otherwise
5541 # - excl_unportable_tests true if tests that fail on some platforms should be
5542 # excluded, blank otherwise
5543 # - single_configure true if a single configure file should be generated,
5544 # false for a separate configure file for the tests
5545 # - avoidlist list of modules to avoid
5546 # - cond_dependencies true if --conditional-dependencies was given, false if
5547 # --no-conditional-dependencies was given, blank otherwise
5548 # - libtool true if --libtool was given, false if --no-libtool was
5549 # given, blank otherwise
5550 # - symbolic true if files should be symlinked, copied otherwise
5551 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
5553 func_create_testdir ()
5557 if test -z "$modules"; then
5558 # All modules together.
5559 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5560 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5561 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5562 modules=`func_all_modules`
5563 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5565 specified_modules="$modules"
5567 # Canonicalize the list of specified modules.
5568 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5570 # Unlike in func_import, here we want to include all kinds of tests for the
5571 # directly specified modules, but not for dependencies.
5572 inc_all_direct_tests=true
5573 inc_all_indirect_tests="$inc_all_tests"
5575 # Check that the license of every module is consistent with the license of
5577 saved_inctests="$inctests"
5578 # When computing transitive closures, don't consider $module to depend on
5579 # $module-tests. Need this because tests are implicitly GPL and may depend
5580 # on GPL modules - therefore we don't want a warning in this case.
5582 for requested_module in $specified_modules; do
5583 requested_license=`func_get_license "$requested_module"`
5584 if test "$requested_license" != GPL; then
5585 # Here we use func_modules_transitive_closure, not just
5586 # func_get_dependencies, so that we also detect weird situations like
5587 # an LGPL module which depends on a GPLed build tool module which depends
5589 modules="$requested_module"
5590 func_modules_transitive_closure
5591 for module in $modules; do
5592 license=`func_get_license "$module"`
5594 'GPLed build tool') ;;
5595 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5597 case "$requested_license" in
5600 GPLv2+ | LGPLv2+) ;;
5601 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5607 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5613 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5622 inctests="$saved_inctests"
5624 # Subdirectory names.
5635 # Determine final module list.
5636 modules="$specified_modules"
5637 func_modules_transitive_closure
5638 if test $verbose -ge 0; then
5639 func_show_module_list
5641 final_modules="$modules"
5643 if $single_configure; then
5644 # Determine main module list and tests-related module list separately.
5645 func_modules_transitive_closure_separately
5648 if $single_configure; then
5649 # Determine whether a $testsbase/libtests.a is needed.
5650 func_determine_use_libtests
5653 # Add the dummy module if needed.
5654 if $single_configure; then
5655 func_modules_add_dummy_separately
5657 func_modules_add_dummy
5660 # Show banner notice of every module.
5661 if $single_configure; then
5662 modules="$main_modules"
5668 # Determine final file list.
5669 if $single_configure; then
5670 func_modules_to_filelist_separately
5672 func_modules_to_filelist
5673 if test $verbose -ge 0; then
5675 echo "$files" | sed -e 's/^/ /'
5678 # Add files for which the copy in gnulib is newer than the one that
5679 # "automake --add-missing --copy" would provide.
5680 files="$files build-aux/config.guess"
5681 files="$files build-aux/config.sub"
5682 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5684 rewritten='%REWRITTEN%'
5685 sed_rewrite_files="\
5686 s,^build-aux/,$rewritten$auxdir/,
5687 s,^doc/,$rewritten$docbase/,
5688 s,^lib/,$rewritten$sourcebase/,
5689 s,^m4/,$rewritten$m4base/,
5690 s,^tests/,$rewritten$testsbase/,
5691 s,^tests=lib/,$rewritten$testsbase/,
5695 # Create directories.
5696 for f in $files; do echo $f; done \
5697 | sed -e "$sed_rewrite_files" \
5698 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5699 | LC_ALL=C sort -u \
5701 { # Rearrange file descriptors. Needed because "while ... done < ..."
5702 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5703 exec 5<&0 < "$tmp"/dirs
5705 mkdir -p "$testdir/$d"
5710 # Copy files or make symbolic links.
5712 for f in $files; do echo $f; done \
5713 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5716 { # Rearrange file descriptors. Needed because "while ... done < ..."
5717 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5718 exec 5<&0 < "$tmp"/files
5721 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5723 func_lookup_file "$f"
5724 if test -n "$lookedup_tmp"; then
5725 cp -p "$lookedup_file" "$testdir/$g"
5727 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5728 if { test -n "$symbolic" \
5729 || { test -n "$lsymbolic" \
5730 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5731 func_ln "$lookedup_file" "$testdir/$g"
5733 cp -p "$lookedup_file" "$testdir/$g"
5740 # Determine include_guard_prefix.
5741 func_compute_include_guard_prefix
5743 # Create Makefile.ams that are for testing.
5746 # No special edits are needed.
5749 # Create $sourcebase/Makefile.am.
5750 mkdir -p "$testdir/$sourcebase"
5751 destfile="$sourcebase/Makefile.am"
5752 if $single_configure; then
5753 modules="$main_modules"
5755 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5756 any_uses_subdirs="$uses_subdirs"
5758 # Create $m4base/Makefile.am.
5759 mkdir -p "$testdir/$m4base"
5760 (echo "## Process this file with automake to produce Makefile.in."
5766 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5769 ) > "$testdir/$m4base/Makefile.am"
5771 subdirs="$sourcebase $m4base"
5772 subdirs_with_configure_ac=""
5774 if false && test -f "$testdir"/$m4base/gettext.m4; then
5775 # Avoid stupid error message from automake:
5776 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5777 mkdir -p "$testdir/po"
5778 (echo "## Process this file with automake to produce Makefile.in."
5779 ) > "$testdir/po/Makefile.am"
5780 func_append subdirs " po"
5784 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5785 if $single_configure; then
5786 # Create $testsbase/Makefile.am.
5787 destfile="$testsbase/Makefile.am"
5788 modules="$testsrelated_modules"
5789 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
5791 # Viewed from the $testsbase subdirectory, $auxdir is different.
5792 saved_auxdir="$auxdir"
5793 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5794 # Create $testsbase/Makefile.am.
5796 destfile="$testsbase/Makefile.am"
5797 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5798 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5799 # Create $testsbase/configure.ac.
5800 (echo "# Process this file with autoconf to produce a configure script."
5801 echo "AC_INIT([dummy], [0])"
5802 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5803 echo "AM_INIT_AUTOMAKE"
5805 echo "AC_CONFIG_HEADERS([config.h])"
5808 echo "AC_PROG_INSTALL"
5809 echo "AC_PROG_MAKE_SET"
5810 echo "gl_PROG_AR_RANLIB"
5812 if test -n "$uses_subdirs"; then
5813 echo "AM_PROG_CC_C_O"
5816 for module in $modules; do
5818 if test -n "$module"; then
5820 gnumakefile | maintainer-makefile)
5821 # These modules are meant to be used only in the top-level directory.
5824 func_get_autoconf_early_snippet "$module"
5829 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5830 if test "$libtool" = true; then
5831 echo "LT_INIT([win32-dll])"
5832 echo "LT_LANG([C++])"
5833 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5834 echo "gl_cond_libtool=true"
5836 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5837 echo "gl_cond_libtool=false"
5839 echo "gl_ltlibdeps="
5841 # Wrap the set of autoconf snippets into an autoconf macro that is then
5842 # invoked. This is needed because autoconf does not support AC_REQUIRE
5844 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5845 # but we want the AC_REQUIRE to have its normal meaning (provide one
5846 # expansion of the required macro before the current point, and only one
5848 echo "AC_DEFUN([gl_INIT], ["
5849 sed_replace_build_aux='
5851 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5852 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5855 echo "gl_m4_base='../$m4base'"
5856 func_emit_initmacro_start $macro_prefix
5857 # We don't have explicit ordering constraints between the various
5858 # autoconf snippets. It's cleanest to put those of the library before
5859 # those of the tests.
5860 echo "gl_source_base='../$sourcebase'"
5861 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
5862 echo "gl_source_base='.'"
5863 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
5864 func_emit_initmacro_end $macro_prefix
5865 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5866 # created using libtool, because libtool already handles the dependencies.
5867 if test "$libtool" != true; then
5868 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5869 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5870 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5871 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5872 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5875 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5879 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5880 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5881 echo "AH_TOP([#include \"../config.h\"])"
5883 echo "AC_CONFIG_FILES([Makefile])"
5885 ) > "$testdir/$testsbase/configure.ac"
5886 auxdir="$saved_auxdir"
5887 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5889 func_append subdirs " $testsbase"
5892 # Create Makefile.am.
5893 (echo "## Process this file with automake to produce Makefile.in."
5895 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
5897 echo "SUBDIRS = $subdirs"
5899 echo "ACLOCAL_AMFLAGS = -I $m4base"
5900 ) > "$testdir/Makefile.am"
5902 # Create configure.ac.
5903 (echo "# Process this file with autoconf to produce a configure script."
5904 echo "AC_INIT([dummy], [0])"
5905 if test "$auxdir" != "."; then
5906 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5908 echo "AM_INIT_AUTOMAKE"
5910 echo "AC_CONFIG_HEADERS([config.h])"
5913 echo "AC_PROG_INSTALL"
5914 echo "AC_PROG_MAKE_SET"
5916 echo "# For autobuild."
5917 echo "AC_CANONICAL_BUILD"
5918 echo "AC_CANONICAL_HOST"
5920 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5921 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5922 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5923 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5925 echo "gl_PROG_AR_RANLIB"
5927 if test -n "$any_uses_subdirs"; then
5928 echo "AM_PROG_CC_C_O"
5931 for module in $final_modules; do
5932 if $single_configure; then
5935 func_verify_nontests_module
5937 if test -n "$module"; then
5938 func_get_autoconf_early_snippet "$module"
5941 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5942 if test "$libtool" = true; then
5943 echo "LT_INIT([win32-dll])"
5944 echo "LT_LANG([C++])"
5945 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5946 echo "gl_cond_libtool=true"
5948 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5949 echo "gl_cond_libtool=false"
5951 echo "gl_ltlibdeps="
5953 # Wrap the set of autoconf snippets into an autoconf macro that is then
5954 # invoked. This is needed because autoconf does not support AC_REQUIRE
5956 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5957 # but we want the AC_REQUIRE to have its normal meaning (provide one
5958 # expansion of the required macro before the current point, and only one
5960 echo "AC_DEFUN([gl_INIT], ["
5961 if test "$auxdir" != "build-aux"; then
5962 sed_replace_build_aux='
5964 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5965 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5969 sed_replace_build_aux="$sed_noop"
5971 echo "gl_m4_base='$m4base'"
5972 func_emit_initmacro_start $macro_prefix
5973 echo "gl_source_base='$sourcebase'"
5974 if $single_configure; then
5975 func_emit_autoconf_snippets "$main_modules" func_verify_module true false false
5977 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
5979 func_emit_initmacro_end $macro_prefix
5980 if $single_configure; then
5981 echo " gltests_libdeps="
5982 echo " gltests_ltlibdeps="
5983 func_emit_initmacro_start ${macro_prefix}tests
5984 echo " gl_source_base='$testsbase'"
5985 # Define a tests witness macro.
5986 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
5987 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5988 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5989 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5990 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true false false
5991 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5992 func_emit_initmacro_end ${macro_prefix}tests
5994 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5995 # created using libtool, because libtool already handles the dependencies.
5996 if test "$libtool" != true; then
5997 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5998 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5999 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6000 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6001 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6003 if $single_configure; then
6004 if $use_libtests; then
6005 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6006 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6010 func_emit_initmacro_done $macro_prefix $sourcebase
6011 if $single_configure; then
6012 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6017 if test -n "$subdirs_with_configure_ac"; then
6018 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6020 makefiles="Makefile"
6021 for d in $subdirs; do
6022 # For subdirs that have a configure.ac by their own, it's the subdir's
6023 # configure.ac which creates the subdir's Makefile.am, not this one.
6024 case " $subdirs_with_configure_ac " in
6026 *) func_append makefiles " $d/Makefile" ;;
6029 echo "AC_CONFIG_FILES([$makefiles])"
6031 ) > "$testdir/configure.ac"
6033 # Create autogenerated files.
6035 # Do not use "${AUTORECONF} --force --install", because it may invoke
6036 # autopoint, which brings in older versions of some of our .m4 files.
6037 if test -f $m4base/gettext.m4; then
6038 func_execute_command ${AUTOPOINT} --force || func_exit 1
6039 for f in $m4base/*.m4~; do
6041 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6045 if test "$libtool" = true; then
6046 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6048 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6049 if ! test -d build-aux; then
6050 func_execute_command mkdir build-aux || func_exit 1
6052 func_execute_command ${AUTOCONF} || func_exit 1
6053 func_execute_command ${AUTOHEADER} || func_exit 1
6054 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6056 if $inctests && ! $single_configure; then
6057 # Create autogenerated files.
6058 (cd "$testdir/$testsbase" || func_exit 1
6059 # Do not use "${AUTORECONF} --force --install", because it may invoke
6060 # autopoint, which brings in older versions of some of our .m4 files.
6061 if test -f ../$m4base/gettext.m4; then
6062 func_execute_command ${AUTOPOINT} --force || func_exit 1
6063 for f in ../$m4base/*.m4~; do
6065 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6069 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6070 if ! test -d ../build-aux; then
6071 func_execute_command mkdir ../build-aux
6073 func_execute_command ${AUTOCONF} || func_exit 1
6074 func_execute_command ${AUTOHEADER} || func_exit 1
6075 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6078 # Need to run configure and make once, to create built files that are to be
6079 # distributed (such as parse-datetime.c).
6080 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6081 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6082 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6083 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6084 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6085 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6086 # such $(FOO_H) because they don't refer to distributed files.
6087 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6088 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6089 | sed -e "$sed_remove_make_variables"`
6090 distributed_built_sources=`for file in $built_sources; do
6091 case "$cleaned_files" in
6096 tests_distributed_built_sources=
6098 # Likewise for built files in the $testsbase directory.
6099 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6100 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6101 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6102 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6103 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6104 | sed -e "$sed_remove_make_variables"`
6105 tests_distributed_built_sources=`for file in $tests_built_sources; do
6106 case "$tests_cleaned_files" in
6112 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6114 ./configure || func_exit 1
6115 if test -n "$distributed_built_sources"; then
6117 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6118 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6123 if test -n "$tests_distributed_built_sources"; then
6125 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6126 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6131 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6138 # func_create_megatestdir megatestdir allmodules
6140 # - local_gnulib_dir from --local-dir
6141 # - modcache true or false, from --cache-modules/--no-cache-modules
6142 # - auxdir directory relative to destdir where to place build aux files
6143 func_create_megatestdir ()
6147 if test -z "$allmodules"; then
6148 allmodules=`func_all_modules`
6152 # First, all modules one by one.
6153 for onemodule in $allmodules; do
6154 func_create_testdir "$megatestdir/$onemodule" $onemodule
6155 func_append megasubdirs "$onemodule "
6157 # Then, all modules all together.
6158 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6159 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6160 func_create_testdir "$megatestdir/ALL" "$allmodules"
6161 func_append megasubdirs "ALL"
6164 cvsdate=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6165 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6166 | sed -e 's,January,01,' -e 's,Jan,01,' \
6167 -e 's,February,02,' -e 's,Feb,02,' \
6168 -e 's,March,03,' -e 's,Mar,03,' \
6169 -e 's,April,04,' -e 's,Apr,04,' \
6171 -e 's,June,06,' -e 's,Jun,06,' \
6172 -e 's,July,07,' -e 's,Jul,07,' \
6173 -e 's,August,08,' -e 's,Aug,08,' \
6174 -e 's,September,09,' -e 's,Sep,09,' \
6175 -e 's,October,10,' -e 's,Oct,10,' \
6176 -e 's,November,11,' -e 's,Nov,11,' \
6177 -e 's,December,12,' -e 's,Dec,12,' \
6178 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6179 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6181 echo "CVSDATE=$cvsdate"
6182 echo ": \${MAKE=make}"
6183 echo "test -d logs || mkdir logs"
6184 echo "for module in $megasubdirs; do"
6185 echo " echo \"Working on module \$module...\""
6186 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6187 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6190 echo " : autobuild project... \$module"
6191 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6192 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6193 echo " : autobuild hostname... \`hostname\`"
6194 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6196 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6198 ) > "$megatestdir/do-autobuild"
6199 chmod a+x "$megatestdir/do-autobuild"
6201 # Create Makefile.am.
6202 (echo "## Process this file with automake to produce Makefile.in."
6204 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
6206 echo "SUBDIRS = $megasubdirs"
6208 echo "EXTRA_DIST = do-autobuild"
6209 ) > "$megatestdir/Makefile.am"
6211 # Create configure.ac.
6212 (echo "# Process this file with autoconf to produce a configure script."
6213 echo "AC_INIT([dummy], [0])"
6214 if test "$auxdir" != "."; then
6215 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6217 echo "AM_INIT_AUTOMAKE"
6219 echo "AC_PROG_MAKE_SET"
6221 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6222 echo "AC_CONFIG_FILES([Makefile])"
6224 ) > "$megatestdir/configure.ac"
6226 # Create autogenerated files.
6228 # Do not use "${AUTORECONF} --install", because autoreconf operates
6229 # recursively, but the subdirectories are already finished, therefore
6230 # calling autoreconf here would only waste lots of CPU time.
6231 func_execute_command ${ACLOCAL} || func_exit 1
6232 func_execute_command mkdir build-aux
6233 func_execute_command ${AUTOCONF} || func_exit 1
6234 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6240 func_fatal_error "no mode specified" ;;
6247 # sed expression that converts a literal to a basic regular expression.
6248 # Needs to handle . [ \ * ^ $.
6249 sed_literal_to_basic_regex='s/\\/\\\\/g
6255 if test -f "$gnulib_dir/$filename" \
6256 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
6257 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6258 filename_line_regex='^'"$filename_anywhere_regex"'$'
6261 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6262 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
6263 (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$,,')
6266 | func_sanitize_modulelist \
6269 for module in $module_candidates; do
6270 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6275 func_warning "file $filename does not exist"
6280 import | add-import | remove-import | update )
6283 if test -z "$destdir"; then
6286 test -d "$destdir" \
6287 || func_fatal_error "destination directory does not exist: $destdir"
6289 # Prefer configure.ac to configure.in.
6290 if test -f "$destdir"/configure.ac; then
6291 configure_ac="$destdir/configure.ac"
6293 if test -f "$destdir"/configure.in; then
6294 configure_ac="$destdir/configure.in"
6296 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6300 # Analyze configure.ac.
6302 guessed_libtool=false
6307 /AC_CONFIG_AUX_DIR/ {
6308 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6310 /A[CM]_PROG_LIBTOOL/ {
6311 s,^.*$,guessed_libtool=true,p
6313 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6315 if test -z "$auxdir"; then
6316 auxdir="$guessed_auxdir"
6319 # Determine where to apply func_import.
6320 if test "$mode" = import; then
6321 # Apply func_import to a particular gnulib directory.
6322 # The command line contains the complete specification; don't look at
6323 # the contents of gnulib-cache.m4.
6324 test -n "$supplied_libname" || supplied_libname=true
6325 test -n "$sourcebase" || sourcebase="lib"
6326 test -n "$m4base" || m4base="m4"
6327 test -n "$docbase" || docbase="doc"
6328 test -n "$testsbase" || testsbase="tests"
6329 test -n "$macro_prefix" || macro_prefix="gl"
6332 if test -n "$m4base"; then
6333 # Apply func_import to a particular gnulib directory.
6334 # Any number of additional modules can be given.
6335 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6336 # First use of gnulib in the given m4base.
6337 test -n "$supplied_libname" || supplied_libname=true
6338 test -n "$sourcebase" || sourcebase="lib"
6339 test -n "$docbase" || docbase="doc"
6340 test -n "$testsbase" || testsbase="tests"
6341 test -n "$macro_prefix" || macro_prefix="gl"
6345 # Apply func_import to all gnulib directories.
6346 # To get this list of directories, look at Makefile.am. (Not at
6347 # configure, because it may be omitted from version control. Also,
6348 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6352 if test -f "$destdir"/Makefile.am; then
6353 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6355 for arg in $aclocal_amflags; do
6356 if test -n "$m4dir_is_next"; then
6357 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6361 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6362 func_append m4dirs " $arg"
6363 m4dirs_count=`expr $m4dirs_count + 1`
6369 if test "X$arg" = "X-I"; then
6377 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6378 if test -f "$destdir"/aclocal.m4; then
6379 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6380 sedexpr2='s,^[^/]*$,.,'
6381 sedexpr3='s,/[^/]*$,,'
6382 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6383 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6384 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6387 if test $m4dirs_count = 0; then
6388 # First use of gnulib in a package.
6389 # Any number of additional modules can be given.
6390 test -n "$supplied_libname" || supplied_libname=true
6391 test -n "$sourcebase" || sourcebase="lib"
6393 test -n "$docbase" || docbase="doc"
6394 test -n "$testsbase" || testsbase="tests"
6395 test -n "$macro_prefix" || macro_prefix="gl"
6398 if test $m4dirs_count = 1; then
6399 # There's only one use of gnulib here. Assume the user means it.
6400 # Any number of additional modules can be given.
6401 for m4base in $m4dirs; do
6405 # Ambiguous - guess what the user meant.
6406 if test $# = 0; then
6407 # No further arguments. Guess the user wants to update all of them.
6408 for m4base in $m4dirs; do
6409 # Perform func_import in a subshell, so that variable values
6411 # local_gnulib_dir, incobsolete, inc_cxx_tests,
6412 # inc_longrunning_tests, inc_privileged_tests,
6413 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6414 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6415 # makefile_name, libtool, macro_prefix, po_domain,
6416 # witness_c_macro, vc_files
6417 # don't propagate from one directory to another.
6418 (func_import) || func_exit 1
6422 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6431 if test -z "$destdir"; then
6432 func_fatal_error "please specify --dir option"
6435 test -d "$destdir" \
6436 || func_fatal_error "could not create destination directory"
6437 test -n "$auxdir" || auxdir="build-aux"
6438 func_create_testdir "$destdir" "$*"
6441 create-megatestdir )
6442 if test -z "$destdir"; then
6443 func_fatal_error "please specify --dir option"
6445 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6446 test -n "$auxdir" || auxdir="build-aux"
6447 func_create_megatestdir "$destdir" "$*"
6451 test -n "$destdir" || destdir=testdir$$
6452 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6453 test -n "$auxdir" || auxdir="build-aux"
6454 func_create_testdir "$destdir" "$*"
6458 ../configure || func_exit 1
6459 $MAKE || func_exit 1
6460 $MAKE check || func_exit 1
6461 $MAKE distclean || func_exit 1
6462 remaining=`find . -type f -print`
6463 if test -n "$remaining"; then
6464 echo "Remaining files:" $remaining 1>&2
6465 echo "gnulib-tool: *** Stop." 1>&2
6474 test -n "$destdir" || destdir=testdir$$
6475 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6476 test -n "$auxdir" || auxdir="build-aux"
6477 func_create_megatestdir "$destdir" "$*"
6485 remaining=`find . -type f -print`
6486 if test -n "$remaining"; then
6487 echo "Remaining files:" $remaining 1>&2
6488 echo "gnulib-tool: *** Stop." 1>&2
6496 extract-description )
6500 if test -n "$module"; then
6501 func_get_description "$module"
6510 if test -n "$module"; then
6511 func_get_comment "$module"
6520 if test -n "$module"; then
6521 func_get_status "$module"
6530 if test -n "$module"; then
6531 func_get_notice "$module"
6536 extract-applicability )
6540 if test -n "$module"; then
6541 func_get_applicability "$module"
6550 if test -n "$module"; then
6551 func_get_filelist "$module"
6556 extract-dependencies )
6557 if test -n "$avoidlist"; then
6558 func_fatal_error "cannot combine --avoid and --extract-dependencies"
6563 if test -n "$module"; then
6564 func_get_dependencies "$module"
6569 extract-autoconf-snippet )
6573 if test -n "$module"; then
6574 func_get_autoconf_snippet "$module"
6579 extract-automake-snippet )
6583 if test -n "$module"; then
6584 func_get_automake_snippet "$module"
6589 extract-include-directive )
6593 if test -n "$module"; then
6594 func_get_include_directive "$module"
6599 extract-link-directive )
6603 if test -n "$module"; then
6604 func_get_link_directive "$module"
6613 if test -n "$module"; then
6614 func_get_license "$module"
6619 extract-maintainer )
6623 if test -n "$module"; then
6624 func_get_maintainer "$module"
6629 extract-tests-module )
6633 if test -n "$module"; then
6634 func_get_tests_module "$module"
6640 # Verify the number of arguments.
6641 if test $# -lt 1 || test $# -gt 2; then
6642 func_fatal_error "invalid number of arguments for --$mode"
6645 # The first argument is the file to be copied.
6647 # Verify the file exists.
6648 func_lookup_file "$f"
6650 # The second argument is the destination; either a directory ot a file.
6651 # It defaults to the current directory.
6653 test -n "$dest" || dest='.'
6654 test -n "$sourcebase" || sourcebase="lib"
6655 test -n "$m4base" || m4base="m4"
6656 test -n "$docbase" || docbase="doc"
6657 test -n "$testsbase" || testsbase="tests"
6658 test -n "$auxdir" || auxdir="build-aux"
6659 rewritten='%REWRITTEN%'
6660 sed_rewrite_files="\
6661 s,^build-aux/,$rewritten$auxdir/,
6662 s,^doc/,$rewritten$docbase/,
6663 s,^lib/,$rewritten$sourcebase/,
6664 s,^m4/,$rewritten$m4base/,
6665 s,^tests/,$rewritten$testsbase/,
6668 if test -d "$dest"; then
6670 g=`echo "$f" | sed -e "$sed_rewrite_files"`
6672 destdir=`dirname "$dest"`
6673 g=`basename "$dest"`
6676 # Create the directory for destfile.
6677 d=`dirname "$destdir/$g"`
6679 if test -n "$d" && test ! -d "$d"; then
6680 mkdir -p "$d" || func_fatal_error "failed"
6684 func_dest_tmpfilename "$g"
6685 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
6686 already_present=true
6687 if test -f "$destdir/$g"; then
6688 # The file already exists.
6692 # Don't protest if the file should be there but isn't: it happens
6693 # frequently that developers don't put autogenerated files under version
6701 func_fatal_error "unknown operation mode --$mode" ;;
6705 # Undo the effect of the previous 'trap' command. Some shellology:
6706 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6707 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6708 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6709 # 128 + signal number and is set before the trap-registered command is run.
6711 trap 'func_exit $?' 1 2 3 13 15
6716 # indent-tabs-mode: nil
6717 # whitespace-check-buffer-indent: nil