3 # Copyright (C) 2002-2012 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
75 if test -z "${MAKE}"; then
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # AIX 5.3 sed barfs over indented comments.
113 if echo fo | sed -e 's/f/g/
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
123 # outputs to stdout the --help usage message.
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
130 gnulib-tool --add-import [module1 ... moduleN]
131 gnulib-tool --remove-import [module1 ... moduleN]
133 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
134 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
135 gnulib-tool --test --dir=directory module1 ... moduleN
136 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
137 gnulib-tool --extract-description module
138 gnulib-tool --extract-comment module
139 gnulib-tool --extract-status module
140 gnulib-tool --extract-notice module
141 gnulib-tool --extract-applicability module
142 gnulib-tool --extract-filelist module
143 gnulib-tool --extract-dependencies module
144 gnulib-tool --extract-autoconf-snippet module
145 gnulib-tool --extract-automake-snippet module
146 gnulib-tool --extract-include-directive module
147 gnulib-tool --extract-link-directive module
148 gnulib-tool --extract-license module
149 gnulib-tool --extract-maintainer module
150 gnulib-tool --extract-tests-module module
151 gnulib-tool --copy-file file [destination]
155 --list print the available module names
156 --find find the modules which contain the specified file
157 --import import the given modules into the current package
158 --add-import augment the list of imports from gnulib into the
159 current package, by adding the given modules;
160 if no modules are specified, update the current
161 package from the current gnulib
162 --remove-import reduce the list of imports from gnulib into the
163 current package, by removing the given modules
164 --update update the current package, restore files omitted
166 --create-testdir create a scratch package with the given modules
167 (pass --with-tests to include the unit tests)
168 --create-megatestdir create a mega scratch package with the given modules
169 one by one and all together
170 (pass --with-tests to include the unit tests)
171 --test test the combination of the given modules
172 (pass --with-tests to include the unit tests)
173 (recommended to use CC=\"gcc -Wall\" here)
174 --megatest test the given modules one by one and all together
175 (pass --with-tests to include the unit tests)
176 (recommended to use CC=\"gcc -Wall\" here)
177 --extract-description extract the description
178 --extract-comment extract the comment
179 --extract-status extract the status (obsolete etc.)
180 --extract-notice extract the notice or banner
181 --extract-applicability extract the applicability
182 --extract-filelist extract the list of files
183 --extract-dependencies extract the dependencies
184 --extract-autoconf-snippet extract the snippet for configure.ac
185 --extract-automake-snippet extract the snippet for library makefile
186 --extract-include-directive extract the #include directive
187 --extract-link-directive extract the linker directive
188 --extract-license report the license terms of the source files
190 --extract-maintainer report the maintainer(s) inside gnulib
191 --extract-tests-module report the unit test module, if it exists
192 --copy-file copy a file that is not part of any module
196 --dir=DIRECTORY Specify the target directory.
197 For --import, this specifies where your
198 configure.ac can be found. Defaults to current
200 --local-dir=DIRECTORY Specify a local override directory where to look
201 up files before looking in gnulib's directory.
202 --cache-modules Enable module caching optimization.
203 --no-cache-modules Disable module caching optimization.
205 --verbose Increase verbosity. May be repeated.
206 --quiet Decrease verbosity. May be repeated.
207 --help Show this help text.
208 --version Show version and authorship information.
210 Options for --import, --add/remove-import, --update:
212 --dry-run Only print what would have been done.
214 Options for --import, --add/remove-import,
215 --create-[mega]testdir, --[mega]test:
217 --with-tests Include unit tests for the included modules.
218 --with-obsolete Include obsolete modules when they occur among the
219 dependencies. By default, dependencies to obsolete
221 --with-c++-tests Include even unit tests for C++ interoperability.
222 --with-longrunning-tests
223 Include even unit tests that are long-runners.
224 --with-privileged-tests
225 Include even unit tests that require root
227 --with-unportable-tests
228 Include even unit tests that fail on some platforms.
229 --with-all-tests Include all kinds of problematic unit tests.
230 --avoid=MODULE Avoid including the given MODULE. Useful if you
231 have code that provides equivalent functionality.
232 This option can be repeated.
233 --conditional-dependencies
234 Support conditional dependencies (may save configure
235 time and object code).
236 --no-conditional-dependencies
237 Don't use conditional dependencies.
238 --libtool Use libtool rules.
239 --no-libtool Don't use libtool rules.
241 Options for --import, --add/remove-import:
243 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
244 --source-base=DIRECTORY
245 Directory relative to --dir where source code is
246 placed (default \"lib\").
247 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
248 placed (default \"m4\").
249 --po-base=DIRECTORY Directory relative to --dir where *.po files are
250 placed (default \"po\").
251 --doc-base=DIRECTORY Directory relative to --dir where doc files are
252 placed (default \"doc\").
253 --tests-base=DIRECTORY
254 Directory relative to --dir where unit tests are
255 placed (default \"tests\").
256 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
257 tools are placed (default comes from configure.ac).
258 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
259 Also modify license template from GPL to LGPL.
260 The version number of the LGPL can be specified;
261 the default is currently LGPLv3.
262 --makefile-name=NAME Name of makefile in automake syntax in the
263 source-base and tests-base directories
264 (default \"Makefile.am\").
265 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
266 'gl_INIT'. Default is 'gl'.
267 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
268 the package name. A suffix '-gnulib' is appended.
269 --witness-c-macro=NAME Specify the C macro that is defined when the
270 sources in this directory are compiled or used.
271 --vc-files Update version control related files.
272 --no-vc-files Don't update version control related files
273 (.gitignore and/or .cvsignore).
274 --no-changelog Don't update or create ChangeLog files.
276 Options for --create-[mega]testdir, --[mega]test:
278 --without-c++-tests Exclude unit tests for C++ interoperability.
279 --without-longrunning-tests
280 Exclude unit tests that are long-runners.
281 --without-privileged-tests
282 Exclude unit tests that require root privileges.
283 --without-unportable-tests
284 Exclude unit tests that fail on some platforms.
285 --single-configure Generate a single configure file, not a separate
286 configure file for the tests directory.
288 Options for --import, --add/remove-import, --update,
289 --create-[mega]testdir, --[mega]test:
291 -s, --symbolic, --symlink Make symbolic links instead of copying files.
292 --local-symlink Make symbolic links instead of copying files, only
293 for files from the local override directory.
295 Options for --import, --add/remove-import, --update:
297 -S, --more-symlinks Make symbolic links instead of copying files, and
298 don't replace copyright notices.
300 Report bugs to <bug-gnulib@gnu.org>."
304 # outputs to stdout the --version message.
308 if test -d "$gnulib_dir"/.git \
309 && (git --version) >/dev/null 2>/dev/null \
310 && (date --version) >/dev/null 2>/dev/null; then
311 # gnulib checked out from git.
312 sed_extract_first_date='/^Date/{
316 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
317 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
318 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
319 date=`echo "$date" | sed -e "$sed_year_before_time"`
320 # Use GNU date to compute the time in GMT.
321 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
322 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
324 if test -d "$gnulib_dir"/CVS \
325 && (cvs --version) >/dev/null 2>/dev/null; then
326 # gnulib checked out from CVS.
327 sed_extract_first_date='/^date: /{
328 s/^date: \([0-9][0-9][0-9][0-9]\).\([0-9][0-9]\).\([0-9][0-9]\) \([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\).*/\1-\2-\3 \4/p
331 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
333 # gnulib copy without versioning information.
334 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
338 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
340 gnulib-tool (GNU $package $date)$version
341 Copyright (C) $year Free Software Foundation, Inc.
342 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
343 This is free software: you are free to change and redistribute it.
344 There is NO WARRANTY, to the extent permitted by law.
346 Written by" "Bruno Haible" "and" "Simon Josefsson"
349 # func_emit_copyright_notice
350 # outputs to stdout a header for a generated file.
351 func_emit_copyright_notice ()
353 sed -n -e '/Copyright/ {
356 }' < "$self_abspathname"
358 echo "# This file is free software; you can redistribute it and/or modify"
359 echo "# it under the terms of the GNU General Public License as published by"
360 echo "# the Free Software Foundation; either version 3 of the License, or"
361 echo "# (at your option) any later version."
363 echo "# This file is distributed in the hope that it will be useful,"
364 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
365 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
366 echo "# GNU General Public License for more details."
368 echo "# You should have received a copy of the GNU General Public License"
369 echo "# along with this file. If not, see <http://www.gnu.org/licenses/>."
371 echo "# As a special exception to the GNU General Public License,"
372 echo "# this file may be distributed as part of a program that"
373 echo "# contains a configuration script generated by Autoconf, under"
374 echo "# the same distribution terms as the rest of that program."
376 echo "# Generated by gnulib-tool."
380 # exits with a given status.
381 # This function needs to be used, rather than 'exit', when a 'trap' handler is
382 # in effect that refers to $?.
389 # locates the directory where the gnulib repository lives
391 # - progname name of this program
393 # - self_abspathname absolute pathname of gnulib-tool
394 # - gnulib_dir absolute pathname of gnulib repository
398 /*) self_abspathname="$progname" ;;
399 */*) self_abspathname=`pwd`/"$progname" ;;
402 # Iterate through the elements of $PATH.
403 # We use IFS=: instead of
404 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
405 # because the latter does not work when some PATH element contains spaces.
406 # We use a canonicalized $pathx instead of $PATH, because empty PATH
407 # elements are by definition equivalent to '.', however field splitting
408 # according to IFS=: loses empty fields in many shells:
409 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
410 # beginning, at the end, and in the middle),
411 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
412 # at the beginning and at the end,
413 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
414 # Solaris lose empty fields at the end.
415 # The 'case' statement is an optimization, to avoid evaluating the
416 # explicit canonicalization command when $PATH contains no empty fields.
418 if test "${PATH_SEPARATOR+set}" != set; then
419 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
420 # contains only /bin. Note that ksh looks also at the FPATH variable,
421 # so we have to set that as well for the test.
423 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
424 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
425 || PATH_SEPARATOR=';'
428 if test "$PATH_SEPARATOR" = ";"; then
429 # On Windows, programs are searched in "." before $PATH.
432 # On Unix, we have to convert empty PATH elements to ".".
436 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
441 IFS="$PATH_SEPARATOR"
445 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
446 self_abspathname="$d/$progname"
451 if test -z "$self_abspathname"; then
452 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
456 while test -h "$self_abspathname"; do
457 # Resolve symbolic link.
458 linkval=`func_readlink "$self_abspathname"`
459 test -n "$linkval" || break
461 /* ) self_abspathname="$linkval" ;;
462 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
465 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
469 # creates a temporary directory.
471 # - progname name of this program
473 # - tmp pathname of freshly created temporary directory
476 # Use the environment variable TMPDIR, falling back to /tmp. This allows
477 # users to specify a different temporary directory, for example, if their
478 # /tmp is filled up or too small.
481 # Use the mktemp program if available. If not available, hide the error
483 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
484 test -n "$tmp" && test -d "$tmp"
487 # Use a simple mkdir command. It is guaranteed to fail if the directory
488 # already exists. $RANDOM is bash specific and expands to empty in shells
489 # other than bash, ksh and zsh. Its use does not increase security;
490 # rather, it minimizes the probability of failure in a very cluttered /tmp
492 tmp=$TMPDIR/gl$$-$RANDOM
493 (umask 077 && mkdir "$tmp")
496 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
501 # func_append var value
502 # appends the given value to the shell variable var.
503 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
504 # Use bash's += operator. It reduces complexity of appending repeatedly to
505 # a single variable from O(n^2) to O(n).
510 fast_func_append=true
514 eval "$1=\"\$$1\$2\""
516 fast_func_append=false
519 # func_remove_prefix var prefix
520 # removes the given prefix from the value of the shell variable var.
521 # var should be the name of a shell variable.
522 # Its value should not contain a newline and not start or end with whitespace.
523 # prefix should not contain the characters "$`\{}[]^|.
524 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
525 func_remove_prefix ()
529 fast_func_remove_prefix=true
531 func_remove_prefix ()
533 eval "value=\"\$$1\""
537 sed_escape_dots='s/\([.]\)/\\\1/g'
538 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
541 value=`echo "$value" | sed -e "s|^${prefix}||"`
542 eval "$1=\"\$value\""
544 fast_func_remove_prefix=false
547 # func_remove_suffix var suffix
548 # removes the given suffix from the value of the shell variable var.
549 # var should be the name of a shell variable.
550 # Its value should not contain a newline and not start or end with whitespace.
551 # suffix should not contain the characters "$`\{}[]^|.
552 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
553 func_remove_suffix ()
557 fast_func_remove_suffix=true
559 func_remove_suffix ()
561 eval "value=\"\$$1\""
565 sed_escape_dots='s/\([.]\)/\\\1/g'
566 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
569 value=`echo "$value" | sed -e "s|${suffix}\$||"`
570 eval "$1=\"\$value\""
572 fast_func_remove_suffix=false
575 # func_fatal_error message
576 # outputs to stderr a fatal error message, and terminates the program.
578 # - progname name of this program
581 echo "$progname: *** $1" 1>&2
582 echo "$progname: *** Stop." 1>&2
586 # func_warning message
587 # Outputs to stderr a warning message,
590 echo "gnulib-tool: warning: $1" 1>&2
593 # func_readlink SYMLINK
594 # outputs the target of the given symlink.
595 if (type -p readlink) > /dev/null 2>&1; then
598 # Use the readlink program from GNU coreutils.
604 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
605 # would do the wrong thing if the link target contains " -> ".
606 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
610 # func_relativize DIR1 DIR2
611 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
613 # - DIR1 relative pathname, relative to the current directory
614 # - DIR2 relative pathname, relative to the current directory
616 # - reldir relative pathname of DIR2, relative to DIR1
622 sed_first='s,^\([^/]*\)/.*$,\1,'
623 sed_rest='s,^[^/]*/*,,'
624 sed_last='s,^.*/\([^/]*\)$,\1,'
625 sed_butlast='s,/*[^/]*$,,'
626 while test -n "$dir1"; do
627 first=`echo "$dir1" | sed -e "$sed_first"`
628 if test "$first" != "."; then
629 if test "$first" = ".."; then
630 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
631 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
633 first2=`echo "$dir2" | sed -e "$sed_first"`
634 if test "$first2" = "$first"; then
635 dir2=`echo "$dir2" | sed -e "$sed_rest"`
639 dir0="$dir0"/"$first"
642 dir1=`echo "$dir1" | sed -e "$sed_rest"`
647 # func_relconcat DIR1 DIR2
648 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
650 # - DIR1 relative pathname, relative to the current directory
651 # - DIR2 relative pathname, relative to DIR1
653 # - relconcat DIR1/DIR2, relative to the current directory
658 sed_first='s,^\([^/]*\)/.*$,\1,'
659 sed_rest='s,^[^/]*/*,,'
660 sed_last='s,^.*/\([^/]*\)$,\1,'
661 sed_butlast='s,/*[^/]*$,,'
663 first=`echo "$dir2" | sed -e "$sed_first"`
664 if test "$first" = "."; then
665 dir2=`echo "$dir2" | sed -e "$sed_rest"`
666 if test -z "$dir2"; then
671 last=`echo "$dir1" | sed -e "$sed_last"`
672 while test "$last" = "."; do
673 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
674 last=`echo "$dir1" | sed -e "$sed_last"`
676 if test -z "$dir1"; then
680 if test "$first" = ".."; then
681 if test "$last" = ".."; then
682 relconcat="$dir1/$dir2"
685 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
686 dir2=`echo "$dir2" | sed -e "$sed_rest"`
687 if test -z "$dir1"; then
691 if test -z "$dir2"; then
696 relconcat="$dir1/$dir2"
704 # Like ln -s, except that SRC is given relative to the current directory (or
705 # absolute), not given relative to the directory of DEST.
711 *) # SRC is relative.
714 ln -s "`pwd`/$1" "$2" ;;
715 *) # DEST is relative too.
716 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
717 test -n "$ln_destdir" || ln_destdir="."
718 func_relativize "$ln_destdir" "$1"
726 # func_ln_if_changed SRC DEST
727 # Like func_ln, but avoids munging timestamps if the link is correct.
728 func_ln_if_changed ()
730 if test $# -ne 2; then
731 echo "usage: func_ln_if_changed SRC DEST" >&2
733 ln_target=`func_readlink "$2"`
734 if test -h "$2" && test "$1" = "$ln_target"; then
742 # Ensure an 'echo' command that
743 # 1. does not interpret backslashes and
744 # 2. does not print an error message "broken pipe" when writing into a pipe
747 # Test cases for problem 1:
748 # echo '\n' | wc -l prints 1 when OK, 2 when KO
749 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
750 # Test cases for problem 2:
751 # echo hi | true frequently prints
752 # "bash: echo: write error: Broken pipe"
753 # to standard error in bash 3.2.
755 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
756 # BSD echo interprets '-n' as an option, which is also not desirable).
757 # Nowadays the problem occurs in 4 situations:
758 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
759 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
760 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
761 # - in zsh, when sh-emulation is not set,
762 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
763 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
764 # - in Solaris /bin/sh and OSF/1 /bin/sh.
765 # We try the following workarounds:
766 # - for all: respawn using $CONFIG_SHELL if that is set and works.
767 # - for bash >= 2.04: unset the shell option xpg_echo.
768 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
769 # - for bash < 2.0: define echo to a function that uses cat of a here document.
770 # - for zsh: turn sh-emulation on.
771 # - for ksh: alias echo to 'print -r'.
772 # - for ksh: alias echo to a function that uses cat of a here document.
773 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
774 # the ksh workaround.
775 # - otherwise: respawn using /bin/sh and rely on the workarounds.
776 # When respawning, we pass --no-reexec as first argument, so as to avoid
777 # turning this script into a fork bomb in unlucky situations.
779 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
780 # the 'printf' built-in. See
781 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
782 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
783 # The workaround is: define echo to a function that uses the printf built-in.
785 if echo '\t' | grep t > /dev/null; then
786 have_echo=yes # Lucky!
788 # Try the workarounds.
789 # Respawn using $CONFIG_SHELL if that is set and works.
790 if test -z "$have_echo" \
791 && test "X$1" != "X--no-reexec" \
792 && test -n "$CONFIG_SHELL" \
793 && test -f "$CONFIG_SHELL" \
794 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
795 exec $CONFIG_SHELL "$0" --no-reexec "$@"
798 # For bash >= 2.04: unset the shell option xpg_echo.
799 if test -z "$have_echo" \
800 && test -n "$BASH_VERSION" \
801 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
805 # For bash >= 2.0: define echo to a function that uses the printf built-in.
806 # For bash < 2.0: define echo to a function that uses cat of a here document.
807 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
808 # Also handle problem 2, specific to bash 3.2, here.
809 if { test -z "$have_echo" \
810 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
812 && test -n "$BASH_VERSION"; then \
813 if type printf 2>/dev/null | grep / > /dev/null; then
814 # 'printf' is not a shell built-in.
822 # 'printf' is a shell built-in.
828 if echo '\t' | grep t > /dev/null; then
832 # For zsh: turn sh-emulation on.
833 if test -z "$have_echo" \
834 && test -n "$ZSH_VERSION" \
835 && (emulate sh) >/dev/null 2>&1; then
838 # For ksh: alias echo to 'print -r'.
839 if test -z "$have_echo" \
840 && (type print) >/dev/null 2>&1; then
841 # A 'print' command exists.
842 if type print 2>/dev/null | grep / > /dev/null; then
845 # 'print' is a shell built-in.
846 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
847 # 'print' is the ksh shell built-in.
848 alias echo='print -r'
852 if test -z "$have_echo" \
853 && echo '\t' | grep t > /dev/null; then
856 # For ksh: alias echo to a function that uses cat of a here document.
857 # The ksh manual page says:
858 # "Aliasing is performed when scripts are read, not while they are executed.
859 # Therefore, for an alias to take effect, the alias definition command has
860 # to be executed before the command which references the alias is read."
861 # Because of this, we have to play strange tricks with have_echo, to ensure
862 # that the top-level statement containing the test starts after the 'alias'
864 if test -z "$have_echo"; then
871 if (alias echo=bsd_echo) 2>/dev/null; then
872 alias echo=bsd_echo 2>/dev/null
875 if test -z "$have_echo" \
876 && echo '\t' | grep t > /dev/null; then
879 if test -z "$have_echo"; then
880 if (alias echo=bsd_echo) 2>/dev/null; then
881 unalias echo 2>/dev/null
884 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
885 if test -z "$have_echo" \
886 && test "X$1" != "X--no-reexec" \
887 && test -f /bin/ksh; then
888 exec /bin/ksh "$0" --no-reexec "$@"
891 # Otherwise: respawn using /bin/sh.
892 if test -z "$have_echo" \
893 && test "X$1" != "X--no-reexec" \
894 && test -f /bin/sh; then
895 exec /bin/sh "$0" --no-reexec "$@"
898 if test -z "$have_echo"; then
899 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
901 if echo '\t' | grep t > /dev/null; then
904 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
906 if test "X$1" = "X--no-reexec"; then
910 # Command-line option processing.
911 # Removes the OPTIONS from the arguments. Sets the variables:
912 # - mode list or import or add-import or remove-import or update
913 # or create-testdir or create-megatestdir
914 # - destdir from --dir
915 # - local_gnulib_dir from --local-dir
916 # - modcache true or false, from --cache-modules/--no-cache-modules
917 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
918 # - libname, supplied_libname from --lib
919 # - sourcebase from --source-base
920 # - m4base from --m4-base
921 # - pobase from --po-base
922 # - docbase from --doc-base
923 # - testsbase from --tests-base
924 # - auxdir from --aux-dir
925 # - inctests true if --with-tests was given, blank otherwise
926 # - incobsolete true if --with-obsolete was given, blank otherwise
927 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
928 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
930 # - inc_privileged_tests true if --with-privileged-tests was given, blank
932 # - inc_unportable_tests true if --with-unportable-tests was given, blank
934 # - inc_all_tests true if --with-all-tests was given, blank otherwise
935 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
936 # - excl_longrunning_tests true if --without-longrunning-tests was given,
938 # - excl_privileged_tests true if --without-privileged-tests was given, blank
940 # - excl_unportable_tests true if --without-unportable-tests was given, blank
942 # - single_configure true if --single-configure was given, false otherwise
943 # - avoidlist list of modules to avoid, from --avoid
944 # - cond_dependencies true if --conditional-dependencies was given, false if
945 # --no-conditional-dependencies was given, blank otherwise
946 # - lgpl yes or a number if --lgpl was given, blank otherwise
947 # - makefile_name from --makefile-name
948 # - libtool true if --libtool was given, false if --no-libtool was
949 # given, blank otherwise
950 # - macro_prefix from --macro-prefix
951 # - po_domain from --po-domain
952 # - witness_c_macro from --witness-c-macro
953 # - vc_files true if --vc-files was given, false if --no-vc-files was
954 # given, blank otherwise
955 # - autoconf_minversion minimum supported autoconf version
956 # - do_changelog false if --no-changelog was given, : otherwise
957 # - doit : if actions shall be executed, false if only to be printed
958 # - symbolic true if --symlink or --more-symlinks was given, blank
960 # - lsymbolic true if --local-symlink was given, blank otherwise
961 # - do_copyrights blank if --more-symlinks was given, true otherwise
979 inc_longrunning_tests=
980 inc_privileged_tests=
981 inc_unportable_tests=
984 excl_longrunning_tests=
985 excl_privileged_tests=
986 excl_unportable_tests=
987 single_configure=false
1005 while test $# -gt 0; do
1010 --find | --fin | --fi | --f )
1013 --import | --impor | --impo | --imp | --im | --i )
1016 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1019 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1022 --update | --updat | --upda | --upd | --up | --u )
1025 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1028 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1029 mode=create-megatestdir
1031 --test | --tes | --te | --t )
1034 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1038 mode=`echo "X$1" | sed -e 's/^X--//'`
1040 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1045 if test $# = 0; then
1046 func_fatal_error "missing argument for --dir"
1051 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1055 if test $# = 0; then
1056 func_fatal_error "missing argument for --local-dir"
1061 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1063 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1066 --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 )
1069 --verbose | --verbos | --verbo | --verb )
1070 verbose=`expr $verbose + 1`
1072 --quiet | --quie | --qui | --qu | --q )
1073 verbose=`expr $verbose - 1`
1077 if test $# = 0; then
1078 func_fatal_error "missing argument for --lib"
1081 supplied_libname=true
1084 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1085 supplied_libname=true
1089 if test $# = 0; then
1090 func_fatal_error "missing argument for --source-base"
1095 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1099 if test $# = 0; then
1100 func_fatal_error "missing argument for --m4-base"
1105 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1109 if test $# = 0; then
1110 func_fatal_error "missing argument for --po-base"
1115 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1119 if test $# = 0; then
1120 func_fatal_error "missing argument for --doc-base"
1125 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1129 if test $# = 0; then
1130 func_fatal_error "missing argument for --tests-base"
1135 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1139 if test $# = 0; then
1140 func_fatal_error "missing argument for --aux-dir"
1145 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1147 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1150 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1153 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1156 --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)
1157 inc_longrunning_tests=true
1159 --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)
1160 inc_privileged_tests=true
1162 --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)
1163 inc_unportable_tests=true
1165 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1168 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1171 --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)
1172 excl_longrunning_tests=true
1174 --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)
1175 excl_privileged_tests=true
1177 --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)
1178 excl_unportable_tests=true
1180 --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)
1181 single_configure=true
1185 if test $# = 0; then
1186 func_fatal_error "missing argument for --avoid"
1188 func_append avoidlist " $1"
1191 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1192 func_append avoidlist " $arg"
1194 --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)
1195 cond_dependencies=true
1197 --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)
1198 cond_dependencies=false
1204 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1207 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1213 if test $# = 0; then
1214 func_fatal_error "missing argument for --makefile-name"
1219 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1229 if test $# = 0; then
1230 func_fatal_error "missing argument for --macro-prefix"
1235 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1239 if test $# = 0; then
1240 func_fatal_error "missing argument for --po-domain"
1245 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1249 if test $# = 0; then
1250 func_fatal_error "missing argument for --witness-c-macro"
1252 witness_c_macro="$1"
1254 --witness-c-macro=* )
1255 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1263 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1269 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1272 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1275 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1279 --help | --hel | --he | --h )
1282 --version | --versio | --versi | --vers )
1286 # Stop option processing
1290 echo "gnulib-tool: unknown option $1" 1>&2
1291 echo "Try 'gnulib-tool --help' for more information." 1>&2
1298 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1299 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1300 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1301 || test "$single_configure" != false; then
1302 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1303 echo "Try 'gnulib-tool --help' for more information." 1>&2
1307 # This code helps migrating from --import to --add-import or --update. It can
1308 # be removed on 2012-01-01.
1309 if test "$mode" = import && test $# = 0; then
1310 echo "gnulib-tool: cowardly refusing to erase the module list." 1>&2
1311 echo "The meaning of the option '--import' has changed." 1>&2
1312 echo "See the documentation at" 1>&2
1313 echo "<http://www.gnu.org/software/gnulib/manual/html_node/Modified-imports.html>." 1>&2
1314 echo "For updating to a newer version of gnulib, use" 1>&2
1315 echo " gnulib-tool --add-import" 1>&2
1316 echo "For restoring files that were omitted from version control, use" 1>&2
1317 echo " gnulib-tool --update" 1>&2
1320 if test "$mode" = update; then
1321 if test $# != 0; then
1322 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1323 echo "Try 'gnulib-tool --help' for more information." 1>&2
1324 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1325 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1328 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1329 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1330 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1331 || test -n "$inctests" || test -n "$incobsolete" \
1332 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1333 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1334 || test -n "$inc_all_tests" \
1335 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1336 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1337 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1338 || test -n "$macro_prefix" || test -n "$po_domain" \
1339 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1340 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1341 echo "Try 'gnulib-tool --help' for more information." 1>&2
1342 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1343 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1348 if test -n "$pobase" && test -z "$po_domain"; then
1349 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1350 echo "Try 'gnulib-tool --help' for more information." 1>&2
1353 if test -z "$pobase" && test -n "$po_domain"; then
1354 func_warning "--po-domain has no effect without a --po-base option"
1356 if test "$cond_dependencies" = true && test -n "$inctests"; then
1357 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1361 # Determine the minimum supported autoconf version from the project's
1363 DEFAULT_AUTOCONF_MINVERSION="2.59"
1364 autoconf_minversion=
1366 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1367 && test -n "$destdir"; then
1368 if test -f "$destdir"/configure.ac; then
1369 configure_ac="$destdir/configure.ac"
1371 if test -f "$destdir"/configure.in; then
1372 configure_ac="$destdir/configure.in"
1376 if test -f configure.ac; then
1377 configure_ac="configure.ac"
1379 if test -f configure.in; then
1380 configure_ac="configure.in"
1384 if test -n "$configure_ac"; then
1385 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1386 # because when some m4 files are omitted from a version control repository,
1387 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1388 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1389 # autom4te: m4 failed with exit status: 1
1396 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1398 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1399 if test -n "$prereqs"; then
1400 autoconf_minversion=`
1401 for version in $prereqs; do echo $version; done |
1402 LC_ALL=C sort -nru | sed -e 1q
1406 if test -z "$autoconf_minversion"; then
1407 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1409 case "$autoconf_minversion" in
1410 1.* | 2.[0-4]* | 2.5[0-8]*)
1411 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1414 # Remove trailing slashes from the directory names. This is necessary for
1415 # m4base (to avoid an error in func_import) and optional for the others.
1416 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1417 case "$local_gnulib_dir" in
1418 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1420 case "$sourcebase" in
1421 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1424 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1427 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1430 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1432 case "$testsbase" in
1433 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1436 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1442 trap 'exit_status=$?
1443 if test "$signal" != 0; then
1444 echo "caught signal $signal" >&2
1447 exit $exit_status' 0
1448 for signal in 1 2 3 13 15; do
1449 trap '{ signal='$signal'; func_exit 1; }' $signal
1453 # Note: The 'eval' silences stderr output in dash.
1454 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1455 # Zsh 4 and Bash 4 have associative arrays.
1456 have_associative=true
1458 # For other shells, use 'eval' with computed shell variable names.
1459 have_associative=false
1462 # func_lookup_file file
1463 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1466 # - local_gnulib_dir from --local-dir
1468 # - lookedup_file name of the merged (combined) file
1469 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1473 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1474 lookedup_file="$local_gnulib_dir/$lkfile"
1477 if test -f "$gnulib_dir/$lkfile"; then
1478 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1479 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1480 rm -f "$tmp/$lkbase"
1481 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1482 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1483 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1484 lookedup_file="$tmp/$lkbase"
1487 lookedup_file="$gnulib_dir/$lkfile"
1491 func_fatal_error "file $gnulib_dir/$lkfile not found"
1496 # func_sanitize_modulelist
1497 # receives a list of possible module names on standard input, one per line.
1498 # It removes those which are just file names unrelated to modules, and outputs
1499 # the resulting list to standard output, one per line.
1500 func_sanitize_modulelist ()
1502 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1503 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1504 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1505 -e '/^README$/d' -e '/\/README$/d' \
1506 -e '/^TEMPLATE$/d' \
1507 -e '/^TEMPLATE-EXTENDED$/d' \
1508 -e '/^TEMPLATE-TESTS$/d' \
1515 # - local_gnulib_dir from --local-dir
1518 # Filter out metainformation files like README, which are not modules.
1519 # Filter out unit test modules; they can be retrieved through
1520 # --extract-tests-module if desired.
1522 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1523 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1524 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1527 | func_sanitize_modulelist \
1528 | sed -e '/-tests$/d' \
1532 # func_exists_module module
1533 # tests whether a module, given by name, exists
1535 # - local_gnulib_dir from --local-dir
1536 func_exists_module ()
1538 { test -f "$gnulib_dir/modules/$1" \
1539 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1540 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1541 && test "CVS" != "$1" \
1542 && test "ChangeLog" != "$1" \
1543 && test "COPYING" != "$1" \
1544 && test "README" != "$1" \
1545 && test "TEMPLATE" != "$1" \
1546 && test "TEMPLATE-EXTENDED" != "$1" \
1547 && test "TEMPLATE-TESTS" != "$1"
1550 # func_verify_module
1551 # verifies a module name
1553 # - local_gnulib_dir from --local-dir
1554 # - module module name argument
1555 func_verify_module ()
1557 if func_exists_module "$module"; then
1558 # OK, $module is a correct module name.
1559 # Verify that building the module description with 'patch' succeeds.
1560 func_lookup_file "modules/$module"
1562 func_warning "module $module doesn't exist"
1567 # func_verify_nontests_module
1568 # verifies a module name, excluding tests modules
1570 # - local_gnulib_dir from --local-dir
1571 # - module module name argument
1572 func_verify_nontests_module ()
1575 *-tests ) module= ;;
1576 * ) func_verify_module ;;
1580 # func_verify_tests_module
1581 # verifies a module name, considering only tests modules
1583 # - local_gnulib_dir from --local-dir
1584 # - module module name argument
1585 func_verify_tests_module ()
1588 *-tests ) func_verify_module ;;
1593 # Suffix of a sed expression that extracts a particular field from a
1594 # module description.
1595 # A field starts with a line that contains a keyword, such as 'Description',
1596 # followed by a colon and optional whitespace. All following lines, up to
1597 # the next field (or end of file if there is none) form the contents of the
1599 # An absent field is equivalent to a field with empty contents.
1600 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1601 sed_extract_prog=':[ ]*$/ {
1604 s/^Description:[ ]*$//
1608 s/^Applicability:[ ]*$//
1610 s/^Depends-on:[ ]*$//
1611 s/^configure\.ac-early:[ ]*$//
1612 s/^configure\.ac:[ ]*$//
1613 s/^Makefile\.am:[ ]*$//
1617 s/^Maintainer:[ ]*$//
1624 # Piece of a sed expression that converts a field header line to a shell
1626 # NOTE: Keep this in sync with sed_extract_prog above!
1627 sed_extract_field_header='
1628 s/^Description:[ ]*$/description/
1629 s/^Comment:[ ]*$/comment/
1630 s/^Status:[ ]*$/status/
1631 s/^Notice:[ ]*$/notice/
1632 s/^Applicability:[ ]*$/applicability/
1633 s/^Files:[ ]*$/files/
1634 s/^Depends-on:[ ]*$/dependson/
1635 s/^configure\.ac-early:[ ]*$/configureac_early/
1636 s/^configure\.ac:[ ]*$/configureac/
1637 s/^Makefile\.am:[ ]*$/makefile/
1638 s/^Include:[ ]*$/include/
1640 s/^License:[ ]*$/license/
1641 s/^Maintainer:[ ]*$/maintainer/'
1645 if $have_associative; then
1647 # Declare the associative arrays.
1648 declare -A modcache_cached
1649 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1650 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1651 eval "$declare_script"
1655 # func_cache_var module
1656 # computes the cache variable name corresponding to $module.
1657 # Note: This computation can map different module names to the same
1658 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1659 # to protect against this case.
1661 # - cachevar a shell variable name
1662 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1663 # Bash 2.0 and newer, ksh, and zsh support the syntax
1664 # ${param//pattern/replacement}
1665 # as a shorthand for
1666 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1667 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1668 eval 'func_cache_var ()
1670 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1677 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1686 # func_init_sed_convert_to_cache_statements
1688 # - modcachevar_assignment
1690 # - sed_convert_to_cache_statements
1691 func_init_sed_convert_to_cache_statements ()
1693 # 'sed' script that turns a module description into shell script
1694 # assignments, suitable to be eval'ed. All active characters are escaped.
1697 # Some module's description
1702 # modcache_description[$1]=\
1703 # 'Some module'"'"'s description
1705 # modcache_files[$1]=\
1708 # c_MODULE_description_set=set; c_MODULE_description=\
1709 # 'Some module'"'"'s description
1711 # c_MODULE_files_set=set; c_MODULE_files=\
1713 # The script consists of two parts:
1714 # 1) Ignore the lines before the first field header.
1715 # 2) A loop, treating non-field-header lines by escaping single quotes
1716 # and adding a closing quote in the last line,
1717 sed_convert_to_cache_statements="
1719 # Here we have not yet seen a field header.
1721 # See if the current line contains a field header.
1724 ${sed_extract_field_header}
1727 # No field header. Ignore the line.
1729 # Read the next line. Upon EOF, just exit.
1734 # The current line contains a field header.
1736 # Turn it into the beginning of an assignment.
1737 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1739 # Move it to the hold space. Don't print it yet,
1740 # because we want no assignment if the field is empty.
1743 # Read the next line.
1744 # Upon EOF, the field was empty. Print no assignment. Just exit.
1747 # See if the current line contains a field header.
1750 ${sed_extract_field_header}
1751 # If it is, the previous field was empty. Print no assignment.
1754 # Not a field header.
1756 # Print the previous line, held in the hold space.
1761 # Transform single quotes.
1764 # Prepend a single quote.
1769 # Move it to the hold space.
1772 # Read the next line.
1779 # See if the current line contains a field header.
1782 ${sed_extract_field_header}
1785 # Print the previous line, held in the hold space.
1790 # Transform single quotes.
1797 # Print the previous line, held in the hold space, with a single quote
1798 # to end the assignment.
1808 # Print the previous line, held in the hold space, with a single quote
1809 # to end the assignment.
1816 if ! $sed_comments; then
1818 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1819 | sed -e 's/^ *//' -e 's/^#.*//'`
1823 if $have_associative; then
1824 # sed_convert_to_cache_statements does not depend on the module.
1825 modcachevar_assignment='modcache_\1[$1]='
1826 func_init_sed_convert_to_cache_statements
1829 # func_cache_lookup_module module
1831 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1832 # of its relevant data in a cache in the memory of the processing shell. If
1833 # already cached, it does not look it up again, thus saving file access time.
1835 # - module non-empty string
1836 # Output if $have_associative:
1837 # - modcache_cached[$module] set to yes
1838 # - modcache_description[$module] ==
1839 # - modcache_status[$module] \ set to the field's value, minus the
1840 # - ... / final newline,
1841 # - modcache_maintainer[$module] == or unset if the field's value is empty
1842 # Output if ! $have_associative:
1843 # - cachevar a shell variable name
1844 # - ${cachevar}_cached set to $module
1845 # - ${cachevar}_description ==
1846 # - ${cachevar}_status \ set to the field's value, minus the
1847 # - ... / final newline,
1848 # - ${cachevar}_maintainer == or unset if the field's value is empty
1849 # - ${cachevar}_description_set ==
1850 # - ${cachevar}_status_set \ set to non-empty if the field's value
1851 # - ... / is non-empty,
1852 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1853 func_cache_lookup_module ()
1855 if $have_associative; then
1856 eval 'cached=${modcache_cached[$1]}'
1859 eval "cached=\"\$${cachevar}_cached\""
1861 if test -z "$cached"; then
1862 # Not found in cache. Look it up on the file system.
1863 func_lookup_file "modules/$1"
1864 if $have_associative; then
1865 eval 'modcache_cached[$1]=yes'
1867 eval "${cachevar}_cached=\"\$1\""
1869 if ! $have_associative; then
1870 # sed_convert_to_cache_statements depends on the module.
1871 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1872 func_init_sed_convert_to_cache_statements
1874 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1875 eval "$cache_statements"
1877 if ! $have_associative; then
1878 if test "$1" != "$cached"; then
1879 func_fatal_error "cache variable collision between $1 and $cached"
1887 # func_get_description module
1889 # - local_gnulib_dir from --local-dir
1890 # - modcache true or false, from --cache-modules/--no-cache-modules
1891 func_get_description ()
1893 if ! $modcache; then
1894 func_lookup_file "modules/$1"
1895 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1897 func_cache_lookup_module "$1"
1898 # Output the field's value, including the final newline (if any).
1899 if $have_associative; then
1900 if eval 'test -n "${modcache_description[$1]+set}"'; then
1901 eval 'echo "${modcache_description[$1]}"'
1904 eval "field_set=\"\$${cachevar}_description_set\""
1905 if test -n "$field_set"; then
1906 eval "field_value=\"\$${cachevar}_description\""
1907 echo "${field_value}"
1913 # func_get_comment module
1915 # - local_gnulib_dir from --local-dir
1916 # - modcache true or false, from --cache-modules/--no-cache-modules
1919 if ! $modcache; then
1920 func_lookup_file "modules/$1"
1921 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1923 func_cache_lookup_module "$1"
1924 # Output the field's value, including the final newline (if any).
1925 if $have_associative; then
1926 if eval 'test -n "${modcache_comment[$1]+set}"'; then
1927 eval 'echo "${modcache_comment[$1]}"'
1930 eval "field_set=\"\$${cachevar}_comment_set\""
1931 if test -n "$field_set"; then
1932 eval "field_value=\"\$${cachevar}_comment\""
1933 echo "${field_value}"
1939 # func_get_status module
1941 # - local_gnulib_dir from --local-dir
1942 # - modcache true or false, from --cache-modules/--no-cache-modules
1945 if ! $modcache; then
1946 func_lookup_file "modules/$1"
1947 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1949 func_cache_lookup_module "$1"
1950 # Output the field's value, including the final newline (if any).
1951 if $have_associative; then
1952 if eval 'test -n "${modcache_status[$1]+set}"'; then
1953 eval 'echo "${modcache_status[$1]}"'
1956 eval "field_set=\"\$${cachevar}_status_set\""
1957 if test -n "$field_set"; then
1958 eval "field_value=\"\$${cachevar}_status\""
1959 echo "${field_value}"
1965 # func_get_notice module
1967 # - local_gnulib_dir from --local-dir
1968 # - modcache true or false, from --cache-modules/--no-cache-modules
1971 if ! $modcache; then
1972 func_lookup_file "modules/$1"
1973 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1975 func_cache_lookup_module "$1"
1976 # Output the field's value, including the final newline (if any).
1977 if $have_associative; then
1978 if eval 'test -n "${modcache_notice[$1]+set}"'; then
1979 eval 'echo "${modcache_notice[$1]}"'
1982 eval "field_set=\"\$${cachevar}_notice_set\""
1983 if test -n "$field_set"; then
1984 eval "field_value=\"\$${cachevar}_notice\""
1985 echo "${field_value}"
1991 # func_get_applicability module
1993 # - local_gnulib_dir from --local-dir
1994 # - modcache true or false, from --cache-modules/--no-cache-modules
1995 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1996 func_get_applicability ()
1998 if ! $modcache; then
1999 func_lookup_file "modules/$1"
2000 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2002 func_cache_lookup_module "$1"
2003 # Get the field's value, without the final newline.
2004 if $have_associative; then
2005 eval 'my_applicability="${modcache_applicability[$1]}"'
2007 eval "my_applicability=\"\$${cachevar}_applicability\""
2010 if test -n "$my_applicability"; then
2011 echo $my_applicability
2013 # The default is 'main' or 'tests', depending on the module's name.
2015 *-tests) echo "tests";;
2021 # func_get_filelist module
2023 # - local_gnulib_dir from --local-dir
2024 # - modcache true or false, from --cache-modules/--no-cache-modules
2025 func_get_filelist ()
2027 if ! $modcache; then
2028 func_lookup_file "modules/$1"
2029 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2031 func_cache_lookup_module "$1"
2032 # Output the field's value, including the final newline (if any).
2033 if $have_associative; then
2034 if eval 'test -n "${modcache_files[$1]+set}"'; then
2035 eval 'echo "${modcache_files[$1]}"'
2038 eval "field_set=\"\$${cachevar}_files_set\""
2039 if test -n "$field_set"; then
2040 eval "field_value=\"\$${cachevar}_files\""
2041 echo "${field_value}"
2046 echo m4/gnulib-common.m4
2047 case "$autoconf_minversion" in
2054 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2055 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2056 # elements starting with prefix and ending with suffix are considered.
2057 # Processing: removed_prefix and removed_suffix are removed from each element,
2058 # added_prefix and added_suffix are added to each element.
2059 # prefix, suffix should not contain shell-special characters.
2060 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2061 # added_prefix, added_suffix should not contain the characters \|&.
2062 func_filter_filelist ()
2064 if test "$2" != "$nl" \
2065 || { $fast_func_append \
2066 && { test -z "$6" || $fast_func_remove_prefix; } \
2067 && { test -z "$7" || $fast_func_remove_suffix; }; \
2071 # Do not quote possibly-empty parameters in case patterns,
2072 # AIX and HP-UX ksh won't match them if they are empty.
2075 if test -n "$6"; then
2076 func_remove_prefix fff "$6"
2078 if test -n "$7"; then
2079 func_remove_suffix fff "$7"
2082 if test -z "$ffflist"; then
2085 func_append ffflist "$2${fff}"
2091 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2092 ffflist=`for fff in $3; do
2094 $4*$5) echo "$fff" ;;
2096 done | sed -e "$sed_fff_filter"`
2098 eval "$1=\"\$ffflist\""
2101 # func_get_dependencies module
2103 # - local_gnulib_dir from --local-dir
2104 # - modcache true or false, from --cache-modules/--no-cache-modules
2105 func_get_dependencies ()
2107 # ${module}-tests implicitly depends on ${module}, if that module exists.
2111 func_remove_suffix fgd1 '-tests'
2112 if func_exists_module "$fgd1"; then
2117 # Then the explicit dependencies listed in the module description.
2118 { if ! $modcache; then
2119 func_lookup_file "modules/$1"
2120 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2122 func_cache_lookup_module "$1"
2123 # Output the field's value, including the final newline (if any).
2124 if $have_associative; then
2125 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2126 eval 'echo "${modcache_dependson[$1]}"'
2129 eval "field_set=\"\$${cachevar}_dependson_set\""
2130 if test -n "$field_set"; then
2131 eval "field_value=\"\$${cachevar}_dependson\""
2132 echo "${field_value}"
2140 # func_get_autoconf_early_snippet module
2142 # - local_gnulib_dir from --local-dir
2143 # - modcache true or false, from --cache-modules/--no-cache-modules
2144 func_get_autoconf_early_snippet ()
2146 if ! $modcache; then
2147 func_lookup_file "modules/$1"
2148 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2150 func_cache_lookup_module "$1"
2151 # Output the field's value, including the final newline (if any).
2152 if $have_associative; then
2153 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2154 eval 'echo "${modcache_configureac_early[$1]}"'
2157 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2158 if test -n "$field_set"; then
2159 eval "field_value=\"\$${cachevar}_configureac_early\""
2160 echo "${field_value}"
2166 # func_get_autoconf_snippet module
2168 # - local_gnulib_dir from --local-dir
2169 # - modcache true or false, from --cache-modules/--no-cache-modules
2170 func_get_autoconf_snippet ()
2172 if ! $modcache; then
2173 func_lookup_file "modules/$1"
2174 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2176 func_cache_lookup_module "$1"
2177 # Output the field's value, including the final newline (if any).
2178 if $have_associative; then
2179 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2180 eval 'echo "${modcache_configureac[$1]}"'
2183 eval "field_set=\"\$${cachevar}_configureac_set\""
2184 if test -n "$field_set"; then
2185 eval "field_value=\"\$${cachevar}_configureac\""
2186 echo "${field_value}"
2192 # func_get_automake_snippet_conditional module
2193 # returns the part of the Makefile.am snippet that can be put inside Automake
2196 # - local_gnulib_dir from --local-dir
2197 # - modcache true or false, from --cache-modules/--no-cache-modules
2198 func_get_automake_snippet_conditional ()
2200 if ! $modcache; then
2201 func_lookup_file "modules/$1"
2202 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2204 func_cache_lookup_module "$1"
2205 # Output the field's value, including the final newline (if any).
2206 if $have_associative; then
2207 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2208 eval 'echo "${modcache_makefile[$1]}"'
2211 eval "field_set=\"\$${cachevar}_makefile_set\""
2212 if test -n "$field_set"; then
2213 eval "field_value=\"\$${cachevar}_makefile\""
2214 echo "${field_value}"
2220 # func_get_automake_snippet_unconditional module
2221 # returns the part of the Makefile.am snippet that must stay outside of
2222 # Automake conditionals.
2224 # - local_gnulib_dir from --local-dir
2225 # - modcache true or false, from --cache-modules/--no-cache-modules
2226 func_get_automake_snippet_unconditional ()
2230 # *-tests module live in tests/, not lib/.
2231 # Synthesize an EXTRA_DIST augmentation.
2232 all_files=`func_get_filelist $1`
2233 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2234 extra_files="$tests_files"
2235 if test -n "$extra_files"; then
2236 echo "EXTRA_DIST +=" $extra_files
2241 # Synthesize an EXTRA_DIST augmentation.
2242 sed_combine_lines='/\\$/{
2249 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2250 already_mentioned_files=` \
2251 { if ! $modcache; then
2252 func_lookup_file "modules/$1"
2253 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2255 func_cache_lookup_module "$1"
2256 if $have_associative; then
2257 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2258 eval 'echo "${modcache_makefile[$1]}"'
2261 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2262 if test -n "$field_set"; then
2263 eval 'field_value="$'"${cachevar}"'_makefile"'
2264 echo "${field_value}"
2269 | sed -e "$sed_combine_lines" \
2270 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2271 all_files=`func_get_filelist $1`
2272 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2273 # Remove $already_mentioned_files from $lib_files.
2274 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2275 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2276 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2277 if test -n "$extra_files"; then
2278 echo "EXTRA_DIST +=" $extra_files
2281 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2282 # This is necessary so that automake can generate the right list of
2284 # A possible approach would be to use autom4te --trace of the redefined
2285 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2286 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2287 # inside autoconf's built-in macros are not missed).
2288 # But it's simpler and more robust to do it here, based on the file list.
2289 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2290 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2291 # automake will generate a useless dependency; this is harmless.
2293 relocatable-prog-wrapper) ;;
2296 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2297 if test -n "$extra_files"; then
2298 echo "EXTRA_lib_SOURCES +=" $extra_files
2303 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2304 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2305 if test -n "$buildaux_files"; then
2306 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2307 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2310 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2311 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2312 if test -n "$top_files"; then
2313 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2314 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2321 # func_get_automake_snippet module
2323 # - local_gnulib_dir from --local-dir
2324 # - modcache true or false, from --cache-modules/--no-cache-modules
2325 func_get_automake_snippet ()
2327 func_get_automake_snippet_conditional "$1"
2328 func_get_automake_snippet_unconditional "$1"
2331 # func_get_include_directive module
2333 # - local_gnulib_dir from --local-dir
2334 # - modcache true or false, from --cache-modules/--no-cache-modules
2335 func_get_include_directive ()
2338 if ! $modcache; then
2339 func_lookup_file "modules/$1"
2340 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2342 func_cache_lookup_module "$1"
2343 # Output the field's value, including the final newline (if any).
2344 if $have_associative; then
2345 if eval 'test -n "${modcache_include[$1]+set}"'; then
2346 eval 'echo "${modcache_include[$1]}"'
2349 eval "field_set=\"\$${cachevar}_include_set\""
2350 if test -n "$field_set"; then
2351 eval "field_value=\"\$${cachevar}_include\""
2352 echo "${field_value}"
2356 } | sed -e 's/^\(["<]\)/#include \1/'
2359 # func_get_link_directive module
2361 # - local_gnulib_dir from --local-dir
2362 # - modcache true or false, from --cache-modules/--no-cache-modules
2363 func_get_link_directive ()
2365 if ! $modcache; then
2366 func_lookup_file "modules/$1"
2367 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2369 func_cache_lookup_module "$1"
2370 # Output the field's value, including the final newline (if any).
2371 if $have_associative; then
2372 if eval 'test -n "${modcache_link[$1]+set}"'; then
2373 eval 'echo "${modcache_link[$1]}"'
2376 eval "field_set=\"\$${cachevar}_link_set\""
2377 if test -n "$field_set"; then
2378 eval "field_value=\"\$${cachevar}_link\""
2379 echo "${field_value}"
2385 # func_get_license_raw module
2387 # - local_gnulib_dir from --local-dir
2388 # - modcache true or false, from --cache-modules/--no-cache-modules
2389 func_get_license_raw ()
2391 if ! $modcache; then
2392 func_lookup_file "modules/$1"
2393 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2395 func_cache_lookup_module "$1"
2396 # Output the field's value, including the final newline (if any).
2397 if $have_associative; then
2398 if eval 'test -n "${modcache_license[$1]+set}"'; then
2399 eval 'echo "${modcache_license[$1]}"'
2402 eval "field_set=\"\$${cachevar}_license_set\""
2403 if test -n "$field_set"; then
2404 eval "field_value=\"\$${cachevar}_license\""
2405 echo "${field_value}"
2411 # func_get_license module
2413 # - local_gnulib_dir from --local-dir
2414 # - modcache true or false, from --cache-modules/--no-cache-modules
2417 # Warn if the License field is missing.
2421 license=`func_get_license_raw "$1"`
2422 if test -z "$license"; then
2423 func_warning "module $1 lacks a License"
2428 func_get_license_raw "$1"
2429 # The default is GPL.
2431 } | sed -e 's,^ *$,,' | sed -e 1q
2434 # func_get_maintainer module
2436 # - local_gnulib_dir from --local-dir
2437 # - modcache true or false, from --cache-modules/--no-cache-modules
2438 func_get_maintainer ()
2440 if ! $modcache; then
2441 func_lookup_file "modules/$1"
2442 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2444 func_cache_lookup_module "$1"
2445 # Output the field's value, including the final newline (if any).
2446 if $have_associative; then
2447 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2448 eval 'echo "${modcache_maintainer[$1]}"'
2451 eval "field_set=\"\$${cachevar}_maintainer_set\""
2452 if test -n "$field_set"; then
2453 eval "field_value=\"\$${cachevar}_maintainer\""
2454 echo "${field_value}"
2460 # func_get_tests_module module
2462 # - local_gnulib_dir from --local-dir
2463 func_get_tests_module ()
2465 # The naming convention for tests modules is hardwired: ${module}-tests.
2466 if test -f "$gnulib_dir/modules/$1"-tests \
2467 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2468 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2473 # func_acceptable module
2474 # tests whether a module is acceptable.
2476 # - avoidlist list of modules to avoid
2479 for avoid in $avoidlist; do
2480 if test "$avoid" = "$1"; then
2487 # sed expression to keep the first 32 characters of each line.
2488 sed_first_32_chars='s/^\(................................\).*/\1/'
2490 # func_module_shellfunc_name module
2491 # computes the shell function name that will contain the m4 macros for the module.
2493 # - macro_prefix prefix to use
2495 # - shellfunc shell function name
2496 func_module_shellfunc_name ()
2500 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2502 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2506 # func_module_shellvar_name module
2507 # computes the shell variable name the will be set to true once the m4 macros
2508 # for the module have been executed.
2510 # - shellvar shell variable name
2511 func_module_shellvar_name ()
2515 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2517 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2521 # func_module_conditional_name module
2522 # computes the automake conditional name for the module.
2524 # - conditional name of automake conditional
2525 func_module_conditional_name ()
2529 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2531 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2535 # func_uncond_add_module B
2536 # notes the presence of B as an unconditional module.
2538 # func_conddep_add_module A B cond
2539 # notes the presence of a conditional dependency from module A to module B,
2540 # subject to the condition that A is enabled and cond is true.
2542 # func_cond_module_p B
2543 # tests whether module B is conditional.
2545 # func_cond_module_condition A B
2546 # returns the condition when B should be enabled as a dependency of A, once the
2547 # m4 code for A has been executed.
2548 # Output: - condition
2550 if $have_associative; then
2551 declare -A conddep_isuncond
2552 declare -A conddep_dependers
2553 declare -A conddep_condition
2554 func_uncond_add_module ()
2556 eval 'conddep_isuncond[$1]=true'
2557 eval 'unset conddep_dependers[$1]'
2559 func_conddep_add_module ()
2561 eval 'isuncond="${conddep_isuncond[$2]}"'
2562 if test -z "$isuncond"; then
2563 # No unconditional dependency to B known at this point.
2564 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2565 eval 'conddep_condition[$1---$2]="$3"'
2568 func_cond_module_p ()
2570 eval 'previous_dependers="${conddep_dependers[$1]}"'
2571 test -n "$previous_dependers"
2573 func_cond_module_condition ()
2575 eval 'condition="${conddep_condition[$1---$2]}"'
2578 func_uncond_add_module ()
2582 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2586 eval 'conddep_isuncond_'"$suffix"'=true'
2587 eval 'unset conddep_dependers_'"$suffix"
2589 func_conddep_add_module ()
2593 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2597 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2598 if test -z "$isuncond"; then
2599 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2600 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2601 eval 'conddep_condition_'"$suffix"'="$3"'
2604 func_cond_module_p ()
2608 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2612 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2613 test -n "$previous_dependers"
2615 func_cond_module_condition ()
2617 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2618 eval 'condition="${conddep_condition_'"$suffix"'}"'
2622 sed_dependencies_without_conditions='s/ *\[.*//'
2624 # func_modules_transitive_closure
2626 # - local_gnulib_dir from --local-dir
2627 # - modcache true or false, from --cache-modules/--no-cache-modules
2628 # - modules list of specified modules
2629 # - inctests true if tests should be included, blank otherwise
2630 # - incobsolete true if obsolete modules among dependencies should be
2631 # included, blank otherwise
2632 # - inc_cxx_tests true if C++ interoperability tests should be included,
2634 # - inc_longrunning_tests true if long-runnings tests should be included,
2636 # - inc_privileged_tests true if tests that require root privileges should be
2637 # included, blank otherwise
2638 # - inc_unportable_tests true if tests that fail on some platforms should be
2639 # included, blank otherwise
2640 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2641 # the unit tests of the specified modules should be
2642 # included, blank otherwise
2643 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2644 # the unit tests of the dependencies should be
2645 # included, blank otherwise
2646 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2648 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2650 # - excl_privileged_tests true if tests that require root privileges should be
2651 # excluded, blank otherwise
2652 # - excl_unportable_tests true if tests that fail on some platforms should be
2653 # excluded, blank otherwise
2654 # - avoidlist list of modules to avoid
2655 # - cond_dependencies true if conditional dependencies shall be supported,
2657 # - tmp pathname of a temporary directory
2659 # - modules list of modules, including dependencies
2660 # - conddep_dependers, conddep_condition information about conditionally
2662 func_modules_transitive_closure ()
2664 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2665 # In order to process every module only once (for speed), process an "input
2666 # list" of modules, producing an "output list" of modules. During each round,
2667 # more modules can be queued in the input list. Once a module on the input
2668 # list has been processed, it is added to the "handled list", so we can avoid
2669 # to process it again.
2671 inmodules="$modules"
2673 fmtc_inc_all_tests="$inc_all_direct_tests"
2674 if test "$cond_dependencies" = true; then
2675 for module in $inmodules; do
2677 if test -n "$module"; then
2678 if func_acceptable $module; then
2679 func_uncond_add_module $module
2684 while test -n "$inmodules"; do
2685 inmodules_this_round="$inmodules"
2686 inmodules= # Accumulator, queue for next round
2687 for module in $inmodules_this_round; do
2689 if test -n "$module"; then
2690 if func_acceptable $module; then
2691 func_append outmodules " $module"
2692 if test "$cond_dependencies" = true; then
2693 if func_get_automake_snippet_conditional $module | grep '^if ' > /dev/null; then
2694 # A module whose Makefile.am snippet contains a reference to an
2695 # automake conditional. If we were to use it conditionally, we
2696 # would get an error
2697 # configure: error: conditional "..." was never defined.
2698 # because automake 1.11.1 does not handle nested conditionals
2699 # correctly. As a workaround, make the module unconditional.
2700 func_uncond_add_module $module
2702 if func_cond_module_p $module; then
2708 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2709 # Duplicate dependencies are harmless, but Jim wants a warning.
2710 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2711 if test -n "$duplicated_deps"; then
2712 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2714 if test -n "$inctests"; then
2715 testsmodule=`func_get_tests_module $module`
2716 if test -n "$testsmodule"; then
2717 deps="$deps $testsmodule"
2720 for dep in $deps; do
2721 # Determine whether to include the dependency or tests module.
2723 for word in `func_get_status $dep`; do
2726 test -n "$incobsolete" \
2730 test -z "$excl_cxx_tests" \
2732 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2736 test -z "$excl_longrunning_tests" \
2738 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2742 test -z "$excl_privileged_tests" \
2744 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2748 test -z "$excl_unportable_tests" \
2750 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2754 test -n "$fmtc_inc_all_tests" \
2759 if $inc && func_acceptable "$dep"; then
2760 func_append inmodules " $dep"
2761 if test "$cond_dependencies" = true; then
2762 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2763 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2766 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2767 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2769 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2770 if test "$condition" = true; then
2773 if test -n "$condition"; then
2774 func_conddep_add_module "$module" "$dep" "$condition"
2776 if $conditional; then
2777 func_conddep_add_module "$module" "$dep" true
2779 func_uncond_add_module "$dep"
2788 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2789 # Remove $handledmodules from $inmodules.
2790 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2791 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2792 fmtc_inc_all_tests="$inc_all_indirect_tests"
2794 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2795 rm -f "$tmp"/queued-modules
2798 # func_show_module_list
2800 # - specified_modules list of specified modules (one per line, sorted)
2801 # - modules complete list of modules (one per line, sorted)
2802 # - tmp pathname of a temporary directory
2803 func_show_module_list ()
2809 # Assume xterm compatible escape sequences.
2810 bold_on=`printf '\x1b[1m'`
2811 bold_off=`printf '\x1b[0m'`
2816 echo "Module list with included dependencies (indented):"
2817 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2818 echo "$modules" | sed -e '/^$/d' \
2819 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2820 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2823 # func_modules_transitive_closure_separately
2824 # Determine main module list and tests-related module list separately.
2825 # The main module list is the transitive closure of the specified modules,
2826 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2827 # is specified, it will consist only of LGPLed source.
2828 # The tests-related module list is the transitive closure of the specified
2829 # modules, including tests modules, minus the main module list excluding
2830 # modules of applicability 'all'. Its lib/* sources (brought in through
2831 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2832 # source, even if --lgpl is specified.
2834 # - local_gnulib_dir from --local-dir
2835 # - modcache true or false, from --cache-modules/--no-cache-modules
2836 # - specified_modules list of specified modules
2837 # - inctests true if tests should be included, blank otherwise
2838 # - incobsolete true if obsolete modules among dependencies should be
2839 # included, blank otherwise
2840 # - inc_cxx_tests true if C++ interoperability tests should be included,
2842 # - inc_longrunning_tests true if long-runnings tests should be included,
2844 # - inc_privileged_tests true if tests that require root privileges should be
2845 # included, blank otherwise
2846 # - inc_unportable_tests true if tests that fail on some platforms should be
2847 # included, blank otherwise
2848 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2849 # the unit tests of the specified modules should be
2850 # included, blank otherwise
2851 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2852 # the unit tests of the dependencies should be
2853 # included, blank otherwise
2854 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2856 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2858 # - excl_privileged_tests true if tests that require root privileges should be
2859 # excluded, blank otherwise
2860 # - excl_unportable_tests true if tests that fail on some platforms should be
2861 # excluded, blank otherwise
2862 # - avoidlist list of modules to avoid
2863 # - cond_dependencies true if conditional dependencies shall be supported,
2865 # - tmp pathname of a temporary directory
2867 # - main_modules list of modules, including dependencies
2868 # - testsrelated_modules list of tests-related modules, including dependencies
2869 # - conddep_dependers, conddep_condition information about conditionally
2871 func_modules_transitive_closure_separately ()
2873 # Determine main module list.
2874 saved_inctests="$inctests"
2876 modules="$specified_modules"
2877 func_modules_transitive_closure
2878 main_modules="$modules"
2879 inctests="$saved_inctests"
2880 if test $verbose -ge 1; then
2881 echo "Main module list:"
2882 echo "$main_modules" | sed -e 's/^/ /'
2884 # Determine tests-related module list.
2885 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2886 testsrelated_modules=`for module in $main_modules; do
2887 if test \`func_get_applicability $module\` = main; then
2891 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2892 if test $verbose -ge 1; then
2893 echo "Tests-related module list:"
2894 echo "$testsrelated_modules" | sed -e 's/^/ /'
2898 # func_determine_use_libtests
2899 # Determines whether a $testsbase/libtests.a is needed.
2901 # - local_gnulib_dir from --local-dir
2902 # - modcache true or false, from --cache-modules/--no-cache-modules
2903 # - testsrelated_modules list of tests-related modules, including dependencies
2905 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2906 func_determine_use_libtests ()
2909 for module in $testsrelated_modules; do
2910 func_verify_nontests_module
2911 if test -n "$module"; then
2912 all_files=`func_get_filelist $module`
2913 # Test whether some file in $all_files lies in lib/.
2914 for f in $all_files; do
2926 # func_modules_add_dummy
2928 # - local_gnulib_dir from --local-dir
2929 # - modcache true or false, from --cache-modules/--no-cache-modules
2930 # - modules list of modules, including dependencies
2932 # - modules list of modules, including 'dummy' if needed
2933 func_modules_add_dummy ()
2935 # Determine whether any module provides a lib_SOURCES augmentation.
2937 sed_remove_backslash_newline=':a
2944 for module in $modules; do
2945 func_verify_nontests_module
2946 if test -n "$module"; then
2947 # Extract the value of "lib_SOURCES += ...".
2948 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2949 # Ignore .h files since they are not compiled.
2953 have_lib_SOURCES=yes
2960 # Add the dummy module, to make sure the library will be non-empty.
2961 if test -z "$have_lib_SOURCES"; then
2962 if func_acceptable "dummy"; then
2963 func_append modules " dummy"
2968 # func_modules_add_dummy_separately
2970 # - local_gnulib_dir from --local-dir
2971 # - modcache true or false, from --cache-modules/--no-cache-modules
2972 # - main_modules list of modules, including dependencies
2973 # - testsrelated_modules list of tests-related modules, including dependencies
2974 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2976 # - main_modules list of modules, including 'dummy' if needed
2977 # - testsrelated_modules list of tests-related modules, including 'dummy' if
2979 func_modules_add_dummy_separately ()
2981 # Add the dummy module to the main module list if needed.
2982 modules="$main_modules"
2983 func_modules_add_dummy
2984 main_modules="$modules"
2986 # Add the dummy module to the tests-related module list if needed.
2987 if $use_libtests; then
2988 modules="$testsrelated_modules"
2989 func_modules_add_dummy
2990 testsrelated_modules="$modules"
2994 # func_modules_notice
2996 # - local_gnulib_dir from --local-dir
2997 # - modcache true or false, from --cache-modules/--no-cache-modules
2998 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2999 # - modules list of modules, including dependencies
3000 func_modules_notice ()
3002 if test $verbose -ge -1; then
3003 for module in $modules; do
3005 if test -n "$module"; then
3006 msg=`func_get_notice $module`
3007 if test -n "$msg"; then
3008 echo "Notice from module $module:"
3009 echo "$msg" | sed -e 's/^/ /'
3016 # func_modules_to_filelist
3018 # - local_gnulib_dir from --local-dir
3019 # - modcache true or false, from --cache-modules/--no-cache-modules
3020 # - modules list of modules, including dependencies
3022 # - files list of files
3023 func_modules_to_filelist ()
3026 for module in $modules; do
3028 if test -n "$module"; then
3029 fs=`func_get_filelist $module`
3030 func_append files " $fs"
3033 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3036 # func_modules_to_filelist_separately
3037 # Determine the final file lists.
3038 # They must be computed separately, because files in lib/* go into
3039 # $sourcebase/ if they are in the main file list but into $testsbase/
3040 # if they are in the tests-related file list. Furthermore lib/dummy.c
3043 # - local_gnulib_dir from --local-dir
3044 # - modcache true or false, from --cache-modules/--no-cache-modules
3045 # - main_modules list of modules, including dependencies
3046 # - testsrelated_modules list of tests-related modules, including dependencies
3047 func_modules_to_filelist_separately ()
3049 # Determine final main file list.
3050 modules="$main_modules"
3051 func_modules_to_filelist
3053 # Determine final tests-related file list.
3054 modules="$testsrelated_modules"
3055 func_modules_to_filelist
3056 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3057 # Merge both file lists.
3058 sed_remove_empty_lines='/^$/d'
3059 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3060 if test $verbose -ge 0; then
3062 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3063 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3067 # func_compute_include_guard_prefix
3068 # Determine include_guard_prefix.
3070 # - macro_prefix prefix of gl_LIBOBJS macros to use
3072 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3073 # - sed_replace_include_guard_prefix
3074 # sed expression for resolving ${gl_include_guard_prefix}
3075 func_compute_include_guard_prefix ()
3077 if test "$macro_prefix" = gl; then
3078 include_guard_prefix='GL'
3080 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3082 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3085 # func_execute_command command [args...]
3086 # Executes a command.
3087 # Uses also the variables
3088 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3089 func_execute_command ()
3091 if test $verbose -ge 0; then
3095 # Commands like automake produce output to stderr even when they succeed.
3096 # Turn this output off if the command succeeds.
3097 "$@" > "$tmp"/cmdout 2>&1
3099 if test $cmdret = 0; then
3103 cat "$tmp"/cmdout 1>&2
3110 # func_dest_tmpfilename file
3111 # determines the name of a temporary file (file is relative to destdir).
3113 # - destdir target directory
3114 # - doit : if actions shall be executed, false if only to be printed
3115 # - tmp pathname of a temporary directory
3117 # - tmpfile absolute filename of the temporary file
3118 func_dest_tmpfilename ()
3121 # Put the new contents of $file in a file in the same directory (needed
3122 # to guarantee that an 'mv' to "$destdir/$file" works).
3123 tmpfile="$destdir/$1.tmp"
3125 # Put the new contents of $file in a file in a temporary directory
3126 # (because the directory of "$file" might not exist).
3127 tmpfile="$tmp"/`basename "$1"`.tmp
3132 # copies a file from gnulib into the destination directory. The destination
3133 # is known to not exist.
3135 # - destdir target directory
3136 # - local_gnulib_dir from --local-dir
3137 # - modcache true or false, from --cache-modules/--no-cache-modules
3138 # - f the original file name
3139 # - lookedup_file name of the merged (combined) file
3140 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3141 # - g the rewritten file name
3142 # - tmpfile absolute filename of the temporary file
3143 # - doit : if actions shall be executed, false if only to be printed
3144 # - symbolic true if files should be symlinked, copied otherwise
3145 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3150 echo "Copying file $g"
3151 if { test -n "$symbolic" \
3152 || { test -n "$lsymbolic" \
3153 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3154 && test -z "$lookedup_tmp" \
3155 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
3156 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3158 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3166 # copies a file from gnulib into the destination directory. The destination
3167 # is known to exist.
3169 # - destdir target directory
3170 # - local_gnulib_dir from --local-dir
3171 # - modcache true or false, from --cache-modules/--no-cache-modules
3172 # - f the original file name
3173 # - lookedup_file name of the merged (combined) file
3174 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3175 # - g the rewritten file name
3176 # - tmpfile absolute filename of the temporary file
3177 # - doit : if actions shall be executed, false if only to be printed
3178 # - symbolic true if files should be symlinked, copied otherwise
3179 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3181 # - already_present nonempty if the file should already exist, empty otherwise
3184 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
3185 : # The file has not changed.
3189 if test -n "$already_present"; then
3190 echo "Updating file $g (backup in ${g}~)"
3192 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3194 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3195 if { test -n "$symbolic" \
3196 || { test -n "$lsymbolic" \
3197 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3198 && test -z "$lookedup_tmp" \
3199 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
3200 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3202 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3205 if test -n "$already_present"; then
3206 echo "Update file $g (backup in ${g}~)"
3208 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3214 # func_emit_lib_Makefile_am
3215 # emits the contents of library makefile to standard output.
3217 # - local_gnulib_dir from --local-dir
3218 # - modcache true or false, from --cache-modules/--no-cache-modules
3219 # - modules list of modules, including dependencies
3220 # - libname library name
3221 # - pobase directory relative to destdir where to place *.po files
3222 # - auxdir directory relative to destdir where to place build aux files
3223 # - makefile_name from --makefile-name
3224 # - libtool true if libtool will be used, false or blank otherwise
3225 # - macro_prefix prefix of gl_LIBOBJS macros to use
3226 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3227 # - witness_c_macro from --witness-c-macro
3228 # - actioncmd (optional) command that will reproduce this invocation
3229 # - for_test true if creating a package for testing, false otherwise
3230 # - sed_replace_include_guard_prefix
3231 # sed expression for resolving ${gl_include_guard_prefix}
3232 # - destfile filename relative to destdir of makefile being generated
3234 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3235 # list of edits to be done to Makefile.am variables
3237 # - uses_subdirs nonempty if object files in subdirs exist
3238 func_emit_lib_Makefile_am ()
3240 # When creating an includable Makefile.am snippet, augment variables with
3241 # += instead of assigning them.
3242 if test -n "$makefile_name"; then
3247 if test "$libtool" = true; then
3250 sed_eliminate_LDFLAGS="$sed_noop"
3254 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3257 # When creating a package for testing: Attempt to provoke failures,
3258 # especially link errors, already during "make" rather than during
3259 # "make check", because "make check" is not possible in a cross-compiling
3260 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3261 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3263 sed_transform_check_PROGRAMS="$sed_noop"
3265 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3266 echo "## Process this file with automake to produce Makefile.in."
3267 func_emit_copyright_notice
3268 if test -n "$actioncmd"; then
3269 # The maximum line length (excluding the terminating newline) of any file
3270 # that is to be preprocessed by config.status is 3070. config.status uses
3271 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3272 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3273 len=`echo "$actioncmd" | wc -c`
3274 if test -n "$len" && test "$len" -le 3000; then
3275 echo "# Reproduce by: $actioncmd"
3281 for module in $modules; do
3282 func_verify_nontests_module
3283 if test -n "$module"; then
3285 func_get_automake_snippet_conditional "$module" |
3287 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3288 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3289 -e "$sed_eliminate_LDFLAGS" \
3290 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3291 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3292 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3293 -e "$sed_transform_check_PROGRAMS" \
3294 -e "$sed_replace_include_guard_prefix"
3295 if test "$module" = 'alloca'; then
3296 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3297 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3299 } > "$tmp"/amsnippet1
3301 func_get_automake_snippet_unconditional "$module" |
3302 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3303 } > "$tmp"/amsnippet2
3304 # Skip the contents if it's entirely empty.
3305 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3306 echo "## begin gnulib module $module"
3308 if test "$cond_dependencies" = true; then
3309 if func_cond_module_p "$module"; then
3310 func_module_conditional_name "$module"
3311 echo "if $conditional"
3314 cat "$tmp"/amsnippet1
3315 if test "$cond_dependencies" = true; then
3316 if func_cond_module_p "$module"; then
3320 cat "$tmp"/amsnippet2
3321 echo "## end gnulib module $module"
3324 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3325 # Test whether there are some source files in subdirectories.
3326 for f in `func_get_filelist "$module"`; do
3336 } > "$tmp"/allsnippets
3337 if test -z "$makefile_name"; then
3338 # If there are source files in subdirectories, prevent collision of the
3339 # object files (example: hash.c and libxml/hash.c).
3341 if test -n "$uses_subdirs"; then
3342 subdir_options=' subdir-objects'
3344 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
3347 if test -z "$makefile_name"; then
3349 echo "noinst_HEADERS ="
3350 echo "noinst_LIBRARIES ="
3351 echo "noinst_LTLIBRARIES ="
3352 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3353 # if you specify pkgdata_DATA to empty. This is a workaround.
3354 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3355 echo "pkgdata_DATA ="
3358 echo "BUILT_SOURCES ="
3361 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3362 if test -z "$makefile_name"; then
3363 echo "MOSTLYCLEANDIRS ="
3365 echo "DISTCLEANFILES ="
3366 echo "MAINTAINERCLEANFILES ="
3368 # Execute edits that apply to the Makefile.am being generated.
3370 while test $edit != $makefile_am_edits; do
3371 edit=`expr $edit + 1`
3372 eval dir=\"\$makefile_am_edit${edit}_dir\"
3373 eval var=\"\$makefile_am_edit${edit}_var\"
3374 eval val=\"\$makefile_am_edit${edit}_val\"
3375 if test -n "$var"; then
3376 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3377 echo "${var} += ${val}"
3378 eval "makefile_am_edit${edit}_var="
3382 if test -n "$witness_c_macro"; then
3383 cppflags_part1=" -D$witness_c_macro=1"
3388 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3392 if test -z "$makefile_name"; then
3394 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3397 if test -n "$cppflags_part1$cppflags_part2"; then
3399 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3403 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3404 || { test -n "$makefile_name" \
3405 && test -f "$sourcebase/Makefile.am" \
3406 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3408 # One of the snippets or the user's Makefile.am already specifies an
3409 # installation location for the library. Don't confuse automake by saying
3410 # it should not be installed.
3413 # By default, the generated library should not be installed.
3414 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3417 echo "${libname}_${libext}_SOURCES ="
3418 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3419 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3420 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3421 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3422 echo "EXTRA_${libname}_${libext}_SOURCES ="
3423 if test "$libtool" = true; then
3424 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3425 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3426 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3427 # the link dependencies of all modules.
3428 for module in $modules; do
3429 func_verify_nontests_module
3430 if test -n "$module"; then
3431 func_get_link_directive "$module"
3434 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3435 | LC_ALL=C sort -u \
3436 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3439 if test -n "$pobase"; then
3440 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3443 cat "$tmp"/allsnippets \
3444 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3446 echo "mostlyclean-local: mostlyclean-generic"
3447 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3448 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3449 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3453 rm -f "$tmp"/allsnippets
3456 # func_emit_po_Makevars
3457 # emits the contents of po/ makefile parameterization to standard output.
3459 # - local_gnulib_dir from --local-dir
3460 # - modcache true or false, from --cache-modules/--no-cache-modules
3461 # - sourcebase directory relative to destdir where to place source code
3462 # - pobase directory relative to destdir where to place *.po files
3463 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3464 func_emit_po_Makevars ()
3466 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3467 func_emit_copyright_notice
3469 echo "# Usually the message domain is the same as the package name."
3470 echo "# But here it has a '-gnulib' suffix."
3471 echo "DOMAIN = ${po_domain}-gnulib"
3473 echo "# These two variables depend on the location of this directory."
3474 echo "subdir = ${pobase}"
3475 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3478 # These options get passed to xgettext.
3479 XGETTEXT_OPTIONS = \
3480 --keyword=_ --flag=_:1:pass-c-format \
3481 --keyword=N_ --flag=N_:1:pass-c-format \
3482 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3483 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3484 --flag=error:3:c-format --flag=error_at_line:5:c-format
3486 # This is the copyright holder that gets inserted into the header of the
3487 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3488 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3490 # This is the email address or URL to which the translators shall report
3491 # bugs in the untranslated strings:
3492 # - Strings which are not entire sentences, see the maintainer guidelines
3493 # in the GNU gettext documentation, section 'Preparing Strings'.
3494 # - Strings which use unclear terms or require additional context to be
3496 # - Strings which make invalid assumptions about notation of date, time or
3498 # - Pluralisation problems.
3499 # - Incorrect English spelling.
3500 # - Incorrect formatting.
3501 # It can be your email address, or a mailing list address where translators
3502 # can write to without being subscribed, or the URL of a web page through
3503 # which the translators can contact you.
3504 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3506 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3507 # message catalogs shall be used. It is usually empty.
3508 EXTRA_LOCALE_CATEGORIES =
3510 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3511 # context. Possible values are "yes" and "no". Set this to yes if the
3512 # package uses functions taking also a message context, like pgettext(), or
3513 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3518 # func_emit_po_POTFILES_in
3519 # emits the file list to be passed to xgettext to standard output.
3521 # - local_gnulib_dir from --local-dir
3522 # - modcache true or false, from --cache-modules/--no-cache-modules
3523 # - sourcebase directory relative to destdir where to place source code
3524 # - files list of new files
3525 func_emit_po_POTFILES_in ()
3527 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3528 func_emit_copyright_notice
3530 echo "# List of files which contain translatable strings."
3531 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3534 # func_emit_tests_Makefile_am witness_macro
3535 # emits the contents of tests makefile to standard output.
3537 # - local_gnulib_dir from --local-dir
3538 # - modcache true or false, from --cache-modules/--no-cache-modules
3539 # - modules list of modules, including dependencies
3540 # - libname library name
3541 # - auxdir directory relative to destdir where to place build aux files
3542 # - makefile_name from --makefile-name
3543 # - libtool true if libtool will be used, false or blank otherwise
3544 # - sourcebase relative directory containing lib source code
3545 # - m4base relative directory containing autoconf macros
3546 # - testsbase relative directory containing unit test code
3547 # - macro_prefix prefix of gl_LIBOBJS macros to use
3548 # - witness_c_macro from --witness-c-macro
3549 # - for_test true if creating a package for testing, false otherwise
3550 # - single_configure true if a single configure file should be generated,
3551 # false for a separate configure file for the tests
3552 # - use_libtests true if a libtests.a should be built, false otherwise
3553 # - sed_replace_include_guard_prefix
3554 # sed expression for resolving ${gl_include_guard_prefix}
3555 # - destfile filename relative to destdir of makefile being generated
3557 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3558 # list of edits to be done to Makefile.am variables
3560 # - uses_subdirs nonempty if object files in subdirs exist
3561 func_emit_tests_Makefile_am ()
3564 if test "$libtool" = true; then
3566 sed_eliminate_LDFLAGS="$sed_noop"
3569 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3572 # When creating a package for testing: Attempt to provoke failures,
3573 # especially link errors, already during "make" rather than during
3574 # "make check", because "make check" is not possible in a cross-compiling
3575 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3576 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3578 sed_transform_check_PROGRAMS="$sed_noop"
3580 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3581 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3582 echo "## Process this file with automake to produce Makefile.in."
3583 func_emit_copyright_notice
3587 for module in $modules; do
3588 if $for_test && ! $single_configure; then
3589 func_verify_tests_module
3593 if test -n "$module"; then
3595 func_get_automake_snippet "$module" |
3597 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3598 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3599 -e "$sed_eliminate_LDFLAGS" \
3600 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3601 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3602 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3603 -e "$sed_transform_check_PROGRAMS" \
3604 -e "$sed_replace_include_guard_prefix"
3605 if $use_libtests && test "$module" = 'alloca'; then
3606 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3607 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3609 } > "$tmp"/amsnippet
3610 # Skip the contents if it's entirely empty.
3611 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3612 # Mention long-running tests at the end.
3614 for word in `func_get_status "$module"`; do
3615 if test "$word" = 'longrunning-test'; then
3620 { echo "## begin gnulib module $module"
3622 cat "$tmp"/amsnippet
3623 echo "## end gnulib module $module"
3627 rm -f "$tmp"/amsnippet
3628 # Test whether there are some source files in subdirectories.
3629 for f in `func_get_filelist "$module"`; do
3631 lib/*/*.c | tests/*/*.c)
3639 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3640 # Generate dependencies here, since it eases the debugging of test failures.
3641 # If there are source files in subdirectories, prevent collision of the
3642 # object files (example: hash.c and libxml/hash.c).
3644 if test -n "$uses_subdirs"; then
3645 subdir_options=' subdir-objects'
3647 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3649 if $for_test && ! $single_configure; then
3650 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3653 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3654 # variable is needed to avoid an error from automake:
3655 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3658 echo "XFAIL_TESTS ="
3659 echo "TESTS_ENVIRONMENT ="
3660 echo "noinst_PROGRAMS ="
3661 if ! $for_test; then
3662 echo "check_PROGRAMS ="
3664 echo "noinst_HEADERS ="
3665 echo "noinst_LIBRARIES ="
3666 if $use_libtests; then
3668 echo "noinst_LIBRARIES += libtests.a"
3670 echo "check_LIBRARIES = libtests.a"
3673 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3674 # if you specify pkgdata_DATA to empty. This is a workaround.
3675 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3676 echo "pkgdata_DATA ="
3679 echo "BUILT_SOURCES ="
3681 echo "MOSTLYCLEANFILES = core *.stackdump"
3682 echo "MOSTLYCLEANDIRS ="
3684 echo "DISTCLEANFILES ="
3685 echo "MAINTAINERCLEANFILES ="
3686 # Execute edits that apply to the Makefile.am being generated.
3688 while test $edit != $makefile_am_edits; do
3689 edit=`expr $edit + 1`
3690 eval dir=\"\$makefile_am_edit${edit}_dir\"
3691 eval var=\"\$makefile_am_edit${edit}_var\"
3692 eval val=\"\$makefile_am_edit${edit}_val\"
3693 if test -n "$var"; then
3694 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3695 echo "${var} += ${val}"
3696 eval "makefile_am_edit${edit}_var="
3701 echo "AM_CPPFLAGS = \\"
3703 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3705 if test -n "$witness_c_macro"; then
3706 echo " -D$witness_c_macro=1 \\"
3708 if test -n "${witness_macro}"; then
3709 echo " -D@${witness_macro}@=1 \\"
3711 echo " -I. -I\$(srcdir) \\"
3712 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3713 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3715 local_ldadd_before=''
3716 local_ldadd_after=''
3717 if $use_libtests; then
3718 # All test programs need to be linked with libtests.a.
3719 # It needs to be passed to the linker before ${libname}.${libext}, since
3720 # the tests-related modules depend on the main modules.
3721 # It also needs to be passed to the linker after ${libname}.${libext}
3722 # because the latter might contain incomplete modules (such as the 'error'
3723 # module whose dependency to 'progname' is voluntarily omitted).
3724 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3726 local_ldadd_before=' libtests.a'
3727 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3729 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3731 if $use_libtests; then
3732 echo "libtests_a_SOURCES ="
3733 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3734 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3735 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3736 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3737 echo "EXTRA_libtests_a_SOURCES ="
3738 # The circular dependency in LDADD requires this.
3739 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3742 # Many test scripts use ${EXEEXT} or ${srcdir}.
3743 # EXEEXT is defined by AC_PROG_CC through autoconf.
3744 # srcdir is defined by autoconf and automake.
3745 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3747 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3748 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3749 echo "# Clean up after Solaris cc."
3751 echo " rm -rf SunWS_cache"
3753 echo "mostlyclean-local: mostlyclean-generic"
3754 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3755 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3756 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3760 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3763 # func_emit_initmacro_start macro_prefix
3764 # emits the first few statements of the gl_INIT macro to standard output.
3765 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3766 func_emit_initmacro_start ()
3768 macro_prefix_arg="$1"
3769 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3770 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3771 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3772 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3774 # Furthermore it avoids an automake error like this when a Makefile.am
3775 # that uses pieces of gnulib also uses $(LIBOBJ):
3776 # automatically discovered file `error.c' should not be explicitly mentioned
3777 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3778 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3779 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3780 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3781 # automatically discovered file `error.c' should not be explicitly mentioned
3782 # We let automake know about the files to be distributed through the
3783 # EXTRA_lib_SOURCES variable.
3784 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3785 # Create data variables for checking the presence of files that are mentioned
3786 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3787 # because we want the check to happen when the configure file is created,
3788 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3789 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3790 # in which to expect them.
3791 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3792 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3796 # func_emit_initmacro_end macro_prefix
3797 # emits the last few statements of the gl_INIT macro to standard output.
3798 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3799 func_emit_initmacro_end ()
3801 macro_prefix_arg="$1"
3802 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3803 # The check is performed only when autoconf is run from the directory where
3804 # the configure.ac resides; if it is run from a different directory, the
3806 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3807 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3808 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3809 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3810 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3814 echo " m4_if(m4_sysval, [0], [],"
3815 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3817 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3818 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3819 echo " m4_popdef([AC_LIBSOURCES])"
3820 echo " m4_popdef([AC_REPLACE_FUNCS])"
3821 echo " m4_popdef([AC_LIBOBJ])"
3822 echo " AC_CONFIG_COMMANDS_PRE(["
3823 echo " ${macro_prefix_arg}_libobjs="
3824 echo " ${macro_prefix_arg}_ltlibobjs="
3825 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3826 echo " # Remove the extension."
3827 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3828 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3829 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3830 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3833 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3834 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3838 # func_emit_initmacro_done macro_prefix sourcebase
3839 # emits a few statements after the gl_INIT macro to standard output.
3840 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3841 # - sourcebase directory relative to destdir where to place source code
3842 func_emit_initmacro_done ()
3844 macro_prefix_arg="$1"
3847 echo "# Like AC_LIBOBJ, except that the module name goes"
3848 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3849 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3850 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3851 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3854 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3855 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3856 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3857 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3858 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3861 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3862 echo "# expected is derived from the gnulib-tool parameterization,"
3863 echo "# and alloca is special cased (for the alloca-opt module)."
3864 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3865 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3866 echo " m4_foreach([_gl_NAME], [\$1], ["
3867 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3868 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3869 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3875 # func_emit_autoconf_snippet indentation
3876 # emits the autoconf snippet of a module.
3878 # - local_gnulib_dir from --local-dir
3879 # - modcache true or false, from --cache-modules/--no-cache-modules
3880 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3881 # - sed_replace_include_guard_prefix
3882 # sed expression for resolving ${gl_include_guard_prefix}
3883 # - module the module name
3884 # - toplevel true or false. 'false' means a subordinate use of
3886 # - disable_libtool true or false. It tells whether to disable libtool
3887 # handling even if it has been specified through the
3888 # command line options.
3889 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3891 # - indentation spaces to prepend on each line
3892 func_emit_autoconf_snippet ()
3894 if { case $module in
3895 gnumakefile | maintainer-makefile)
3896 # These modules are meant to be used only in the top-level directory.
3902 func_get_autoconf_snippet "$module" \
3903 | sed -e '/^$/d;' -e "s/^/$indentation/" \
3904 -e "$sed_replace_build_aux" \
3905 -e "$sed_replace_include_guard_prefix" \
3906 | { if $disable_libtool; then
3907 sed -e 's/\$gl_cond_libtool/false/g' \
3908 -e 's/gl_libdeps/gltests_libdeps/g' \
3909 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3914 | { if $disable_gettext; then
3915 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
3920 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
3921 echo 'changequote(,)dnl'
3922 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3923 echo 'changequote([, ])dnl'
3924 echo 'AC_SUBST([LTALLOCA])'
3929 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
3930 # collects and emit the autoconf snippets of a set of modules.
3932 # - local_gnulib_dir from --local-dir
3933 # - modcache true or false, from --cache-modules/--no-cache-modules
3934 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3935 # - sed_replace_include_guard_prefix
3936 # sed expression for resolving ${gl_include_guard_prefix}
3937 # - modules the list of modules.
3938 # - verifier one of func_verify_module, func_verify_nontests_module,
3939 # func_verify_tests_module. It selects the subset of
3940 # $modules to consider.
3941 # - toplevel true or false. 'false' means a subordinate use of
3943 # - disable_libtool true or false. It tells whether to disable libtool
3944 # handling even if it has been specified through the
3945 # command line options.
3946 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3948 func_emit_autoconf_snippets ()
3952 disable_libtool="$4"
3953 disable_gettext="$5"
3954 if test "$cond_dependencies" = true; then
3955 for m in $modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
3956 # Emit the autoconf code for the unconditional modules.
3957 for module in $1; do
3959 if test -n "$module"; then
3960 if func_cond_module_p "$module"; then
3963 func_emit_autoconf_snippet " "
3967 # Initialize the shell variables indicating that the modules are enabled.
3968 for module in $1; do
3970 if test -n "$module"; then
3971 if func_cond_module_p "$module"; then
3972 func_module_shellvar_name "$module"
3973 echo " $shellvar=false"
3977 # Emit the autoconf code for the conditional modules, each in a separate
3978 # function. This makes it possible to support cycles among conditional
3980 for module in $1; do
3982 if test -n "$module"; then
3983 if func_cond_module_p "$module"; then
3984 func_module_shellfunc_name "$module"
3985 func_module_shellvar_name "$module"
3986 echo " $shellfunc ()"
3988 echo " if ! \$$shellvar; then"
3989 func_emit_autoconf_snippet " "
3990 echo " $shellvar=true"
3991 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3992 # Intersect $deps with the modules list $1.
3993 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
3994 for dep in $deps; do
3995 if func_cond_module_p "$dep"; then
3996 func_module_shellfunc_name "$dep"
3997 func_cond_module_condition "$module" "$dep"
3998 if test "$condition" != true; then
3999 echo " if $condition; then"
4006 # The autoconf code for $dep has already been emitted above and
4007 # therefore is already executed when this function is run.
4016 # Emit the dependencies from the unconditional to the conditional modules.
4017 for module in $1; do
4019 if test -n "$module"; then
4020 if func_cond_module_p "$module"; then
4023 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4024 # Intersect $deps with the modules list $1.
4025 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4026 for dep in $deps; do
4027 if func_cond_module_p "$dep"; then
4028 func_module_shellfunc_name "$dep"
4029 func_cond_module_condition "$module" "$dep"
4030 if test "$condition" != true; then
4031 echo " if $condition; then"
4038 # The autoconf code for $dep has already been emitted above and
4039 # therefore is already executed when this code is run.
4046 # Define the Automake conditionals.
4047 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4048 for module in $1; do
4050 if test -n "$module"; then
4051 if func_cond_module_p "$module"; then
4052 func_module_conditional_name "$module"
4053 func_module_shellvar_name "$module"
4054 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4059 # Ignore the conditions, and enable all modules unconditionally.
4060 for module in $1; do
4062 if test -n "$module"; then
4063 func_emit_autoconf_snippet " "
4069 # func_import modules
4070 # Uses also the variables
4071 # - mode import or add-import or remove-import or update
4072 # - destdir target directory
4073 # - local_gnulib_dir from --local-dir
4074 # - modcache true or false, from --cache-modules/--no-cache-modules
4075 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4076 # - libname library name
4077 # - supplied_libname true if --lib was given, blank otherwise
4078 # - sourcebase directory relative to destdir where to place source code
4079 # - m4base directory relative to destdir where to place *.m4 macros
4080 # - pobase directory relative to destdir where to place *.po files
4081 # - docbase directory relative to destdir where to place doc files
4082 # - testsbase directory relative to destdir where to place unit test code
4083 # - auxdir directory relative to destdir where to place build aux files
4084 # - inctests true if --with-tests was given, blank otherwise
4085 # - incobsolete true if --with-obsolete was given, blank otherwise
4086 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4087 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4089 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4091 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4093 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4094 # - avoidlist list of modules to avoid, from --avoid
4095 # - cond_dependencies true if --conditional-dependencies was given, false if
4096 # --no-conditional-dependencies was given, blank otherwise
4097 # - lgpl yes or a number if library's license shall be LGPL,
4099 # - makefile_name from --makefile-name
4100 # - libtool true if --libtool was given, false if --no-libtool was
4101 # given, blank otherwise
4102 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4103 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4104 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4105 # - witness_c_macro from --witness-c-macro
4106 # - vc_files true if --vc-files was given, false if --no-vc-files was
4107 # given, blank otherwise
4108 # - autoconf_minversion minimum supported autoconf version
4109 # - doit : if actions shall be executed, false if only to be printed
4110 # - symbolic true if files should be symlinked, copied otherwise
4111 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4113 # - do_copyrights true if copyright notices in files should be replaced,
4117 # Get the cached settings.
4118 # In 'import' mode, we read them only for the purpose of knowing the old
4119 # installed file list, and don't use them as defaults.
4120 cached_local_gnulib_dir=
4121 cached_specified_modules=
4123 cached_inc_cxx_tests=
4124 cached_inc_longrunning_tests=
4125 cached_inc_privileged_tests=
4126 cached_inc_unportable_tests=
4127 cached_inc_all_tests=
4137 cached_makefile_name=
4138 cached_cond_dependencies=
4140 cached_macro_prefix=
4142 cached_witness_c_macro=
4145 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4146 cached_libtool=false
4152 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
4162 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4164 /gl_WITH_OBSOLETE/ {
4165 s,^.*$,cached_incobsolete=true,p
4167 /gl_WITH_CXX_TESTS/ {
4168 s,^.*$,cached_inc_cxx_tests=true,p
4170 /gl_WITH_LONGRUNNING_TESTS/ {
4171 s,^.*$,cached_inc_longrunning_tests=true,p
4173 /gl_WITH_PRIVILEGED_TESTS/ {
4174 s,^.*$,cached_inc_privileged_tests=true,p
4176 /gl_WITH_UNPORTABLE_TESTS/ {
4177 s,^.*$,cached_inc_unportable_tests=true,p
4179 /gl_WITH_ALL_TESTS/ {
4180 s,^.*$,cached_inc_all_tests=true,p
4183 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4186 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4189 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4192 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4195 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4198 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4201 s,^.*$,cached_inctests=true,p
4204 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4207 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4210 s,^.*$,cached_lgpl=yes,p
4212 /gl_MAKEFILE_NAME(/ {
4213 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4215 /gl_CONDITIONAL_DEPENDENCIES/ {
4216 s,^.*$,cached_cond_dependencies=true,p
4219 s,^.*$,cached_libtool=true,p
4221 /gl_MACRO_PREFIX(/ {
4222 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4225 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4227 /gl_WITNESS_C_MACRO(/ {
4228 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4231 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4233 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4234 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4239 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4240 s,^.*$,cached_files=",p
4253 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4257 if test "$mode" = import; then
4258 # In 'import' mode, the new set of specified modules overrides the cached
4259 # set of modules. Ignore the cached settings.
4260 specified_modules="$1"
4262 # Merge the cached settings with the specified ones.
4263 # The m4base must be the same as expected from the pathname.
4264 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4265 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4267 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
4268 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4269 if test -z "$local_gnulib_dir"; then
4270 if test -n "$cached_local_gnulib_dir"; then
4273 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4275 case "$cached_local_gnulib_dir" in
4277 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4279 func_relconcat "$destdir" "$cached_local_gnulib_dir"
4280 local_gnulib_dir="$relconcat" ;;
4287 # Append the cached and the specified module names. So that
4288 # "gnulib-tool --add-import foo" means to add the module foo.
4289 specified_modules="$cached_specified_modules $1"
4292 # Take the cached module names, minus the specified module names.
4294 if $have_associative; then
4295 # Use an associative array, for O(N) worst-case run time.
4296 declare -A to_remove
4298 eval 'to_remove[$m]=yes'
4300 for module in $cached_specified_modules; do
4301 if eval 'test -z "${to_remove[$module]}"'; then
4302 func_append specified_modules "$module "
4306 # This loop has O(N²) worst-case run time.
4307 for module in $cached_specified_modules; do
4310 if test "$m" = "$module"; then
4315 if test -z "$to_remove"; then
4316 func_append specified_modules "$module "
4322 # Take the cached module names. There are no specified module names.
4323 specified_modules="$cached_specified_modules"
4326 # Included obsolete modules among the dependencies if specified either way.
4327 if test -z "$incobsolete"; then
4328 incobsolete="$cached_incobsolete"
4330 # Included special kinds of tests modules among the dependencies if specified
4332 if test -z "$inc_cxx_tests"; then
4333 inc_cxx_tests="$cached_inc_cxx_tests"
4335 if test -z "$inc_longrunning_tests"; then
4336 inc_longrunning_tests="$cached_inc_longrunning_tests"
4338 if test -z "$inc_privileged_tests"; then
4339 inc_privileged_tests="$cached_inc_privileged_tests"
4341 if test -z "$inc_unportable_tests"; then
4342 inc_unportable_tests="$cached_inc_unportable_tests"
4344 if test -z "$inc_all_tests"; then
4345 inc_all_tests="$cached_inc_all_tests"
4347 # Append the cached and the specified avoidlist. This is probably better
4348 # than dropping the cached one when --avoid is specified at least once.
4349 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4350 avoidlist=`echo $avoidlist`
4352 # The sourcebase defaults to the cached one.
4353 if test -z "$sourcebase"; then
4354 sourcebase="$cached_sourcebase"
4355 if test -z "$sourcebase"; then
4356 func_fatal_error "missing --source-base option"
4359 # The pobase defaults to the cached one.
4360 if test -z "$pobase"; then
4361 pobase="$cached_pobase"
4363 # The docbase defaults to the cached one.
4364 if test -z "$docbase"; then
4365 docbase="$cached_docbase"
4366 if test -z "$docbase"; then
4367 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."
4370 # The testsbase defaults to the cached one.
4371 if test -z "$testsbase"; then
4372 testsbase="$cached_testsbase"
4373 if test -z "$testsbase"; then
4374 func_fatal_error "missing --tests-base option"
4377 # Require the tests if specified either way.
4378 if test -z "$inctests"; then
4379 inctests="$cached_inctests"
4381 # The libname defaults to the cached one.
4382 if test -z "$supplied_libname"; then
4383 libname="$cached_libname"
4384 if test -z "$libname"; then
4385 func_fatal_error "missing --lib option"
4388 # Require LGPL if specified either way.
4389 if test -z "$lgpl"; then
4392 # The makefile_name defaults to the cached one.
4393 if test -z "$makefile_name"; then
4394 makefile_name="$cached_makefile_name"
4396 # Use conditional dependencies if specified either way.
4397 if test -z "$cond_dependencies"; then
4398 cond_dependencies="$cached_cond_dependencies"
4400 # Use libtool if specified either way, or if guessed.
4401 if test -z "$libtool"; then
4402 if test -n "$cached_m4base"; then
4403 libtool="$cached_libtool"
4405 libtool="$guessed_libtool"
4408 # The macro_prefix defaults to the cached one.
4409 if test -z "$macro_prefix"; then
4410 macro_prefix="$cached_macro_prefix"
4411 if test -z "$macro_prefix"; then
4412 func_fatal_error "missing --macro-prefix option"
4415 # The po_domain defaults to the cached one.
4416 if test -z "$po_domain"; then
4417 po_domain="$cached_po_domain"
4419 # The witness_c_macro defaults to the cached one.
4420 if test -z "$witness_c_macro"; then
4421 witness_c_macro="$cached_witness_c_macro"
4423 # The vc_files defaults to the cached one.
4424 if test -z "$vc_files"; then
4425 vc_files="$cached_vc_files"
4427 # Ensure constraints.
4428 if test "$cond_dependencies" = true && test -n "$inctests"; then
4429 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4433 # --without-*-tests options are not supported here.
4435 excl_longrunning_tests=
4436 excl_privileged_tests=
4437 excl_unportable_tests=
4439 # Canonicalize the list of specified modules.
4440 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4442 # Include all kinds of tests modules if --with-all-tests was specified.
4443 inc_all_direct_tests="$inc_all_tests"
4444 inc_all_indirect_tests="$inc_all_tests"
4446 # Determine final module list.
4447 modules="$specified_modules"
4448 func_modules_transitive_closure
4449 if test $verbose -ge 0; then
4450 func_show_module_list
4452 final_modules="$modules"
4454 # Determine main module list and tests-related module list separately.
4455 func_modules_transitive_closure_separately
4457 # Determine whether a $testsbase/libtests.a is needed.
4458 func_determine_use_libtests
4460 # Add the dummy module to the main module list or to the tests-related module
4462 func_modules_add_dummy_separately
4464 # If --lgpl, verify that the licenses of modules are compatible.
4465 if test -n "$lgpl"; then
4466 license_incompatibilities=
4467 for module in $main_modules; do
4468 license=`func_get_license $module`
4470 'GPLed build tool') ;;
4471 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4476 LGPL | LGPLv2+ | LGPLv3+) ;;
4477 *) func_append license_incompatibilities "$module $license$nl" ;;
4483 *) func_append license_incompatibilities "$module $license$nl" ;;
4486 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4491 if test -n "$license_incompatibilities"; then
4492 # Format the license incompatibilities as a table.
4493 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4494 s,^\(.................................................[^ ]*\) *, \1 ,'
4495 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4496 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4500 # Show banner notice of every module.
4501 modules="$main_modules"
4504 # Determine script to apply to imported library files.
4505 sed_transform_lib_file=
4506 for module in $main_modules; do
4507 if test $module = config-h; then
4508 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4509 sed_transform_lib_file=$sed_transform_lib_file'
4510 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4515 sed_transform_main_lib_file="$sed_transform_lib_file"
4516 if test -n "$do_copyrights"; then
4517 if test -n "$lgpl"; then
4521 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4522 s/GNU General/GNU Lesser General/g
4523 s/General Public License/Lesser General Public License/g
4524 s/Lesser Lesser General Public License/Lesser General Public License/g
4528 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4529 s/GNU General/GNU Lesser General/g
4530 s/General Public License/Lesser General Public License/g
4531 s/Lesser Lesser General Public License/Lesser General Public License/g
4533 s/version [23]\([ ,]\)/version 2.1\1/g
4536 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4540 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4541 s/GNU Lesser General/GNU General/g
4542 s/Lesser General Public License/General Public License/g
4544 s/GNU Library General/GNU General/g
4545 s/Library General Public License/General Public License/g
4547 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4552 # Determine script to apply to auxiliary files that go into $auxdir/.
4553 sed_transform_build_aux_file=
4554 if test -n "$do_copyrights"; then
4556 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4557 s/GNU Lesser General/GNU General/g
4558 s/Lesser General Public License/General Public License/g
4560 s/GNU Library General/GNU General/g
4561 s/Library General Public License/General Public License/g
4563 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4567 # Determine script to apply to library files that go into $testsbase/.
4568 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4569 if test -n "$do_copyrights"; then
4571 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4572 s/GNU Lesser General/GNU General/g
4573 s/Lesser General Public License/General Public License/g
4575 s/GNU Library General/GNU General/g
4576 s/Library General Public License/General Public License/g
4578 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4582 # Determine the final file lists.
4583 func_modules_to_filelist_separately
4586 || func_fatal_error "refusing to do nothing"
4588 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4589 new_files="$files m4/gnulib-tool.m4"
4590 old_files="$cached_files"
4591 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4592 func_append old_files " m4/gnulib-tool.m4"
4595 rewritten='%REWRITTEN%'
4596 sed_rewrite_old_files="\
4597 s,^build-aux/,$rewritten$auxdir/,
4598 s,^doc/,$rewritten$cached_docbase/,
4599 s,^lib/,$rewritten$cached_sourcebase/,
4600 s,^m4/,$rewritten$cached_m4base/,
4601 s,^tests/,$rewritten$cached_testsbase/,
4602 s,^tests=lib/,$rewritten$cached_testsbase/,
4605 sed_rewrite_new_files="\
4606 s,^build-aux/,$rewritten$auxdir/,
4607 s,^doc/,$rewritten$docbase/,
4608 s,^lib/,$rewritten$sourcebase/,
4609 s,^m4/,$rewritten$m4base/,
4610 s,^tests/,$rewritten$testsbase/,
4611 s,^tests=lib/,$rewritten$testsbase/,
4615 # Create directories.
4616 { echo "$sourcebase"
4618 if test -n "$pobase"; then
4621 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4622 if test -n "$docfiles"; then
4625 if test -n "$inctests"; then
4629 for f in $files; do echo $f; done \
4630 | sed -e "$sed_rewrite_new_files" \
4631 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4634 { # Rearrange file descriptors. Needed because "while ... done < ..."
4635 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4636 exec 5<&0 < "$tmp"/dirs
4638 if test ! -d "$destdir/$d"; then
4640 echo "Creating directory $destdir/$d"
4641 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4643 echo "Create directory $destdir/$d"
4650 # Copy files or make symbolic links. Remove obsolete files.
4654 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4655 # representing the files according to the last gnulib-tool invocation.
4656 for f in $old_files; do echo $f; done \
4657 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4660 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4661 # representing the files after this gnulib-tool invocation.
4662 for f in $new_files; do echo $f; done \
4663 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4666 # First the files that are in old-files, but not in new-files:
4667 sed_take_first_column='s,'"$delimiter"'.*,,'
4668 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4669 # Remove the file. Do nothing if the user already removed it.
4670 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4672 echo "Removing file $g (backup in ${g}~)"
4673 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4675 echo "Remove file $g (backup in ${g}~)"
4677 func_append removed_files "$g$nl"
4680 # func_add_or_update handles a file that ought to be present afterwards.
4682 # - f the original file name
4683 # - g the rewritten file name
4684 # - already_present nonempty if the file should already exist, empty
4686 func_add_or_update ()
4690 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4692 func_dest_tmpfilename "$g"
4693 func_lookup_file "$f"
4694 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4695 if test -n "$sed_transform_main_lib_file"; then
4698 sed -e "$sed_transform_main_lib_file" \
4699 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4703 if test -n "$sed_transform_build_aux_file"; then
4706 sed -e "$sed_transform_build_aux_file" \
4707 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4711 if test -n "$sed_transform_testsrelated_lib_file"; then
4714 sed -e "$sed_transform_testsrelated_lib_file" \
4715 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4719 if test -f "$destdir/$g"; then
4720 # The file already exists.
4724 # Don't protest if the file should be there but isn't: it happens
4725 # frequently that developers don't put autogenerated files under version control.
4727 func_append added_files "$g$nl"
4731 # Then the files that are in new-files, but not in old-files:
4732 sed_take_last_column='s,^.*'"$delimiter"',,'
4734 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4735 | sed -e "$sed_take_last_column" \
4736 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4737 { # Rearrange file descriptors. Needed because "while ... done < ..."
4738 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4739 exec 5<&0 < "$tmp"/added-files
4745 # Then the files that are in new-files and in old-files:
4746 already_present=true
4747 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4748 | sed -e "$sed_take_last_column" \
4749 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-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"/kept-files
4759 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4760 actioncmd="gnulib-tool --import"
4761 func_append actioncmd " --dir=$destdir"
4762 if test -n "$local_gnulib_dir"; then
4763 func_append actioncmd " --local-dir=$local_gnulib_dir"
4765 func_append actioncmd " --lib=$libname"
4766 func_append actioncmd " --source-base=$sourcebase"
4767 func_append actioncmd " --m4-base=$m4base"
4768 if test -n "$pobase"; then
4769 func_append actioncmd " --po-base=$pobase"
4771 func_append actioncmd " --doc-base=$docbase"
4772 func_append actioncmd " --tests-base=$testsbase"
4773 func_append actioncmd " --aux-dir=$auxdir"
4774 if test -n "$inctests"; then
4775 func_append actioncmd " --with-tests"
4777 if test -n "$incobsolete"; then
4778 func_append actioncmd " --with-obsolete"
4780 if test -n "$inc_cxx_tests"; then
4781 func_append actioncmd " --with-c++-tests"
4783 if test -n "$inc_longrunning_tests"; then
4784 func_append actioncmd " --with-longrunning-tests"
4786 if test -n "$inc_privileged_tests"; then
4787 func_append actioncmd " --with-privileged-tests"
4789 if test -n "$inc_unportable_tests"; then
4790 func_append actioncmd " --with-unportable-tests"
4792 if test -n "$inc_all_tests"; then
4793 func_append actioncmd " --with-all-tests"
4795 for module in $avoidlist; do
4796 func_append actioncmd " --avoid=$module"
4798 if test -n "$lgpl"; then
4799 if test "$lgpl" = yes; then
4800 func_append actioncmd " --lgpl"
4802 func_append actioncmd " --lgpl=$lgpl"
4805 if test -n "$makefile_name"; then
4806 func_append actioncmd " --makefile-name=$makefile_name"
4808 if test "$cond_dependencies" = true; then
4809 func_append actioncmd " --conditional-dependencies"
4811 func_append actioncmd " --no-conditional-dependencies"
4813 if test "$libtool" = true; then
4814 func_append actioncmd " --libtool"
4816 func_append actioncmd " --no-libtool"
4818 func_append actioncmd " --macro-prefix=$macro_prefix"
4819 if test -n "$po_domain"; then
4820 func_append actioncmd " --po-domain=$po_domain"
4822 if test -n "$witness_c_macro"; then
4823 func_append actioncmd " --witness-c-macro=$witness_c_macro"
4825 if test -n "$vc_files"; then
4826 if test "$vc_files" = true; then
4827 func_append actioncmd " --vc-files"
4829 func_append actioncmd " --no-vc-files"
4832 func_append actioncmd " `echo $specified_modules`"
4834 # Determine include_guard_prefix.
4835 func_compute_include_guard_prefix
4837 # Default the makefile name to Makefile.am.
4838 if test -n "$makefile_name"; then
4839 makefile_am=$makefile_name
4841 makefile_am=Makefile.am
4844 # Create normal Makefile.ams.
4847 # Setup list of Makefile.am edits that are to be performed afterwards.
4848 # Some of these edits apply to files that we will generate; others are
4849 # under the responsibility of the developer.
4851 # func_note_Makefile_am_edit dir var value
4852 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4854 func_note_Makefile_am_edit ()
4856 makefile_am_edits=`expr $makefile_am_edits + 1`
4857 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4858 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4859 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4861 if test "$makefile_am" = Makefile.am; then
4862 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4863 sourcebase_base=`basename "$sourcebase"`
4864 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4866 if test -n "$pobase"; then
4867 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4868 pobase_base=`basename "$pobase"`
4869 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4871 if test -n "$inctests"; then
4872 if test "$makefile_am" = Makefile.am; then
4873 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4874 testsbase_base=`basename "$testsbase"`
4875 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4878 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4880 # Find the first parent directory of $m4base that contains or will contain
4882 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4884 sed_butlast='s,[^/][^/]*//*$,,'
4885 dir1="${m4base}/"; dir2=""
4886 while test -n "$dir1" \
4887 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4888 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4889 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4890 || { test -n "$inctests" \
4891 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4892 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4893 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4894 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4896 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4899 # Create library makefile.
4900 func_dest_tmpfilename $sourcebase/$makefile_am
4901 destfile="$sourcebase/$makefile_am"
4902 modules="$main_modules"
4903 func_emit_lib_Makefile_am > "$tmpfile"
4904 if test -f "$destdir"/$sourcebase/$makefile_am; then
4905 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4909 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4910 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4911 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4913 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4919 echo "Creating $sourcebase/$makefile_am"
4920 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4922 echo "Create $sourcebase/$makefile_am"
4925 func_append added_files "$sourcebase/$makefile_am$nl"
4928 # Create po/ directory.
4929 if test -n "$pobase"; then
4930 # Create po makefile and auxiliary files.
4931 for file in Makefile.in.in remove-potcdate.sin; do
4932 func_dest_tmpfilename $pobase/$file
4933 func_lookup_file build-aux/po/$file
4934 cat "$lookedup_file" > "$tmpfile"
4935 if test -f "$destdir"/$pobase/$file; then
4936 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4940 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4941 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4942 mv -f "$tmpfile" "$destdir"/$pobase/$file
4944 echo "Update $pobase/$file (backup in $pobase/$file~)"
4950 echo "Creating $pobase/$file"
4951 mv -f "$tmpfile" "$destdir"/$pobase/$file
4953 echo "Create $pobase/$file"
4956 func_append added_files "$pobase/$file$nl"
4959 # Create po makefile parameterization, part 1.
4960 func_dest_tmpfilename $pobase/Makevars
4961 func_emit_po_Makevars > "$tmpfile"
4962 if test -f "$destdir"/$pobase/Makevars; then
4963 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4967 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4968 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4969 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4971 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4977 echo "Creating $pobase/Makevars"
4978 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4980 echo "Create $pobase/Makevars"
4983 func_append added_files "$pobase/Makevars$nl"
4985 # Create po makefile parameterization, part 2.
4986 func_dest_tmpfilename $pobase/POTFILES.in
4987 func_emit_po_POTFILES_in > "$tmpfile"
4988 if test -f "$destdir"/$pobase/POTFILES.in; then
4989 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4993 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4994 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4995 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4997 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5003 echo "Creating $pobase/POTFILES.in"
5004 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5006 echo "Create $pobase/POTFILES.in"
5009 func_append added_files "$pobase/POTFILES.in$nl"
5012 TP_URL="http://translationproject.org/latest/"
5013 TP_RSYNC_URI="translationproject.org::tp/latest/"
5015 echo "Fetching gnulib PO files from $TP_URL"
5016 (cd "$destdir"/$pobase \
5017 && { # Prefer rsync over wget if it is available, since it consumes
5018 # less network bandwidth, due to compression.
5019 if type rsync 2>/dev/null | grep / > /dev/null; then
5020 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
5022 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
5027 echo "Fetch gnulib PO files from $TP_URL"
5029 # Create po/LINGUAS.
5031 func_dest_tmpfilename $pobase/LINGUAS
5032 (cd "$destdir"/$pobase \
5033 && { echo '# Set of available languages.'
5034 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5037 if test -f "$destdir"/$pobase/LINGUAS; then
5038 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
5041 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5042 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5043 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5046 echo "Creating $pobase/LINGUAS"
5047 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5048 func_append added_files "$pobase/LINGUAS$nl"
5051 if test -f "$destdir"/$pobase/LINGUAS; then
5052 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5054 echo "Create $pobase/LINGUAS"
5059 # Create m4/gnulib-cache.m4.
5060 func_dest_tmpfilename $m4base/gnulib-cache.m4
5062 func_emit_copyright_notice
5064 echo "# This file represents the specification of how gnulib-tool is used."
5065 echo "# It acts as a cache: It is written and read by gnulib-tool."
5066 echo "# In projects that use version control, this file is meant to be put under"
5067 echo "# version control, like the configure.ac and various Makefile.am files."
5070 echo "# Specification in the form of a command-line invocation:"
5073 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5074 # Store the local_gnulib_dir relative to destdir.
5075 case "$local_gnulib_dir" in
5077 relative_local_gnulib_dir="$local_gnulib_dir" ;;
5080 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
5082 # destdir, local_gnulib_dir are both relative.
5083 func_relativize "$destdir" "$local_gnulib_dir"
5084 relative_local_gnulib_dir="$reldir" ;;
5087 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
5089 echo "$specified_modules" | sed -e 's/^/ /g'
5091 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5092 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5093 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5094 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5095 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5096 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5097 echo "gl_AVOID([$avoidlist])"
5098 echo "gl_SOURCE_BASE([$sourcebase])"
5099 echo "gl_M4_BASE([$m4base])"
5100 echo "gl_PO_BASE([$pobase])"
5101 echo "gl_DOC_BASE([$docbase])"
5102 echo "gl_TESTS_BASE([$testsbase])"
5103 test -z "$inctests" || echo "gl_WITH_TESTS"
5104 echo "gl_LIB([$libname])"
5105 if test -n "$lgpl"; then
5106 if test "$lgpl" = yes; then
5109 echo "gl_LGPL([$lgpl])"
5112 echo "gl_MAKEFILE_NAME([$makefile_name])"
5113 if test "$cond_dependencies" = true; then
5114 echo "gl_CONDITIONAL_DEPENDENCIES"
5116 if test "$libtool" = true; then
5119 echo "gl_MACRO_PREFIX([$macro_prefix])"
5120 echo "gl_PO_DOMAIN([$po_domain])"
5121 echo "gl_WITNESS_C_DOMAIN([$witness_c_macro])"
5122 if test -n "$vc_files"; then
5123 echo "gl_VC_FILES([$vc_files])"
5126 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5127 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
5131 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5132 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5133 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5135 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5139 echo "# gnulib-cache.m4 ends here"
5146 echo "Creating $m4base/gnulib-cache.m4"
5147 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5149 echo "Create $m4base/gnulib-cache.m4"
5155 # Create m4/gnulib-comp.m4.
5156 func_dest_tmpfilename $m4base/gnulib-comp.m4
5158 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5159 func_emit_copyright_notice
5161 echo "# This file represents the compiled summary of the specification in"
5162 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5163 echo "# to be invoked from configure.ac."
5164 echo "# In projects that use version control, this file can be treated like"
5165 echo "# other built files."
5168 echo "# This macro should be invoked from $configure_ac, in the section"
5169 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5170 echo "# any checks for libraries, header files, types and library functions."
5171 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5173 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5174 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5175 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5176 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5177 echo " AC_REQUIRE([gl_PROG_AR_RANLIB])"
5178 if test -n "$uses_subdirs"; then
5179 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5181 for module in $final_modules; do
5183 if test -n "$module"; then
5184 echo "# Code from module $module:"
5185 func_get_autoconf_early_snippet "$module"
5188 | sed -e '/^$/d;' -e 's/^/ /'
5191 echo "# This macro should be invoked from $configure_ac, in the section"
5192 echo "# \"Check for header files, types and library functions\"."
5193 echo "AC_DEFUN([${macro_prefix}_INIT],"
5195 if test "$libtool" = true; then
5196 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5197 echo " gl_cond_libtool=true"
5199 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5200 echo " gl_cond_libtool=false"
5202 echo " gl_ltlibdeps="
5204 if test "$auxdir" != "build-aux"; then
5205 sed_replace_build_aux='
5207 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5208 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5212 sed_replace_build_aux="$sed_noop"
5214 echo " gl_m4_base='$m4base'"
5215 func_emit_initmacro_start $macro_prefix
5216 echo " gl_source_base='$sourcebase'"
5217 if test -n "$witness_c_macro"; then
5218 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5220 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
5221 if test -n "$witness_c_macro"; then
5222 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5224 echo " # End of code from modules"
5225 func_emit_initmacro_end $macro_prefix
5226 echo " gltests_libdeps="
5227 echo " gltests_ltlibdeps="
5228 func_emit_initmacro_start ${macro_prefix}tests
5229 echo " gl_source_base='$testsbase'"
5230 # Define a tests witness macro that depends on the package.
5231 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5232 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5233 echo "changequote(,)dnl"
5234 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"
5235 echo "changequote([, ])dnl"
5236 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5237 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5238 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5239 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
5240 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5241 func_emit_initmacro_end ${macro_prefix}tests
5242 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5243 # created using libtool, because libtool already handles the dependencies.
5244 if test "$libtool" != true; then
5245 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5246 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5247 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5248 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5249 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5251 if $use_libtests; then
5252 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5253 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5256 func_emit_initmacro_done $macro_prefix $sourcebase
5257 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5259 echo "# This macro records the list of files which have been installed by"
5260 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5261 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5262 echo "$files" | sed -e 's,^, ,'
5265 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5266 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
5270 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5271 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5272 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5274 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5278 echo "# gnulib-comp.m4 ends here"
5285 echo "Creating $m4base/gnulib-comp.m4"
5286 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5288 echo "Create $m4base/gnulib-comp.m4"
5294 if test -n "$inctests"; then
5295 # Create tests makefile.
5296 func_dest_tmpfilename $testsbase/$makefile_am
5297 destfile="$testsbase/$makefile_am"
5298 modules="$testsrelated_modules"
5299 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5300 if test -f "$destdir"/$testsbase/$makefile_am; then
5301 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
5305 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5306 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5307 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5309 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5315 echo "Creating $testsbase/$makefile_am"
5316 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5318 echo "Create $testsbase/$makefile_am"
5321 func_append added_files "$testsbase/$makefile_am$nl"
5325 if test "$vc_files" != false; then
5326 # Update the .cvsignore and .gitignore files.
5327 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5328 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5329 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5330 echo "$m4base/|A|gnulib-comp.m4"
5331 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5332 { # Rearrange file descriptors. Needed because "while ... done < ..."
5333 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5334 exec 5<&0 < "$tmp"/fileset-changes
5335 func_update_ignorelist ()
5338 if test "$ignore" = .gitignore; then
5339 # In a .gitignore file, "foo" applies to the current directory and all
5340 # subdirectories, whereas "/foo" applies to the current directory only.
5343 doubly_escaped_anchor='\\/'
5347 doubly_escaped_anchor=''
5349 if test -f "$destdir/$dir$ignore"; then
5350 if test -n "$dir_added" || test -n "$dir_removed"; then
5351 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5352 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5353 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5354 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5355 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
5357 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5359 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5360 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5361 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5362 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5363 } > "$tmp"/sed-ignore-removed
5364 { cat "$destdir/$dir$ignore"~
5365 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5366 } | sed -f "$tmp"/sed-ignore-removed \
5367 > "$destdir/$dir$ignore"
5369 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5374 if test -n "$dir_added"; then
5376 echo "Creating $destdir/$dir$ignore"
5378 if test "$ignore" = .cvsignore; then
5380 # Automake generates Makefile rules that create .dirstamp files.
5383 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5384 } > "$destdir/$dir$ignore"
5386 echo "Create $destdir/$dir$ignore"
5396 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5397 func_update_ignorelist .cvsignore
5399 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5400 func_update_ignorelist .gitignore
5407 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5408 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5409 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5410 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5411 if test "$next_dir" != "$last_dir"; then
5412 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5413 last_dir="$next_dir"
5418 A) func_append last_dir_added "$file$nl";;
5419 R) func_append last_dir_removed "$file$nl";;
5422 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5429 echo "You may need to add #include directives for the following .h files."
5430 # Intersect $specified_modules and $main_modules
5431 # (since $specified_modules is not necessarily of subset of $main_modules
5432 # - some may have been skipped through --avoid, and since the elements of
5433 # $main_modules but not in $specified_modules can go away without explicit
5434 # notice - through changes in the module dependencies).
5435 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5436 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5437 # First the #include <...> directives without #ifs, sorted for convenience,
5438 # then the #include "..." directives without #ifs, sorted for convenience,
5439 # then the #include directives that are surrounded by #ifs. Not sorted.
5440 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5441 include_directive=`func_get_include_directive "$module"`
5442 case "$nl$include_directive" in
5444 echo "$include_directive" 1>&5
5447 echo "$include_directive" | grep -v 'include "' 1>&6
5448 echo "$include_directive" | grep 'include "' 1>&7
5451 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5453 LC_ALL=C sort -u "$tmp"/include-angles
5454 LC_ALL=C sort -u "$tmp"/include-quotes
5455 cat "$tmp"/include-if
5456 ) | sed -e '/^$/d' -e 's/^/ /'
5457 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5459 for module in $main_modules; do
5460 func_get_link_directive "$module"
5462 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5463 if test `wc -l < "$tmp"/link` != 0; then
5465 echo "You may need to use the following Makefile variables when linking."
5466 echo "Use them in <program>_LDADD when linking a program, or"
5467 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5473 echo "Don't forget to"
5474 if test "$makefile_am" = Makefile.am; then
5475 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5477 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5479 if test -n "$pobase"; then
5480 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5482 if test -n "$inctests"; then
5483 if test "$makefile_am" = Makefile.am; then
5484 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5486 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5490 while test $edit != $makefile_am_edits; do
5491 edit=`expr $edit + 1`
5492 eval dir=\"\$makefile_am_edit${edit}_dir\"
5493 eval var=\"\$makefile_am_edit${edit}_var\"
5494 eval val=\"\$makefile_am_edit${edit}_val\"
5495 if test -n "$var"; then
5496 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5499 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
5500 position_early_after=AC_PROG_CC_STDC
5502 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
5503 position_early_after=AC_PROG_CC_C99
5505 position_early_after=AC_PROG_CC
5508 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
5509 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5512 # func_create_testdir testdir modules
5514 # - local_gnulib_dir from --local-dir
5515 # - modcache true or false, from --cache-modules/--no-cache-modules
5516 # - auxdir directory relative to destdir where to place build aux files
5517 # - inctests true if tests should be included, blank otherwise
5518 # - incobsolete true if obsolete modules among dependencies should be
5519 # included, blank otherwise
5520 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5522 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5524 # - excl_privileged_tests true if tests that require root privileges should be
5525 # excluded, blank otherwise
5526 # - excl_unportable_tests true if tests that fail on some platforms should be
5527 # excluded, blank otherwise
5528 # - single_configure true if a single configure file should be generated,
5529 # false for a separate configure file for the tests
5530 # - avoidlist list of modules to avoid
5531 # - cond_dependencies true if --conditional-dependencies was given, false if
5532 # --no-conditional-dependencies was given, blank otherwise
5533 # - libtool true if --libtool was given, false if --no-libtool was
5534 # given, blank otherwise
5535 # - symbolic true if files should be symlinked, copied otherwise
5536 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
5538 func_create_testdir ()
5542 if test -z "$modules"; then
5543 # All modules together.
5544 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5545 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5546 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5547 modules=`func_all_modules`
5548 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5550 specified_modules="$modules"
5552 # Canonicalize the list of specified modules.
5553 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5555 # Unlike in func_import, here we want to include all kinds of tests for the
5556 # directly specified modules, but not for dependencies.
5557 inc_all_direct_tests=true
5558 inc_all_indirect_tests="$inc_all_tests"
5560 # Check that the license of every module is consistent with the license of
5562 saved_inctests="$inctests"
5563 # When computing transitive closures, don't consider $module to depend on
5564 # $module-tests. Need this because tests are implicitly GPL and may depend
5565 # on GPL modules - therefore we don't want a warning in this case.
5567 for requested_module in $specified_modules; do
5568 requested_license=`func_get_license "$requested_module"`
5569 if test "$requested_license" != GPL; then
5570 # Here we use func_modules_transitive_closure, not just
5571 # func_get_dependencies, so that we also detect weird situations like
5572 # an LGPL module which depends on a GPLed build tool module which depends
5574 modules="$requested_module"
5575 func_modules_transitive_closure
5576 for module in $modules; do
5577 license=`func_get_license "$module"`
5579 'GPLed build tool') ;;
5580 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5582 case "$requested_license" in
5585 GPLv2+ | LGPLv2+) ;;
5586 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5592 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5598 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5607 inctests="$saved_inctests"
5609 # Subdirectory names.
5620 # Determine final module list.
5621 modules="$specified_modules"
5622 func_modules_transitive_closure
5623 if test $verbose -ge 0; then
5624 func_show_module_list
5626 final_modules="$modules"
5628 if $single_configure; then
5629 # Determine main module list and tests-related module list separately.
5630 func_modules_transitive_closure_separately
5633 if $single_configure; then
5634 # Determine whether a $testsbase/libtests.a is needed.
5635 func_determine_use_libtests
5638 # Add the dummy module if needed.
5639 if $single_configure; then
5640 func_modules_add_dummy_separately
5642 func_modules_add_dummy
5645 # Show banner notice of every module.
5646 if $single_configure; then
5647 modules="$main_modules"
5653 # Determine final file list.
5654 if $single_configure; then
5655 func_modules_to_filelist_separately
5657 func_modules_to_filelist
5658 if test $verbose -ge 0; then
5660 echo "$files" | sed -e 's/^/ /'
5663 # Add files for which the copy in gnulib is newer than the one that
5664 # "automake --add-missing --copy" would provide.
5665 files="$files build-aux/config.guess"
5666 files="$files build-aux/config.sub"
5667 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5669 rewritten='%REWRITTEN%'
5670 sed_rewrite_files="\
5671 s,^build-aux/,$rewritten$auxdir/,
5672 s,^doc/,$rewritten$docbase/,
5673 s,^lib/,$rewritten$sourcebase/,
5674 s,^m4/,$rewritten$m4base/,
5675 s,^tests/,$rewritten$testsbase/,
5676 s,^tests=lib/,$rewritten$testsbase/,
5680 # Create directories.
5681 for f in $files; do echo $f; done \
5682 | sed -e "$sed_rewrite_files" \
5683 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5684 | LC_ALL=C sort -u \
5686 { # Rearrange file descriptors. Needed because "while ... done < ..."
5687 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5688 exec 5<&0 < "$tmp"/dirs
5690 mkdir -p "$testdir/$d"
5695 # Copy files or make symbolic links.
5697 for f in $files; do echo $f; done \
5698 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
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"/files
5706 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5708 func_lookup_file "$f"
5709 if test -n "$lookedup_tmp"; then
5710 cp -p "$lookedup_file" "$testdir/$g"
5712 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5713 if { test -n "$symbolic" \
5714 || { test -n "$lsymbolic" \
5715 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5716 func_ln "$lookedup_file" "$testdir/$g"
5718 cp -p "$lookedup_file" "$testdir/$g"
5725 # Determine include_guard_prefix.
5726 func_compute_include_guard_prefix
5728 # Create Makefile.ams that are for testing.
5731 # No special edits are needed.
5734 # Create $sourcebase/Makefile.am.
5735 mkdir -p "$testdir/$sourcebase"
5736 destfile="$sourcebase/Makefile.am"
5737 if $single_configure; then
5738 modules="$main_modules"
5740 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5741 any_uses_subdirs="$uses_subdirs"
5743 # Create $m4base/Makefile.am.
5744 mkdir -p "$testdir/$m4base"
5745 (echo "## Process this file with automake to produce Makefile.in."
5751 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5754 ) > "$testdir/$m4base/Makefile.am"
5756 subdirs="$sourcebase $m4base"
5757 subdirs_with_configure_ac=""
5759 if false && test -f "$testdir"/$m4base/gettext.m4; then
5760 # Avoid stupid error message from automake:
5761 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5762 mkdir -p "$testdir/po"
5763 (echo "## Process this file with automake to produce Makefile.in."
5764 ) > "$testdir/po/Makefile.am"
5765 func_append subdirs " po"
5768 if test -n "$inctests"; then
5769 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5770 if $single_configure; then
5771 # Create $testsbase/Makefile.am.
5772 destfile="$testsbase/Makefile.am"
5773 modules="$testsrelated_modules"
5774 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
5776 # Viewed from the $testsbase subdirectory, $auxdir is different.
5777 saved_auxdir="$auxdir"
5778 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5779 # Create $testsbase/Makefile.am.
5781 destfile="$testsbase/Makefile.am"
5782 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5783 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5784 # Create $testsbase/configure.ac.
5785 (echo "# Process this file with autoconf to produce a configure script."
5786 echo "AC_INIT([dummy], [0])"
5787 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5788 echo "AM_INIT_AUTOMAKE"
5790 echo "AC_CONFIG_HEADERS([config.h])"
5793 echo "AC_PROG_INSTALL"
5794 echo "AC_PROG_MAKE_SET"
5795 echo "gl_PROG_AR_RANLIB"
5797 if test -n "$uses_subdirs"; then
5798 echo "AM_PROG_CC_C_O"
5801 for module in $modules; do
5803 if test -n "$module"; then
5805 gnumakefile | maintainer-makefile)
5806 # These modules are meant to be used only in the top-level directory.
5809 func_get_autoconf_early_snippet "$module"
5814 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5815 if test "$libtool" = true; then
5816 echo "LT_INIT([win32-dll])"
5817 echo "LT_LANG([C++])"
5818 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5819 echo "gl_cond_libtool=true"
5821 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5822 echo "gl_cond_libtool=false"
5824 echo "gl_ltlibdeps="
5826 # Wrap the set of autoconf snippets into an autoconf macro that is then
5827 # invoked. This is needed because autoconf does not support AC_REQUIRE
5829 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5830 # but we want the AC_REQUIRE to have its normal meaning (provide one
5831 # expansion of the required macro before the current point, and only one
5833 echo "AC_DEFUN([gl_INIT], ["
5834 sed_replace_build_aux='
5836 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5837 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5840 echo "gl_m4_base='../$m4base'"
5841 func_emit_initmacro_start $macro_prefix
5842 # We don't have explicit ordering constraints between the various
5843 # autoconf snippets. It's cleanest to put those of the library before
5844 # those of the tests.
5845 echo "gl_source_base='../$sourcebase'"
5846 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
5847 echo "gl_source_base='.'"
5848 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
5849 func_emit_initmacro_end $macro_prefix
5850 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5851 # created using libtool, because libtool already handles the dependencies.
5852 if test "$libtool" != true; then
5853 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5854 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5855 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5856 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5857 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5860 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5864 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5865 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5866 echo "AH_TOP([#include \"../config.h\"])"
5868 echo "AC_CONFIG_FILES([Makefile])"
5870 ) > "$testdir/$testsbase/configure.ac"
5871 auxdir="$saved_auxdir"
5872 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5874 func_append subdirs " $testsbase"
5877 # Create Makefile.am.
5878 (echo "## Process this file with automake to produce Makefile.in."
5880 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5882 echo "SUBDIRS = $subdirs"
5884 echo "ACLOCAL_AMFLAGS = -I $m4base"
5885 ) > "$testdir/Makefile.am"
5887 # Create configure.ac.
5888 (echo "# Process this file with autoconf to produce a configure script."
5889 echo "AC_INIT([dummy], [0])"
5890 if test "$auxdir" != "."; then
5891 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5893 echo "AM_INIT_AUTOMAKE"
5895 echo "AC_CONFIG_HEADERS([config.h])"
5898 echo "AC_PROG_INSTALL"
5899 echo "AC_PROG_MAKE_SET"
5901 echo "# For autobuild."
5902 echo "AC_CANONICAL_BUILD"
5903 echo "AC_CANONICAL_HOST"
5905 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5906 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5907 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5908 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5910 echo "gl_PROG_AR_RANLIB"
5912 if test -n "$any_uses_subdirs"; then
5913 echo "AM_PROG_CC_C_O"
5916 for module in $final_modules; do
5917 if $single_configure; then
5920 func_verify_nontests_module
5922 if test -n "$module"; then
5923 func_get_autoconf_early_snippet "$module"
5926 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5927 if test "$libtool" = true; then
5928 echo "LT_INIT([win32-dll])"
5929 echo "LT_LANG([C++])"
5930 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5931 echo "gl_cond_libtool=true"
5933 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5934 echo "gl_cond_libtool=false"
5936 echo "gl_ltlibdeps="
5938 # Wrap the set of autoconf snippets into an autoconf macro that is then
5939 # invoked. This is needed because autoconf does not support AC_REQUIRE
5941 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5942 # but we want the AC_REQUIRE to have its normal meaning (provide one
5943 # expansion of the required macro before the current point, and only one
5945 echo "AC_DEFUN([gl_INIT], ["
5946 if test "$auxdir" != "build-aux"; then
5947 sed_replace_build_aux='
5949 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5950 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5954 sed_replace_build_aux="$sed_noop"
5956 echo "gl_m4_base='$m4base'"
5957 func_emit_initmacro_start $macro_prefix
5958 echo "gl_source_base='$sourcebase'"
5959 if $single_configure; then
5960 func_emit_autoconf_snippets "$main_modules" func_verify_module true false false
5962 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
5964 func_emit_initmacro_end $macro_prefix
5965 if $single_configure; then
5966 echo " gltests_libdeps="
5967 echo " gltests_ltlibdeps="
5968 func_emit_initmacro_start ${macro_prefix}tests
5969 echo " gl_source_base='$testsbase'"
5970 # Define a tests witness macro.
5971 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
5972 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5973 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5974 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5975 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true false false
5976 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5977 func_emit_initmacro_end ${macro_prefix}tests
5979 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5980 # created using libtool, because libtool already handles the dependencies.
5981 if test "$libtool" != true; then
5982 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5983 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5984 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5985 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5986 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5988 if $single_configure; then
5989 if $use_libtests; then
5990 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5991 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5995 func_emit_initmacro_done $macro_prefix $sourcebase
5996 if $single_configure; then
5997 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6002 if test -n "$subdirs_with_configure_ac"; then
6003 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6005 makefiles="Makefile"
6006 for d in $subdirs; do
6007 # For subdirs that have a configure.ac by their own, it's the subdir's
6008 # configure.ac which creates the subdir's Makefile.am, not this one.
6009 case " $subdirs_with_configure_ac " in
6011 *) func_append makefiles " $d/Makefile" ;;
6014 echo "AC_CONFIG_FILES([$makefiles])"
6016 ) > "$testdir/configure.ac"
6018 # Create autogenerated files.
6020 # Do not use "${AUTORECONF} --force --install", because it may invoke
6021 # autopoint, which brings in older versions of some of our .m4 files.
6022 if test -f $m4base/gettext.m4; then
6023 func_execute_command ${AUTOPOINT} --force || func_exit 1
6024 for f in $m4base/*.m4~; do
6026 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6030 if test "$libtool" = true; then
6031 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6033 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6034 if ! test -d build-aux; then
6035 func_execute_command mkdir build-aux || func_exit 1
6037 func_execute_command ${AUTOCONF} || func_exit 1
6038 func_execute_command ${AUTOHEADER} || func_exit 1
6039 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6041 if test -n "$inctests" && ! $single_configure; then
6042 # Create autogenerated files.
6043 (cd "$testdir/$testsbase" || func_exit 1
6044 # Do not use "${AUTORECONF} --force --install", because it may invoke
6045 # autopoint, which brings in older versions of some of our .m4 files.
6046 if test -f ../$m4base/gettext.m4; then
6047 func_execute_command ${AUTOPOINT} --force || func_exit 1
6048 for f in ../$m4base/*.m4~; do
6050 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6054 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6055 if ! test -d ../build-aux; then
6056 func_execute_command mkdir ../build-aux
6058 func_execute_command ${AUTOCONF} || func_exit 1
6059 func_execute_command ${AUTOHEADER} || func_exit 1
6060 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6063 # Need to run configure and make once, to create built files that are to be
6064 # distributed (such as parse-datetime.c).
6065 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6066 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6067 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6068 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6069 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6070 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6071 # such $(FOO_H) because they don't refer to distributed files.
6072 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6073 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6074 | sed -e "$sed_remove_make_variables"`
6075 distributed_built_sources=`for file in $built_sources; do
6076 case "$cleaned_files" in
6081 tests_distributed_built_sources=
6082 if test -n "$inctests"; then
6083 # Likewise for built files in the $testsbase directory.
6084 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6085 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6086 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6087 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6088 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6089 | sed -e "$sed_remove_make_variables"`
6090 tests_distributed_built_sources=`for file in $tests_built_sources; do
6091 case "$tests_cleaned_files" in
6097 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6099 ./configure || func_exit 1
6100 if test -n "$distributed_built_sources"; then
6102 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6103 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6108 if test -n "$tests_distributed_built_sources"; then
6110 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6111 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6116 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6123 # func_create_megatestdir megatestdir allmodules
6125 # - local_gnulib_dir from --local-dir
6126 # - modcache true or false, from --cache-modules/--no-cache-modules
6127 # - auxdir directory relative to destdir where to place build aux files
6128 func_create_megatestdir ()
6132 if test -z "$allmodules"; then
6133 allmodules=`func_all_modules`
6137 # First, all modules one by one.
6138 for onemodule in $allmodules; do
6139 func_create_testdir "$megatestdir/$onemodule" $onemodule
6140 func_append megasubdirs "$onemodule "
6142 # Then, all modules all together.
6143 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6144 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6145 func_create_testdir "$megatestdir/ALL" "$allmodules"
6146 func_append megasubdirs "ALL"
6149 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
6150 vc_witness="$gnulib_dir/CVS/Entries"; \
6152 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6154 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6155 | sed -e 's,January,01,' -e 's,Jan,01,' \
6156 -e 's,February,02,' -e 's,Feb,02,' \
6157 -e 's,March,03,' -e 's,Mar,03,' \
6158 -e 's,April,04,' -e 's,Apr,04,' \
6160 -e 's,June,06,' -e 's,Jun,06,' \
6161 -e 's,July,07,' -e 's,Jul,07,' \
6162 -e 's,August,08,' -e 's,Aug,08,' \
6163 -e 's,September,09,' -e 's,Sep,09,' \
6164 -e 's,October,10,' -e 's,Oct,10,' \
6165 -e 's,November,11,' -e 's,Nov,11,' \
6166 -e 's,December,12,' -e 's,Dec,12,' \
6167 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6168 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6170 echo "CVSDATE=$cvsdate"
6171 echo ": \${MAKE=make}"
6172 echo "test -d logs || mkdir logs"
6173 echo "for module in $megasubdirs; do"
6174 echo " echo \"Working on module \$module...\""
6175 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6176 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6179 echo " : autobuild project... \$module"
6180 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6181 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6182 echo " : autobuild hostname... \`hostname\`"
6183 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6185 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6187 ) > "$megatestdir/do-autobuild"
6188 chmod a+x "$megatestdir/do-autobuild"
6190 # Create Makefile.am.
6191 (echo "## Process this file with automake to produce Makefile.in."
6193 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
6195 echo "SUBDIRS = $megasubdirs"
6197 echo "EXTRA_DIST = do-autobuild"
6198 ) > "$megatestdir/Makefile.am"
6200 # Create configure.ac.
6201 (echo "# Process this file with autoconf to produce a configure script."
6202 echo "AC_INIT([dummy], [0])"
6203 if test "$auxdir" != "."; then
6204 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6206 echo "AM_INIT_AUTOMAKE"
6208 echo "AC_PROG_MAKE_SET"
6210 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6211 echo "AC_CONFIG_FILES([Makefile])"
6213 ) > "$megatestdir/configure.ac"
6215 # Create autogenerated files.
6217 # Do not use "${AUTORECONF} --install", because autoreconf operates
6218 # recursively, but the subdirectories are already finished, therefore
6219 # calling autoreconf here would only waste lots of CPU time.
6220 func_execute_command ${ACLOCAL} || func_exit 1
6221 func_execute_command mkdir build-aux
6222 func_execute_command ${AUTOCONF} || func_exit 1
6223 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6229 func_fatal_error "no mode specified" ;;
6236 # sed expression that converts a literal to a basic regular expression.
6237 # Needs to handle . [ \ * ^ $.
6238 sed_literal_to_basic_regex='s/\\/\\\\/g
6244 if test -f "$gnulib_dir/$filename" \
6245 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
6246 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6247 filename_line_regex='^'"$filename_anywhere_regex"'$'
6250 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6251 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
6252 (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$,,')
6255 | func_sanitize_modulelist \
6258 for module in $module_candidates; do
6259 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6264 func_warning "file $filename does not exist"
6269 import | add-import | remove-import | update )
6272 if test -z "$destdir"; then
6275 test -d "$destdir" \
6276 || func_fatal_error "destination directory does not exist: $destdir"
6278 # Prefer configure.ac to configure.in.
6279 if test -f "$destdir"/configure.ac; then
6280 configure_ac="$destdir/configure.ac"
6282 if test -f "$destdir"/configure.in; then
6283 configure_ac="$destdir/configure.in"
6285 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6289 # Analyze configure.ac.
6291 guessed_libtool=false
6296 /AC_CONFIG_AUX_DIR/ {
6297 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6299 /A[CM]_PROG_LIBTOOL/ {
6300 s,^.*$,guessed_libtool=true,p
6302 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6304 if test -z "$auxdir"; then
6305 auxdir="$guessed_auxdir"
6308 # Determine where to apply func_import.
6309 if test "$mode" = import; then
6310 # Apply func_import to a particular gnulib directory.
6311 # The command line contains the complete specification; don't look at
6312 # the contents of gnulib-cache.m4.
6313 test -n "$supplied_libname" || supplied_libname=true
6314 test -n "$sourcebase" || sourcebase="lib"
6315 test -n "$m4base" || m4base="m4"
6316 test -n "$docbase" || docbase="doc"
6317 test -n "$testsbase" || testsbase="tests"
6318 test -n "$macro_prefix" || macro_prefix="gl"
6321 if test -n "$m4base"; then
6322 # Apply func_import to a particular gnulib directory.
6323 # Any number of additional modules can be given.
6324 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6325 # First use of gnulib in the given m4base.
6326 test -n "$supplied_libname" || supplied_libname=true
6327 test -n "$sourcebase" || sourcebase="lib"
6328 test -n "$docbase" || docbase="doc"
6329 test -n "$testsbase" || testsbase="tests"
6330 test -n "$macro_prefix" || macro_prefix="gl"
6334 # Apply func_import to all gnulib directories.
6335 # To get this list of directories, look at Makefile.am. (Not at
6336 # configure, because it may be omitted from version control. Also,
6337 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6341 if test -f "$destdir"/Makefile.am; then
6342 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6344 for arg in $aclocal_amflags; do
6345 if test -n "$m4dir_is_next"; then
6346 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6350 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6351 func_append m4dirs " $arg"
6352 m4dirs_count=`expr $m4dirs_count + 1`
6358 if test "X$arg" = "X-I"; then
6366 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6367 if test -f "$destdir"/aclocal.m4; then
6368 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6369 sedexpr2='s,^[^/]*$,.,'
6370 sedexpr3='s,/[^/]*$,,'
6371 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6372 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6373 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6376 if test $m4dirs_count = 0; then
6377 # First use of gnulib in a package.
6378 # Any number of additional modules can be given.
6379 test -n "$supplied_libname" || supplied_libname=true
6380 test -n "$sourcebase" || sourcebase="lib"
6382 test -n "$docbase" || docbase="doc"
6383 test -n "$testsbase" || testsbase="tests"
6384 test -n "$macro_prefix" || macro_prefix="gl"
6387 if test $m4dirs_count = 1; then
6388 # There's only one use of gnulib here. Assume the user means it.
6389 # Any number of additional modules can be given.
6390 for m4base in $m4dirs; do
6394 # Ambiguous - guess what the user meant.
6395 if test $# = 0; then
6396 # No further arguments. Guess the user wants to update all of them.
6397 for m4base in $m4dirs; do
6398 # Perform func_import in a subshell, so that variable values
6400 # local_gnulib_dir, incobsolete, inc_cxx_tests,
6401 # inc_longrunning_tests, inc_privileged_tests,
6402 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6403 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6404 # makefile_name, libtool, macro_prefix, po_domain,
6405 # witness_c_macro, vc_files
6406 # don't propagate from one directory to another.
6407 (func_import) || func_exit 1
6411 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6420 if test -z "$destdir"; then
6421 func_fatal_error "please specify --dir option"
6424 test -d "$destdir" \
6425 || func_fatal_error "could not create destination directory"
6426 test -n "$auxdir" || auxdir="build-aux"
6427 func_create_testdir "$destdir" "$*"
6430 create-megatestdir )
6431 if test -z "$destdir"; then
6432 func_fatal_error "please specify --dir option"
6434 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6435 test -n "$auxdir" || auxdir="build-aux"
6436 func_create_megatestdir "$destdir" "$*"
6440 test -n "$destdir" || destdir=testdir$$
6441 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6442 test -n "$auxdir" || auxdir="build-aux"
6443 func_create_testdir "$destdir" "$*"
6447 ../configure || func_exit 1
6448 $MAKE || func_exit 1
6449 $MAKE check || func_exit 1
6450 $MAKE distclean || func_exit 1
6451 remaining=`find . -type f -print`
6452 if test -n "$remaining"; then
6453 echo "Remaining files:" $remaining 1>&2
6454 echo "gnulib-tool: *** Stop." 1>&2
6463 test -n "$destdir" || destdir=testdir$$
6464 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6465 test -n "$auxdir" || auxdir="build-aux"
6466 func_create_megatestdir "$destdir" "$*"
6474 remaining=`find . -type f -print`
6475 if test -n "$remaining"; then
6476 echo "Remaining files:" $remaining 1>&2
6477 echo "gnulib-tool: *** Stop." 1>&2
6485 extract-description )
6489 if test -n "$module"; then
6490 func_get_description "$module"
6499 if test -n "$module"; then
6500 func_get_comment "$module"
6509 if test -n "$module"; then
6510 func_get_status "$module"
6519 if test -n "$module"; then
6520 func_get_notice "$module"
6525 extract-applicability )
6529 if test -n "$module"; then
6530 func_get_applicability "$module"
6539 if test -n "$module"; then
6540 func_get_filelist "$module"
6545 extract-dependencies )
6546 if test -n "$avoidlist"; then
6547 func_fatal_error "cannot combine --avoid and --extract-dependencies"
6552 if test -n "$module"; then
6553 func_get_dependencies "$module"
6558 extract-autoconf-snippet )
6562 if test -n "$module"; then
6563 func_get_autoconf_snippet "$module"
6568 extract-automake-snippet )
6572 if test -n "$module"; then
6573 func_get_automake_snippet "$module"
6578 extract-include-directive )
6582 if test -n "$module"; then
6583 func_get_include_directive "$module"
6588 extract-link-directive )
6592 if test -n "$module"; then
6593 func_get_link_directive "$module"
6602 if test -n "$module"; then
6603 func_get_license "$module"
6608 extract-maintainer )
6612 if test -n "$module"; then
6613 func_get_maintainer "$module"
6618 extract-tests-module )
6622 if test -n "$module"; then
6623 func_get_tests_module "$module"
6629 # Verify the number of arguments.
6630 if test $# -lt 1 || test $# -gt 2; then
6631 func_fatal_error "invalid number of arguments for --$mode"
6634 # The first argument is the file to be copied.
6636 # Verify the file exists.
6637 func_lookup_file "$f"
6639 # The second argument is the destination; either a directory ot a file.
6640 # It defaults to the current directory.
6642 test -n "$dest" || dest='.'
6643 test -n "$sourcebase" || sourcebase="lib"
6644 test -n "$m4base" || m4base="m4"
6645 test -n "$docbase" || docbase="doc"
6646 test -n "$testsbase" || testsbase="tests"
6647 test -n "$auxdir" || auxdir="build-aux"
6648 rewritten='%REWRITTEN%'
6649 sed_rewrite_files="\
6650 s,^build-aux/,$rewritten$auxdir/,
6651 s,^doc/,$rewritten$docbase/,
6652 s,^lib/,$rewritten$sourcebase/,
6653 s,^m4/,$rewritten$m4base/,
6654 s,^tests/,$rewritten$testsbase/,
6657 if test -d "$dest"; then
6659 g=`echo "$f" | sed -e "$sed_rewrite_files"`
6661 destdir=`dirname "$dest"`
6662 g=`basename "$dest"`
6665 # Create the directory for destfile.
6666 d=`dirname "$destdir/$g"`
6668 if test -n "$d" && test ! -d "$d"; then
6669 mkdir -p "$d" || func_fatal_error "failed"
6673 func_dest_tmpfilename "$g"
6674 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
6675 already_present=true
6676 if test -f "$destdir/$g"; then
6677 # The file already exists.
6681 # Don't protest if the file should be there but isn't: it happens
6682 # frequently that developers don't put autogenerated files under version
6690 func_fatal_error "unknown operation mode --$mode" ;;
6694 # Undo the effect of the previous 'trap' command. Some shellology:
6695 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6696 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6697 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6698 # 128 + signal number and is set before the trap-registered command is run.
6700 trap 'func_exit $?' 1 2 3 13 15
6705 # indent-tabs-mode: nil
6706 # whitespace-check-buffer-indent: nil