gnulib-tool.py: Make --megatest behaviour more similar to shell impl.
[gnulib.git] / gnulib-tool.sh
blobb5aadcaeaa39c632843e0a0d9e8ccfabe1caf295
1 #! /bin/sh
3 # Copyright (C) 2002-2024 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 <https://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
22 # CODING STYLE for this file:
23 # * Indentation: Indent by 2 spaces. Indent case clauses by 2 spaces as well.
24 # * Shell variable references: Use double-quote around shell variable
25 # references always (except when word splitting is explicitly desired),
26 # even when you know the double-quote are not needed. This style tends to
27 # avoid undesired word splitting caused by omitted double-quotes (the
28 # number one mistake in shell scripts).
29 # When the referenced variable can only have a finite number of possible
30 # values and these values are all simple words (e.g. true and false), it's
31 # OK to omit the double-quotes.
32 # * Backquotes:
33 # - Use backquotes like in `command`, not $(command).
34 # - Don't use `command` inside double-quotes. Instead assign the result of
35 # `command` to a variable, and use the value of the variable afterwards.
36 # * Functions:
37 # - All functions that don't emulate a program or shell built-in have a name
38 # that starts with 'func_'.
39 # - Document the implicit and explicit arguments of all functions, as well
40 # as their output variables and side effects.
41 # * Use test condition instead of [ condition ].
42 # * Minimize the use of eval; when you need it, make sure the string to be
43 # evaluated has a very simple syntactic structure.
45 progname=$0
46 package=gnulib
47 nl='
49 IFS=" "" $nl"
51 # You can set AUTOCONFPATH to empty if autoconf ≥ 2.64 is already in your PATH.
52 AUTOCONFPATH=
53 #case $USER in
54 # bruno )
55 # AUTOCONFBINDIR=/arch/x86-linux/gnu-inst-autoconf/2.64/bin
56 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
57 # ;;
58 #esac
60 # You can set AUTOMAKEPATH to empty if automake ≥ 1.14 is already in your PATH.
61 AUTOMAKEPATH=
63 # You can set GETTEXTPATH to empty if autopoint ≥ 0.15 is already in your PATH.
64 GETTEXTPATH=
66 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
67 LIBTOOLPATH=
69 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
70 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
71 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
72 AUTOCONF="${AUTOCONFPATH}autoconf"
74 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
75 AUTOHEADER="${AUTOCONFPATH}autoheader"
77 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
78 ACLOCAL="${AUTOMAKEPATH}aclocal"
80 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
81 AUTOMAKE="${AUTOMAKEPATH}automake"
83 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
84 AUTORECONF="${AUTOCONFPATH}autoreconf"
87 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
88 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
89 AUTOPOINT="${GETTEXTPATH}autopoint"
92 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
93 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
94 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
97 # You can set MAKE.
98 if test -z "${MAKE}"; then
99 MAKE=make
102 # When using GNU sed, turn off as many GNU extensions as possible,
103 # to minimize the risk of accidentally using non-portable features.
104 # However, do this only for gnulib-tool itself, not for the code that
105 # gnulib-tool generates, since we don't want "sed --posix" to leak
106 # into makefiles. And do it only for sed versions 4.2 or newer,
107 # because "sed --posix" is buggy in GNU sed 4.1.5, see
108 # <https://lists.gnu.org/r/bug-gnulib/2009-02/msg00225.html>.
109 if (alias) > /dev/null 2>&1 \
110 && echo | sed --posix -e d >/dev/null 2>&1 \
111 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
112 [1-3]* | 4.[01]*) false;; \
113 *) true;; \
114 esac \
115 ; then
116 # Define sed as an alias.
117 # It is not always possible to use aliases. Aliases are guaranteed to work
118 # if the executing shell is bash and either it is invoked as /bin/sh or
119 # is a version >= 2.0, supporting shopt. This is the common case.
120 # Two other approaches (use of a variable $sed or of a function func_sed
121 # instead of an alias) require massive, fragile code changes.
122 # An other approach (use of function sed) requires `which sed` - but
123 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
124 if test -n "$BASH_VERSION"; then
125 shopt -s expand_aliases >/dev/null 2>&1
127 alias sed='sed --posix'
130 # sed_noop is a sed expression that does nothing.
131 # An empty expression does not work with the native 'sed' on AIX 6.1.
132 sed_noop='s,x,x,'
134 # sed_comments is true or false, depending whether 'sed' supports comments.
135 # AIX 5.3 sed barfs over indented comments.
136 if echo fo | sed -e 's/f/g/
137 # s/o/u/
138 # indented comment
139 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
140 sed_comments=true
141 else
142 sed_comments=false
145 # func_usage
146 # outputs to stdout the --help usage message.
147 func_usage ()
149 echo "\
150 Usage: gnulib-tool --list
151 gnulib-tool --find filename
152 gnulib-tool --import [module1 ... moduleN]
153 gnulib-tool --add-import [module1 ... moduleN]
154 gnulib-tool --remove-import [module1 ... moduleN]
155 gnulib-tool --update
156 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
157 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
158 gnulib-tool --test --dir=directory [module1 ... moduleN]
159 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
160 gnulib-tool --extract-description module
161 gnulib-tool --extract-comment module
162 gnulib-tool --extract-status module
163 gnulib-tool --extract-notice module
164 gnulib-tool --extract-applicability module
165 gnulib-tool --extract-filelist module
166 gnulib-tool --extract-dependencies module
167 gnulib-tool --extract-recursive-dependencies module
168 gnulib-tool --extract-autoconf-snippet module
169 gnulib-tool --extract-automake-snippet module
170 gnulib-tool --extract-include-directive module
171 gnulib-tool --extract-link-directive module
172 gnulib-tool --extract-recursive-link-directive module
173 gnulib-tool --extract-license module
174 gnulib-tool --extract-maintainer module
175 gnulib-tool --extract-tests-module module
176 gnulib-tool --copy-file file [destination]
178 Operation modes:
180 --list print the available module names
181 --find find the modules which contain the specified file
182 --import import the given modules into the current package
183 --add-import augment the list of imports from gnulib into the
184 current package, by adding the given modules;
185 if no modules are specified, update the current
186 package from the current gnulib
187 --remove-import reduce the list of imports from gnulib into the
188 current package, by removing the given modules
189 --update update the current package, restore files omitted
190 from version control
191 --create-testdir create a scratch package with the given modules
192 --create-megatestdir create a mega scratch package with the given modules
193 one by one and all together
194 --test test the combination of the given modules
195 (recommended to use CC=\"gcc -Wall\" here)
196 --megatest test the given modules one by one and all together
197 (recommended to use CC=\"gcc -Wall\" here)
198 --extract-description extract the description
199 --extract-comment extract the comment
200 --extract-status extract the status (obsolete etc.)
201 --extract-notice extract the notice or banner
202 --extract-applicability extract the applicability
203 --extract-filelist extract the list of files
204 --extract-dependencies extract the dependencies
205 --extract-recursive-dependencies extract the dependencies of the module
206 and its dependencies, recursively, all
207 together, but without the conditions
208 --extract-autoconf-snippet extract the snippet for configure.ac
209 --extract-automake-snippet extract the snippet for library makefile
210 --extract-include-directive extract the #include directive
211 --extract-link-directive extract the linker directive
212 --extract-recursive-link-directive extract the linker directive of the
213 module and its dependencies,
214 recursively, all together
215 --extract-license report the license terms of the source files
216 under lib/
217 --extract-maintainer report the maintainer(s) inside gnulib
218 --extract-tests-module report the unit test module, if it exists
219 --copy-file copy a file that is not part of any module
220 --help Show this help text.
221 --version Show version and authorship information.
223 General options:
225 --dir=DIRECTORY Specify the target directory.
226 For --import, this specifies where your
227 configure.ac can be found. Defaults to current
228 directory.
229 --local-dir=DIRECTORY Specify a local override directory where to look
230 up files before looking in gnulib's directory.
231 --verbose Increase verbosity. May be repeated.
232 --quiet Decrease verbosity. May be repeated.
234 Options for --import, --add/remove-import, --update:
236 --dry-run Only print what would have been done.
238 Options for --import, --add/remove-import:
240 --with-tests Include unit tests for the included modules.
242 Options for --create-[mega]testdir, --[mega]test:
244 --without-tests Don't include unit tests for the included modules.
246 Options for --import, --add/remove-import,
247 --create-[mega]testdir, --[mega]test:
249 --with-obsolete Include obsolete modules when they occur among the
250 dependencies. By default, dependencies to obsolete
251 modules are ignored.
252 --with-c++-tests Include even unit tests for C++ interoperability.
253 --without-c++-tests Exclude unit tests for C++ interoperability.
254 --with-longrunning-tests
255 Include even unit tests that are long-runners.
256 --without-longrunning-tests
257 Exclude unit tests that are long-runners.
258 --with-privileged-tests
259 Include even unit tests that require root
260 privileges.
261 --without-privileged-tests
262 Exclude unit tests that require root privileges.
263 --with-unportable-tests
264 Include even unit tests that fail on some platforms.
265 --without-unportable-tests
266 Exclude unit tests that fail on some platforms.
267 --with-all-tests Include all kinds of problematic unit tests.
268 --avoid=MODULE Avoid including the given MODULE. Useful if you
269 have code that provides equivalent functionality.
270 This option can be repeated.
271 --conditional-dependencies
272 Support conditional dependencies (may save configure
273 time and object code).
274 --no-conditional-dependencies
275 Don't use conditional dependencies.
276 --libtool Use libtool rules.
277 --no-libtool Don't use libtool rules.
279 Options for --import, --add/remove-import:
281 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
282 --source-base=DIRECTORY
283 Directory relative to --dir where source code is
284 placed (default \"lib\").
285 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
286 placed (default \"m4\").
287 --po-base=DIRECTORY Directory relative to --dir where *.po files are
288 placed (default \"po\").
289 --doc-base=DIRECTORY Directory relative to --dir where doc files are
290 placed (default \"doc\").
291 --tests-base=DIRECTORY
292 Directory relative to --dir where unit tests are
293 placed (default \"tests\").
294 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
295 tools are placed (default comes from configure.ac).
296 --gnu-make Output for GNU Make instead of for the default
297 Automake
298 --lgpl[=2|=3orGPLv2|=3]
299 Abort if modules aren't available under the LGPL.
300 Also modify license template from GPL to LGPL.
301 The version number of the LGPL can be specified;
302 the default is currently LGPLv3.
303 --makefile-name=NAME Name of makefile in the source-base and tests-base
304 directories (default \"Makefile.am\", or
305 \"Makefile.in\" if --gnu-make).
306 --tests-makefile-name=NAME
307 Name of makefile in the tests-base directory
308 (default as specified through --makefile-name).
309 --automake-subdir Specify that the makefile in the source-base
310 directory be generated in such a way that it can
311 be 'include'd from the toplevel Makefile.am.
312 --automake-subdir-tests
313 Likewise, but for the tests directory.
314 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
315 'gl_INIT'. Default is 'gl'.
316 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
317 the package name. A suffix '-gnulib' is appended.
318 --witness-c-macro=NAME Specify the C macro that is defined when the
319 sources in this directory are compiled or used.
320 --vc-files Update version control related files.
321 --no-vc-files Don't update version control related files
322 (.gitignore and/or .cvsignore).
324 Options for --create-[mega]testdir, --[mega]test:
326 --single-configure Generate a single configure file, not a separate
327 configure file for the tests directory.
329 Options for --import, --add/remove-import, --update,
330 --create-[mega]testdir, --[mega]test:
332 -s, --symbolic, --symlink Make symbolic links instead of copying files.
333 --local-symlink Make symbolic links instead of copying files, only
334 for files from the local override directory.
335 -h, --hardlink Make hard links instead of copying files.
336 --local-hardlink Make hard links instead of copying files, only
337 for files from the local override directory.
339 Options for --import, --add/remove-import, --update:
341 -S, --more-symlinks Deprecated; equivalent to --symlink.
342 -H, --more-hardlinks Deprecated; equivalent to --hardlink.
344 Report bugs to <bug-gnulib@gnu.org>."
347 # func_version
348 # outputs to stdout the --version message.
349 func_version ()
351 func_gnulib_dir
352 if test -d "$gnulib_dir"/.git \
353 && (git --version) >/dev/null 2>/dev/null \
354 && (date --version) >/dev/null 2>/dev/null; then
355 # gnulib checked out from git.
356 sed_extract_first_date='/^Date/{
357 s/^Date:[ ]*//p
360 date=`cd "$gnulib_dir" && git log -n 1 --format=medium --date=iso ChangeLog | sed -n -e "$sed_extract_first_date"`
361 # Use GNU date to compute the time in GMT.
362 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
363 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
364 else
365 # gnulib copy without versioning information.
366 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
367 version=
369 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
370 echo "\
371 gnulib-tool (GNU $package $date)$version
372 Copyright (C) $year Free Software Foundation, Inc.
373 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
374 This is free software: you are free to change and redistribute it.
375 There is NO WARRANTY, to the extent permitted by law.
377 printf "Written by %s, %s, and %s.\n" "Bruno Haible" "Paul Eggert" "Simon Josefsson"
380 # func_emit_copyright_notice
381 # outputs to stdout a header for a generated file.
382 func_emit_copyright_notice ()
384 sed -n -e '/Copyright/ {
387 }' < "$self_abspathname"
388 echo "#"
389 echo "# This file is free software; you can redistribute it and/or modify"
390 echo "# it under the terms of the GNU General Public License as published by"
391 echo "# the Free Software Foundation, either version 3 of the License, or"
392 echo "# (at your option) any later version."
393 echo "#"
394 echo "# This file is distributed in the hope that it will be useful,"
395 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
396 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
397 echo "# GNU General Public License for more details."
398 echo "#"
399 echo "# You should have received a copy of the GNU General Public License"
400 echo "# along with this file. If not, see <https://www.gnu.org/licenses/>."
401 echo "#"
402 echo "# As a special exception to the GNU General Public License,"
403 echo "# this file may be distributed as part of a program that"
404 echo "# contains a configuration script generated by Autoconf, under"
405 echo "# the same distribution terms as the rest of that program."
406 echo "#"
407 echo "# Generated by gnulib-tool."
410 # func_exit STATUS
411 # exits with a given status.
412 # This function needs to be used, rather than 'exit', when a 'trap' handler is
413 # in effect that refers to $?.
414 func_exit ()
416 (exit $1); exit $1
419 # func_fatal_error message
420 # outputs to stderr a fatal error message, and terminates the program.
421 # Input:
422 # - progname name of this program
423 func_fatal_error ()
425 echo "$progname: *** $1" 1>&2
426 echo "$progname: *** Stop." 1>&2
427 func_exit 1
430 # func_warning message
431 # Outputs to stderr a warning message,
432 func_warning ()
434 echo "gnulib-tool: warning: $1" 1>&2
437 # func_readlink SYMLINK
438 # outputs the target of the given symlink.
439 if (type readlink) > /dev/null 2>&1; then
440 func_readlink ()
442 # Use the readlink program from GNU coreutils.
443 readlink "$1"
445 else
446 func_readlink ()
448 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
449 # would do the wrong thing if the link target contains " -> ".
450 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
454 # func_gnulib_dir
455 # locates the directory where the gnulib repository lives
456 # Input:
457 # - progname name of this program
458 # Sets variables
459 # - self_abspathname absolute pathname of gnulib-tool
460 # - gnulib_dir absolute pathname of gnulib repository
461 func_gnulib_dir ()
463 case "$progname" in
464 /* | ?:*) self_abspathname="$progname" ;;
465 */*) self_abspathname=`pwd`/"$progname" ;;
467 # Look in $PATH.
468 # Iterate through the elements of $PATH.
469 # We use IFS=: instead of
470 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
471 # because the latter does not work when some PATH element contains spaces.
472 # We use a canonicalized $pathx instead of $PATH, because empty PATH
473 # elements are by definition equivalent to '.', however field splitting
474 # according to IFS=: loses empty fields in many shells:
475 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
476 # beginning, at the end, and in the middle),
477 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
478 # at the beginning and at the end,
479 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
480 # Solaris lose empty fields at the end.
481 # The 'case' statement is an optimization, to avoid evaluating the
482 # explicit canonicalization command when $PATH contains no empty fields.
483 self_abspathname=
484 if test "$PATH_SEPARATOR" = ";"; then
485 # On Windows, programs are searched in "." before $PATH.
486 pathx=".;$PATH"
487 else
488 # On Unix, we have to convert empty PATH elements to ".".
489 pathx="$PATH"
490 case :$PATH: in
491 *::*)
492 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
494 esac
496 saved_IFS="$IFS"
497 IFS="$PATH_SEPARATOR"
498 for d in $pathx; do
499 IFS="$saved_IFS"
500 test -z "$d" && d=.
501 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
502 self_abspathname="$d/$progname"
503 break
505 done
506 IFS="$saved_IFS"
507 if test -z "$self_abspathname"; then
508 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
511 esac
512 while test -h "$self_abspathname"; do
513 # Resolve symbolic link.
514 linkval=`func_readlink "$self_abspathname"`
515 test -n "$linkval" || break
516 case "$linkval" in
517 /* | ?:* ) self_abspathname="$linkval" ;;
518 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
519 esac
520 done
521 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
524 # func_tmpdir
525 # creates a temporary directory.
526 # Input:
527 # - progname name of this program
528 # Sets variable
529 # - tmp pathname of freshly created temporary directory
530 func_tmpdir ()
532 # Use the environment variable TMPDIR, falling back to /tmp. This allows
533 # users to specify a different temporary directory, for example, if their
534 # /tmp is filled up or too small.
535 : "${TMPDIR=/tmp}"
537 # Use the mktemp program if available. If not available, hide the error
538 # message.
539 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
540 test -n "$tmp" && test -d "$tmp"
541 } ||
543 # Use a simple mkdir command. It is guaranteed to fail if the directory
544 # already exists. $RANDOM is bash specific and expands to empty in shells
545 # other than bash, ksh and zsh. Its use does not increase security;
546 # rather, it minimizes the probability of failure in a very cluttered /tmp
547 # directory.
548 tmp=$TMPDIR/gl$$-$RANDOM
549 (umask 077 && mkdir "$tmp")
550 } ||
552 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
553 func_exit 1
557 # func_append var value
558 # appends the given value to the shell variable var.
559 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
560 # Use bash's += operator. It reduces complexity of appending repeatedly to
561 # a single variable from O(n^2) to O(n).
562 func_append ()
564 eval "$1+=\"\$2\""
566 fast_func_append=true
567 else
568 func_append ()
570 eval "$1=\"\$$1\$2\""
572 fast_func_append=false
575 # func_remove_prefix var prefix
576 # removes the given prefix from the value of the shell variable var.
577 # var should be the name of a shell variable.
578 # Its value should not contain a newline and not start or end with whitespace.
579 # prefix should not contain the characters "$`\{}[]^|.
580 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
581 func_remove_prefix ()
583 eval "$1=\${$1#\$2}"
585 fast_func_remove_prefix=true
586 else
587 func_remove_prefix ()
589 eval "value=\"\$$1\""
590 prefix="$2"
591 case "$prefix" in
592 *.*)
593 sed_escape_dots='s/\([.]\)/\\\1/g'
594 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
596 esac
597 value=`echo "$value" | sed -e "s|^${prefix}||"`
598 eval "$1=\"\$value\""
600 fast_func_remove_prefix=false
603 # Determine whether we should use ':' or ';' as PATH_SEPARATOR.
604 func_determine_path_separator ()
606 if test "${PATH_SEPARATOR+set}" != set; then
607 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
608 # contains only /bin. Note that ksh looks also at the FPATH variable,
609 # so we have to set that as well for the test.
610 PATH_SEPARATOR=:
611 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
612 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
613 || PATH_SEPARATOR=';'
618 # func_path_append pathvar directory
619 # appends directory to pathvar, delimiting directories by PATH_SEPARATOR.
620 func_path_append ()
622 if eval "test -n \"\$$1\""; then
623 func_append "$1" "$PATH_SEPARATOR$2"
624 else
625 eval "$1=\$2"
629 # func_path_foreach_inner
630 # helper for func_path_foreach because we need new 'args' array
631 # Input:
632 # - fpf_dir directory from local_gnulib_path
633 # - fpf_cb callback to be run for fpf_dir
634 func_path_foreach_inner ()
636 set %start% "$@"
637 for _fpf_arg
639 case "$_fpf_arg" in
640 %start%)
641 set dummy
643 %dir%)
644 set "$@" "$fpf_dir"
647 set "$@" "$_fpf_arg"
649 esac
650 done
651 shift
653 "$fpf_cb" "$@"
656 # func_path_foreach path method args
657 # Execute method for each directory in path. The method will be called
658 # like `method args` while any argument '%dir%' within args will be replaced
659 # with processed directory from path.
660 func_path_foreach ()
662 fpf_dirs="$1"; shift
663 fpf_cb="$1"; shift
664 fpf_rc=false
666 fpf_saved_IFS="$IFS"
667 IFS="$PATH_SEPARATOR"
668 for fpf_dir in $fpf_dirs
670 IFS="$fpf_saved_IFS"
671 func_path_foreach_inner "$@" && fpf_rc=:
672 done
673 IFS="$fpf_saved_IFS"
674 $fpf_rc
677 # func_remove_suffix var suffix
678 # removes the given suffix from the value of the shell variable var.
679 # var should be the name of a shell variable.
680 # Its value should not contain a newline and not start or end with whitespace.
681 # suffix should not contain the characters "$`\{}[]^|.
682 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
683 func_remove_suffix ()
685 eval "$1=\${$1%\$2}"
687 fast_func_remove_suffix=true
688 else
689 func_remove_suffix ()
691 eval "value=\"\$$1\""
692 suffix="$2"
693 case "$suffix" in
694 *.*)
695 sed_escape_dots='s/\([.]\)/\\\1/g'
696 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
698 esac
699 value=`echo "$value" | sed -e "s|${suffix}\$||"`
700 eval "$1=\"\$value\""
702 fast_func_remove_suffix=false
705 # func_relativize DIR1 DIR2
706 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
707 # Input:
708 # - DIR1 relative pathname, relative to the current directory
709 # - DIR2 relative pathname, relative to the current directory
710 # Output:
711 # - reldir relative pathname of DIR2, relative to DIR1
712 func_relativize ()
714 dir0=`pwd`
715 dir1="$1"
716 dir2="$2"
717 sed_first='s,^\([^/]*\)/.*$,\1,'
718 sed_rest='s,^[^/]*/*,,'
719 sed_last='s,^.*/\([^/]*\)$,\1,'
720 sed_butlast='s,/*[^/]*$,,'
721 while test -n "$dir1"; do
722 first=`echo "$dir1" | sed -e "$sed_first"`
723 if test "$first" != "."; then
724 if test "$first" = ".."; then
725 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
726 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
727 else
728 first2=`echo "$dir2" | sed -e "$sed_first"`
729 if test "$first2" = "$first"; then
730 dir2=`echo "$dir2" | sed -e "$sed_rest"`
731 else
732 dir2="../$dir2"
734 dir0="$dir0"/"$first"
737 dir1=`echo "$dir1" | sed -e "$sed_rest"`
738 done
739 reldir="$dir2"
742 # func_relconcat DIR1 DIR2
743 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
744 # Input:
745 # - DIR1 relative pathname, relative to the current directory
746 # - DIR2 relative pathname, relative to DIR1
747 # Output:
748 # - relconcat DIR1/DIR2, relative to the current directory
749 func_relconcat ()
751 dir1="$1"
752 dir2="$2"
753 sed_first='s,^\([^/]*\)/.*$,\1,'
754 sed_rest='s,^[^/]*/*,,'
755 sed_last='s,^.*/\([^/]*\)$,\1,'
756 sed_butlast='s,/*[^/]*$,,'
757 while true; do
758 first=`echo "$dir2" | sed -e "$sed_first"`
759 if test "$first" = "."; then
760 dir2=`echo "$dir2" | sed -e "$sed_rest"`
761 if test -z "$dir2"; then
762 relconcat="$dir1"
763 break
765 else
766 last=`echo "$dir1" | sed -e "$sed_last"`
767 while test "$last" = "."; do
768 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
769 last=`echo "$dir1" | sed -e "$sed_last"`
770 done
771 if test -z "$dir1"; then
772 relconcat="$dir2"
773 break
775 if test "$first" = ".."; then
776 if test "$last" = ".."; then
777 relconcat="$dir1/$dir2"
778 break
780 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
781 dir2=`echo "$dir2" | sed -e "$sed_rest"`
782 if test -z "$dir1"; then
783 relconcat="$dir2"
784 break
786 if test -z "$dir2"; then
787 relconcat="$dir1"
788 break
790 else
791 relconcat="$dir1/$dir2"
792 break
795 done
798 # func_ensure_writable DEST
799 # Ensures the file DEST is writable.
800 func_ensure_writable ()
802 test -w "$1" || chmod u+w "$1"
805 # func_ln_s SRC DEST
806 # Like ln -s, except use cp -p if ln -s fails.
807 func_ln_s ()
809 ln -s "$1" "$2" || {
810 echo "$progname: ln -s failed; falling back on cp -p" >&2
812 case "$1" in
813 /* | ?:*) # SRC is absolute.
814 cp_src="$1" ;;
815 *) # SRC is relative to the directory of DEST.
816 case "$2" in
817 */*) cp_src="${2%/*}/$1" ;;
818 *) cp_src="$1" ;;
819 esac
821 esac
823 cp -p "$cp_src" "$2"
824 func_ensure_writable "$2"
828 # func_symlink_target SRC DEST
829 # Determines LINK_TARGET such that "ln -s LINK_TARGET DEST" will create a
830 # symbolic link DEST that points to SRC.
831 # Output:
832 # - link_target link target, relative to the directory of DEST
833 func_symlink_target ()
835 case "$1" in
836 /* | ?:*)
837 link_target="$1" ;;
838 *) # SRC is relative.
839 case "$2" in
840 /* | ?:*)
841 link_target="`pwd`/$1" ;;
842 *) # DEST is relative too.
843 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
844 test -n "$ln_destdir" || ln_destdir="."
845 func_relativize "$ln_destdir" "$1"
846 link_target="$reldir"
848 esac
850 esac
853 # func_symlink SRC DEST
854 # Like func_ln_s, except that SRC is given relative to the current directory (or
855 # absolute), not given relative to the directory of DEST.
856 func_symlink ()
858 func_symlink_target "$1" "$2"
859 func_ln_s "$link_target" "$2"
862 # func_symlink_if_changed SRC DEST
863 # Like func_symlink, but avoids munging timestamps if the link is correct.
864 # SRC is given relative to the current directory (or absolute).
865 func_symlink_if_changed ()
867 if test $# -ne 2; then
868 echo "usage: func_symlink_if_changed SRC DEST" >&2
870 func_symlink_target "$1" "$2"
871 ln_target=`func_readlink "$2"`
872 if test -h "$2" && test "$link_target" = "$ln_target"; then
874 else
875 rm -f "$2"
876 func_ln_s "$link_target" "$2"
880 # func_hardlink SRC DEST
881 # Like ln, except use cp -p if ln fails.
882 # SRC is given relative to the current directory (or absolute).
883 func_hardlink ()
885 ln "$1" "$2" || {
886 echo "$progname: ln failed; falling back on cp -p" >&2
887 cp -p "$1" "$2"
888 func_ensure_writable "$2"
892 # Ensure an 'echo' command that
893 # 1. does not interpret backslashes and
894 # 2. does not print an error message "broken pipe" when writing into a pipe
895 # with no writers.
897 # Test cases for problem 1:
898 # echo '\n' | wc -l prints 1 when OK, 2 when KO
899 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
900 # Test cases for problem 2:
901 # echo hi | true frequently prints
902 # "bash: echo: write error: Broken pipe"
903 # to standard error in bash 3.2.
905 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
906 # BSD echo interprets '-n' as an option, which is also not desirable).
907 # Nowadays the problem occurs in 4 situations:
908 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
909 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
910 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
911 # - in zsh, when sh-emulation is not set,
912 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
913 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
914 # - in Solaris /bin/sh and OSF/1 /bin/sh.
915 # We try the following workarounds:
916 # - for all: respawn using $CONFIG_SHELL if that is set and works.
917 # - for bash >= 2.04: unset the shell option xpg_echo.
918 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
919 # - for bash < 2.0: define echo to a function that uses cat of a here document.
920 # - for zsh: turn sh-emulation on.
921 # - for ksh: alias echo to 'print -r'.
922 # - for ksh: alias echo to a function that uses cat of a here document.
923 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
924 # the ksh workaround.
925 # - otherwise: respawn using /bin/sh and rely on the workarounds.
926 # When respawning, we pass --no-reexec as first argument, so as to avoid
927 # turning this script into a fork bomb in unlucky situations.
929 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
930 # the 'printf' built-in. See
931 # <https://lists.gnu.org/r/bug-bash/2008-12/msg00050.html>
932 # <https://lists.gnu.org/r/bug-gnulib/2010-02/msg00154.html>
933 # The workaround is: define echo to a function that uses the printf built-in.
934 have_echo=
935 if echo '\t' | grep t > /dev/null; then
936 have_echo=yes # Lucky!
938 # Try the workarounds.
939 # Respawn using $CONFIG_SHELL if that is set and works.
940 if test -z "$have_echo" \
941 && test "X$1" != "X--no-reexec" \
942 && test -n "$CONFIG_SHELL" \
943 && test -f "$CONFIG_SHELL" \
944 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
945 exec $CONFIG_SHELL "$0" --no-reexec "$@"
946 exit 127
948 # For bash >= 2.04: unset the shell option xpg_echo.
949 if test -z "$have_echo" \
950 && test -n "$BASH_VERSION" \
951 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
952 shopt -o xpg_echo
953 have_echo=yes
955 # For bash >= 2.0: define echo to a function that uses the printf built-in.
956 # For bash < 2.0: define echo to a function that uses cat of a here document.
957 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
958 # Also handle problem 2, specific to bash 3.2, here.
959 if { test -z "$have_echo" \
960 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
962 && test -n "$BASH_VERSION"; then \
963 if type printf 2>/dev/null | grep / > /dev/null; then
964 # 'printf' is not a shell built-in.
965 echo ()
967 cat <<EOF
971 else
972 # 'printf' is a shell built-in.
973 echo ()
975 printf '%s\n' "$*"
978 if echo '\t' | grep t > /dev/null; then
979 have_echo=yes
982 # For zsh: turn sh-emulation on.
983 if test -z "$have_echo" \
984 && test -n "$ZSH_VERSION" \
985 && (emulate sh) >/dev/null 2>&1; then
986 emulate sh
988 # For ksh: alias echo to 'print -r'.
989 if test -z "$have_echo" \
990 && (type print) >/dev/null 2>&1; then
991 # A 'print' command exists.
992 if type print 2>/dev/null | grep / > /dev/null; then
994 else
995 # 'print' is a shell built-in.
996 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
997 # 'print' is the ksh shell built-in.
998 alias echo='print -r'
1002 if test -z "$have_echo" \
1003 && echo '\t' | grep t > /dev/null; then
1004 have_echo=yes
1006 # For ksh: alias echo to a function that uses cat of a here document.
1007 # The ksh manual page says:
1008 # "Aliasing is performed when scripts are read, not while they are executed.
1009 # Therefore, for an alias to take effect, the alias definition command has
1010 # to be executed before the command which references the alias is read."
1011 # Because of this, we have to play strange tricks with have_echo, to ensure
1012 # that the top-level statement containing the test starts after the 'alias'
1013 # command.
1014 if test -z "$have_echo"; then
1015 bsd_echo ()
1017 cat <<EOF
1021 if (alias echo=bsd_echo) 2>/dev/null; then
1022 alias echo=bsd_echo 2>/dev/null
1025 if test -z "$have_echo" \
1026 && echo '\t' | grep t > /dev/null; then
1027 have_echo=yes
1029 if test -z "$have_echo"; then
1030 if (alias echo=bsd_echo) 2>/dev/null; then
1031 unalias echo 2>/dev/null
1034 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
1035 if test -z "$have_echo" \
1036 && test "X$1" != "X--no-reexec" \
1037 && test -f /bin/ksh; then
1038 exec /bin/ksh "$0" --no-reexec "$@"
1039 exit 127
1041 # Otherwise: respawn using /bin/sh.
1042 if test -z "$have_echo" \
1043 && test "X$1" != "X--no-reexec" \
1044 && test -f /bin/sh; then
1045 exec /bin/sh "$0" --no-reexec "$@"
1046 exit 127
1048 if test -z "$have_echo"; then
1049 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
1051 if echo '\t' | grep t > /dev/null; then
1052 : # Works fine now.
1053 else
1054 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
1056 if test "X$1" = "X--no-reexec"; then
1057 shift
1060 func_gnulib_dir
1061 func_tmpdir
1062 trap 'exit_status=$?
1063 if test "$signal" != EXIT; then
1064 echo "caught signal SIG$signal" >&2
1066 rm -rf "$tmp"
1067 exit $exit_status' EXIT
1068 for signal in HUP INT QUIT PIPE TERM; do
1069 trap '{ signal='$signal'; func_exit 1; }' $signal
1070 done
1071 signal=EXIT
1073 # The 'join' program does not exist on all platforms (e.g. Alpine Linux), and
1074 # on macOS 12.6, FreeBSD 14.0, NetBSD 9.3 it is buggy, see
1075 # <https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=232405>.
1076 # Search for a working 'join' program, by trying $JOIN, join, gjoin,
1077 # in this order.
1078 echo a > "$tmp"/join-input-1
1079 { echo; echo a; } > "$tmp"/join-input-2
1080 if test -n "$JOIN" \
1081 && LC_ALL=C $JOIN "$tmp"/join-input-1 "$tmp"/join-input-2 >/dev/null \
1082 && LC_ALL=C $JOIN "$tmp"/join-input-1 "$tmp"/join-input-2 | grep a >/dev/null \
1083 && LC_ALL=C $JOIN "$tmp"/join-input-2 "$tmp"/join-input-1 | grep a >/dev/null; then
1085 else
1086 if (type join) >/dev/null 2>&1 \
1087 && LC_ALL=C join "$tmp"/join-input-1 "$tmp"/join-input-2 | grep a >/dev/null \
1088 && LC_ALL=C join "$tmp"/join-input-2 "$tmp"/join-input-1 | grep a >/dev/null; then
1089 JOIN=join
1090 else
1091 if (type gjoin) >/dev/null 2>&1 \
1092 && LC_ALL=C gjoin "$tmp"/join-input-1 "$tmp"/join-input-2 | grep a >/dev/null \
1093 && LC_ALL=C gjoin "$tmp"/join-input-2 "$tmp"/join-input-1 | grep a >/dev/null; then
1094 JOIN=gjoin
1095 else
1096 if (type join) >/dev/null 2>&1; then
1097 echo "$progname: 'join' program is buggy. Consider installing GNU coreutils." >&2
1098 func_exit 1
1099 else
1100 echo "$progname: 'join' program not found. Consider installing GNU coreutils." >&2
1101 func_exit 1
1107 # Unset CDPATH. Otherwise, output from 'cd dir' can surprise callers.
1108 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1110 # Determine the path separator early because the following option parsing code
1111 # requires that.
1112 func_determine_path_separator
1114 # Command-line option processing.
1115 # Removes the OPTIONS from the arguments. Sets the variables:
1116 # - mode one of: list, find, import, add-import, remove-import,
1117 # update, create-testdir, create-megatestdir, test, megatest,
1118 # copy-file
1119 # - destdir from --dir
1120 # - local_gnulib_path from --local-dir, highest priority dir comes first
1121 # - modcache true or false, from --cache-modules/--no-cache-modules
1122 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1123 # - libname, supplied_libname from --lib
1124 # - sourcebase from --source-base
1125 # - m4base from --m4-base
1126 # - pobase from --po-base
1127 # - docbase from --doc-base
1128 # - testsbase from --tests-base
1129 # - auxdir from --aux-dir
1130 # - inctests true if --with-tests was given, false if --without-tests
1131 # was given, blank otherwise
1132 # - incobsolete true if --with-obsolete was given, blank otherwise
1133 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
1134 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
1135 # otherwise
1136 # - inc_privileged_tests true if --with-privileged-tests was given, blank
1137 # otherwise
1138 # - inc_unportable_tests true if --with-unportable-tests was given, blank
1139 # otherwise
1140 # - inc_all_tests true if --with-all-tests was given, blank otherwise
1141 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
1142 # - excl_longrunning_tests true if --without-longrunning-tests was given,
1143 # blank otherwise
1144 # - excl_privileged_tests true if --without-privileged-tests was given, blank
1145 # otherwise
1146 # - excl_unportable_tests true if --without-unportable-tests was given, blank
1147 # otherwise
1148 # - single_configure true if --single-configure was given, false otherwise
1149 # - avoidlist list of modules to avoid, from --avoid
1150 # - cond_dependencies true if --conditional-dependencies was given, false if
1151 # --no-conditional-dependencies was given, blank otherwise
1152 # - lgpl yes or a number if --lgpl was given, blank otherwise
1153 # - gnu_make true if --gnu-make was given, false otherwise
1154 # - makefile_name from --makefile-name
1155 # - tests_makefile_name from --tests-makefile-name
1156 # - automake_subdir true if --automake-subdir was given, false otherwise
1157 # - automake_subdir_tests true if --automake-subdir-tests was given, false otherwise
1158 # - libtool true if --libtool was given, false if --no-libtool was
1159 # given, blank otherwise
1160 # - macro_prefix from --macro-prefix
1161 # - po_domain from --po-domain
1162 # - witness_c_macro from --witness-c-macro
1163 # - vc_files true if --vc-files was given, false if --no-vc-files was
1164 # given, blank otherwise
1165 # - autoconf_minversion minimum supported autoconf version
1166 # - doit : if actions shall be executed, false if only to be printed
1167 # - copymode symlink if --symlink or --more-symlinks was given,
1168 # hardlink if --hardlink or --more-hardlinks was given,
1169 # blank otherwise
1170 # - lcopymode symlink if --local-symlink was given,
1171 # hardlink if --local-hardlink was given,
1172 # blank otherwise
1174 mode=
1175 destdir=
1176 local_gnulib_path=
1177 modcache=true
1178 verbose=0
1179 libname=libgnu
1180 supplied_libname=
1181 sourcebase=
1182 m4base=
1183 pobase=
1184 docbase=
1185 testsbase=
1186 auxdir=
1187 inctests=
1188 incobsolete=
1189 inc_cxx_tests=
1190 inc_longrunning_tests=
1191 inc_privileged_tests=
1192 inc_unportable_tests=
1193 inc_all_tests=
1194 excl_cxx_tests=
1195 excl_longrunning_tests=
1196 excl_privileged_tests=
1197 excl_unportable_tests=
1198 single_configure=false
1199 avoidlist=
1200 cond_dependencies=
1201 lgpl=
1202 gnu_make=false
1203 makefile_name=
1204 tests_makefile_name=
1205 automake_subdir=false
1206 automake_subdir_tests=false
1207 libtool=
1208 macro_prefix=
1209 po_domain=
1210 witness_c_macro=
1211 vc_files=
1212 doit=:
1213 copymode=
1214 lcopymode=
1216 while test $# -gt 0; do
1217 case "$1" in
1218 --list | --lis )
1219 mode=list
1220 shift ;;
1221 --find | --fin | --fi | --f )
1222 mode=find
1223 shift ;;
1224 --import | --impor | --impo | --imp | --im | --i )
1225 mode=import
1226 shift ;;
1227 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1228 mode=add-import
1229 shift ;;
1230 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1231 mode=remove-import
1232 shift ;;
1233 --update | --updat | --upda | --upd | --up | --u )
1234 mode=update
1235 shift ;;
1236 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1237 mode=create-testdir
1238 shift ;;
1239 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1240 mode=create-megatestdir
1241 shift ;;
1242 --test | --tes | --te | --t )
1243 mode=test
1244 shift ;;
1245 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1246 mode=megatest
1247 shift ;;
1248 --extract-* )
1249 mode=`echo "X$1" | sed -e 's/^X--//'`
1250 shift ;;
1251 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1252 mode=copy-file
1253 shift ;;
1254 --dir )
1255 shift
1256 if test $# = 0; then
1257 func_fatal_error "missing argument for --dir"
1259 destdir=$1
1260 shift ;;
1261 --dir=* )
1262 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1263 shift ;;
1264 --local-dir )
1265 shift
1266 if test $# = 0; then
1267 func_fatal_error "missing argument for --local-dir"
1269 func_path_append local_gnulib_path "$1"
1270 shift ;;
1271 --local-dir=* )
1272 local_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1273 func_path_append local_gnulib_path "$local_dir"
1274 shift ;;
1275 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1276 modcache=true
1277 shift ;;
1278 --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 )
1279 modcache=false
1280 shift ;;
1281 --verbose | --verbos | --verbo | --verb )
1282 verbose=`expr $verbose + 1`
1283 shift ;;
1284 --quiet | --quie | --qui | --qu | --q )
1285 verbose=`expr $verbose - 1`
1286 shift ;;
1287 --lib )
1288 shift
1289 if test $# = 0; then
1290 func_fatal_error "missing argument for --lib"
1292 libname=$1
1293 supplied_libname=true
1294 shift ;;
1295 --lib=* )
1296 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1297 supplied_libname=true
1298 shift ;;
1299 --source-base )
1300 shift
1301 if test $# = 0; then
1302 func_fatal_error "missing argument for --source-base"
1304 sourcebase=$1
1305 shift ;;
1306 --source-base=* )
1307 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1308 shift ;;
1309 --m4-base )
1310 shift
1311 if test $# = 0; then
1312 func_fatal_error "missing argument for --m4-base"
1314 m4base=$1
1315 shift ;;
1316 --m4-base=* )
1317 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1318 shift ;;
1319 --po-base )
1320 shift
1321 if test $# = 0; then
1322 func_fatal_error "missing argument for --po-base"
1324 pobase=$1
1325 shift ;;
1326 --po-base=* )
1327 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1328 shift ;;
1329 --doc-base )
1330 shift
1331 if test $# = 0; then
1332 func_fatal_error "missing argument for --doc-base"
1334 docbase=$1
1335 shift ;;
1336 --doc-base=* )
1337 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1338 shift ;;
1339 --tests-base )
1340 shift
1341 if test $# = 0; then
1342 func_fatal_error "missing argument for --tests-base"
1344 testsbase=$1
1345 shift ;;
1346 --tests-base=* )
1347 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1348 shift ;;
1349 --aux-dir )
1350 shift
1351 if test $# = 0; then
1352 func_fatal_error "missing argument for --aux-dir"
1354 auxdir=$1
1355 shift ;;
1356 --aux-dir=* )
1357 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1358 shift ;;
1359 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1360 inctests=true
1361 shift ;;
1362 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1363 incobsolete=true
1364 shift ;;
1365 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1366 inc_cxx_tests=true
1367 shift ;;
1368 --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)
1369 inc_longrunning_tests=true
1370 shift ;;
1371 --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)
1372 inc_privileged_tests=true
1373 shift ;;
1374 --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)
1375 inc_unportable_tests=true
1376 shift ;;
1377 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1378 inc_all_tests=true
1379 shift ;;
1380 --without-tests | --without-test | --without-tes | --without-te | --without-t)
1381 inctests=false
1382 shift ;;
1383 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1384 excl_cxx_tests=true
1385 shift ;;
1386 --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)
1387 excl_longrunning_tests=true
1388 shift ;;
1389 --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)
1390 excl_privileged_tests=true
1391 shift ;;
1392 --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)
1393 excl_unportable_tests=true
1394 shift ;;
1395 --single-configure | --single-configur | --single-configu | --single-config | --single-confi | --single-conf | --single-con | --single-co | --single-c | --single- | --single | --singl | --sing | --sin | --si)
1396 single_configure=true
1397 shift ;;
1398 --avoid )
1399 shift
1400 if test $# = 0; then
1401 func_fatal_error "missing argument for --avoid"
1403 if test -z "$avoidlist"; then
1404 avoidlist="$1"
1405 else
1406 func_append avoidlist " $1"
1408 shift ;;
1409 --avoid=* )
1410 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1411 if test -z "$avoidlist"; then
1412 avoidlist="$arg"
1413 else
1414 func_append avoidlist " $arg"
1416 shift ;;
1417 --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)
1418 cond_dependencies=true
1419 shift ;;
1420 --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)
1421 cond_dependencies=false
1422 shift ;;
1423 --lgpl )
1424 lgpl=yes
1425 shift ;;
1426 --lgpl=* )
1427 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1428 case "$arg" in
1429 2 | 3orGPLv2 | 3) ;;
1430 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1431 esac
1432 lgpl=$arg
1433 shift ;;
1434 --gnu-make )
1435 gnu_make=true
1436 shift ;;
1437 --makefile-name )
1438 shift
1439 if test $# = 0; then
1440 func_fatal_error "missing argument for --makefile-name"
1442 makefile_name="$1"
1443 shift ;;
1444 --makefile-name=* )
1445 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1446 shift ;;
1447 --tests-makefile-name )
1448 shift
1449 if test $# = 0; then
1450 func_fatal_error "missing argument for --tests-makefile-name"
1452 tests_makefile_name="$1"
1453 shift ;;
1454 --tests-makefile-name=* )
1455 tests_makefile_name=`echo "X$1" | sed -e 's/^X--tests-makefile-name=//'`
1456 shift ;;
1457 --automake-subdir )
1458 automake_subdir=true
1459 shift ;;
1460 --automake-subdir-tests )
1461 automake_subdir_tests=true
1462 shift ;;
1463 --libtool )
1464 libtool=true
1465 shift ;;
1466 --no-libtool )
1467 libtool=false
1468 shift ;;
1469 --macro-prefix )
1470 shift
1471 if test $# = 0; then
1472 func_fatal_error "missing argument for --macro-prefix"
1474 macro_prefix="$1"
1475 shift ;;
1476 --macro-prefix=* )
1477 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1478 shift ;;
1479 --po-domain )
1480 shift
1481 if test $# = 0; then
1482 func_fatal_error "missing argument for --po-domain"
1484 po_domain="$1"
1485 shift ;;
1486 --po-domain=* )
1487 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1488 shift ;;
1489 --witness-c-macro )
1490 shift
1491 if test $# = 0; then
1492 func_fatal_error "missing argument for --witness-c-macro"
1494 witness_c_macro="$1"
1495 shift ;;
1496 --witness-c-macro=* )
1497 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1498 shift ;;
1499 --vc-files )
1500 vc_files=true
1501 shift ;;
1502 --no-vc-files )
1503 vc_files=false
1504 shift ;;
1505 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1506 # A no-op for backward compatibility.
1507 shift ;;
1508 --dry-run )
1509 doit=false
1510 shift ;;
1511 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1512 copymode=symlink
1513 shift ;;
1514 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1515 lcopymode=symlink
1516 shift ;;
1517 -h | --hardlink | --hardlin | --hardli | --hardl | --hard | --har | --ha )
1518 copymode=hardlink
1519 shift ;;
1520 --local-hardlink | --local-hardlin | --local-hardli | --local-hardl | --local-hard | --local-har | --local-ha | --local-h )
1521 lcopymode=hardlink
1522 shift ;;
1523 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s )
1524 copymode=symlink
1525 shift ;;
1526 -H | --more-hardlinks | --more-hardlink | --more-hardlin | --more-hardli | --more-hardl | --more-hard | --more-har | --more-ha | --more-h )
1527 copymode=hardlink
1528 shift ;;
1529 --help | --hel | --he )
1530 func_usage
1531 func_exit $? ;;
1532 --version | --versio | --versi | --vers )
1533 func_version
1534 func_exit $? ;;
1535 # Undocumented option. Only used for the gnulib-tool test suite.
1536 --gnulib-dir=* )
1537 gnulib_dir=`echo "X$1" | sed -e 's/^X--gnulib-dir=//'`
1538 gnulib_dir=`cd "$gnulib_dir" && pwd`
1539 shift ;;
1540 -- )
1541 # Stop option processing
1542 shift
1543 break ;;
1544 -* )
1545 echo "gnulib-tool: unknown option $1" 1>&2
1546 echo "Try 'gnulib-tool --help' for more information." 1>&2
1547 func_exit 1 ;;
1549 break ;;
1550 esac
1551 done
1553 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1554 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1555 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1556 || test "$single_configure" != false; then
1557 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1558 echo "Try 'gnulib-tool --help' for more information." 1>&2
1559 func_exit 1
1562 if test "$mode" = update; then
1563 if test $# != 0; then
1564 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1565 echo "Try 'gnulib-tool --help' for more information." 1>&2
1566 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1567 echo "you need to use 'gnulib-tool --import' - at your own risk!" 1>&2
1568 func_exit 1
1570 if test -n "$local_gnulib_path" || test -n "$supplied_libname" \
1571 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1572 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1573 || test -n "$inctests" || test -n "$incobsolete" \
1574 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1575 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1576 || test -n "$inc_all_tests" \
1577 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1578 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1579 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1580 || test -n "$tests_makefile_name" || test "$automake_subdir" != false \
1581 || test "$automake_subdir_tests" != false \
1582 || test -n "$macro_prefix" || test -n "$po_domain" \
1583 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1584 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1585 echo "Try 'gnulib-tool --help' for more information." 1>&2
1586 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1587 echo "you need to use 'gnulib-tool --import' - at your own risk!" 1>&2
1588 func_exit 1
1591 if test -n "$pobase" && test -z "$po_domain"; then
1592 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1593 echo "Try 'gnulib-tool --help' for more information." 1>&2
1594 func_exit 1
1596 if test -z "$pobase" && test -n "$po_domain"; then
1597 func_warning "--po-domain has no effect without a --po-base option"
1599 case $mode,$gnu_make in
1600 *test*,true)
1601 echo "gnulib-tool: --gnu-make not supported when including tests"
1602 func_exit 1;;
1603 esac
1604 # Canonicalize the inctests variable.
1605 case "$mode" in
1606 import | add-import | remove-import | update)
1607 if test -z "$inctests"; then
1608 inctests=false
1611 create-testdir | create-megatestdir | test | megatest)
1612 if test -z "$inctests"; then
1613 inctests=true
1616 esac
1617 # Now the only possible values of "$inctests" are true and false
1618 # (or blank but then it is irrelevant).
1620 # Determine the minimum supported autoconf version from the project's
1621 # configure.ac.
1622 DEFAULT_AUTOCONF_MINVERSION="2.64"
1623 autoconf_minversion=
1624 configure_ac=
1625 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1626 && test -n "$destdir"; then
1627 if test -f "$destdir"/configure.ac; then
1628 configure_ac="$destdir/configure.ac"
1629 else
1630 if test -f "$destdir"/configure.in; then
1631 configure_ac="$destdir/configure.in"
1634 else
1635 if test -f configure.ac; then
1636 configure_ac="configure.ac"
1637 else
1638 if test -f configure.in; then
1639 configure_ac="configure.in"
1643 if test -n "$configure_ac"; then
1644 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1645 # because when some m4 files are omitted from a version control repository,
1646 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1647 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1648 # autom4te: m4 failed with exit status: 1
1649 my_sed_traces='
1650 s,#.*$,,
1651 s,^dnl .*$,,
1652 s, dnl .*$,,
1653 /AC_PREREQ/ {
1654 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1656 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1657 if test -n "$prereqs"; then
1658 autoconf_minversion=`
1659 for version in $prereqs; do echo $version; done |
1660 LC_ALL=C sort -nru | sed -e 1q
1664 if test -z "$autoconf_minversion"; then
1665 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1667 case "$autoconf_minversion" in
1668 1.* | 2.[0-5]* | 2.6[0-3]*)
1669 func_fatal_error "minimum supported autoconf version is 2.64. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1670 esac
1672 # Determine whether --automake-subdir/--automake-subdir-tests are supported.
1673 if $automake_subdir || $automake_subdir_tests; then
1674 found_subdir_objects=false
1675 if test -n "$configure_ac"; then
1676 my_sed_traces='
1677 s,#.*$,,
1678 s,^dnl .*$,,
1679 s, dnl .*$,,
1680 /AM_INIT_AUTOMAKE/ {
1681 s,^.*AM_INIT_AUTOMAKE([[ ]*\([^])]*\).*$,\1,p
1683 automake_options=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1684 for option in $automake_options; do
1685 case "$option" in
1686 subdir-objects ) found_subdir_objects=true ;;
1687 esac
1688 done
1690 if test -f "${destdir:-.}"/Makefile.am; then
1691 automake_options=`sed -n -e 's/^AUTOMAKE_OPTIONS[ ]*=\(.*\)$/\1/p' "${destdir:-.}"/Makefile.am`
1692 for option in $automake_options; do
1693 case "$option" in
1694 subdir-objects ) found_subdir_objects=true ;;
1695 esac
1696 done
1698 if ! $found_subdir_objects; then
1699 func_fatal_error "Option --automake-subdir/--automake-subdir-tests are only supported if the definition of AUTOMAKE_OPTIONS in Makefile.am contains 'subdir-objects'."
1703 # Remove trailing slashes from the directory names. This is necessary for
1704 # m4base (to avoid an error in func_import) and optional for the others.
1705 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1706 old_local_gnulib_path="$local_gnulib_path"
1707 local_gnulib_path=
1708 saved_IFS="$IFS"
1709 IFS=:
1710 for dir in $old_local_gnulib_path
1712 IFS="$saved_IFS"
1713 case "$dir" in
1714 */ ) dir=`echo "$dir" | sed -e "$sed_trimtrailingslashes"` ;;
1715 esac
1716 func_path_append local_gnulib_path "$dir"
1717 done
1718 IFS="$saved_IFS"
1719 case "$sourcebase" in
1720 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1721 esac
1722 case "$m4base" in
1723 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1724 esac
1725 case "$pobase" in
1726 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1727 esac
1728 case "$docbase" in
1729 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1730 esac
1731 case "$testsbase" in
1732 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1733 esac
1734 case "$auxdir" in
1735 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1736 esac
1739 # Note: The 'eval' silences stderr output in dash.
1740 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1741 # Zsh 4 and Bash 4 have associative arrays.
1742 have_associative=true
1743 else
1744 # For other shells, use 'eval' with computed shell variable names.
1745 have_associative=false
1748 # func_lookup_local_file_cb dir file
1749 # returns true and sets func_lookup_local_file_result if the file $dir/$file
1750 # exists.
1751 func_lookup_local_file_cb ()
1753 test -n "$func_lookup_local_file_result" && return 1 # already found?
1754 test -f "$1/$2" || return 1
1755 func_lookup_local_file_result=$1/$2
1759 # func_lookup_local_file file
1760 # looks up a file in $local_gnulib_path.
1761 # Input:
1762 # - local_gnulib_path from --local-dir
1763 # Output:
1764 # - func_lookup_local_file_result name of the file, valid only when the
1765 # function succeeded.
1766 func_lookup_local_file ()
1768 func_lookup_local_file_result=
1769 func_path_foreach "$local_gnulib_path" func_lookup_local_file_cb %dir% "$1"
1772 # func_lookup_file_cb dir
1773 # does one step in processing the $local_gnulib_path, looking for $dir/$lkfile
1774 # and $dir/$lkfile.diff.
1775 func_lookup_file_cb ()
1777 # If we found the file already in a --local-dir of higher priority, nothing
1778 # more to do.
1779 if test -z "$lookedup_file"; then
1780 # Otherwise, look for $dir/$lkfile and $dir/$lkfile.diff.
1781 if test -f "$1/$lkfile"; then
1782 lookedup_file="$1/$lkfile"
1783 else
1784 if test -f "$1/$lkfile.diff"; then
1785 lkpatches="$1/$lkfile.diff${lkpatches:+$PATH_SEPARATOR$lkpatches}"
1791 # func_lookup_file file
1792 # looks up a file in $local_gnulib_path or $gnulib_dir, or combines it through
1793 # 'patch'.
1794 # Input:
1795 # - local_gnulib_path from --local-dir
1796 # Output:
1797 # - lookedup_file name of the merged (combined) file
1798 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1799 func_lookup_file ()
1801 lkfile="$1"
1802 # Each element in $local_gnulib_path is a directory whose contents overrides
1803 # or amends the result of the lookup in the rest of $local_gnulib_path and
1804 # $gnulib_dir. So, the first element of $local_gnulib_path is the highest
1805 # priority one.
1806 lookedup_file=
1807 lkpatches=
1808 func_path_foreach "$local_gnulib_path" func_lookup_file_cb %dir%
1809 # Treat $gnulib_dir like a lowest-priority --local-dir, except that here we
1810 # don't look for .diff files.
1811 if test -z "$lookedup_file"; then
1812 if test -f "$gnulib_dir/$lkfile"; then
1813 lookedup_file="$gnulib_dir/$lkfile"
1814 else
1815 func_fatal_error "file $gnulib_dir/$lkfile not found"
1818 # Now apply the patches, from lowest-priority to highest-priority.
1819 lookedup_tmp=
1820 if test -n "$lkpatches"; then
1821 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1822 rm -f "$tmp/$lkbase"
1823 cp "$lookedup_file" "$tmp/$lkbase"
1824 func_ensure_writable "$tmp/$lkbase"
1825 saved_IFS="$IFS"
1826 IFS="$PATH_SEPARATOR"
1827 for patchfile in $lkpatches; do
1828 IFS="$saved_IFS"
1829 patch -s "$tmp/$lkbase" < "$patchfile" >&2 \
1830 || func_fatal_error "patch file $patchfile didn't apply cleanly"
1831 done
1832 IFS="$saved_IFS"
1833 lookedup_file="$tmp/$lkbase"
1834 lookedup_tmp=true
1838 # func_sanitize_modulelist
1839 # receives a list of possible module names on standard input, one per line.
1840 # It removes those which are just file names unrelated to modules, and outputs
1841 # the resulting list to standard output, one per line.
1842 func_sanitize_modulelist ()
1844 sed -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1845 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1846 -e '/^README$/d' -e '/\/README$/d' \
1847 -e '/^TEMPLATE$/d' \
1848 -e '/^TEMPLATE-EXTENDED$/d' \
1849 -e '/^TEMPLATE-TESTS$/d' \
1850 -e '/^\..*/d' \
1851 -e '/\.orig$/d' \
1852 -e '/\.rej$/d' \
1853 -e '/~$/d'
1857 # func_modules_in_dir dir
1858 # outputs all module files in dir to standard output.
1859 func_modules_in_dir ()
1861 (test -d "$1" && cd "$1" && find modules -type f -print)
1864 # func_all_modules
1865 # Input:
1866 # - local_gnulib_path from --local-dir
1867 func_all_modules ()
1869 # Filter out metainformation files like README, which are not modules.
1870 # Filter out unit test modules; they can be retrieved through
1871 # --extract-tests-module if desired.
1873 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1874 func_path_foreach "$local_gnulib_path" func_modules_in_dir %dir% | sed -e 's,^modules/,,' -e 's,\.diff$,,'
1876 | func_sanitize_modulelist \
1877 | sed -e '/-tests$/d' \
1878 | LC_ALL=C sort -u
1881 # func_exists_local_module dir module
1882 # returns true if module exists in dir
1883 func_exists_local_module ()
1885 test -d "$1/modules" && test -f "$1/modules/$2";
1888 # func_exists_module module
1889 # tests whether a module, given by name, exists
1890 # Input:
1891 # - local_gnulib_path from --local-dir
1892 func_exists_module ()
1894 { test -f "$gnulib_dir/modules/$1" \
1895 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1" ; } \
1896 && test "ChangeLog" != "$1" \
1897 && test "COPYING" != "$1" \
1898 && test "README" != "$1" \
1899 && test "TEMPLATE" != "$1" \
1900 && test "TEMPLATE-EXTENDED" != "$1" \
1901 && test "TEMPLATE-TESTS" != "$1"
1904 # func_verify_module
1905 # verifies a module name
1906 # Input:
1907 # - local_gnulib_path from --local-dir
1908 # - module module name argument
1909 # Output:
1910 # - module unchanged if OK, empty if not OK
1911 # - lookedup_file if OK: name of the merged (combined) module description file
1912 # - lookedup_tmp if OK: true if it is located in the tmp directory, blank otherwise
1913 func_verify_module ()
1915 if func_exists_module "$module"; then
1916 # OK, $module is a correct module name.
1917 # Verify that building the module description with 'patch' succeeds.
1918 func_lookup_file "modules/$module"
1919 else
1920 func_warning "module $module doesn't exist"
1921 module=
1925 # func_verify_nontests_module
1926 # verifies a module name, excluding tests modules
1927 # Input:
1928 # - local_gnulib_path from --local-dir
1929 # - module module name argument
1930 func_verify_nontests_module ()
1932 case "$module" in
1933 *-tests ) module= ;;
1934 * ) func_verify_module ;;
1935 esac
1938 # Suffix of a sed expression that extracts a particular field from a
1939 # module description.
1940 # A field starts with a line that contains a keyword, such as 'Description',
1941 # followed by a colon and optional whitespace. All following lines, up to
1942 # the next field (or end of file if there is none) form the contents of the
1943 # field.
1944 # An absent field is equivalent to a field with empty contents.
1945 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1946 sed_extract_prog=':[ ]*$/ {
1949 s/^Description:[ ]*$//
1950 s/^Comment:[ ]*$//
1951 s/^Status:[ ]*$//
1952 s/^Notice:[ ]*$//
1953 s/^Applicability:[ ]*$//
1954 s/^Files:[ ]*$//
1955 s/^Depends-on:[ ]*$//
1956 s/^configure\.ac-early:[ ]*$//
1957 s/^configure\.ac:[ ]*$//
1958 s/^Makefile\.am:[ ]*$//
1959 s/^Include:[ ]*$//
1960 s/^Link:[ ]*$//
1961 s/^License:[ ]*$//
1962 s/^Maintainer:[ ]*$//
1969 # Piece of a sed expression that converts a field header line to a shell
1970 # variable name,
1971 # NOTE: Keep this in sync with sed_extract_prog above!
1972 sed_extract_field_header='
1973 s/^Description:[ ]*$/description/
1974 s/^Comment:[ ]*$/comment/
1975 s/^Status:[ ]*$/status/
1976 s/^Notice:[ ]*$/notice/
1977 s/^Applicability:[ ]*$/applicability/
1978 s/^Files:[ ]*$/files/
1979 s/^Depends-on:[ ]*$/dependson/
1980 s/^configure\.ac-early:[ ]*$/configureac_early/
1981 s/^configure\.ac:[ ]*$/configureac/
1982 s/^Makefile\.am:[ ]*$/makefile/
1983 s/^Include:[ ]*$/include/
1984 s/^Link:[ ]*$/link/
1985 s/^License:[ ]*$/license/
1986 s/^Maintainer:[ ]*$/maintainer/'
1988 if $modcache; then
1990 if $have_associative; then
1992 # Declare the associative arrays.
1993 declare -A modcache_cached
1994 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1995 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1996 eval "$declare_script"
1998 else
2000 # func_cache_var module
2001 # computes the cache variable name corresponding to $module.
2002 # Note: This computation can map different module names to the same
2003 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
2004 # to protect against this case.
2005 # Output:
2006 # - cachevar a shell variable name
2007 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
2008 # Bash 2.0 and newer, ksh, and zsh support the syntax
2009 # ${param//pattern/replacement}
2010 # as a shorthand for
2011 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
2012 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
2013 eval 'func_cache_var ()
2015 cachevar=c_${1//[!a-zA-Z0-9_]/_}
2017 else
2018 func_cache_var ()
2020 case $1 in
2021 *[!a-zA-Z0-9_]*)
2022 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
2024 cachevar=c_$1 ;;
2025 esac
2031 # func_init_sed_convert_to_cache_statements
2032 # Input:
2033 # - modcachevar_assignment
2034 # Output:
2035 # - sed_convert_to_cache_statements
2036 func_init_sed_convert_to_cache_statements ()
2038 # 'sed' script that turns a module description into shell script
2039 # assignments, suitable to be eval'ed. All active characters are escaped.
2040 # This script turns
2041 # Description:
2042 # Some module's description
2044 # Files:
2045 # lib/file.h
2046 # into:
2047 # modcache_description[$1]=\
2048 # 'Some module'"'"'s description
2050 # modcache_files[$1]=\
2051 # 'lib/file.h'
2052 # or:
2053 # c_MODULE_description_set=set; c_MODULE_description=\
2054 # 'Some module'"'"'s description
2056 # c_MODULE_files_set=set; c_MODULE_files=\
2057 # 'lib/file.h'
2058 # The script consists of two parts:
2059 # 1) Ignore the lines before the first field header.
2060 # 2) A loop, treating non-field-header lines by escaping single quotes
2061 # and adding a closing quote in the last line,
2062 sed_convert_to_cache_statements="
2063 :llla
2064 # Here we have not yet seen a field header.
2066 # See if the current line contains a field header.
2067 t llla1
2068 :llla1
2069 ${sed_extract_field_header}
2070 t lllb
2072 # No field header. Ignore the line.
2074 # Read the next line. Upon EOF, just exit.
2076 b llla
2078 :lllb
2079 # The current line contains a field header.
2081 # Turn it into the beginning of an assignment.
2082 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
2084 # Move it to the hold space. Don't print it yet,
2085 # because we want no assignment if the field is empty.
2088 # Read the next line.
2089 # Upon EOF, the field was empty. Print no assignment. Just exit.
2092 # See if the current line contains a field header.
2093 t lllb1
2094 :lllb1
2095 ${sed_extract_field_header}
2096 # If it is, the previous field was empty. Print no assignment.
2097 t lllb
2099 # Not a field header.
2101 # Print the previous line, held in the hold space.
2106 # Transform single quotes.
2107 s/'/'\"'\"'/g
2109 # Prepend a single quote.
2110 s/^/'/
2112 :lllc
2114 # Move it to the hold space.
2117 # Read the next line.
2118 # Upon EOF, branch.
2120 b llle
2124 # See if the current line contains a field header.
2125 t lllc1
2126 :lllc1
2127 ${sed_extract_field_header}
2128 t llld
2130 # Print the previous line, held in the hold space.
2135 # Transform single quotes.
2136 s/'/'\"'\"'/g
2138 b lllc
2140 :llld
2141 # A field header.
2142 # Print the previous line, held in the hold space, with a single quote
2143 # to end the assignment.
2145 s/\$/'/
2149 b lllb
2151 :llle
2152 # EOF seen.
2153 # Print the previous line, held in the hold space, with a single quote
2154 # to end the assignment.
2156 s/\$/'/
2158 # Exit.
2161 if ! $sed_comments; then
2162 # Remove comments.
2163 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
2164 | sed -e 's/^ *//' -e 's/^#.*//'`
2168 if $have_associative; then
2169 # sed_convert_to_cache_statements does not depend on the module.
2170 modcachevar_assignment='modcache_\1[$1]='
2171 func_init_sed_convert_to_cache_statements
2174 # func_cache_lookup_module module
2176 # looks up a module, like 'func_lookup_file modules/$module', and stores all
2177 # of its relevant data in a cache in the memory of the processing shell. If
2178 # already cached, it does not look it up again, thus saving file access time.
2179 # Parameters:
2180 # - module non-empty string
2181 # Output if $have_associative:
2182 # - modcache_cached[$module] set to yes
2183 # - modcache_description[$module] ==
2184 # - modcache_status[$module] \ set to the field's value, minus the
2185 # - ... / final newline,
2186 # - modcache_maintainer[$module] == or unset if the field's value is empty
2187 # Output if ! $have_associative:
2188 # - cachevar a shell variable name
2189 # - ${cachevar}_cached set to $module
2190 # - ${cachevar}_description ==
2191 # - ${cachevar}_status \ set to the field's value, minus the
2192 # - ... / final newline,
2193 # - ${cachevar}_maintainer == or unset if the field's value is empty
2194 # - ${cachevar}_description_set ==
2195 # - ${cachevar}_status_set \ set to non-empty if the field's value
2196 # - ... / is non-empty,
2197 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
2198 func_cache_lookup_module ()
2200 if $have_associative; then
2201 eval 'cached=${modcache_cached[$1]}'
2202 else
2203 func_cache_var "$1"
2204 eval "cached=\"\$${cachevar}_cached\""
2206 if test -z "$cached"; then
2207 # Not found in cache. Look it up on the file system.
2208 func_lookup_file "modules/$1"
2209 if $have_associative; then
2210 eval 'modcache_cached[$1]=yes'
2211 else
2212 eval "${cachevar}_cached=\"\$1\""
2214 if ! $have_associative; then
2215 # sed_convert_to_cache_statements depends on the module.
2216 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
2217 func_init_sed_convert_to_cache_statements
2219 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
2220 eval "$cache_statements"
2221 else
2222 if ! $have_associative; then
2223 if test "$1" != "$cached"; then
2224 func_fatal_error "cache variable collision between $1 and $cached"
2232 # func_get_description module
2233 # Input:
2234 # - local_gnulib_path from --local-dir
2235 # - modcache true or false, from --cache-modules/--no-cache-modules
2236 func_get_description ()
2238 if ! $modcache; then
2239 func_lookup_file "modules/$1"
2240 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
2241 else
2242 func_cache_lookup_module "$1"
2243 # Output the field's value, including the final newline (if any).
2244 if $have_associative; then
2245 if eval 'test -n "${modcache_description[$1]+set}"'; then
2246 eval 'echo "${modcache_description[$1]}"'
2248 else
2249 eval "field_set=\"\$${cachevar}_description_set\""
2250 if test -n "$field_set"; then
2251 eval "field_value=\"\$${cachevar}_description\""
2252 echo "${field_value}"
2258 # func_get_comment module
2259 # Input:
2260 # - local_gnulib_path from --local-dir
2261 # - modcache true or false, from --cache-modules/--no-cache-modules
2262 func_get_comment ()
2264 if ! $modcache; then
2265 func_lookup_file "modules/$1"
2266 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
2267 else
2268 func_cache_lookup_module "$1"
2269 # Output the field's value, including the final newline (if any).
2270 if $have_associative; then
2271 if eval 'test -n "${modcache_comment[$1]+set}"'; then
2272 eval 'echo "${modcache_comment[$1]}"'
2274 else
2275 eval "field_set=\"\$${cachevar}_comment_set\""
2276 if test -n "$field_set"; then
2277 eval "field_value=\"\$${cachevar}_comment\""
2278 echo "${field_value}"
2284 # func_get_status module
2285 # Input:
2286 # - local_gnulib_path from --local-dir
2287 # - modcache true or false, from --cache-modules/--no-cache-modules
2288 func_get_status ()
2290 if ! $modcache; then
2291 func_lookup_file "modules/$1"
2292 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
2293 else
2294 func_cache_lookup_module "$1"
2295 # Output the field's value, including the final newline (if any).
2296 if $have_associative; then
2297 if eval 'test -n "${modcache_status[$1]+set}"'; then
2298 eval 'echo "${modcache_status[$1]}"'
2300 else
2301 eval "field_set=\"\$${cachevar}_status_set\""
2302 if test -n "$field_set"; then
2303 eval "field_value=\"\$${cachevar}_status\""
2304 echo "${field_value}"
2310 # func_get_notice module
2311 # Input:
2312 # - local_gnulib_path from --local-dir
2313 # - modcache true or false, from --cache-modules/--no-cache-modules
2314 func_get_notice ()
2316 if ! $modcache; then
2317 func_lookup_file "modules/$1"
2318 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
2319 else
2320 func_cache_lookup_module "$1"
2321 # Output the field's value, including the final newline (if any).
2322 if $have_associative; then
2323 if eval 'test -n "${modcache_notice[$1]+set}"'; then
2324 eval 'echo "${modcache_notice[$1]}"'
2326 else
2327 eval "field_set=\"\$${cachevar}_notice_set\""
2328 if test -n "$field_set"; then
2329 eval "field_value=\"\$${cachevar}_notice\""
2330 echo "${field_value}"
2336 # func_get_applicability module
2337 # Input:
2338 # - local_gnulib_path from --local-dir
2339 # - modcache true or false, from --cache-modules/--no-cache-modules
2340 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
2341 func_get_applicability ()
2343 if ! $modcache; then
2344 func_lookup_file "modules/$1"
2345 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2346 else
2347 func_cache_lookup_module "$1"
2348 # Get the field's value, without the final newline.
2349 if $have_associative; then
2350 eval 'my_applicability="${modcache_applicability[$1]}"'
2351 else
2352 eval "my_applicability=\"\$${cachevar}_applicability\""
2355 if test -n "$my_applicability"; then
2356 echo $my_applicability
2357 else
2358 # The default is 'main' or 'tests', depending on the module's name.
2359 case $1 in
2360 *-tests) echo "tests";;
2361 *) echo "main";;
2362 esac
2366 # func_get_filelist module
2367 # Input:
2368 # - local_gnulib_path from --local-dir
2369 # - modcache true or false, from --cache-modules/--no-cache-modules
2370 func_get_filelist ()
2372 if ! $modcache; then
2373 func_lookup_file "modules/$1"
2374 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2375 else
2376 func_cache_lookup_module "$1"
2377 # Output the field's value, including the final newline (if any).
2378 if $have_associative; then
2379 if eval 'test -n "${modcache_files[$1]+set}"'; then
2380 eval 'echo "${modcache_files[$1]}"'
2382 else
2383 eval "field_set=\"\$${cachevar}_files_set\""
2384 if test -n "$field_set"; then
2385 eval "field_value=\"\$${cachevar}_files\""
2386 echo "${field_value}"
2390 echo m4/00gnulib.m4
2391 echo m4/zzgnulib.m4
2392 echo m4/gnulib-common.m4
2395 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2396 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2397 # elements starting with prefix and ending with suffix are considered.
2398 # Processing: removed_prefix and removed_suffix are removed from each element,
2399 # added_prefix and added_suffix are added to each element.
2400 # prefix, suffix should not contain shell-special characters.
2401 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2402 # added_prefix, added_suffix should not contain the characters \|&.
2403 func_filter_filelist ()
2405 if test "$2" != "$nl" \
2406 || { $fast_func_append \
2407 && { test -z "$6" || $fast_func_remove_prefix; } \
2408 && { test -z "$7" || $fast_func_remove_suffix; }; \
2409 }; then
2410 ffflist=
2411 for fff in $3; do
2412 # Do not quote possibly-empty parameters in case patterns,
2413 # AIX and HP-UX ksh won't match them if they are empty.
2414 case "$fff" in
2415 $4*$5)
2416 if test -n "$6"; then
2417 func_remove_prefix fff "$6"
2419 if test -n "$7"; then
2420 func_remove_suffix fff "$7"
2422 fff="$8${fff}$9"
2423 if test -z "$ffflist"; then
2424 ffflist="${fff}"
2425 else
2426 func_append ffflist "$2${fff}"
2429 esac
2430 done
2431 else
2432 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2433 ffflist=`for fff in $3; do
2434 case "$fff" in
2435 $4*$5) echo "$fff" ;;
2436 esac
2437 done | sed -e "$sed_fff_filter"`
2439 eval "$1=\"\$ffflist\""
2442 # func_get_dependencies module
2443 # Input:
2444 # - local_gnulib_path from --local-dir
2445 # - modcache true or false, from --cache-modules/--no-cache-modules
2446 func_get_dependencies ()
2448 # ${module}-tests implicitly depends on ${module}, if that module exists.
2449 case "$1" in
2450 *-tests)
2451 fgd1="$1"
2452 func_remove_suffix fgd1 '-tests'
2453 if func_exists_module "$fgd1"; then
2454 echo "$fgd1"
2457 esac
2458 # Then the explicit dependencies listed in the module description.
2459 { if ! $modcache; then
2460 func_lookup_file "modules/$1"
2461 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2462 else
2463 func_cache_lookup_module "$1"
2464 # Output the field's value, including the final newline (if any).
2465 if $have_associative; then
2466 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2467 eval 'echo "${modcache_dependson[$1]}"'
2469 else
2470 eval "field_set=\"\$${cachevar}_dependson_set\""
2471 if test -n "$field_set"; then
2472 eval "field_value=\"\$${cachevar}_dependson\""
2473 echo "${field_value}"
2478 | sed -e '/^#/d'
2481 sed_dependencies_without_conditions='s/ *\[.*//'
2483 # func_get_autoconf_early_snippet module
2484 # Input:
2485 # - local_gnulib_path from --local-dir
2486 # - modcache true or false, from --cache-modules/--no-cache-modules
2487 func_get_autoconf_early_snippet ()
2489 if ! $modcache; then
2490 func_lookup_file "modules/$1"
2491 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2492 else
2493 func_cache_lookup_module "$1"
2494 # Output the field's value, including the final newline (if any).
2495 if $have_associative; then
2496 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2497 eval 'echo "${modcache_configureac_early[$1]}"'
2499 else
2500 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2501 if test -n "$field_set"; then
2502 eval "field_value=\"\$${cachevar}_configureac_early\""
2503 echo "${field_value}"
2509 # func_get_autoconf_snippet module
2510 # Input:
2511 # - local_gnulib_path from --local-dir
2512 # - modcache true or false, from --cache-modules/--no-cache-modules
2513 func_get_autoconf_snippet ()
2515 if ! $modcache; then
2516 func_lookup_file "modules/$1"
2517 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2518 else
2519 func_cache_lookup_module "$1"
2520 # Output the field's value, including the final newline (if any).
2521 if $have_associative; then
2522 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2523 eval 'echo "${modcache_configureac[$1]}"'
2525 else
2526 eval "field_set=\"\$${cachevar}_configureac_set\""
2527 if test -n "$field_set"; then
2528 eval "field_value=\"\$${cachevar}_configureac\""
2529 echo "${field_value}"
2535 # Concatenate lines with trailing slash.
2536 # $1 is an optional filter to restrict the
2537 # concatenation to groups starting with that expression
2538 combine_lines() {
2539 sed -e "/$1.*"'\\$/{
2542 s/\\\n/ /
2543 s/\\$/\\/
2548 # func_get_automake_snippet_conditional module
2549 # returns the part of the Makefile.am snippet that can be put inside Automake
2550 # conditionals.
2551 # Input:
2552 # - local_gnulib_path from --local-dir
2553 # - modcache true or false, from --cache-modules/--no-cache-modules
2554 func_get_automake_snippet_conditional ()
2556 if ! $modcache; then
2557 func_lookup_file "modules/$1"
2558 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2559 else
2560 func_cache_lookup_module "$1"
2561 # Output the field's value, including the final newline (if any).
2562 if $have_associative; then
2563 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2564 eval 'echo "${modcache_makefile[$1]}"'
2566 else
2567 eval "field_set=\"\$${cachevar}_makefile_set\""
2568 if test -n "$field_set"; then
2569 eval "field_value=\"\$${cachevar}_makefile\""
2570 echo "${field_value}"
2576 # func_get_automake_snippet_unconditional module
2577 # returns the part of the Makefile.am snippet that must stay outside of
2578 # Automake conditionals.
2579 # Input:
2580 # - local_gnulib_path from --local-dir
2581 # - modcache true or false, from --cache-modules/--no-cache-modules
2582 # - auxdir directory relative to destdir where to place build aux files
2583 func_get_automake_snippet_unconditional ()
2585 case "$1" in
2586 *-tests)
2587 # *-tests module live in tests/, not lib/.
2588 # Synthesize an EXTRA_DIST augmentation.
2589 all_files=`func_get_filelist $1`
2590 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2591 extra_files="$tests_files"
2592 if test -n "$extra_files"; then
2593 echo "EXTRA_DIST +=" $extra_files
2594 echo
2598 # Synthesize an EXTRA_DIST augmentation.
2599 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2600 already_mentioned_files=` \
2601 { if ! $modcache; then
2602 func_lookup_file "modules/$1"
2603 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2604 else
2605 func_cache_lookup_module "$1"
2606 if $have_associative; then
2607 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2608 eval 'echo "${modcache_makefile[$1]}"'
2610 else
2611 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2612 if test -n "$field_set"; then
2613 eval 'field_value="$'"${cachevar}"'_makefile"'
2614 echo "${field_value}"
2619 | combine_lines \
2620 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2621 all_files=`func_get_filelist $1`
2622 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2623 # Remove $already_mentioned_files from $lib_files.
2624 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2625 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2626 | LC_ALL=C sort -u | LC_ALL=C $JOIN -v 2 - "$tmp"/lib-files`
2627 if test -n "$extra_files"; then
2628 echo "EXTRA_DIST +=" $extra_files
2629 echo
2631 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2632 # This is necessary so that automake can generate the right list of
2633 # dependency rules.
2634 # A possible approach would be to use autom4te --trace of the redefined
2635 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2636 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2637 # inside autoconf's built-in macros are not missed).
2638 # But it's simpler and more robust to do it here, based on the file list.
2639 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2640 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2641 # automake will generate a useless dependency; this is harmless.
2642 case "$1" in
2643 relocatable-prog-wrapper) ;;
2644 pt_chown) ;;
2646 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2647 if test -n "$extra_files"; then
2648 echo "EXTRA_lib_SOURCES +=" $extra_files
2649 echo
2652 esac
2653 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2654 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2655 if test -n "$buildaux_files"; then
2656 if test "$auxdir" != "."; then
2657 auxdir_subdir="$auxdir/"
2658 else
2659 auxdir_subdir=
2661 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir_subdir"','
2662 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2663 echo
2666 esac
2669 # func_get_automake_snippet module
2670 # Input:
2671 # - local_gnulib_path from --local-dir
2672 # - modcache true or false, from --cache-modules/--no-cache-modules
2673 # - auxdir directory relative to destdir where to place build aux files
2674 func_get_automake_snippet ()
2676 func_get_automake_snippet_conditional "$1"
2677 func_get_automake_snippet_unconditional "$1"
2680 # func_get_include_directive module
2681 # Input:
2682 # - local_gnulib_path from --local-dir
2683 # - modcache true or false, from --cache-modules/--no-cache-modules
2684 func_get_include_directive ()
2687 if ! $modcache; then
2688 func_lookup_file "modules/$1"
2689 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2690 else
2691 func_cache_lookup_module "$1"
2692 # Output the field's value, including the final newline (if any).
2693 if $have_associative; then
2694 if eval 'test -n "${modcache_include[$1]+set}"'; then
2695 eval 'echo "${modcache_include[$1]}"'
2697 else
2698 eval "field_set=\"\$${cachevar}_include_set\""
2699 if test -n "$field_set"; then
2700 eval "field_value=\"\$${cachevar}_include\""
2701 echo "${field_value}"
2705 } | sed -e 's/^\(["<]\)/#include \1/'
2708 # func_get_link_directive module
2709 # Input:
2710 # - local_gnulib_path from --local-dir
2711 # - modcache true or false, from --cache-modules/--no-cache-modules
2712 func_get_link_directive ()
2714 if ! $modcache; then
2715 func_lookup_file "modules/$1"
2716 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2717 else
2718 func_cache_lookup_module "$1"
2719 # Output the field's value, including the final newline (if any).
2720 if $have_associative; then
2721 if eval 'test -n "${modcache_link[$1]+set}"'; then
2722 eval 'echo "${modcache_link[$1]}"'
2724 else
2725 eval "field_set=\"\$${cachevar}_link_set\""
2726 if test -n "$field_set"; then
2727 eval "field_value=\"\$${cachevar}_link\""
2728 echo "${field_value}"
2734 # func_get_license_raw module
2735 # Input:
2736 # - local_gnulib_path from --local-dir
2737 # - modcache true or false, from --cache-modules/--no-cache-modules
2738 func_get_license_raw ()
2740 if ! $modcache; then
2741 func_lookup_file "modules/$1"
2742 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2743 else
2744 func_cache_lookup_module "$1"
2745 # Output the field's value, including the final newline (if any).
2746 if $have_associative; then
2747 if eval 'test -n "${modcache_license[$1]+set}"'; then
2748 eval 'echo "${modcache_license[$1]}"'
2750 else
2751 eval "field_set=\"\$${cachevar}_license_set\""
2752 if test -n "$field_set"; then
2753 eval "field_value=\"\$${cachevar}_license\""
2754 echo "${field_value}"
2760 # func_get_license module
2761 # Input:
2762 # - local_gnulib_path from --local-dir
2763 # - modcache true or false, from --cache-modules/--no-cache-modules
2764 func_get_license ()
2766 # Warn if the License field is missing.
2767 case "$1" in
2768 *-tests ) ;;
2770 license=`func_get_license_raw "$1"`
2771 if test -z "$license"; then
2772 func_warning "module $1 lacks a License"
2775 esac
2776 case "$1" in
2777 parse-datetime* )
2778 # These modules are under a weaker license only for the purpose of some
2779 # users who hand-edit it and don't use gnulib-tool. For the regular
2780 # gnulib users they are under a stricter license.
2781 echo "GPL"
2785 func_get_license_raw "$1"
2786 # The default is GPL.
2787 echo "GPL"
2788 } | sed -e 's,^ *$,,' | sed -e 1q
2790 esac
2793 # func_get_maintainer module
2794 # Input:
2795 # - local_gnulib_path from --local-dir
2796 # - modcache true or false, from --cache-modules/--no-cache-modules
2797 func_get_maintainer ()
2799 if ! $modcache; then
2800 func_lookup_file "modules/$1"
2801 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2802 else
2803 func_cache_lookup_module "$1"
2804 # Output the field's value, including the final newline (if any).
2805 if $have_associative; then
2806 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2807 eval 'echo "${modcache_maintainer[$1]}"'
2809 else
2810 eval "field_set=\"\$${cachevar}_maintainer_set\""
2811 if test -n "$field_set"; then
2812 eval "field_value=\"\$${cachevar}_maintainer\""
2813 echo "${field_value}"
2819 # func_get_tests_module module
2820 # Input:
2821 # - local_gnulib_path from --local-dir
2822 func_get_tests_module ()
2824 # The naming convention for tests modules is hardwired: ${module}-tests.
2825 if test -f "$gnulib_dir/modules/$1"-tests \
2826 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1-tests"; then
2827 echo "$1"-tests
2831 # func_verify_tests_module
2832 # verifies a module name, considering only tests modules and modules with
2833 # applicability 'all'.
2834 # Input:
2835 # - local_gnulib_path from --local-dir
2836 # - modcache true or false, from --cache-modules/--no-cache-modules
2837 # - module module name argument
2838 func_verify_tests_module ()
2840 func_verify_module
2841 if test -n "$module"; then
2842 if test `func_get_applicability $module` = main; then
2843 module=
2848 # func_repeat_module_in_tests
2849 # tests whether, when the tests have their own configure.ac script, a given
2850 # module should be repeated in the tests, although it was already among the main
2851 # modules.
2852 # Input:
2853 # - module module name argument
2854 func_repeat_module_in_tests ()
2856 case "$module" in
2857 libtextstyle-optional)
2858 # This module is special because it relies on a gl_LIBTEXTSTYLE_OPTIONAL
2859 # invocation that it does not itself do or require. Therefore if the
2860 # tests contain such an invocation, the module - as part of tests -
2861 # will produce different AC_SUBSTed variable values than the same module
2862 # - as part of the main configure.ac -.
2863 echo true ;;
2865 echo false ;;
2866 esac
2869 # func_get_dependencies_recursively module
2870 # Input:
2871 # - local_gnulib_path from --local-dir
2872 # - modcache true or false, from --cache-modules/--no-cache-modules
2873 func_get_dependencies_recursively ()
2875 # In order to process every module only once (for speed), process an "input
2876 # list" of modules, producing an "output list" of modules. During each round,
2877 # more modules can be queued in the input list. Once a module on the input
2878 # list has been processed, it is added to the "handled list", so we can avoid
2879 # to process it again.
2880 handledmodules=
2881 inmodules="$1"
2882 outmodules=
2883 while test -n "$inmodules"; do
2884 inmodules_this_round="$inmodules"
2885 inmodules= # Accumulator, queue for next round
2886 for module in $inmodules_this_round; do
2887 func_verify_module
2888 if test -n "$module"; then
2889 func_append outmodules " $module"
2890 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2891 for dep in $deps; do
2892 func_append inmodules " $dep"
2893 done
2895 done
2896 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2897 # Remove $handledmodules from $inmodules.
2898 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2899 inmodules=`echo "$handledmodules" | LC_ALL=C $JOIN -v 2 - "$tmp"/queued-modules`
2900 done
2901 rm -f "$tmp"/queued-modules
2902 for m in $outmodules; do echo $m; done | LC_ALL=C sort -u
2905 # func_get_link_directive_recursively module
2906 # Input:
2907 # - local_gnulib_path from --local-dir
2908 # - modcache true or false, from --cache-modules/--no-cache-modules
2909 func_get_link_directive_recursively ()
2911 # In order to process every module only once (for speed), process an "input
2912 # list" of modules, producing an "output list" of modules. During each round,
2913 # more modules can be queued in the input list. Once a module on the input
2914 # list has been processed, it is added to the "handled list", so we can avoid
2915 # to process it again.
2916 handledmodules=
2917 inmodules="$1"
2918 outmodules=
2919 while test -n "$inmodules"; do
2920 inmodules_this_round="$inmodules"
2921 inmodules= # Accumulator, queue for next round
2922 for module in $inmodules_this_round; do
2923 func_verify_module
2924 if test -n "$module"; then
2925 if grep '^Link:[ ]*$' "$lookedup_file" >/dev/null; then
2926 # The module description has a 'Link:' field. Ignore the dependencies.
2927 func_append outmodules " $module"
2928 else
2929 # The module description has no 'Link:' field. Recurse through the dependencies.
2930 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2931 for dep in $deps; do
2932 func_append inmodules " $dep"
2933 done
2936 done
2937 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2938 # Remove $handledmodules from $inmodules.
2939 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2940 inmodules=`echo "$handledmodules" | LC_ALL=C $JOIN -v 2 - "$tmp"/queued-modules`
2941 done
2942 rm -f "$tmp"/queued-modules
2943 for m in $outmodules; do func_get_link_directive "$m"; done | LC_ALL=C sort -u | sed -e '/^$/d'
2946 # func_acceptable module
2947 # tests whether a module is acceptable.
2948 # Input:
2949 # - avoidlist list of modules to avoid
2950 func_acceptable ()
2952 for avoid in $avoidlist; do
2953 if test "$avoid" = "$1"; then
2954 return 1
2956 done
2957 return 0
2960 # sed expression to keep the first 32 characters of each line.
2961 sed_first_32_chars='s/^\(................................\).*/\1/'
2963 # func_module_shellfunc_name module
2964 # computes the shell function name that will contain the m4 macros for the module.
2965 # Input:
2966 # - macro_prefix prefix to use
2967 # Output:
2968 # - shellfunc shell function name
2969 func_module_shellfunc_name ()
2971 case $1 in
2972 *[!a-zA-Z0-9_]*)
2973 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2975 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2976 esac
2979 # func_module_shellvar_name module
2980 # computes the shell variable name the will be set to true once the m4 macros
2981 # for the module have been executed.
2982 # Output:
2983 # - shellvar shell variable name
2984 func_module_shellvar_name ()
2986 case $1 in
2987 *[!a-zA-Z0-9_]*)
2988 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2990 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2991 esac
2994 # func_module_conditional_name module
2995 # computes the automake conditional name for the module.
2996 # Output:
2997 # - conditional name of automake conditional
2998 func_module_conditional_name ()
3000 case $1 in
3001 *[!a-zA-Z0-9_]*)
3002 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
3004 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
3005 esac
3008 # func_uncond_add_module B
3009 # notes the presence of B as an unconditional module.
3011 # func_conddep_add_module A B cond
3012 # notes the presence of a conditional dependency from module A to module B,
3013 # subject to the condition that A is enabled and cond is true.
3015 # func_cond_module_p B
3016 # tests whether module B is conditional.
3018 # func_cond_module_condition A B
3019 # returns the condition when B should be enabled as a dependency of A, once the
3020 # m4 code for A has been executed.
3021 # Output: - condition
3023 if $have_associative; then
3024 declare -A conddep_isuncond
3025 declare -A conddep_dependers
3026 declare -A conddep_condition
3027 func_uncond_add_module ()
3029 eval 'conddep_isuncond[$1]=true'
3030 eval 'unset conddep_dependers[$1]'
3032 func_conddep_add_module ()
3034 eval 'isuncond="${conddep_isuncond[$2]}"'
3035 if test -z "$isuncond"; then
3036 # No unconditional dependency to B known at this point.
3037 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
3038 eval 'conddep_condition[$1---$2]="$3"'
3041 func_cond_module_p ()
3043 eval 'previous_dependers="${conddep_dependers[$1]}"'
3044 test -n "$previous_dependers"
3046 func_cond_module_condition ()
3048 eval 'condition="${conddep_condition[$1---$2]}"'
3050 else
3051 func_uncond_add_module ()
3053 case $1 in
3054 *[!a-zA-Z0-9_]*)
3055 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
3057 suffix=$1 ;;
3058 esac
3059 eval 'conddep_isuncond_'"$suffix"'=true'
3060 eval 'unset conddep_dependers_'"$suffix"
3062 func_conddep_add_module ()
3064 case $2 in
3065 *[!a-zA-Z0-9_]*)
3066 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
3068 suffix=$2 ;;
3069 esac
3070 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
3071 if test -z "$isuncond"; then
3072 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
3073 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
3074 eval 'conddep_condition_'"$suffix"'="$3"'
3077 func_cond_module_p ()
3079 case $1 in
3080 *[!a-zA-Z0-9_]*)
3081 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
3083 suffix=$1 ;;
3084 esac
3085 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
3086 test -n "$previous_dependers"
3088 func_cond_module_condition ()
3090 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
3091 eval 'condition="${conddep_condition_'"$suffix"'}"'
3095 # func_modules_transitive_closure
3096 # Input:
3097 # - local_gnulib_path from --local-dir
3098 # - gnu_make true if --gnu-make was given, false otherwise
3099 # - modcache true or false, from --cache-modules/--no-cache-modules
3100 # - modules list of specified modules
3101 # - inctests true if tests should be included, false otherwise
3102 # - incobsolete true if obsolete modules among dependencies should be
3103 # included, blank otherwise
3104 # - inc_cxx_tests true if C++ interoperability tests should be included,
3105 # blank otherwise
3106 # - inc_longrunning_tests true if long-runnings tests should be included,
3107 # blank otherwise
3108 # - inc_privileged_tests true if tests that require root privileges should be
3109 # included, blank otherwise
3110 # - inc_unportable_tests true if tests that fail on some platforms should be
3111 # included, blank otherwise
3112 # - inc_all_direct_tests true if all kinds of problematic unit tests among
3113 # the unit tests of the specified modules should be
3114 # included, blank otherwise
3115 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
3116 # the unit tests of the dependencies should be
3117 # included, blank otherwise
3118 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
3119 # blank otherwise
3120 # - excl_longrunning_tests true if long-runnings tests should be excluded,
3121 # blank otherwise
3122 # - excl_privileged_tests true if tests that require root privileges should be
3123 # excluded, blank otherwise
3124 # - excl_unportable_tests true if tests that fail on some platforms should be
3125 # excluded, blank otherwise
3126 # - avoidlist list of modules to avoid
3127 # - cond_dependencies true if conditional dependencies shall be supported,
3128 # blank otherwise
3129 # - tmp pathname of a temporary directory
3130 # Output:
3131 # - modules list of modules, including dependencies
3132 # - conddep_dependers, conddep_condition information about conditionally
3133 # enabled modules
3134 func_modules_transitive_closure ()
3136 sed_escape_dependency='s|\([/.]\)|\\\1|g'
3137 # In order to process every module only once (for speed), process an "input
3138 # list" of modules, producing an "output list" of modules. During each round,
3139 # more modules can be queued in the input list. Once a module on the input
3140 # list has been processed, it is added to the "handled list", so we can avoid
3141 # to process it again.
3142 handledmodules=
3143 inmodules="$modules"
3144 outmodules=
3145 fmtc_inc_all_tests="$inc_all_direct_tests"
3146 if test "$cond_dependencies" = true; then
3147 for module in $inmodules; do
3148 func_verify_module
3149 if test -n "$module"; then
3150 if func_acceptable $module; then
3151 func_uncond_add_module $module
3154 done
3156 while test -n "$inmodules"; do
3157 inmodules_this_round="$inmodules"
3158 inmodules= # Accumulator, queue for next round
3159 for module in $inmodules_this_round; do
3160 func_verify_module
3161 if test -n "$module"; then
3162 if func_acceptable $module; then
3163 func_append outmodules " $module"
3164 if test "$cond_dependencies" = true; then
3165 if func_cond_module_p $module; then
3166 conditional=true
3167 else
3168 conditional=false
3171 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3172 # Duplicate dependencies are harmless, but Jim wants a warning.
3173 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
3174 if test -n "$duplicated_deps"; then
3175 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
3177 if $inctests; then
3178 testsmodule=`func_get_tests_module $module`
3179 if test -n "$testsmodule"; then
3180 deps="$deps $testsmodule"
3183 for dep in $deps; do
3184 # Determine whether to include the dependency or tests module.
3185 inc=true
3186 for word in `func_get_status $dep`; do
3187 case "$word" in
3188 obsolete)
3189 test -n "$incobsolete" \
3190 || inc=false
3192 c++-test)
3193 test -z "$excl_cxx_tests" \
3194 || inc=false
3195 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
3196 || inc=false
3198 longrunning-test)
3199 test -z "$excl_longrunning_tests" \
3200 || inc=false
3201 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
3202 || inc=false
3204 privileged-test)
3205 test -z "$excl_privileged_tests" \
3206 || inc=false
3207 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
3208 || inc=false
3210 unportable-test)
3211 test -z "$excl_unportable_tests" \
3212 || inc=false
3213 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
3214 || inc=false
3216 *-test)
3217 test -n "$fmtc_inc_all_tests" \
3218 || inc=false
3220 esac
3221 done
3222 if $inc && func_acceptable "$dep"; then
3223 func_append inmodules " $dep"
3224 if test "$cond_dependencies" = true; then
3225 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
3226 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
3227 s/^.*$/true/p
3229 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*] *$/{
3230 s/^ *'"$escaped_dep"' *\[\(.*\)] *$/\1/p
3232 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
3233 if test "$condition" = true; then
3234 condition=
3236 if test -n "$condition"; then
3237 func_conddep_add_module "$module" "$dep" "$condition"
3238 else
3239 if $conditional; then
3240 func_conddep_add_module "$module" "$dep" true
3241 else
3242 func_uncond_add_module "$dep"
3247 done
3250 done
3251 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
3252 # Remove $handledmodules from $inmodules.
3253 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
3254 inmodules=`echo "$handledmodules" | LC_ALL=C $JOIN -v 2 - "$tmp"/queued-modules`
3255 fmtc_inc_all_tests="$inc_all_indirect_tests"
3256 done
3257 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
3258 rm -f "$tmp"/queued-modules
3261 # func_show_module_list
3262 # Input:
3263 # - specified_modules list of specified modules (one per line, sorted)
3264 # - modules complete list of modules (one per line, sorted)
3265 # - tmp pathname of a temporary directory
3266 func_show_module_list ()
3268 if test -n "$TERM" && test -t 1; then
3269 case "$TERM" in
3270 xterm*)
3271 # Assume xterm compatible escape sequences.
3272 bold_on=`printf '\033[1m'`
3273 bold_off=`printf '\033[0m'`
3276 # Use the terminfo capability strings for "bold" and "sgr0".
3277 if test "$TERM" = sun-color && test "`tput smso`" != "`tput rev`"; then
3278 # Solaris 11 OmniOS: `tput smso` renders as bold,
3279 # `tput rmso` is the same as `tput sgr0`.
3280 bold_on=`tput smso 2>/dev/null`
3281 bold_off=`tput rmso 2>/dev/null`
3282 else
3283 bold_on=`tput bold 2>/dev/null`
3284 bold_off=`tput sgr0 2>/dev/null`
3286 if test -z "$bold_on" || test -z "$bold_off"; then
3287 bold_on=
3288 bold_off=
3291 esac
3292 else
3293 bold_on=
3294 bold_off=
3296 echo "Module list with included dependencies (indented):"
3297 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
3298 echo "$modules" | sed -e '/^$/d' \
3299 | LC_ALL=C $JOIN -t '|' -a2 "$tmp"/specified-modules - \
3300 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
3303 # func_modules_transitive_closure_separately
3304 # Determine main module list and tests-related module list separately.
3305 # The main module list is the transitive closure of the specified modules,
3306 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3307 # is specified, it will consist only of LGPLed source.
3308 # The tests-related module list is the transitive closure of the specified
3309 # modules, including tests modules, minus the main module list excluding
3310 # modules of applicability 'all'. Its lib/* sources (brought in through
3311 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3312 # source, even if --lgpl is specified.
3313 # Input:
3314 # - local_gnulib_path from --local-dir
3315 # - modcache true or false, from --cache-modules/--no-cache-modules
3316 # - specified_modules list of specified modules
3317 # - inctests true if tests should be included, false otherwise
3318 # - incobsolete true if obsolete modules among dependencies should be
3319 # included, blank otherwise
3320 # - inc_cxx_tests true if C++ interoperability tests should be included,
3321 # blank otherwise
3322 # - inc_longrunning_tests true if long-runnings tests should be included,
3323 # blank otherwise
3324 # - inc_privileged_tests true if tests that require root privileges should be
3325 # included, blank otherwise
3326 # - inc_unportable_tests true if tests that fail on some platforms should be
3327 # included, blank otherwise
3328 # - inc_all_direct_tests true if all kinds of problematic unit tests among
3329 # the unit tests of the specified modules should be
3330 # included, blank otherwise
3331 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
3332 # the unit tests of the dependencies should be
3333 # included, blank otherwise
3334 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
3335 # blank otherwise
3336 # - excl_longrunning_tests true if long-runnings tests should be excluded,
3337 # blank otherwise
3338 # - excl_privileged_tests true if tests that require root privileges should be
3339 # excluded, blank otherwise
3340 # - excl_unportable_tests true if tests that fail on some platforms should be
3341 # excluded, blank otherwise
3342 # - avoidlist list of modules to avoid
3343 # - cond_dependencies true if conditional dependencies shall be supported,
3344 # blank otherwise
3345 # - tmp pathname of a temporary directory
3346 # Output:
3347 # - main_modules list of modules, including dependencies
3348 # - testsrelated_modules list of tests-related modules, including dependencies
3349 # - conddep_dependers, conddep_condition information about conditionally
3350 # enabled modules
3351 func_modules_transitive_closure_separately ()
3353 # Determine main module list.
3354 saved_inctests="$inctests"
3355 inctests=false
3356 modules="$specified_modules"
3357 func_modules_transitive_closure
3358 main_modules="$modules"
3359 inctests="$saved_inctests"
3360 if test $verbose -ge 1; then
3361 echo "Main module list:"
3362 echo "$main_modules" | sed -e 's/^/ /'
3364 # Determine tests-related module list.
3365 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3366 testsrelated_modules=`for module in $main_modules; do
3367 if test \`func_get_applicability $module\` = main; then
3368 echo $module
3370 done \
3371 | LC_ALL=C sort -u | LC_ALL=C $JOIN -v 2 - "$tmp"/final-modules`
3372 # If testsrelated_modules consists only of modules with applicability 'all',
3373 # set it to empty (because such modules are only helper modules for other modules).
3374 have_nontrivial_testsrelated_modules=
3375 for module in $testsrelated_modules; do
3376 if test `func_get_applicability $module` != all; then
3377 have_nontrivial_testsrelated_modules=yes
3378 break
3380 done
3381 if test -z "$have_nontrivial_testsrelated_modules"; then
3382 testsrelated_modules=
3384 if test $verbose -ge 1; then
3385 echo "Tests-related module list:"
3386 echo "$testsrelated_modules" | sed -e 's/^/ /'
3390 # func_determine_use_libtests
3391 # Determines whether a $testsbase/libtests.a is needed.
3392 # Input:
3393 # - local_gnulib_path from --local-dir
3394 # - modcache true or false, from --cache-modules/--no-cache-modules
3395 # - testsrelated_modules list of tests-related modules, including dependencies
3396 # Output:
3397 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3398 func_determine_use_libtests ()
3400 use_libtests=false
3401 for module in $testsrelated_modules; do
3402 func_verify_nontests_module
3403 if test -n "$module"; then
3404 all_files=`func_get_filelist $module`
3405 # Test whether some file in $all_files lies in lib/.
3406 for f in $all_files; do
3407 case $f in
3408 lib/*)
3409 use_libtests=true
3410 break 2
3412 esac
3413 done
3415 done
3418 # func_remove_if_blocks
3419 # removes if...endif blocks from an automake snippet.
3420 func_remove_if_blocks ()
3422 sed -n -e '/^if / {
3425 s/^endif//
3433 # func_modules_add_dummy
3434 # Input:
3435 # - local_gnulib_path from --local-dir
3436 # - modcache true or false, from --cache-modules/--no-cache-modules
3437 # - modules list of modules, including dependencies
3438 # Output:
3439 # - modules list of modules, including 'dummy' if needed
3440 func_modules_add_dummy ()
3442 # Determine whether any module provides a lib_SOURCES augmentation.
3443 have_lib_SOURCES=
3444 for module in $modules; do
3445 func_verify_nontests_module
3446 if test -n "$module"; then
3447 if test "$cond_dependencies" = true && func_cond_module_p $module; then
3448 # Ignore conditional modules, since they are not guaranteed to
3449 # contribute to lib_SOURCES.
3451 else
3452 # Extract the value of unconditional "lib_SOURCES += ..." augmentations.
3453 for file in `func_get_automake_snippet "$module" | combine_lines |
3454 func_remove_if_blocks |
3455 sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
3456 # Ignore .h files since they are not compiled.
3457 case "$file" in
3458 *.h) ;;
3460 have_lib_SOURCES=yes
3461 break 2
3463 esac
3464 done
3467 done
3468 # Add the dummy module, to make sure the library will be non-empty.
3469 if test -z "$have_lib_SOURCES"; then
3470 if func_acceptable "dummy"; then
3471 func_append modules " dummy"
3476 # func_modules_add_dummy_separately
3477 # Input:
3478 # - local_gnulib_path from --local-dir
3479 # - modcache true or false, from --cache-modules/--no-cache-modules
3480 # - main_modules list of modules, including dependencies
3481 # - testsrelated_modules list of tests-related modules, including dependencies
3482 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3483 # Output:
3484 # - main_modules list of modules, including 'dummy' if needed
3485 # - testsrelated_modules list of tests-related modules, including 'dummy' if
3486 # needed
3487 func_modules_add_dummy_separately ()
3489 # Add the dummy module to the main module list if needed.
3490 modules="$main_modules"
3491 func_modules_add_dummy
3492 main_modules="$modules"
3494 # Add the dummy module to the tests-related module list if needed.
3495 if $use_libtests; then
3496 modules="$testsrelated_modules"
3497 func_modules_add_dummy
3498 testsrelated_modules="$modules"
3502 # func_modules_notice
3503 # Input:
3504 # - local_gnulib_path from --local-dir
3505 # - modcache true or false, from --cache-modules/--no-cache-modules
3506 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3507 # - modules list of modules, including dependencies
3508 func_modules_notice ()
3510 if test $verbose -ge -1; then
3511 for module in $modules; do
3512 func_verify_module
3513 if test -n "$module"; then
3514 msg=`func_get_notice $module`
3515 if test -n "$msg"; then
3516 echo "Notice from module $module:"
3517 echo "$msg" | sed -e 's/^/ /'
3520 done
3524 # func_modules_to_filelist
3525 # Input:
3526 # - local_gnulib_path from --local-dir
3527 # - modcache true or false, from --cache-modules/--no-cache-modules
3528 # - modules list of modules, including dependencies
3529 # Output:
3530 # - files list of files
3531 func_modules_to_filelist ()
3533 files=
3534 for module in $modules; do
3535 func_verify_module
3536 if test -n "$module"; then
3537 fs=`func_get_filelist $module`
3538 func_append files " $fs"
3540 done
3541 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3544 # func_modules_to_filelist_separately
3545 # Determine the final file lists.
3546 # They must be computed separately, because files in lib/* go into
3547 # $sourcebase/ if they are in the main file list but into $testsbase/
3548 # if they are in the tests-related file list. Furthermore lib/dummy.c
3549 # can be in both.
3550 # Input:
3551 # - local_gnulib_path from --local-dir
3552 # - modcache true or false, from --cache-modules/--no-cache-modules
3553 # - main_modules list of modules, including dependencies
3554 # - testsrelated_modules list of tests-related modules, including dependencies
3555 func_modules_to_filelist_separately ()
3557 # Determine final main file list.
3558 modules="$main_modules"
3559 func_modules_to_filelist
3560 main_files="$files"
3561 # Determine final tests-related file list.
3562 modules="$testsrelated_modules"
3563 func_modules_to_filelist
3564 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3565 # Merge both file lists.
3566 sed_remove_empty_lines='/^$/d'
3567 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3568 if test $verbose -ge 0; then
3569 echo "File list:"
3570 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3571 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3575 # func_compute_include_guard_prefix
3576 # Determine include_guard_prefix and module_indicator_prefix.
3577 # Input:
3578 # - macro_prefix prefix of gl_LIBOBJS macros to use
3579 # Output:
3580 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3581 # - sed_replace_include_guard_prefix
3582 # sed expression for resolving ${gl_include_guard_prefix}
3583 # - module_indicator_prefix prefix of GNULIB_<modulename> variables to use
3584 func_compute_include_guard_prefix ()
3586 if test "$macro_prefix" = gl; then
3587 include_guard_prefix='GL'
3588 else
3589 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3591 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3592 module_indicator_prefix="${include_guard_prefix}"
3595 # func_execute_command command [args...]
3596 # Executes a command.
3597 # Uses also the variables
3598 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3599 func_execute_command ()
3601 if test $verbose -ge 0; then
3602 echo "executing $*"
3603 "$@"
3604 else
3605 # Commands like automake produce output to stderr even when they succeed.
3606 # Turn this output off if the command succeeds.
3607 "$@" > "$tmp"/cmdout 2>&1
3608 cmdret=$?
3609 if test $cmdret = 0; then
3610 rm -f "$tmp"/cmdout
3611 else
3612 echo "executing $*"
3613 cat "$tmp"/cmdout 1>&2
3614 rm -f "$tmp"/cmdout
3615 (exit $cmdret)
3620 # func_dest_tmpfilename file
3621 # determines the name of a temporary file (file is relative to destdir).
3622 # Input:
3623 # - destdir target directory
3624 # - doit : if actions shall be executed, false if only to be printed
3625 # - tmp pathname of a temporary directory
3626 # Sets variable:
3627 # - tmpfile absolute filename of the temporary file
3628 func_dest_tmpfilename ()
3630 if $doit; then
3631 # Put the new contents of $file in a file in the same directory (needed
3632 # to guarantee that an 'mv' to "$destdir/$file" works).
3633 tmpfile="$destdir/$1.tmp"
3634 else
3635 # Put the new contents of $file in a file in a temporary directory
3636 # (because the directory of "$file" might not exist).
3637 tmpfile="$tmp"/`basename "$1"`.tmp
3641 # func_is_local_file lookedup_file file
3642 # check whether file should be instantiated from local gnulib directory
3643 func_is_local_file ()
3645 dname=$1
3646 func_remove_suffix dname "/$2"
3647 func_path_foreach "$local_gnulib_path" test %dir% = "$dname"
3650 # func_should_link
3651 # determines whether the file $f should be copied, symlinked, or hardlinked.
3652 # Input:
3653 # - copymode copy mode for files in general
3654 # - lcopymode copy mode for files from local_gnulib_path
3655 # - f the original file name
3656 # - lookedup_file name of the merged (combined) file
3657 # Sets variable:
3658 # - copyaction copy or symlink or hardlink
3659 func_should_link ()
3661 if test -n "$lcopymode" && func_is_local_file "$lookedup_file" "$f"; then
3662 copyaction="$lcopymode"
3663 else
3664 if test -n "$copymode"; then
3665 copyaction="$copymode"
3666 else
3667 copyaction=copy
3672 # func_add_file
3673 # copies a file from gnulib into the destination directory. The destination
3674 # is known to not exist.
3675 # Input:
3676 # - destdir target directory
3677 # - local_gnulib_path from --local-dir
3678 # - modcache true or false, from --cache-modules/--no-cache-modules
3679 # - f the original file name
3680 # - lookedup_file name of the merged (combined) file
3681 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3682 # - g the rewritten file name
3683 # - tmpfile absolute filename of the temporary file
3684 # - doit : if actions shall be executed, false if only to be printed
3685 # - copymode copy mode for files in general
3686 # - lcopymode copy mode for files from local_gnulib_path
3687 func_add_file ()
3689 if $doit; then
3690 echo "Copying file $g"
3691 func_should_link
3692 if test "$copyaction" = symlink \
3693 && test -z "$lookedup_tmp" \
3694 && cmp -s "$lookedup_file" "$tmpfile"; then
3695 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3696 else
3697 if test "$copyaction" = hardlink \
3698 && test -z "$lookedup_tmp" \
3699 && cmp -s "$lookedup_file" "$tmpfile"; then
3700 func_hardlink "$lookedup_file" "$destdir/$g"
3701 else
3702 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3705 else
3706 echo "Copy file $g"
3710 # func_update_file
3711 # copies a file from gnulib into the destination directory. The destination
3712 # is known to exist.
3713 # Input:
3714 # - destdir target directory
3715 # - local_gnulib_path from --local-dir
3716 # - modcache true or false, from --cache-modules/--no-cache-modules
3717 # - f the original file name
3718 # - lookedup_file name of the merged (combined) file
3719 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3720 # - g the rewritten file name
3721 # - tmpfile absolute filename of the temporary file
3722 # - doit : if actions shall be executed, false if only to be printed
3723 # - copymode copy mode for files in general
3724 # - lcopymode copy mode for files from local_gnulib_path
3725 # - already_present nonempty if the file should already exist, empty otherwise
3726 func_update_file ()
3728 if cmp -s "$destdir/$g" "$tmpfile"; then
3729 : # The file has not changed.
3730 else
3731 # Replace the file.
3732 if $doit; then
3733 if test -n "$already_present"; then
3734 echo "Updating file $g (backup in ${g}~)"
3735 else
3736 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3738 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3739 func_should_link
3740 if test "$copyaction" = symlink \
3741 && test -z "$lookedup_tmp" \
3742 && cmp -s "$lookedup_file" "$tmpfile"; then
3743 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3744 else
3745 if test "$copyaction" = hardlink \
3746 && test -z "$lookedup_tmp" \
3747 && cmp -s "$lookedup_file" "$tmpfile"; then
3748 func_hardlink "$lookedup_file" "$destdir/$g"
3749 else
3750 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3753 else
3754 if test -n "$already_present"; then
3755 echo "Update file $g (backup in ${g}~)"
3756 else
3757 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3763 # func_emit_lib_Makefile_am
3764 # emits the contents of library makefile to standard output.
3765 # Input:
3766 # - local_gnulib_path from --local-dir
3767 # - modcache true or false, from --cache-modules/--no-cache-modules
3768 # - modules list of modules, including dependencies
3769 # - libname library name
3770 # - pobase directory relative to destdir where to place *.po files
3771 # - auxdir directory relative to destdir where to place build aux files
3772 # - gnu_make true if --gnu-make was given, false otherwise
3773 # - makefile_name from --makefile-name
3774 # - automake_subdir true if --automake-subdir was given, false otherwise
3775 # - libtool true if libtool will be used, false or blank otherwise
3776 # - macro_prefix prefix of gl_LIBOBJS macros to use
3777 # - module_indicator_prefix prefix of GNULIB_<modulename> variables to use
3778 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3779 # - witness_c_macro from --witness-c-macro
3780 # - actioncmd (optional) command that will reproduce this invocation
3781 # - for_test true if creating a package for testing, false otherwise
3782 # - sed_replace_include_guard_prefix
3783 # sed expression for resolving ${gl_include_guard_prefix}
3784 # - destfile filename relative to destdir of makefile being generated
3785 # Input/Output:
3786 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
3787 # list of edits to be done to Makefile.am variables
3788 func_emit_lib_Makefile_am ()
3790 # When using GNU make, or when creating an includable Makefile.am snippet,
3791 # augment variables with += instead of assigning them.
3792 if $gnu_make || test -n "$makefile_name"; then
3793 assign='+='
3794 else
3795 assign='='
3797 if test "$libtool" = true; then
3798 libext=la
3799 perhapsLT=LT
3800 sed_eliminate_LDFLAGS="$sed_noop"
3801 else
3802 libext=a
3803 perhapsLT=
3804 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3806 # Replace NMD, so as to remove redundant "$(MKDIR_P) '.'" invocations.
3807 # The logic is similar to how we define gl_source_base_prefix.
3808 if $automake_subdir; then
3809 sed_eliminate_NMD='s/^@NMD@//;/^@!NMD@/d'
3810 else
3811 sed_eliminate_NMD='/^@NMD@/d;s/^@!NMD@//'
3813 if $for_test; then
3814 # When creating a package for testing: Attempt to provoke failures,
3815 # especially link errors, already during "make" rather than during
3816 # "make check", because "make check" is not possible in a cross-compiling
3817 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3818 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3819 else
3820 sed_transform_check_PROGRAMS="$sed_noop"
3822 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3823 if ! $gnu_make; then
3824 echo "## Process this file with automake to produce Makefile.in."
3826 func_emit_copyright_notice
3827 if test -n "$actioncmd"; then
3828 printf '# Reproduce by:\n%s\n' "$actioncmd"
3830 echo
3831 uses_subdirs=
3833 for module in $modules; do
3834 func_verify_nontests_module
3835 if test -n "$module"; then
3837 func_get_automake_snippet_conditional "$module" |
3838 LC_ALL=C \
3839 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3840 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3841 -e "$sed_eliminate_LDFLAGS" \
3842 -e "$sed_eliminate_NMD" \
3843 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3844 -e 's,\$(GNULIB_,$('"${module_indicator_prefix}"'_GNULIB_,' \
3845 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3846 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3847 -e "$sed_transform_check_PROGRAMS" \
3848 -e "$sed_replace_include_guard_prefix"
3849 if test "$module" = 'alloca'; then
3850 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3851 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3853 } | combine_lines "${libname}_${libext}_SOURCES" > "$tmp"/amsnippet1
3855 func_get_automake_snippet_unconditional "$module" |
3856 LC_ALL=C \
3857 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3858 -e 's,\$(GNULIB_,$('"${module_indicator_prefix}"'_GNULIB_,'
3859 } > "$tmp"/amsnippet2
3860 # Skip the contents if it's entirely empty.
3861 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3862 echo "## begin gnulib module $module"
3863 if $gnu_make; then
3864 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
3865 convert_to_gnu_make_1='s/^if \(.*\)/ifneq (,$(\1_CONDITION))/'
3866 convert_to_gnu_make_2='s|%reldir%/||g'
3867 convert_to_gnu_make_3='s|%reldir%|.|g'
3869 echo
3870 if test "$cond_dependencies" = true; then
3871 if func_cond_module_p "$module"; then
3872 func_module_conditional_name "$module"
3873 if $gnu_make; then
3874 echo "ifneq (,\$(${conditional}_CONDITION))"
3875 else
3876 echo "if $conditional"
3880 if $gnu_make; then
3881 sed -e "$convert_to_gnu_make_1" \
3882 -e "$convert_to_gnu_make_2" \
3883 -e "$convert_to_gnu_make_3" \
3884 "$tmp"/amsnippet1
3885 else
3886 cat "$tmp"/amsnippet1
3888 if test "$cond_dependencies" = true; then
3889 if func_cond_module_p "$module"; then
3890 echo "endif"
3893 if $gnu_make; then
3894 sed -e "$convert_to_gnu_make_1" \
3895 -e "$convert_to_gnu_make_2" \
3896 -e "$convert_to_gnu_make_3" \
3897 "$tmp"/amsnippet2
3898 else
3899 cat "$tmp"/amsnippet2
3901 if $gnu_make; then
3902 echo "endif"
3904 echo "## end gnulib module $module"
3905 echo
3907 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3908 # Test whether there are some source files in subdirectories.
3909 for f in `func_get_filelist "$module"`; do
3910 case $f in
3911 lib/*/*.c)
3912 uses_subdirs=yes
3913 break
3915 esac
3916 done
3918 done
3919 } > "$tmp"/allsnippets
3920 if test -z "$makefile_name"; then
3921 # If there are source files in subdirectories, prevent collision of the
3922 # object files (example: hash.c and libxml/hash.c).
3923 subdir_options=
3924 if test -n "$uses_subdirs"; then
3925 subdir_options=' subdir-objects'
3927 echo "AUTOMAKE_OPTIONS = 1.14 gnits${subdir_options}"
3929 echo
3930 if test -z "$makefile_name"; then
3931 echo "SUBDIRS ="
3932 echo "noinst_HEADERS ="
3933 echo "noinst_LIBRARIES ="
3934 echo "noinst_LTLIBRARIES ="
3935 echo "pkgdata_DATA ="
3936 echo "EXTRA_DIST ="
3937 echo "BUILT_SOURCES ="
3938 echo "SUFFIXES ="
3940 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3941 if test -z "$makefile_name"; then
3942 echo "MOSTLYCLEANDIRS ="
3943 echo "CLEANFILES ="
3944 echo "DISTCLEANFILES ="
3945 echo "MAINTAINERCLEANFILES ="
3947 if $gnu_make; then
3948 echo "# Start of GNU Make output."
3950 # Put autoconf output into a temporary file, so that its exit status
3951 # can be checked from the shell. Signal any error by putting a
3952 # syntax error into the output makefile.
3953 ${AUTOCONF} -t 'AC_SUBST:$1 = @$1@' "$configure_ac" \
3954 >"$tmp"/makeout 2>"$tmp"/makeout2 &&
3955 LC_ALL=C sort -u "$tmp"/makeout || {
3956 echo "== gnulib-tool GNU Make output failed as follows =="
3957 sed 's/^/# stderr: /' "$tmp"/makeout2
3959 rm -f "$tmp"/makeout "$tmp"/makeout2
3961 echo "# End of GNU Make output."
3962 else
3963 echo "# No GNU Make output."
3965 # Execute edits that apply to the Makefile.am being generated.
3966 edit=0
3967 while test $edit != $makefile_am_edits; do
3968 edit=`expr $edit + 1`
3969 eval dir=\"\$makefile_am_edit${edit}_dir\"
3970 eval var=\"\$makefile_am_edit${edit}_var\"
3971 eval val=\"\$makefile_am_edit${edit}_val\"
3972 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
3973 if test -n "$var"; then
3974 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3975 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
3976 # The added subdirectory ${val} needs to be mentioned after '.'.
3977 # Since we don't have '.' among SUBDIRS so far, add it now.
3978 val=". ${val}"
3980 echo "${var} += ${val}"
3981 eval "makefile_am_edit${edit}_var="
3984 done
3985 if test -n "$witness_c_macro"; then
3986 cppflags_part1=" -D$witness_c_macro=1"
3987 else
3988 cppflags_part1=
3990 if $for_test; then
3991 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3992 else
3993 cppflags_part2=
3995 if test -z "$makefile_name"; then
3996 echo
3997 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3998 echo "AM_CFLAGS ="
3999 else
4000 if test -n "$cppflags_part1$cppflags_part2"; then
4001 echo
4002 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
4005 echo
4006 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
4007 || { test -n "$makefile_name" \
4008 && test -f "$sourcebase/Makefile.am" \
4009 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
4010 }; then
4011 # One of the snippets or the user's Makefile.am already specifies an
4012 # installation location for the library. Don't confuse automake by saying
4013 # it should not be installed.
4015 else
4016 # By default, the generated library should not be installed.
4017 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
4019 echo
4020 echo "${libname}_${libext}_SOURCES ="
4021 if ! $for_test; then
4022 echo "${libname}_${libext}_CFLAGS = \$(AM_CFLAGS) \$(GL_CFLAG_GNULIB_WARNINGS)"
4024 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
4025 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
4026 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
4027 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
4028 echo "EXTRA_${libname}_${libext}_SOURCES ="
4029 if test "$libtool" = true; then
4030 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
4031 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
4032 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
4033 # the link dependencies of all modules.
4034 for module in $modules; do
4035 func_verify_nontests_module
4036 if test -n "$module"; then
4037 func_get_link_directive "$module"
4039 done \
4040 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
4041 | LC_ALL=C sort -u \
4042 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
4044 echo
4045 if test -n "$pobase"; then
4046 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
4047 echo
4049 cat "$tmp"/allsnippets \
4050 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
4051 echo
4052 echo "mostlyclean-local: mostlyclean-generic"
4053 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
4054 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
4055 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
4056 echo " fi; \\"
4057 echo " done; \\"
4058 echo " :"
4059 # Emit rules to erase .Po and .Plo files for AC_LIBOBJ invocations.
4060 # Extend the 'distclean' rule.
4061 echo "distclean-local: distclean-gnulib-libobjs"
4062 echo "distclean-gnulib-libobjs:"
4063 echo " -rm -f @${macro_prefix}_LIBOBJDEPS@"
4064 # Extend the 'maintainer-clean' rule.
4065 echo "maintainer-clean-local: distclean-gnulib-libobjs"
4066 rm -f "$tmp"/allsnippets
4069 # func_emit_po_Makevars
4070 # emits the contents of po/ makefile parameterization to standard output.
4071 # Input:
4072 # - local_gnulib_path from --local-dir
4073 # - modcache true or false, from --cache-modules/--no-cache-modules
4074 # - sourcebase directory relative to destdir where to place source code
4075 # - pobase directory relative to destdir where to place *.po files
4076 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4077 func_emit_po_Makevars ()
4079 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
4080 func_emit_copyright_notice
4081 echo
4082 echo "# Usually the message domain is the same as the package name."
4083 echo "# But here it has a '-gnulib' suffix."
4084 echo "DOMAIN = ${po_domain}-gnulib"
4085 echo
4086 echo "# These two variables depend on the location of this directory."
4087 echo "subdir = ${pobase}"
4088 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
4089 echo
4090 cat <<\EOF
4091 # These options get passed to xgettext.
4092 XGETTEXT_OPTIONS = \
4093 --keyword=_ --flag=_:1:pass-c-format \
4094 --keyword=N_ --flag=N_:1:pass-c-format \
4095 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
4096 --keyword='proper_name_lite:1,"This is a proper name. See the gettext manual, section Names."' \
4097 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
4098 --flag=error:3:c-format --flag=error_at_line:5:c-format
4100 # This is the copyright holder that gets inserted into the header of the
4101 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
4102 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
4104 # This is the email address or URL to which the translators shall report
4105 # bugs in the untranslated strings:
4106 # - Strings which are not entire sentences, see the maintainer guidelines
4107 # in the GNU gettext documentation, section 'Preparing Strings'.
4108 # - Strings which use unclear terms or require additional context to be
4109 # understood.
4110 # - Strings which make invalid assumptions about notation of date, time or
4111 # money.
4112 # - Pluralisation problems.
4113 # - Incorrect English spelling.
4114 # - Incorrect formatting.
4115 # It can be your email address, or a mailing list address where translators
4116 # can write to without being subscribed, or the URL of a web page through
4117 # which the translators can contact you.
4118 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
4120 # This is the list of locale categories, beyond LC_MESSAGES, for which the
4121 # message catalogs shall be used. It is usually empty.
4122 EXTRA_LOCALE_CATEGORIES =
4124 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
4125 # context. Possible values are "yes" and "no". Set this to yes if the
4126 # package uses functions taking also a message context, like pgettext(), or
4127 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
4128 USE_MSGCTXT = no
4132 # func_emit_po_POTFILES_in
4133 # emits the file list to be passed to xgettext to standard output.
4134 # Input:
4135 # - local_gnulib_path from --local-dir
4136 # - modcache true or false, from --cache-modules/--no-cache-modules
4137 # - sourcebase directory relative to destdir where to place source code
4138 # - files list of new files
4139 func_emit_po_POTFILES_in ()
4141 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
4142 func_emit_copyright_notice
4143 echo
4144 echo "# List of files which contain translatable strings."
4145 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
4148 # func_emit_tests_Makefile_am witness_macro
4149 # emits the contents of tests makefile to standard output.
4150 # Input:
4151 # - local_gnulib_path from --local-dir
4152 # - modcache true or false, from --cache-modules/--no-cache-modules
4153 # - modules list of modules, including dependencies
4154 # - libname library name
4155 # - auxdir directory relative to destdir where to place build aux files
4156 # - gnu_make true if --gnu-make was given, false otherwise
4157 # - makefile_name from --makefile-name
4158 # - tests_makefile_name from --tests-makefile-name
4159 # - libtool true if libtool will be used, false or blank otherwise
4160 # - sourcebase relative directory containing lib source code
4161 # - m4base relative directory containing autoconf macros
4162 # - testsbase relative directory containing unit test code
4163 # - macro_prefix prefix of gl_LIBOBJS macros to use
4164 # - module_indicator_prefix prefix of GNULIB_<modulename> variables to use
4165 # - witness_c_macro from --witness-c-macro
4166 # - for_test true if creating a package for testing, false otherwise
4167 # - single_configure true if a single configure file should be generated,
4168 # false for a separate configure file for the tests
4169 # - use_libtests true if a libtests.a should be built, false otherwise
4170 # - sed_replace_include_guard_prefix
4171 # sed expression for resolving ${gl_include_guard_prefix}
4172 # - destfile filename relative to destdir of makefile being generated
4173 # Input/Output:
4174 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
4175 # list of edits to be done to Makefile.am variables
4176 func_emit_tests_Makefile_am ()
4178 witness_macro="$1"
4179 if test "$libtool" = true; then
4180 libext=la
4181 sed_eliminate_LDFLAGS="$sed_noop"
4182 else
4183 libext=a
4184 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
4186 # Replace NMD, so as to remove redundant "$(MKDIR_P) '.'" invocations.
4187 # The logic is similar to how we define gl_source_base_prefix.
4188 sed_eliminate_NMD='/^@NMD@/d;s/^@!NMD@//'
4189 if $for_test; then
4190 # When creating a package for testing: Attempt to provoke failures,
4191 # especially link errors, already during "make" rather than during
4192 # "make check", because "make check" is not possible in a cross-compiling
4193 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
4194 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
4195 else
4196 sed_transform_check_PROGRAMS="$sed_noop"
4198 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
4199 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
4200 echo "## Process this file with automake to produce Makefile.in."
4201 func_emit_copyright_notice
4202 echo
4203 uses_subdirs=
4205 for module in $modules; do
4206 if $for_test && ! $single_configure; then
4207 if `func_repeat_module_in_tests`; then
4208 func_verify_module
4209 else
4210 func_verify_tests_module
4212 else
4213 func_verify_module
4215 if test -n "$module"; then
4217 func_get_automake_snippet_conditional "$module" |
4218 LC_ALL=C \
4219 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
4220 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
4221 -e "$sed_eliminate_LDFLAGS" \
4222 -e "$sed_eliminate_NMD" \
4223 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
4224 -e 's,\$(GNULIB_,$('"${module_indicator_prefix}"'_GNULIB_,' \
4225 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
4226 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
4227 -e "$sed_transform_check_PROGRAMS" \
4228 -e "$sed_replace_include_guard_prefix"
4229 if $use_libtests && test "$module" = 'alloca'; then
4230 echo "libtests_a_LIBADD += @ALLOCA@"
4231 echo "libtests_a_DEPENDENCIES += @ALLOCA@"
4233 } | combine_lines "libtests_a_SOURCES" > "$tmp"/amsnippet1
4235 func_get_automake_snippet_unconditional "$module" |
4236 LC_ALL=C \
4237 sed -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
4238 -e 's,\$(GNULIB_,$('"${module_indicator_prefix}"'_GNULIB_,'
4239 } > "$tmp"/amsnippet2
4240 # Skip the contents if it's entirely empty.
4241 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
4242 # Mention long-running tests at the end.
4243 ofd=3
4244 for word in `func_get_status "$module"`; do
4245 if test "$word" = 'longrunning-test'; then
4246 ofd=4
4247 break
4249 done
4250 { echo "## begin gnulib module $module"
4251 if $gnu_make; then
4252 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
4253 convert_to_gnu_make_1='s/^if \(.*\)/ifneq (,$(\1_CONDITION))/'
4254 convert_to_gnu_make_2='s|%reldir%/||g'
4255 convert_to_gnu_make_3='s|%reldir%|.|g'
4257 echo
4258 if test "$cond_dependencies" = true; then
4259 if func_cond_module_p "$module"; then
4260 func_module_conditional_name "$module"
4261 if $gnu_make; then
4262 echo "ifneq (,\$(${conditional}_CONDITION))"
4263 else
4264 echo "if $conditional"
4268 if $gnu_make; then
4269 sed -e "$convert_to_gnu_make_1" \
4270 -e "$convert_to_gnu_make_2" \
4271 -e "$convert_to_gnu_make_3" \
4272 "$tmp"/amsnippet1
4273 else
4274 cat "$tmp"/amsnippet1
4276 if test "$cond_dependencies" = true; then
4277 if func_cond_module_p "$module"; then
4278 echo "endif"
4281 if $gnu_make; then
4282 sed -e "$convert_to_gnu_make_1" \
4283 -e "$convert_to_gnu_make_2" \
4284 -e "$convert_to_gnu_make_3" \
4285 "$tmp"/amsnippet2
4286 else
4287 cat "$tmp"/amsnippet2
4289 if $gnu_make; then
4290 echo "endif"
4292 echo "## end gnulib module $module"
4293 echo
4294 } >&$ofd
4296 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
4297 # Test whether there are some source files in subdirectories.
4298 for f in `func_get_filelist "$module"`; do
4299 case $f in
4300 lib/*/*.c | tests/*/*.c)
4301 uses_subdirs=yes
4302 break
4304 esac
4305 done
4307 done
4308 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
4309 # Generate dependencies here, since it eases the debugging of test failures.
4310 # If there are source files in subdirectories, prevent collision of the
4311 # object files (example: hash.c and libxml/hash.c).
4312 subdir_options=
4313 if test -n "$uses_subdirs"; then
4314 subdir_options=' subdir-objects'
4316 echo "AUTOMAKE_OPTIONS = 1.14 foreign${subdir_options}"
4317 echo
4318 if $for_test && ! $single_configure; then
4319 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
4320 echo
4322 # Nothing is being added to SUBDIRS; nevertheless the existence of this
4323 # variable is needed to avoid an error from automake:
4324 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
4325 echo "SUBDIRS = ."
4326 echo "TESTS ="
4327 echo "XFAIL_TESTS ="
4328 echo "TESTS_ENVIRONMENT ="
4329 echo "noinst_PROGRAMS ="
4330 if ! $for_test; then
4331 echo "check_PROGRAMS ="
4333 echo "EXTRA_PROGRAMS ="
4334 echo "noinst_HEADERS ="
4335 echo "noinst_LIBRARIES ="
4336 if $use_libtests; then
4337 if $for_test; then
4338 echo "noinst_LIBRARIES += libtests.a"
4339 else
4340 echo "check_LIBRARIES = libtests.a"
4343 echo "pkgdata_DATA ="
4344 echo "EXTRA_DIST ="
4345 echo "BUILT_SOURCES ="
4346 echo "SUFFIXES ="
4347 echo "MOSTLYCLEANFILES = core *.stackdump"
4348 echo "MOSTLYCLEANDIRS ="
4349 echo "CLEANFILES ="
4350 echo "DISTCLEANFILES ="
4351 echo "MAINTAINERCLEANFILES ="
4352 # Execute edits that apply to the Makefile.am being generated.
4353 edit=0
4354 while test $edit != $makefile_am_edits; do
4355 edit=`expr $edit + 1`
4356 eval dir=\"\$makefile_am_edit${edit}_dir\"
4357 eval var=\"\$makefile_am_edit${edit}_var\"
4358 eval val=\"\$makefile_am_edit${edit}_val\"
4359 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
4360 if test -n "$var"; then
4361 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
4362 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
4363 # The added subdirectory ${val} needs to be mentioned after '.'.
4364 # But we have '.' among SUBDIRS already, so do nothing.
4367 echo "${var} += ${val}"
4368 eval "makefile_am_edit${edit}_var="
4371 done
4372 echo
4373 # Insert a '-Wno-error' option in the compilation commands emitted by
4374 # Automake, between $(AM_CPPFLAGS) and before the reference to @CFLAGS@.
4375 # Why?
4376 # 1) Because parts of the Gnulib tests exercise corner cases (invalid
4377 # arguments, endless recursions, etc.) that a compiler may warn about,
4378 # even with just the normal '-Wall' option.
4379 # 2) Because every package maintainer has their preferred set of warnings
4380 # that they may want to enforce in the main source code of their package.
4381 # But Gnulib tests are maintained in Gnulib and don't end up in binaries
4382 # that that package installs; therefore it does not make sense for
4383 # package maintainers to enforce the absence of warnings on these tests.
4384 # Why before @CFLAGS@?
4385 # - Because "the user is always right": If a user adds '-Werror' to their
4386 # CFLAGS, they have asked for errors, they will get errors. But they have
4387 # no right to complain about these errors, because Gnulib does not support
4388 # '-Werror'.
4389 cflags_for_gnulib_code=
4390 if ! $for_test; then
4391 # Enable or disable warnings as suitable for the Gnulib coding style.
4392 cflags_for_gnulib_code=" \$(GL_CFLAG_GNULIB_WARNINGS)"
4394 echo "CFLAGS = @GL_CFLAG_ALLOW_WARNINGS@${cflags_for_gnulib_code} @CFLAGS@"
4395 echo "CXXFLAGS = @GL_CXXFLAG_ALLOW_WARNINGS@ @CXXFLAGS@"
4396 echo
4397 echo "AM_CPPFLAGS = \\"
4398 if $for_test; then
4399 echo " -DGNULIB_STRICT_CHECKING=1 \\"
4401 if test -n "$witness_c_macro"; then
4402 echo " -D$witness_c_macro=1 \\"
4404 if test -n "${witness_macro}"; then
4405 echo " -D@${witness_macro}@=1 \\"
4407 echo " -I. -I\$(srcdir) \\"
4408 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
4409 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
4410 echo
4411 if $use_libtests; then
4412 # All test programs need to be linked with libtests.a.
4413 # It needs to be passed to the linker before ${libname}.${libext}, since
4414 # the tests-related modules depend on the main modules.
4415 # It also needs to be passed to the linker after ${libname}.${libext}
4416 # because the latter might contain incomplete modules (such as the
4417 # 'version-etc' module whose dependency to 'version-etc-fsf' is voluntarily
4418 # omitted).
4419 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
4420 # not matter.
4421 echo "LDADD = libtests.a ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext} libtests.a ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext} libtests.a \$(LIBTESTS_LIBDEPS)"
4422 else
4423 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
4425 echo
4426 if $use_libtests; then
4427 echo "libtests_a_SOURCES ="
4428 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
4429 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
4430 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
4431 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
4432 echo "EXTRA_libtests_a_SOURCES ="
4433 # The circular dependency in LDADD requires this.
4434 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
4435 echo
4437 # Many test scripts use ${EXEEXT} or ${srcdir}.
4438 # EXEEXT is defined by AC_PROG_CC through autoconf.
4439 # srcdir is defined by autoconf and automake.
4440 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
4441 echo
4442 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
4443 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
4444 # Arrange to print a message before compiling the files in this directory.
4445 echo "all: all-notice"
4446 echo "all-notice:"
4447 echo " @echo '## ---------------------------------------------------- ##'"
4448 echo " @echo '## ------------------- Gnulib tests ------------------- ##'"
4449 echo " @echo '## You can ignore compiler warnings in this directory. ##'"
4450 echo " @echo '## ---------------------------------------------------- ##'"
4451 echo
4452 # Arrange to print a message before executing the tests in this directory.
4453 echo "check-am: check-notice"
4454 echo "check-notice:"
4455 echo " @echo '## ---------------------------------------------------------------------- ##'"
4456 echo " @echo '## ---------------------------- Gnulib tests ---------------------------- ##'"
4457 echo " @echo '## Please report test failures in this directory to <bug-gnulib@gnu.org>. ##'"
4458 echo " @echo '## ---------------------------------------------------------------------- ##'"
4459 echo
4460 echo "# Clean up after Solaris cc."
4461 echo "clean-local:"
4462 echo " rm -rf SunWS_cache"
4463 echo
4464 echo "mostlyclean-local: mostlyclean-generic"
4465 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
4466 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
4467 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
4468 echo " fi; \\"
4469 echo " done; \\"
4470 echo " :"
4471 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
4474 # func_emit_initmacro_start macro_prefix gentests
4475 # emits the first few statements of the gl_INIT macro to standard output.
4476 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4477 # - gentests true if a tests Makefile.am is being generated,
4478 # false otherwise
4479 # - module_indicator_prefix prefix of GNULIB_<modulename> variables to use
4480 func_emit_initmacro_start ()
4482 macro_prefix_arg="$1"
4483 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
4484 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
4485 # LIBOBJS. The purpose is to allow several gnulib instantiations under
4486 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
4487 # flexibility.)
4488 # Furthermore it avoids an automake error like this when a Makefile.am
4489 # that uses pieces of gnulib also uses $(LIBOBJ):
4490 # automatically discovered file `error.c' should not be explicitly mentioned
4491 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
4492 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
4493 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
4494 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
4495 # automatically discovered file `error.c' should not be explicitly mentioned
4496 # We let automake know about the files to be distributed through the
4497 # EXTRA_lib_SOURCES variable.
4498 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
4499 # Create data variables for checking the presence of files that are mentioned
4500 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
4501 # because we want the check to happen when the configure file is created,
4502 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
4503 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
4504 # in which to expect them.
4505 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
4506 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
4507 # Scope for m4 macros.
4508 echo " m4_pushdef([GL_MACRO_PREFIX], [${macro_prefix_arg}])"
4509 # Scope the GNULIB_<modulename> variables.
4510 echo " m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [${module_indicator_prefix}])"
4511 echo " gl_COMMON"
4512 if "$2"; then
4513 echo " AC_REQUIRE([gl_CC_ALLOW_WARNINGS])"
4514 echo " AC_REQUIRE([gl_CXX_ALLOW_WARNINGS])"
4518 # func_emit_initmacro_end macro_prefix gentests
4519 # emits the last few statements of the gl_INIT macro to standard output.
4520 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4521 # - gentests true if a tests Makefile.am is being generated,
4522 # false otherwise
4523 # - automake_subdir true if --automake-subdir was given, false otherwise
4524 # - libtool true if --libtool was given, false if --no-libtool was
4525 # given, blank otherwise
4526 func_emit_initmacro_end ()
4528 macro_prefix_arg="$1"
4529 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
4530 # The check is performed only when autoconf is run from the directory where
4531 # the configure.ac resides; if it is run from a different directory, the
4532 # check is skipped.
4533 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
4534 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
4535 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
4536 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
4537 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
4538 echo " exit 1"
4539 echo " fi"
4540 echo " done])dnl"
4541 echo " m4_if(m4_sysval, [0], [],"
4542 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
4543 echo " ])"
4544 echo " m4_popdef([GL_MODULE_INDICATOR_PREFIX])"
4545 echo " m4_popdef([GL_MACRO_PREFIX])"
4546 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
4547 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
4548 echo " m4_popdef([AC_LIBSOURCES])"
4549 echo " m4_popdef([AC_REPLACE_FUNCS])"
4550 echo " m4_popdef([AC_LIBOBJ])"
4551 echo " AC_CONFIG_COMMANDS_PRE(["
4552 echo " ${macro_prefix_arg}_libobjs="
4553 echo " ${macro_prefix_arg}_ltlibobjs="
4554 echo " ${macro_prefix_arg}_libobjdeps="
4555 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
4556 echo " # Remove the extension."
4557 echo "changequote(,)dnl"
4558 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
4559 echo " sed_dirname1='s,//*,/,g'"
4560 echo " sed_dirname2='s,\\(.\\)/\$,\\1,'"
4561 echo " sed_dirname3='s,^[^/]*\$,.,'"
4562 echo " sed_dirname4='s,\\(.\\)/[^/]*\$,\\1,'"
4563 echo " sed_basename1='s,.*/,,'"
4564 echo "changequote([, ])dnl"
4565 if $automake_subdir && ! "$2" && test -n "$sourcebase" && test "$sourcebase" != '.'; then
4566 subdir="$sourcebase/"
4567 elif $automake_subdir_tests && "$2" && test -n "$testsbase" && test "$testsbase" != '.'; then
4568 subdir="$testsbase/"
4569 else
4570 subdir=
4572 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
4573 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs ${subdir}\$i.\$ac_objext\""
4574 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs ${subdir}\$i.lo\""
4575 echo " i_dir=\`echo \"\$i\" | sed -e \"\$sed_dirname1\" -e \"\$sed_dirname2\" -e \"\$sed_dirname3\" -e \"\$sed_dirname4\"\`"
4576 echo " i_base=\`echo \"\$i\" | sed -e \"\$sed_basename1\"\`"
4577 if test "$libtool" = true; then
4578 echo " ${macro_prefix_arg}_libobjdeps=\"\$${macro_prefix_arg}_libobjdeps ${subdir}\$i_dir/\\\$(DEPDIR)/\$i_base.Plo\""
4579 else
4580 echo " ${macro_prefix_arg}_libobjdeps=\"\$${macro_prefix_arg}_libobjdeps ${subdir}\$i_dir/\\\$(DEPDIR)/\$i_base.Po\""
4582 echo " done"
4583 echo " fi"
4584 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
4585 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
4586 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJDEPS], [\$${macro_prefix_arg}_libobjdeps])"
4587 echo " ])"
4590 # func_emit_initmacro_done macro_prefix sourcebase
4591 # emits a few statements after the gl_INIT macro to standard output.
4592 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4593 # - sourcebase directory relative to destdir where to place source code
4594 func_emit_initmacro_done ()
4596 macro_prefix_arg="$1"
4597 sourcebase_arg="$2"
4598 echo
4599 echo "# Like AC_LIBOBJ, except that the module name goes"
4600 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4601 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
4602 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
4603 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
4604 echo "])"
4605 echo
4606 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
4607 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4608 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
4609 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
4610 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
4611 echo "])"
4612 echo
4613 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
4614 echo "# expected is derived from the gnulib-tool parameterization,"
4615 echo "# and alloca is special cased (for the alloca-opt module)."
4616 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
4617 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
4618 echo " m4_foreach([_gl_NAME], [\$1], ["
4619 echo " m4_if(_gl_NAME, [alloca.c], [], ["
4620 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
4621 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
4622 echo " ])"
4623 echo " ])"
4624 echo "])"
4627 # func_emit_shellvars_init gentests base
4628 # emits some shell variable assignments to standard output.
4629 # - gentests true if a tests Makefile.am is being generated,
4630 # false otherwise
4631 # - base base directory, relative to the top-level directory
4632 # - automake_subdir true if --automake-subdir was given, false otherwise
4633 # - automake_subdir_tests true if --automake-subdir-tests was given, false otherwise
4634 func_emit_shellvars_init ()
4636 # Define the base directory, relative to the top-level directory.
4637 echo " gl_source_base='$2'"
4638 # Define the prefix for the file name of generated files.
4639 if $1 && $automake_subdir_tests; then
4640 # When tests share the same Makefile as the whole project, they
4641 # share the same base prefix.
4642 if test "$2" = "$testsbase"; then
4643 echo " gl_source_base_prefix='\$(top_build_prefix)$sourcebase/'"
4644 else
4645 echo " gl_source_base_prefix='\$(top_build_prefix)$2/'"
4647 elif ! $1 && $automake_subdir; then
4648 echo " gl_source_base_prefix='\$(top_build_prefix)$2/'"
4649 else
4650 echo " gl_source_base_prefix="
4654 # func_emit_autoconf_snippet indentation
4655 # emits the autoconf snippet of a module.
4656 # Input:
4657 # - indentation spaces to prepend on each line
4658 # - local_gnulib_path from --local-dir
4659 # - modcache true or false, from --cache-modules/--no-cache-modules
4660 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4661 # - sed_replace_include_guard_prefix
4662 # sed expression for resolving ${gl_include_guard_prefix}
4663 # - module the module name
4664 # - toplevel true or false. 'false' means a subordinate use of
4665 # gnulib-tool.
4666 # - disable_libtool true or false. It tells whether to disable libtool
4667 # handling even if it has been specified through the
4668 # command line options.
4669 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4670 # invocations.
4671 func_emit_autoconf_snippet ()
4673 indentation="$1"
4674 if { case $module in
4675 gnumakefile | maintainer-makefile)
4676 # These modules are meant to be used only in the top-level directory.
4677 $toplevel ;;
4679 true ;;
4680 esac
4681 }; then
4682 func_get_autoconf_snippet "$module" \
4683 | sed -e '/^$/d;' -e "s/^/$indentation/" \
4684 -e "$sed_replace_build_aux" \
4685 -e "$sed_replace_include_guard_prefix" \
4686 | { if $disable_libtool; then
4687 sed -e 's/\$gl_cond_libtool/false/g' \
4688 -e 's/gl_libdeps/gltests_libdeps/g' \
4689 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4690 else
4694 | { if $disable_gettext; then
4695 sed -e 's/AM_GNU_GETTEXT(\[external])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
4696 else
4697 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
4698 # autopoint through at least GNU gettext version 0.18.2.
4699 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
4702 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
4703 echo 'changequote(,)dnl'
4704 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4705 echo 'changequote([, ])dnl'
4706 echo 'AC_SUBST([LTALLOCA])'
4711 # func_emit_autoconf_snippets modules referenceable_modules verifier toplevel disable_libtool disable_gettext
4712 # collects and emit the autoconf snippets of a set of modules.
4713 # Input:
4714 # - local_gnulib_path from --local-dir
4715 # - modcache true or false, from --cache-modules/--no-cache-modules
4716 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4717 # - sed_replace_include_guard_prefix
4718 # sed expression for resolving ${gl_include_guard_prefix}
4719 # - modules the list of modules.
4720 # - referenceable_modules the list of modules which may be referenced as dependencies.
4721 # - verifier one of func_verify_module, func_verify_nontests_module,
4722 # func_verify_tests_module. It selects the subset of
4723 # $modules to consider.
4724 # - toplevel true or false. 'false' means a subordinate use of
4725 # gnulib-tool.
4726 # - disable_libtool true or false. It tells whether to disable libtool
4727 # handling even if it has been specified through the
4728 # command line options.
4729 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4730 # invocations.
4731 func_emit_autoconf_snippets ()
4733 referenceable_modules="$2"
4734 verifier="$3"
4735 toplevel="$4"
4736 disable_libtool="$5"
4737 disable_gettext="$6"
4738 if test "$cond_dependencies" = true; then
4739 for m in $referenceable_modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
4740 # Emit the autoconf code for the unconditional modules.
4741 for module in $1; do
4742 eval $verifier
4743 if test -n "$module"; then
4744 if func_cond_module_p "$module"; then
4746 else
4747 func_emit_autoconf_snippet " "
4750 done
4751 # Initialize the shell variables indicating that the modules are enabled.
4752 for module in $1; do
4753 eval $verifier
4754 if test -n "$module"; then
4755 if func_cond_module_p "$module"; then
4756 func_module_shellvar_name "$module"
4757 echo " $shellvar=false"
4760 done
4761 # Emit the autoconf code for the conditional modules, each in a separate
4762 # function. This makes it possible to support cycles among conditional
4763 # modules.
4764 for module in $1; do
4765 eval $verifier
4766 if test -n "$module"; then
4767 if func_cond_module_p "$module"; then
4768 func_module_shellfunc_name "$module"
4769 func_module_shellvar_name "$module"
4770 echo " $shellfunc ()"
4771 echo ' {'
4772 echo " if \$$shellvar; then :; else"
4773 func_emit_autoconf_snippet " "
4774 echo " $shellvar=true"
4775 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4776 # Intersect $deps with the modules list $1.
4777 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C $JOIN - "$tmp"/modules`
4778 for dep in $deps; do
4779 if func_cond_module_p "$dep"; then
4780 func_module_shellfunc_name "$dep"
4781 func_cond_module_condition "$module" "$dep"
4782 if test "$condition" != true; then
4783 echo " if $condition; then"
4784 echo " $shellfunc"
4785 echo ' fi'
4786 else
4787 echo " $shellfunc"
4789 else
4790 # The autoconf code for $dep has already been emitted above and
4791 # therefore is already executed when this function is run.
4794 done
4795 echo ' fi'
4796 echo ' }'
4799 done
4800 # Emit the dependencies from the unconditional to the conditional modules.
4801 for module in $1; do
4802 eval $verifier
4803 if test -n "$module"; then
4804 if func_cond_module_p "$module"; then
4806 else
4807 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4808 # Intersect $deps with the modules list $1.
4809 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C $JOIN - "$tmp"/modules`
4810 for dep in $deps; do
4811 if func_cond_module_p "$dep"; then
4812 func_module_shellfunc_name "$dep"
4813 func_cond_module_condition "$module" "$dep"
4814 if test "$condition" != true; then
4815 echo " if $condition; then"
4816 echo " $shellfunc"
4817 echo ' fi'
4818 else
4819 echo " $shellfunc"
4821 else
4822 # The autoconf code for $dep has already been emitted above and
4823 # therefore is already executed when this code is run.
4826 done
4829 done
4830 # Define the Automake conditionals.
4831 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4832 for module in $1; do
4833 eval $verifier
4834 if test -n "$module"; then
4835 if func_cond_module_p "$module"; then
4836 func_module_conditional_name "$module"
4837 func_module_shellvar_name "$module"
4838 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4841 done
4842 else
4843 # Ignore the conditions, and enable all modules unconditionally.
4844 for module in $1; do
4845 eval $verifier
4846 if test -n "$module"; then
4847 func_emit_autoconf_snippet " "
4849 done
4853 # func_emit_pre_early_macros require indentation modules
4854 # The require parameter can be ':' (AC_REQUIRE) or 'false' (direct call).
4855 func_emit_pre_early_macros ()
4857 echo
4858 echo "${2}# Pre-early section."
4859 if $1; then
4860 _pre_early_snippet="echo \"${2}AC_REQUIRE([\$_pre_early_macro])\""
4861 else
4862 _pre_early_snippet="echo \"${2}\$_pre_early_macro\""
4865 # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB. Doing
4866 # AC_REQUIRE in configure-ac.early is not early enough.
4867 _pre_early_macro="gl_USE_SYSTEM_EXTENSIONS"
4868 case "${nl}${3}${nl}" in
4869 *${nl}extensions${nl}*) eval "$_pre_early_snippet" ;;
4870 esac
4872 _pre_early_macro="gl_PROG_AR_RANLIB"
4873 eval "$_pre_early_snippet"
4874 echo
4877 # func_reconstruct_cached_dir
4878 # callback for func_reconstruct_cached_local_gnulib_path
4879 # Input:
4880 # - destdir from --dir
4881 # Output:
4882 # - local_gnulib_path restored '--local-dir' path from cache
4883 func_reconstruct_cached_dir ()
4885 cached_dir=$1
4886 if test -n "$cached_dir"; then
4887 case "$cached_dir" in
4889 func_path_append local_gnulib_path "$cached_dir" ;;
4891 case "$destdir" in
4893 # XXX This doesn't look right.
4894 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4896 func_relconcat "$destdir" "$cached_dir"
4897 func_path_append local_gnulib_path "$relconcat" ;;
4898 esac ;;
4899 esac
4903 # func_reconstruct_cached_local_gnulib_path
4904 # reconstruct local_gnulib_path from cached_local_gnulib_path to be set
4905 # relatively to $destdir again.
4906 # Input:
4907 # - cached_local_gnulib_path local_gnulib_path stored within gnulib-cache.m4
4908 # - destdir from --dir
4909 # Output:
4910 # - local_gnulib_path restored '--local-dir' path from cache
4911 func_reconstruct_cached_local_gnulib_path ()
4913 func_path_foreach "$cached_local_gnulib_path" func_reconstruct_cached_dir %dir%
4916 # func_import modules
4917 # Uses also the variables
4918 # - mode import or add-import or remove-import or update
4919 # - destdir target directory
4920 # - local_gnulib_path from --local-dir
4921 # - modcache true or false, from --cache-modules/--no-cache-modules
4922 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4923 # - libname library name
4924 # - supplied_libname true if --lib was given, blank otherwise
4925 # - sourcebase directory relative to destdir where to place source code
4926 # - m4base directory relative to destdir where to place *.m4 macros
4927 # - pobase directory relative to destdir where to place *.po files
4928 # - docbase directory relative to destdir where to place doc files
4929 # - testsbase directory relative to destdir where to place unit test code
4930 # - auxdir directory relative to destdir where to place build aux files
4931 # - inctests true if --with-tests was given, false otherwise
4932 # - incobsolete true if --with-obsolete was given, blank otherwise
4933 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4934 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4935 # otherwise
4936 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4937 # otherwise
4938 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4939 # otherwise
4940 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4941 # - avoidlist list of modules to avoid, from --avoid
4942 # - cond_dependencies true if --conditional-dependencies was given, false if
4943 # --no-conditional-dependencies was given, blank otherwise
4944 # - lgpl yes or a number if library's license shall be LGPL,
4945 # blank otherwise
4946 # - makefile_name from --makefile-name
4947 # - tests_makefile_name from --tests-makefile-name
4948 # - libtool true if --libtool was given, false if --no-libtool was
4949 # given, blank otherwise
4950 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4951 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4952 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4953 # - witness_c_macro from --witness-c-macro
4954 # - vc_files true if --vc-files was given, false if --no-vc-files was
4955 # given, blank otherwise
4956 # - autoconf_minversion minimum supported autoconf version
4957 # - doit : if actions shall be executed, false if only to be printed
4958 # - copymode copy mode for files in general
4959 # - lcopymode copy mode for files from local_gnulib_path
4960 func_import ()
4962 # Get the cached settings.
4963 # In 'import' mode, we read them only for the purpose of knowing the old
4964 # installed file list, and don't use them as defaults.
4965 cached_local_gnulib_path=
4966 cached_specified_modules=
4967 cached_incobsolete=
4968 cached_inc_cxx_tests=
4969 cached_inc_longrunning_tests=
4970 cached_inc_privileged_tests=
4971 cached_inc_unportable_tests=
4972 cached_inc_all_tests=
4973 cached_avoidlist=
4974 cached_sourcebase=
4975 cached_m4base=
4976 cached_pobase=
4977 cached_docbase=
4978 cached_testsbase=
4979 cached_inctests=
4980 cached_libname=
4981 cached_lgpl=
4982 cached_makefile_name=
4983 cached_tests_makefile_name=
4984 cached_automake_subdir=
4985 cached_cond_dependencies=
4986 cached_libtool=
4987 cached_macro_prefix=
4988 cached_po_domain=
4989 cached_witness_c_macro=
4990 cached_vc_files=
4991 cached_files=
4992 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4993 cached_libtool=false
4994 my_sed_traces='
4995 s,#.*$,,
4996 s,^dnl .*$,,
4997 s, dnl .*$,,
4998 /gl_LOCAL_DIR(/ {
4999 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_path="\1",p
5001 /gl_MODULES(/ {
5004 s/)/)/
5009 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
5011 /gl_WITH_OBSOLETE/ {
5012 s,^.*$,cached_incobsolete=true,p
5014 /gl_WITH_CXX_TESTS/ {
5015 s,^.*$,cached_inc_cxx_tests=true,p
5017 /gl_WITH_LONGRUNNING_TESTS/ {
5018 s,^.*$,cached_inc_longrunning_tests=true,p
5020 /gl_WITH_PRIVILEGED_TESTS/ {
5021 s,^.*$,cached_inc_privileged_tests=true,p
5023 /gl_WITH_UNPORTABLE_TESTS/ {
5024 s,^.*$,cached_inc_unportable_tests=true,p
5026 /gl_WITH_ALL_TESTS/ {
5027 s,^.*$,cached_inc_all_tests=true,p
5029 /gl_AVOID(/ {
5030 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
5032 /gl_SOURCE_BASE(/ {
5033 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
5035 /gl_M4_BASE(/ {
5036 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
5038 /gl_PO_BASE(/ {
5039 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
5041 /gl_DOC_BASE(/ {
5042 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
5044 /gl_TESTS_BASE(/ {
5045 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
5047 /gl_WITH_TESTS/ {
5048 s,^.*$,cached_inctests=true,p
5050 /gl_LIB(/ {
5051 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
5053 /gl_LGPL(/ {
5054 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
5056 /gl_LGPL/ {
5057 s,^.*$,cached_lgpl=yes,p
5059 /gl_MAKEFILE_NAME(/ {
5060 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
5062 /gl_TESTS_MAKEFILE_NAME(/ {
5063 s,^.*gl_TESTS_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_tests_makefile_name="\1",p
5065 /gl_AUTOMAKE_SUBDIR/ {
5066 s,^.*$,cached_automake_subdir=true,p
5068 /gl_CONDITIONAL_DEPENDENCIES/ {
5069 s,^.*$,cached_cond_dependencies=true,p
5071 /gl_LIBTOOL/ {
5072 s,^.*$,cached_libtool=true,p
5074 /gl_MACRO_PREFIX(/ {
5075 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
5077 /gl_PO_DOMAIN(/ {
5078 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
5080 /gl_WITNESS_C_MACRO(/ {
5081 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
5083 /gl_VC_FILES(/ {
5084 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
5086 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
5087 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5088 my_sed_traces='
5089 s,#.*$,,
5090 s,^dnl .*$,,
5091 s, dnl .*$,,
5092 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST], \[/ {
5093 s,^.*$,cached_files=",p
5097 s,^]).*$,",
5099 s,["$`\\],,g
5106 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
5110 if test "$mode" = import; then
5111 # In 'import' mode, the new set of specified modules overrides the cached
5112 # set of modules. Ignore the cached settings.
5113 specified_modules="$1"
5114 else
5115 # Merge the cached settings with the specified ones.
5116 # The m4base must be the same as expected from the pathname.
5117 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
5118 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
5120 # The local_gnulib_path defaults to the cached one. Recall that the cached one
5121 # is relative to $destdir, whereas the one we use is relative to . or absolute.
5122 if test -z "$local_gnulib_path"; then
5123 func_reconstruct_cached_local_gnulib_path
5125 case $mode in
5126 add-import)
5127 # Append the cached and the specified module names. So that
5128 # "gnulib-tool --add-import foo" means to add the module foo.
5129 specified_modules="$cached_specified_modules $1"
5131 remove-import)
5132 # Take the cached module names, minus the specified module names.
5133 specified_modules=
5134 if $have_associative; then
5135 # Use an associative array, for O(N) worst-case run time.
5136 declare -A to_remove
5137 for m in $1; do
5138 eval 'to_remove[$m]=yes'
5139 done
5140 for module in $cached_specified_modules; do
5141 if eval 'test -z "${to_remove[$module]}"'; then
5142 func_append specified_modules "$module "
5144 done
5145 else
5146 # This loop has O(N**2) worst-case run time.
5147 for module in $cached_specified_modules; do
5148 to_remove=
5149 for m in $1; do
5150 if test "$m" = "$module"; then
5151 to_remove=yes
5152 break
5154 done
5155 if test -z "$to_remove"; then
5156 func_append specified_modules "$module "
5158 done
5161 update)
5162 # Take the cached module names. There are no specified module names.
5163 specified_modules="$cached_specified_modules"
5165 esac
5166 # Included obsolete modules among the dependencies if specified either way.
5167 if test -z "$incobsolete"; then
5168 incobsolete="$cached_incobsolete"
5170 # Included special kinds of tests modules among the dependencies if specified
5171 # either way.
5172 if test -z "$inc_cxx_tests"; then
5173 inc_cxx_tests="$cached_inc_cxx_tests"
5175 if test -z "$inc_longrunning_tests"; then
5176 inc_longrunning_tests="$cached_inc_longrunning_tests"
5178 if test -z "$inc_privileged_tests"; then
5179 inc_privileged_tests="$cached_inc_privileged_tests"
5181 if test -z "$inc_unportable_tests"; then
5182 inc_unportable_tests="$cached_inc_unportable_tests"
5184 if test -z "$inc_all_tests"; then
5185 inc_all_tests="$cached_inc_all_tests"
5187 # Append the cached and the specified avoidlist. This is probably better
5188 # than dropping the cached one when --avoid is specified at least once.
5189 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
5190 avoidlist=`echo $avoidlist`
5192 # The sourcebase defaults to the cached one.
5193 if test -z "$sourcebase"; then
5194 sourcebase="$cached_sourcebase"
5195 if test -z "$sourcebase"; then
5196 func_fatal_error "missing --source-base option"
5199 # The pobase defaults to the cached one.
5200 if test -z "$pobase"; then
5201 pobase="$cached_pobase"
5203 # The docbase defaults to the cached one.
5204 if test -z "$docbase"; then
5205 docbase="$cached_docbase"
5206 if test -z "$docbase"; then
5207 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."
5210 # The testsbase defaults to the cached one.
5211 if test -z "$testsbase"; then
5212 testsbase="$cached_testsbase"
5213 if test -z "$testsbase"; then
5214 func_fatal_error "missing --tests-base option"
5217 # Require the tests if specified either way.
5218 if ! $inctests; then
5219 inctests="$cached_inctests"
5220 if test -z "$inctests"; then
5221 inctests=false
5224 # The libname defaults to the cached one.
5225 if test -z "$supplied_libname"; then
5226 libname="$cached_libname"
5227 if test -z "$libname"; then
5228 func_fatal_error "missing --lib option"
5231 # Require LGPL if specified either way.
5232 if test -z "$lgpl"; then
5233 lgpl="$cached_lgpl"
5235 # The makefile_name defaults to the cached one.
5236 if test -z "$makefile_name"; then
5237 makefile_name="$cached_makefile_name"
5239 # The tests_makefile_name defaults to the cached one.
5240 if test -z "$tests_makefile_name"; then
5241 tests_makefile_name="$cached_tests_makefile_name"
5243 # Use automake-subdir mode if specified either way.
5244 if ! $automake_subdir; then
5245 automake_subdir="$cached_automake_subdir"
5246 if test -z "$automake_subdir"; then
5247 automake_subdir=false
5250 # Use conditional dependencies if specified either way.
5251 if test -z "$cond_dependencies"; then
5252 cond_dependencies="$cached_cond_dependencies"
5254 # Use libtool if specified either way, or if guessed.
5255 if test -z "$libtool"; then
5256 if test -n "$cached_m4base"; then
5257 libtool="$cached_libtool"
5258 else
5259 libtool="$guessed_libtool"
5262 # The macro_prefix defaults to the cached one.
5263 if test -z "$macro_prefix"; then
5264 macro_prefix="$cached_macro_prefix"
5265 if test -z "$macro_prefix"; then
5266 func_fatal_error "missing --macro-prefix option"
5269 # The po_domain defaults to the cached one.
5270 if test -z "$po_domain"; then
5271 po_domain="$cached_po_domain"
5273 # The witness_c_macro defaults to the cached one.
5274 if test -z "$witness_c_macro"; then
5275 witness_c_macro="$cached_witness_c_macro"
5277 # The vc_files defaults to the cached one.
5278 if test -z "$vc_files"; then
5279 vc_files="$cached_vc_files"
5282 # --without-*-tests options are not supported here.
5283 excl_cxx_tests=
5284 excl_longrunning_tests=
5285 excl_privileged_tests=
5286 excl_unportable_tests=
5288 # Canonicalize the list of specified modules.
5289 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5291 # Include all kinds of tests modules if --with-all-tests was specified.
5292 inc_all_direct_tests="$inc_all_tests"
5293 inc_all_indirect_tests="$inc_all_tests"
5295 # Determine final module list.
5296 modules="$specified_modules"
5297 func_modules_transitive_closure
5298 if test $verbose -ge 0; then
5299 func_show_module_list
5301 final_modules="$modules"
5303 # Determine main module list and tests-related module list separately.
5304 func_modules_transitive_closure_separately
5306 # Determine whether a $testsbase/libtests.a is needed.
5307 func_determine_use_libtests
5309 # Add the dummy module to the main module list or to the tests-related module
5310 # list if needed.
5311 func_modules_add_dummy_separately
5313 # If --lgpl, verify that the licenses of modules are compatible.
5314 if test -n "$lgpl"; then
5315 license_incompatibilities=
5316 for module in $main_modules; do
5317 license=`func_get_license $module`
5318 case $license in
5319 'GPLv2+ build tool' | 'GPLed build tool') ;;
5320 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5322 case "$lgpl" in
5323 yes | 3)
5324 case $license in
5325 LGPLv2+ | 'LGPLv3+ or GPLv2+' | LGPLv3+ | LGPL) ;;
5326 *) func_append license_incompatibilities "$module $license$nl" ;;
5327 esac
5329 3orGPLv2)
5330 case $license in
5331 LGPLv2+ | 'LGPLv3+ or GPLv2+') ;;
5332 *) func_append license_incompatibilities "$module $license$nl" ;;
5333 esac
5336 case $license in
5337 LGPLv2+) ;;
5338 *) func_append license_incompatibilities "$module $license$nl" ;;
5339 esac
5341 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
5342 esac
5344 esac
5345 done
5346 if test -n "$license_incompatibilities"; then
5347 # Format the license incompatibilities as a table.
5348 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
5349 s,^\(.................................................[^ ]*\) *, \1 ,'
5350 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
5351 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
5355 # Show banner notice of every module.
5356 modules="$main_modules"
5357 func_modules_notice
5359 # Determine script to apply to imported library files.
5360 sed_transform_lib_file=
5361 for module in $main_modules; do
5362 if test $module = config-h; then
5363 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
5364 sed_transform_lib_file=$sed_transform_lib_file'
5365 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
5367 break
5369 done
5370 sed_transform_main_lib_file="$sed_transform_lib_file"
5372 # Determine script to apply to auxiliary files that go into $auxdir/.
5373 sed_transform_build_aux_file=
5375 # Determine script to apply to library files that go into $testsbase/.
5376 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
5378 # Determine the final file lists.
5379 func_modules_to_filelist_separately
5381 test -n "$files" \
5382 || func_fatal_error "refusing to do nothing"
5384 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
5385 new_files="$files m4/gnulib-tool.m4"
5386 old_files="$cached_files"
5387 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
5388 func_append old_files " m4/gnulib-tool.m4"
5391 rewritten='%REWRITTEN%'
5392 if test "$auxdir" = '.'; then
5393 auxdir_prefix=
5394 else
5395 auxdir_prefix="$auxdir/"
5397 if test "$cached_docbase" = '.'; then
5398 cached_docbase_prefix=
5399 else
5400 cached_docbase_prefix="$cached_docbase/"
5402 if test "$cached_sourcebase" = '.'; then
5403 cached_sourcebase_prefix=
5404 else
5405 cached_sourcebase_prefix="$cached_sourcebase/"
5407 if test "$cached_m4base" = '.'; then
5408 cached_m4base_prefix=
5409 else
5410 cached_m4base_prefix="$cached_m4base/"
5412 if test "$cached_testsbase" = '.'; then
5413 cached_testsbase_prefix=
5414 else
5415 cached_testsbase_prefix="$cached_testsbase/"
5417 if test "$docbase" = '.'; then
5418 docbase_prefix=
5419 else
5420 docbase_prefix="$docbase/"
5422 if test "$sourcebase" = '.'; then
5423 sourcebase_prefix=
5424 else
5425 sourcebase_prefix="$sourcebase/"
5427 if test "$m4base" = '.'; then
5428 m4base_prefix=
5429 else
5430 m4base_prefix="$m4base/"
5432 if test "$testsbase" = '.'; then
5433 testsbase_prefix=
5434 else
5435 testsbase_prefix="$testsbase/"
5437 sed_rewrite_old_files="\
5438 s,^build-aux/,$rewritten$auxdir_prefix,
5439 s,^doc/,$rewritten$cached_docbase_prefix,
5440 s,^lib/,$rewritten$cached_sourcebase_prefix,
5441 s,^m4/,$rewritten$cached_m4base_prefix,
5442 s,^tests/,$rewritten$cached_testsbase_prefix,
5443 s,^tests=lib/,$rewritten$cached_testsbase_prefix,
5444 s,^top/,$rewritten,
5445 s,^$rewritten,,"
5446 sed_rewrite_new_files="\
5447 s,^build-aux/,$rewritten$auxdir_prefix,
5448 s,^doc/,$rewritten$docbase_prefix,
5449 s,^lib/,$rewritten$sourcebase_prefix,
5450 s,^m4/,$rewritten$m4base_prefix,
5451 s,^tests/,$rewritten$testsbase_prefix,
5452 s,^tests=lib/,$rewritten$testsbase_prefix,
5453 s,^top/,$rewritten,
5454 s,^$rewritten,,"
5456 # Determine whether to put anything into $testsbase.
5457 testsfiles=`echo "$files" | sed -n -e 's,^tests/,,p' -e 's,^tests=lib/,,p'`
5458 if test -n "$testsfiles"; then
5459 gentests=true
5460 else
5461 gentests=false
5464 # Create directories.
5465 { echo "$sourcebase"
5466 echo "$m4base"
5467 if test -n "$pobase"; then
5468 echo "$pobase"
5470 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
5471 if test -n "$docfiles"; then
5472 echo "$docbase"
5474 if $gentests; then
5475 echo "$testsbase"
5477 echo "$auxdir"
5478 for f in $files; do echo $f; done \
5479 | sed -e "$sed_rewrite_new_files" \
5480 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5481 | LC_ALL=C sort -u
5482 } > "$tmp"/dirs
5483 { # Rearrange file descriptors. Needed because "while ... done < ..."
5484 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5485 exec 5<&0 < "$tmp"/dirs
5486 while read d; do
5487 if test ! -d "$destdir/$d"; then
5488 if $doit; then
5489 echo "Creating directory $destdir/$d"
5490 mkdir -p "$destdir/$d" || func_fatal_error "failed"
5491 else
5492 echo "Create directory $destdir/$d"
5495 done
5496 exec 0<&5 5<&-
5499 # Copy files or make symbolic links or hard links. Remove obsolete files.
5500 added_files=''
5501 removed_files=''
5502 delimiter=' '
5503 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5504 # representing the files according to the last gnulib-tool invocation.
5505 for f in $old_files; do echo $f; done \
5506 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
5507 | LC_ALL=C sort \
5508 > "$tmp"/old-files
5509 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5510 # representing the files after this gnulib-tool invocation.
5511 for f in $new_files; do echo $f; done \
5512 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
5513 | LC_ALL=C sort \
5514 > "$tmp"/new-files
5515 # First the files that are in old-files, but not in new-files:
5516 sed_take_first_column='s,'"$delimiter"'.*,,'
5517 for g in `LC_ALL=C $JOIN -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
5518 # Remove the file. Do nothing if the user already removed it.
5519 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
5520 if $doit; then
5521 echo "Removing file $g (backup in ${g}~)"
5522 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
5523 else
5524 echo "Remove file $g (backup in ${g}~)"
5526 func_append removed_files "$g$nl"
5528 done
5529 # func_add_or_update handles a file that ought to be present afterwards.
5530 # Uses parameters
5531 # - f the original file name
5532 # - g the rewritten file name
5533 # - already_present nonempty if the file should already exist, empty
5534 # otherwise
5535 func_add_or_update ()
5537 of="$f"
5538 case "$f" in
5539 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5540 esac
5541 func_dest_tmpfilename "$g"
5542 func_lookup_file "$f"
5543 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5544 func_ensure_writable "$tmpfile"
5545 case "$f" in
5546 *.class | *.mo )
5547 # Don't process binary files with sed.
5550 if test -n "$sed_transform_main_lib_file"; then
5551 case "$of" in
5552 lib/*)
5553 sed -e "$sed_transform_main_lib_file" \
5554 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5556 esac
5558 if test -n "$sed_transform_build_aux_file"; then
5559 case "$of" in
5560 build-aux/*)
5561 sed -e "$sed_transform_build_aux_file" \
5562 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5564 esac
5566 if test -n "$sed_transform_testsrelated_lib_file"; then
5567 case "$of" in
5568 tests=lib/*)
5569 sed -e "$sed_transform_testsrelated_lib_file" \
5570 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5572 esac
5575 esac
5576 if test -f "$destdir/$g"; then
5577 # The file already exists.
5578 func_update_file
5579 else
5580 # Install the file.
5581 # Don't protest if the file should be there but isn't: it happens
5582 # frequently that developers don't put autogenerated files under version control.
5583 func_add_file
5584 func_append added_files "$g$nl"
5586 rm -f "$tmpfile"
5588 # Then the files that are in new-files, but not in old-files:
5589 sed_take_last_column='s,^.*'"$delimiter"',,'
5590 already_present=
5591 LC_ALL=C $JOIN -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
5592 | sed -e "$sed_take_last_column" \
5593 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
5594 { # Rearrange file descriptors. Needed because "while ... done < ..."
5595 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5596 exec 5<&0 < "$tmp"/added-files
5597 while read g f; do
5598 func_add_or_update
5599 done
5600 exec 0<&5 5<&-
5602 # Then the files that are in new-files and in old-files:
5603 already_present=true
5604 LC_ALL=C $JOIN -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
5605 | sed -e "$sed_take_last_column" \
5606 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
5607 { # Rearrange file descriptors. Needed because "while ... done < ..."
5608 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5609 exec 5<&0 < "$tmp"/kept-files
5610 while read g f; do
5611 func_add_or_update
5612 done
5613 exec 0<&5 5<&-
5616 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
5617 actioncmd="# gnulib-tool --import"
5619 # Break the action command log into multiple lines.
5620 # Emacs puts some gnulib-tool log lines in its source repository, and
5621 # git send-email rejects patch lines longer than 998 characters.
5622 # Also, config.status uses awk, and the HP-UX 11.00 awk fails if a
5623 # line has length >= 3071; similarly, the IRIX 6.5 awk fails if a
5624 # line has length >= 3072.
5625 func_append_actionarg ()
5627 func_append actioncmd " \\$nl# $1"
5630 # Local helper.
5631 func_append_actioncmd_local_dir ()
5633 func_append_actionarg "--local-dir=$1"
5635 func_path_foreach "$local_gnulib_path" func_append_actioncmd_local_dir %dir%
5637 func_append_actionarg "--lib=$libname"
5638 func_append_actionarg "--source-base=$sourcebase"
5639 func_append_actionarg "--m4-base=$m4base"
5640 if test -n "$pobase"; then
5641 func_append_actionarg "--po-base=$pobase"
5643 func_append_actionarg "--doc-base=$docbase"
5644 func_append_actionarg "--tests-base=$testsbase"
5645 func_append_actionarg "--aux-dir=$auxdir"
5646 if $inctests; then
5647 func_append_actionarg "--with-tests"
5649 if test -n "$incobsolete"; then
5650 func_append_actionarg "--with-obsolete"
5652 if test -n "$inc_cxx_tests"; then
5653 func_append_actionarg "--with-c++-tests"
5655 if test -n "$inc_longrunning_tests"; then
5656 func_append_actionarg "--with-longrunning-tests"
5658 if test -n "$inc_privileged_tests"; then
5659 func_append_actionarg "--with-privileged-tests"
5661 if test -n "$inc_unportable_tests"; then
5662 func_append_actionarg "--with-unportable-tests"
5664 if test -n "$inc_all_tests"; then
5665 func_append_actionarg "--with-all-tests"
5667 if test -n "$lgpl"; then
5668 if test "$lgpl" = yes; then
5669 func_append_actionarg "--lgpl"
5670 else
5671 func_append_actionarg "--lgpl=$lgpl"
5674 if $gnu_make; then
5675 func_append_actionarg "--gnu-make"
5677 if test -n "$makefile_name"; then
5678 func_append_actionarg "--makefile-name=$makefile_name"
5680 if test -n "$tests_makefile_name"; then
5681 func_append_actionarg "--tests-makefile-name=$tests_makefile_name"
5683 if $automake_subdir; then
5684 func_append_actionarg "--automake-subdir"
5686 if $automake_subdir_tests; then
5687 func_append_actionarg "--automake-subdir-tests"
5689 if test "$cond_dependencies" = true; then
5690 func_append_actionarg "--conditional-dependencies"
5691 else
5692 func_append_actionarg "--no-conditional-dependencies"
5694 if test "$libtool" = true; then
5695 func_append_actionarg "--libtool"
5696 else
5697 func_append_actionarg "--no-libtool"
5699 func_append_actionarg "--macro-prefix=$macro_prefix"
5700 if test -n "$po_domain"; then
5701 func_append_actionarg "--po-domain=$po_domain"
5703 if test -n "$witness_c_macro"; then
5704 func_append_actionarg "--witness-c-macro=$witness_c_macro"
5706 if test -n "$vc_files"; then
5707 if test "$vc_files" = true; then
5708 func_append_actionarg "--vc-files"
5709 else
5710 func_append_actionarg "--no-vc-files"
5713 for module in $avoidlist; do
5714 func_append_actionarg "--avoid=$module"
5715 done
5716 for module in $specified_modules; do
5717 func_append_actionarg "$module"
5718 done
5720 # Determine include_guard_prefix and module_indicator_prefix.
5721 func_compute_include_guard_prefix
5723 # Default the source makefile name to Makefile.am.
5724 if test -n "$makefile_name"; then
5725 source_makefile_am="$makefile_name"
5726 else
5727 source_makefile_am='Makefile.am'
5729 # Default the tests makefile name to the source makefile name.
5730 if test -n "$tests_makefile_name"; then
5731 tests_makefile_am="$tests_makefile_name"
5732 else
5733 tests_makefile_am="$source_makefile_am"
5736 # Create normal Makefile.ams.
5737 for_test=false
5739 # Setup list of Makefile.am edits that are to be performed afterwards.
5740 # Some of these edits apply to files that we will generate; others are
5741 # under the responsibility of the developer.
5742 makefile_am_edits=0
5743 # func_note_Makefile_am_edit dir var value [dotfirst]
5744 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
5745 # ${value}.
5746 # If ${dotfirst} is non-empty, this mention needs to be present after '.'.
5747 # This is a special hack for the SUBDIRS variable, cf.
5748 # <https://www.gnu.org/software/automake/manual/html_node/Subdirectories.html>.
5749 func_note_Makefile_am_edit ()
5751 makefile_am_edits=`expr $makefile_am_edits + 1`
5752 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
5753 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
5754 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
5755 eval makefile_am_edit${makefile_am_edits}_dotfirst=\"\$4\"
5757 if test "$source_makefile_am" = Makefile.am; then
5758 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
5759 sourcebase_base=`basename "$sourcebase"`
5760 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
5762 if test -n "$pobase"; then
5763 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
5764 pobase_base=`basename "$pobase"`
5765 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
5767 if $inctests; then
5768 if test "$tests_makefile_am" = Makefile.am; then
5769 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
5770 testsbase_base=`basename "$testsbase"`
5771 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base" true
5774 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "${m4base}"
5776 # Find the first parent directory of $m4base that contains or will contain
5777 # a Makefile.am.
5778 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
5779 s,//*$,/,'
5780 sed_butlast='s,[^/][^/]*//*$,,'
5781 dir1="${m4base}/"; dir2=""
5782 while test -n "$dir1" \
5783 && ! { test -f "${destdir}/${dir1}Makefile.am" \
5784 || test "${dir1}Makefile.am" = "$sourcebase/$source_makefile_am" \
5785 || test "./${dir1}Makefile.am" = "$sourcebase/$source_makefile_am" \
5786 || { $gentests \
5787 && { test "${dir1}Makefile.am" = "$testsbase/$tests_makefile_am" \
5788 || test "./${dir1}Makefile.am" = "$testsbase/$tests_makefile_am"; }; }; }; do
5789 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
5790 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
5791 done
5792 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
5795 # Create po/ directory.
5796 if test -n "$pobase"; then
5797 # Create po makefile and auxiliary files.
5798 for file in Makefile.in.in remove-potcdate.sin; do
5799 func_dest_tmpfilename $pobase/$file
5800 func_lookup_file build-aux/po/$file
5801 cat "$lookedup_file" > "$tmpfile"
5802 if test -f "$destdir"/$pobase/$file; then
5803 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
5804 rm -f "$tmpfile"
5805 else
5806 if $doit; then
5807 echo "Updating $pobase/$file (backup in $pobase/$file~)"
5808 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
5809 mv -f "$tmpfile" "$destdir"/$pobase/$file
5810 else
5811 echo "Update $pobase/$file (backup in $pobase/$file~)"
5812 rm -f "$tmpfile"
5815 else
5816 if $doit; then
5817 echo "Creating $pobase/$file"
5818 mv -f "$tmpfile" "$destdir"/$pobase/$file
5819 else
5820 echo "Create $pobase/$file"
5821 rm -f "$tmpfile"
5823 func_append added_files "$pobase/$file$nl"
5825 done
5826 # Create po makefile parameterization, part 1.
5827 func_dest_tmpfilename $pobase/Makevars
5828 func_emit_po_Makevars > "$tmpfile"
5829 if test -f "$destdir"/$pobase/Makevars; then
5830 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
5831 rm -f "$tmpfile"
5832 else
5833 if $doit; then
5834 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
5835 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
5836 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5837 else
5838 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
5839 rm -f "$tmpfile"
5842 else
5843 if $doit; then
5844 echo "Creating $pobase/Makevars"
5845 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5846 else
5847 echo "Create $pobase/Makevars"
5848 rm -f "$tmpfile"
5850 func_append added_files "$pobase/Makevars$nl"
5852 # Create po makefile parameterization, part 2.
5853 func_dest_tmpfilename $pobase/POTFILES.in
5854 func_emit_po_POTFILES_in > "$tmpfile"
5855 if test -f "$destdir"/$pobase/POTFILES.in; then
5856 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5857 rm -f "$tmpfile"
5858 else
5859 if $doit; then
5860 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5861 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5862 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5863 else
5864 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5865 rm -f "$tmpfile"
5868 else
5869 if $doit; then
5870 echo "Creating $pobase/POTFILES.in"
5871 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5872 else
5873 echo "Create $pobase/POTFILES.in"
5874 rm -f "$tmpfile"
5876 func_append added_files "$pobase/POTFILES.in$nl"
5878 # Fetch PO files.
5879 TP_URL="https://translationproject.org/latest/"
5880 if $doit; then
5881 echo "Fetching gnulib PO files from $TP_URL"
5882 (cd "$destdir"/$pobase \
5883 && wget --no-verbose --mirror --level=1 -nd -A.po -P . "${TP_URL}gnulib/"
5885 else
5886 echo "Fetch gnulib PO files from $TP_URL"
5888 # Create po/LINGUAS.
5889 if $doit; then
5890 func_dest_tmpfilename $pobase/LINGUAS
5891 (cd "$destdir"/$pobase \
5892 && { echo '# Set of available languages.'
5893 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5895 ) > "$tmpfile"
5896 if test -f "$destdir"/$pobase/LINGUAS; then
5897 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5898 rm -f "$tmpfile"
5899 else
5900 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5901 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5902 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5904 else
5905 echo "Creating $pobase/LINGUAS"
5906 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5907 func_append added_files "$pobase/LINGUAS$nl"
5909 else
5910 if test -f "$destdir"/$pobase/LINGUAS; then
5911 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5912 else
5913 echo "Create $pobase/LINGUAS"
5918 # func_compute_relative_local_gnulib_path
5919 # gl_LOCAL_DIR requires local_gnulib_path to be set relatively to destdir
5920 # Input:
5921 # - local_gnulib_path from --local-dir
5922 # - destdir from --dir
5923 # Output:
5924 # - relative_local_dir path to be stored into gl_LOCAL_DIR
5925 func_compute_relative_local_gnulib_path ()
5927 relative_local_gnulib_path=
5928 saved_IFS="$IFS"
5929 IFS="$PATH_SEPARATOR"
5930 for local_dir in $local_gnulib_path
5932 IFS="$saved_IFS"
5933 # Store the local_dir relative to destdir.
5934 case "$local_dir" in
5935 "" | /*)
5936 relative_local_dir="$local_dir" ;;
5938 case "$destdir" in
5940 # XXX This doesn't look right.
5941 relative_local_dir="$local_dir" ;;
5943 # destdir, local_dir are both relative.
5944 func_relativize "$destdir" "$local_dir"
5945 relative_local_dir="$reldir" ;;
5946 esac ;;
5947 esac
5948 func_path_append relative_local_gnulib_path "$relative_local_dir"
5949 done
5950 IFS="$saved_IFS"
5953 # Create m4/gnulib-cache.m4.
5954 func_dest_tmpfilename $m4base/gnulib-cache.m4
5956 func_emit_copyright_notice
5957 echo "#"
5958 echo "# This file represents the specification of how gnulib-tool is used."
5959 echo "# It acts as a cache: It is written and read by gnulib-tool."
5960 echo "# In projects that use version control, this file is meant to be put under"
5961 echo "# version control, like the configure.ac and various Makefile.am files."
5962 echo
5963 echo
5964 echo "# Specification in the form of a command-line invocation:"
5965 printf '%s\n' "$actioncmd"
5966 echo
5967 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5968 func_compute_relative_local_gnulib_path
5969 echo "gl_LOCAL_DIR([$relative_local_gnulib_path])"
5970 echo "gl_MODULES(["
5971 echo "$specified_modules" | sed -e 's/^/ /g'
5972 echo "])"
5973 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5974 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5975 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5976 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5977 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5978 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5979 echo "gl_AVOID([$avoidlist])"
5980 echo "gl_SOURCE_BASE([$sourcebase])"
5981 echo "gl_M4_BASE([$m4base])"
5982 echo "gl_PO_BASE([$pobase])"
5983 echo "gl_DOC_BASE([$docbase])"
5984 echo "gl_TESTS_BASE([$testsbase])"
5985 if $inctests; then
5986 echo "gl_WITH_TESTS"
5988 echo "gl_LIB([$libname])"
5989 if test -n "$lgpl"; then
5990 if test "$lgpl" = yes; then
5991 echo "gl_LGPL"
5992 else
5993 echo "gl_LGPL([$lgpl])"
5996 echo "gl_MAKEFILE_NAME([$makefile_name])"
5997 if test -n "$tests_makefile_name"; then
5998 echo "gl_TESTS_MAKEFILE_NAME([$tests_makefile_name])"
6000 if test "$automake_subdir" = true; then
6001 echo "gl_AUTOMAKE_SUBDIR"
6003 if test "$cond_dependencies" = true; then
6004 echo "gl_CONDITIONAL_DEPENDENCIES"
6006 if test "$libtool" = true; then
6007 echo "gl_LIBTOOL"
6009 echo "gl_MACRO_PREFIX([$macro_prefix])"
6010 echo "gl_PO_DOMAIN([$po_domain])"
6011 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
6012 if test -n "$vc_files"; then
6013 echo "gl_VC_FILES([$vc_files])"
6015 ) > "$tmpfile"
6016 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
6017 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
6018 rm -f "$tmpfile"
6019 else
6020 if $doit; then
6021 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
6022 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
6023 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
6024 else
6025 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
6026 if false; then
6027 cat "$tmpfile"
6028 echo
6029 echo "# gnulib-cache.m4 ends here"
6031 rm -f "$tmpfile"
6034 else
6035 if $doit; then
6036 echo "Creating $m4base/gnulib-cache.m4"
6037 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
6038 else
6039 echo "Create $m4base/gnulib-cache.m4"
6040 cat "$tmpfile"
6041 rm -f "$tmpfile"
6045 # Create m4/gnulib-comp.m4.
6046 func_dest_tmpfilename $m4base/gnulib-comp.m4
6048 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
6049 func_emit_copyright_notice
6050 echo "#"
6051 echo "# This file represents the compiled summary of the specification in"
6052 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
6053 echo "# to be invoked from configure.ac."
6054 echo "# In projects that use version control, this file can be treated like"
6055 echo "# other built files."
6056 echo
6057 echo
6058 echo "# This macro should be invoked from $configure_ac, in the section"
6059 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
6060 echo "# any checks for libraries, header files, types and library functions."
6061 echo "AC_DEFUN([${macro_prefix}_EARLY],"
6062 echo "["
6063 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
6064 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
6065 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6066 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6068 func_emit_pre_early_macros : ' ' "$final_modules"
6070 for module in $final_modules; do
6071 func_verify_module
6072 if test -n "$module"; then
6073 echo "# Code from module $module:"
6074 func_get_autoconf_early_snippet "$module"
6076 done \
6077 | sed -e '/^$/d;' -e 's/^/ /'
6078 echo "])"
6079 echo
6080 echo "# This macro should be invoked from $configure_ac, in the section"
6081 echo "# \"Check for header files, types and library functions\"."
6082 echo "AC_DEFUN([${macro_prefix}_INIT],"
6083 echo "["
6084 # This AC_CONFIG_LIBOBJ_DIR invocation silences an error from the automake
6085 # front end:
6086 # error: required file './alloca.c' not found
6087 # It is needed because of the last remaining use of AC_LIBSOURCES in
6088 # _AC_LIBOBJ_ALLOCA, invoked from AC_FUNC_ALLOCA.
6089 # All the m4_pushdef/m4_popdef logic in func_emit_initmacro_start/_end
6090 # does not help to avoid this error.
6091 if grep ' lib/alloca\.c$' "$tmp"/new-files >/dev/null; then
6092 # alloca.c will be present in $sourcebase.
6093 echo " AC_CONFIG_LIBOBJ_DIR([$sourcebase])"
6094 else
6095 if grep ' tests=lib/alloca\.c$' "$tmp"/new-files >/dev/null; then
6096 # alloca.c will be present in $testsbase.
6097 echo " AC_CONFIG_LIBOBJ_DIR([$testsbase])"
6100 if test "$libtool" = true; then
6101 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6102 echo " gl_cond_libtool=true"
6103 else
6104 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6105 echo " gl_cond_libtool=false"
6106 echo " gl_libdeps="
6107 echo " gl_ltlibdeps="
6109 if test "$auxdir" != "build-aux"; then
6110 sed_replace_build_aux='
6112 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6113 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6116 else
6117 sed_replace_build_aux="$sed_noop"
6119 echo " gl_m4_base='$m4base'"
6120 func_emit_initmacro_start $macro_prefix false
6121 func_emit_shellvars_init false "$sourcebase"
6122 if test -n "$witness_c_macro"; then
6123 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
6125 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false true
6126 if test -n "$witness_c_macro"; then
6127 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6129 echo " # End of code from modules"
6130 func_emit_initmacro_end $macro_prefix false
6131 echo " gltests_libdeps="
6132 echo " gltests_ltlibdeps="
6133 func_emit_initmacro_start ${macro_prefix}tests $gentests
6134 func_emit_shellvars_init true "$testsbase"
6135 # Define a tests witness macro that depends on the package.
6136 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
6137 # See <https://lists.gnu.org/r/automake/2009-05/msg00145.html>.
6138 echo "changequote(,)dnl"
6139 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"
6140 echo "changequote([, ])dnl"
6141 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6142 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6143 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6144 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true true true
6145 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6146 func_emit_initmacro_end ${macro_prefix}tests $gentests
6147 echo " AC_REQUIRE([gl_CC_GNULIB_WARNINGS])"
6148 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6149 # created using libtool, because libtool already handles the dependencies.
6150 if test "$libtool" != true; then
6151 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6152 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6153 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6154 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6155 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6157 if $use_libtests; then
6158 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6159 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6161 echo "])"
6162 func_emit_initmacro_done $macro_prefix $sourcebase
6163 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6164 echo
6165 echo "# This macro records the list of files which have been installed by"
6166 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
6167 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
6168 echo "$files" | sed -e 's,^, ,'
6169 echo "])"
6170 ) > "$tmpfile"
6171 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
6172 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
6173 rm -f "$tmpfile"
6174 else
6175 if $doit; then
6176 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
6177 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
6178 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
6179 else
6180 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
6181 if false; then
6182 cat "$tmpfile"
6183 echo
6184 echo "# gnulib-comp.m4 ends here"
6186 rm -f "$tmpfile"
6189 else
6190 if $doit; then
6191 echo "Creating $m4base/gnulib-comp.m4"
6192 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
6193 else
6194 echo "Create $m4base/gnulib-comp.m4"
6195 cat "$tmpfile"
6196 rm -f "$tmpfile"
6200 # Create library makefile.
6201 # Do this after creating gnulib-comp.m4, because func_emit_lib_Makefile_am
6202 # can run 'autoconf -t', which reads gnulib-comp.m4.
6203 func_dest_tmpfilename $sourcebase/$source_makefile_am
6204 destfile="$sourcebase/$source_makefile_am"
6205 modules="$main_modules"
6206 if $automake_subdir; then
6207 func_emit_lib_Makefile_am | "$gnulib_dir"/build-aux/prefix-gnulib-mk --from-gnulib-tool --lib-name="$libname" --prefix="$sourcebase/" > "$tmpfile"
6208 else
6209 func_emit_lib_Makefile_am > "$tmpfile"
6211 if test -f "$destdir"/$sourcebase/$source_makefile_am; then
6212 if cmp -s "$destdir"/$sourcebase/$source_makefile_am "$tmpfile"; then
6213 rm -f "$tmpfile"
6214 else
6215 if $doit; then
6216 echo "Updating $sourcebase/$source_makefile_am (backup in $sourcebase/$source_makefile_am~)"
6217 mv -f "$destdir"/$sourcebase/$source_makefile_am "$destdir"/$sourcebase/$source_makefile_am~
6218 mv -f "$tmpfile" "$destdir"/$sourcebase/$source_makefile_am
6219 else
6220 echo "Update $sourcebase/$source_makefile_am (backup in $sourcebase/$source_makefile_am~)"
6221 rm -f "$tmpfile"
6224 else
6225 if $doit; then
6226 echo "Creating $sourcebase/$source_makefile_am"
6227 mv -f "$tmpfile" "$destdir"/$sourcebase/$source_makefile_am
6228 else
6229 echo "Create $sourcebase/$source_makefile_am"
6230 rm -f "$tmpfile"
6232 func_append added_files "$sourcebase/$source_makefile_am$nl"
6235 if $gentests; then
6236 # Create tests makefile.
6237 func_dest_tmpfilename $testsbase/$tests_makefile_am
6238 destfile="$testsbase/$tests_makefile_am"
6239 modules="$testsrelated_modules"
6240 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
6241 if test -f "$destdir"/$testsbase/$tests_makefile_am; then
6242 if cmp -s "$destdir"/$testsbase/$tests_makefile_am "$tmpfile"; then
6243 rm -f "$tmpfile"
6244 else
6245 if $doit; then
6246 echo "Updating $testsbase/$tests_makefile_am (backup in $testsbase/$tests_makefile_am~)"
6247 mv -f "$destdir"/$testsbase/$tests_makefile_am "$destdir"/$testsbase/$tests_makefile_am~
6248 mv -f "$tmpfile" "$destdir"/$testsbase/$tests_makefile_am
6249 else
6250 echo "Update $testsbase/$tests_makefile_am (backup in $testsbase/$tests_makefile_am~)"
6251 rm -f "$tmpfile"
6254 else
6255 if $doit; then
6256 echo "Creating $testsbase/$tests_makefile_am"
6257 mv -f "$tmpfile" "$destdir"/$testsbase/$tests_makefile_am
6258 else
6259 echo "Create $testsbase/$tests_makefile_am"
6260 rm -f "$tmpfile"
6262 func_append added_files "$testsbase/$tests_makefile_am$nl"
6266 if test "$vc_files" != false; then
6267 # Update the .cvsignore and .gitignore files.
6268 { echo "$added_files" | sed -e '/^$/d' -e 's,^\([^/]*\)$,./\1,' -e 's,/\([^/]*\)$,|A|\1,'
6269 echo "$removed_files" | sed -e '/^$/d' -e 's,^\([^/]*\)$,./\1,' -e 's,/\([^/]*\)$,|R|\1,'
6270 # Treat gnulib-comp.m4 like an added file, even if it already existed.
6271 echo "$m4base|A|gnulib-comp.m4"
6272 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
6273 { # Rearrange file descriptors. Needed because "while ... done < ..."
6274 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6275 exec 5<&0 < "$tmp"/fileset-changes
6276 func_update_ignorelist ()
6278 ignore="$1"
6279 if test "$ignore" = .gitignore; then
6280 # In a .gitignore file, "foo" applies to the current directory and all
6281 # subdirectories, whereas "/foo" applies to the current directory only.
6282 anchor='/'
6283 escaped_anchor='\/'
6284 doubly_escaped_anchor='\\/'
6285 else
6286 anchor=''
6287 escaped_anchor=''
6288 doubly_escaped_anchor=''
6290 if test -f "$destdir/$dir$ignore"; then
6291 if test -n "$dir_added" || test -n "$dir_removed"; then
6292 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
6293 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
6294 | LC_ALL=C $JOIN -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
6295 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
6296 > "$tmp"/ignore-removed
6298 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
6299 if $doit; then
6300 echo "Updating $dir$ignore (backup in $dir${ignore}~)"
6301 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
6302 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
6303 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
6304 } > "$tmp"/sed-ignore-removed
6305 { cat "$destdir/$dir$ignore"~
6306 # Add a newline if the original $dir$ignore file ended
6307 # with a character other than a newline.
6308 if test `tail -c 1 < "$destdir/$dir$ignore"~ | tr -d '\n' | wc -c` = 1; then echo; fi
6309 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
6310 } | sed -f "$tmp"/sed-ignore-removed \
6311 > "$destdir/$dir$ignore"
6312 else
6313 echo "Update $dir$ignore (backup in $dir${ignore}~)"
6317 else
6318 if test -n "$dir_added"; then
6319 if $doit; then
6320 echo "Creating $dir$ignore"
6322 if test "$ignore" = .cvsignore; then
6323 echo ".deps"
6324 # Automake generates Makefile rules that create .dirstamp files.
6325 echo ".dirstamp"
6327 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
6328 } > "$destdir/$dir$ignore"
6329 else
6330 echo "Create $dir$ignore"
6335 func_done_dir ()
6337 dir="$1"
6338 dir_added="$2"
6339 dir_removed="$3"
6340 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
6341 func_update_ignorelist .cvsignore
6343 if test -d "$destdir/.git" || test -f "$destdir/.gitignore" || test -f "$destdir/${dir}.gitignore"; then
6344 func_update_ignorelist .gitignore
6347 last_dir=
6348 last_dir_added=
6349 last_dir_removed=
6350 while read line; do
6351 # Why not ''read next_dir op file'' ? Because I hate working with IFS.
6352 next_dir=`echo "$line" | sed -e 's,|.*,,'`
6353 if test "$next_dir" = '.'; then
6354 next_dir=
6355 else
6356 next_dir="$next_dir/"
6358 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
6359 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
6360 if test "$next_dir" != "$last_dir"; then
6361 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
6362 last_dir="$next_dir"
6363 last_dir_added=
6364 last_dir_removed=
6366 case $op in
6367 A) func_append last_dir_added "$file$nl";;
6368 R) func_append last_dir_removed "$file$nl";;
6369 esac
6370 done
6371 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
6372 exec 0<&5 5<&-
6376 echo "Finished."
6377 echo
6378 echo "You may need to add #include directives for the following .h files."
6379 # Intersect $specified_modules and $main_modules
6380 # (since $specified_modules is not necessarily of subset of $main_modules
6381 # - some may have been skipped through --avoid, and since the elements of
6382 # $main_modules but not in $specified_modules can go away without explicit
6383 # notice - through changes in the module dependencies).
6384 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
6385 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
6386 # First the #include <...> directives without #ifs, sorted for convenience,
6387 # then the #include "..." directives without #ifs, sorted for convenience,
6388 # then the #include directives that are surrounded by #ifs. Not sorted.
6389 for module in `LC_ALL=C $JOIN "$tmp"/modules1 "$tmp"/modules2`; do
6390 include_directive=`func_get_include_directive "$module"`
6391 case "$nl$include_directive" in
6392 *"$nl#if"*)
6393 echo "$include_directive" 1>&5
6396 echo "$include_directive" | grep -v 'include "' 1>&6
6397 echo "$include_directive" | grep 'include "' 1>&7
6399 esac
6400 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
6402 LC_ALL=C sort -u "$tmp"/include-angles
6403 LC_ALL=C sort -u "$tmp"/include-quotes
6404 cat "$tmp"/include-if
6405 ) | sed -e '/^$/d' -e 's/^/ /'
6406 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
6408 for module in $main_modules; do
6409 func_get_link_directive "$module"
6410 done \
6411 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
6412 if test `wc -l < "$tmp"/link` != 0; then
6413 echo
6414 echo "You may need to use the following Makefile variables when linking."
6415 echo "Use them in <program>_LDADD when linking a program, or"
6416 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
6417 cat "$tmp"/link
6419 rm -f "$tmp"/link
6421 echo
6422 echo "Don't forget to"
6423 if test "$source_makefile_am" = Makefile.am; then
6424 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
6425 else
6426 echo " - \"include $source_makefile_am\" from within \"$sourcebase/Makefile.am\","
6428 if test -n "$pobase"; then
6429 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
6431 if $gentests; then
6432 if test "$tests_makefile_am" = Makefile.am; then
6433 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
6434 else
6435 echo " - \"include $tests_makefile_am\" from within \"$testsbase/Makefile.am\","
6438 edit=0
6439 while test $edit != $makefile_am_edits; do
6440 edit=`expr $edit + 1`
6441 eval dir=\"\$makefile_am_edit${edit}_dir\"
6442 eval var=\"\$makefile_am_edit${edit}_var\"
6443 eval val=\"\$makefile_am_edit${edit}_val\"
6444 if test -n "$var"; then
6445 if test "$var" = ACLOCAL_AMFLAGS; then
6446 echo " - mention \"-I ${val}\" in ${var} in ${dir}Makefile.am"
6447 echo " or add an AC_CONFIG_MACRO_DIRS([${val}]) invocation in $configure_ac,"
6448 else
6449 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
6452 done
6453 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
6454 echo " - replace AC_PROG_CC_STDC with AC_PROG_CC in $configure_ac,"
6455 position_early_after=AC_PROG_CC_STDC
6456 else
6457 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
6458 echo " - replace AC_PROG_CC_C99 with AC_PROG_CC in $configure_ac,"
6459 position_early_after=AC_PROG_CC_C99
6460 else
6461 position_early_after=AC_PROG_CC
6464 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
6465 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
6468 # func_create_testdir testdir modules
6469 # Input:
6470 # - local_gnulib_path from --local-dir
6471 # - modcache true or false, from --cache-modules/--no-cache-modules
6472 # - auxdir directory relative to destdir where to place build aux files
6473 # - inctests true if tests should be included, false otherwise
6474 # - incobsolete true if obsolete modules among dependencies should be
6475 # included, blank otherwise
6476 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
6477 # blank otherwise
6478 # - excl_longrunning_tests true if long-runnings tests should be excluded,
6479 # blank otherwise
6480 # - excl_privileged_tests true if tests that require root privileges should be
6481 # excluded, blank otherwise
6482 # - excl_unportable_tests true if tests that fail on some platforms should be
6483 # excluded, blank otherwise
6484 # - single_configure true if a single configure file should be generated,
6485 # false for a separate configure file for the tests
6486 # - avoidlist list of modules to avoid
6487 # - cond_dependencies true if --conditional-dependencies was given, false if
6488 # --no-conditional-dependencies was given, blank otherwise
6489 # - libtool true if --libtool was given, false if --no-libtool was
6490 # given, blank otherwise
6491 # - copymode copy mode for files in general
6492 # - lcopymode copy mode for files from local_gnulib_path
6493 func_create_testdir ()
6495 testdir="$1"
6496 modules="$2"
6497 if test -z "$modules"; then
6498 # All modules together.
6499 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6500 # Except non-recursive-gnulib-prefix-hack, which represents a nonstandard
6501 # way of using Automake.
6502 # Except timevar, which lacks the required file timevar.def.
6503 # Except mountlist, which aborts the configuration on mingw. FIXME.
6504 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
6505 modules=`func_all_modules`
6506 modules=`for m in $modules; do case $m in config-h | non-recursive-gnulib-prefix-hack | timevar | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
6507 else
6508 # Validate the list of specified modules.
6509 modules=`for module in $modules; do func_verify_module; if test -n "$module"; then echo "$module"; fi; done`
6511 specified_modules="$modules"
6513 # Canonicalize the list of specified modules.
6514 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
6516 # Test modules which invoke AC_CONFIG_FILES cannot be used with
6517 # --with-tests --single-configure. Avoid them.
6518 if $inctests && $single_configure; then
6519 avoidlist="$avoidlist havelib-tests"
6522 # Unlike in func_import, here we want to include all kinds of tests for the
6523 # directly specified modules, but not for dependencies.
6524 inc_all_direct_tests=true
6525 inc_all_indirect_tests="$inc_all_tests"
6527 # Check that the license of every module is consistent with the license of
6528 # its dependencies.
6529 saved_inctests="$inctests"
6530 # When computing transitive closures, don't consider $module to depend on
6531 # $module-tests. Need this because tests are implicitly GPL and may depend
6532 # on GPL modules - therefore we don't want a warning in this case.
6533 inctests=false
6534 for requested_module in $specified_modules; do
6535 requested_license=`func_get_license "$requested_module"`
6536 if test "$requested_license" != GPL; then
6537 # Here we use func_modules_transitive_closure, not just
6538 # func_get_dependencies, so that we also detect weird situations like
6539 # an LGPL module which depends on a GPLed build tool module which depends
6540 # on a GPL module.
6541 modules="$requested_module"
6542 func_modules_transitive_closure
6543 for module in $modules; do
6544 license=`func_get_license "$module"`
6545 case "$license" in
6546 'GPLv2+ build tool' | 'GPLed build tool') ;;
6547 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
6549 case "$requested_license" in
6550 GPLv3+ | GPL)
6551 case "$license" in
6552 LGPLv2+ | 'LGPLv3+ or GPLv2+' | LGPLv3+ | LGPL | GPLv2+ | GPLv3+ | GPL) ;;
6553 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6554 esac
6556 GPLv2+)
6557 case "$license" in
6558 LGPLv2+ | 'LGPLv3+ or GPLv2+' | GPLv2+) ;;
6559 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6560 esac
6562 LGPLv3+ | LGPL)
6563 case "$license" in
6564 LGPLv2+ | 'LGPLv3+ or GPLv2+' | LGPLv3+ | LGPL) ;;
6565 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6566 esac
6568 'LGPLv3+ or GPLv2+')
6569 case "$license" in
6570 LGPLv2+ | 'LGPLv3+ or GPLv2+') ;;
6571 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6572 esac
6574 LGPLv2+)
6575 case "$license" in
6576 LGPLv2+) ;;
6577 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6578 esac
6580 esac
6582 esac
6583 done
6585 done
6586 inctests="$saved_inctests"
6588 # Subdirectory names.
6589 sourcebase=gllib
6590 m4base=glm4
6591 pobase=
6592 docbase=gldoc
6593 testsbase=gltests
6594 macro_prefix=gl
6595 po_domain=
6596 witness_c_macro=
6597 vc_files=
6599 # Determine final module list.
6600 modules="$specified_modules"
6601 func_modules_transitive_closure
6602 if test $verbose -ge 0; then
6603 func_show_module_list
6605 final_modules="$modules"
6607 if $single_configure; then
6608 # Determine main module list and tests-related module list separately.
6609 func_modules_transitive_closure_separately
6612 if $single_configure; then
6613 # Determine whether a $testsbase/libtests.a is needed.
6614 func_determine_use_libtests
6617 # Add the dummy module if needed.
6618 if $single_configure; then
6619 func_modules_add_dummy_separately
6620 else
6621 func_modules_add_dummy
6624 # Note:
6625 # If $single_configure, we use the module lists $main_modules and
6626 # $testsrelated_modules; $modules is merely a temporary variable.
6627 # Whereas if ! $single_configure, the module list is $modules.
6629 # Show banner notice of every module.
6630 if $single_configure; then
6631 modules="$main_modules"
6632 func_modules_notice
6633 else
6634 func_modules_notice
6637 # Determine final file list.
6638 if $single_configure; then
6639 func_modules_to_filelist_separately
6640 else
6641 main_modules="$modules"
6642 testsrelated_modules=`for module in $modules; do
6643 if \`func_repeat_module_in_tests\`; then
6644 echo $module
6646 done`
6647 saved_modules="$modules"
6648 func_modules_to_filelist_separately
6649 modules="$saved_modules"
6651 # Add files for which the copy in gnulib is newer than the one that
6652 # "automake --add-missing --copy" would provide.
6653 files="$files build-aux/config.guess"
6654 files="$files build-aux/config.sub"
6655 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
6657 rewritten='%REWRITTEN%'
6658 sed_rewrite_files="\
6659 s,^build-aux/,$rewritten$auxdir/,
6660 s,^doc/,$rewritten$docbase/,
6661 s,^lib/,$rewritten$sourcebase/,
6662 s,^m4/,$rewritten$m4base/,
6663 s,^tests/,$rewritten$testsbase/,
6664 s,^tests=lib/,$rewritten$testsbase/,
6665 s,^top/,$rewritten,
6666 s,^$rewritten,,"
6668 # Create directories.
6669 for f in $files; do echo $f; done \
6670 | sed -e "$sed_rewrite_files" \
6671 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
6672 | LC_ALL=C sort -u \
6673 > "$tmp"/dirs
6674 { # Rearrange file descriptors. Needed because "while ... done < ..."
6675 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6676 exec 5<&0 < "$tmp"/dirs
6677 while read d; do
6678 mkdir -p "$testdir/$d"
6679 done
6680 exec 0<&5 5<&-
6683 # Copy files or make symbolic links or hard links.
6684 delimiter=' '
6685 for f in $files; do echo $f; done \
6686 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
6687 | LC_ALL=C sort \
6688 > "$tmp"/files
6689 { # Rearrange file descriptors. Needed because "while ... done < ..."
6690 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6691 exec 5<&0 < "$tmp"/files
6692 while read g f; do
6693 case "$f" in
6694 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
6695 esac
6696 func_lookup_file "$f"
6697 if test -n "$lookedup_tmp"; then
6698 cp -p "$lookedup_file" "$testdir/$g"
6699 func_ensure_writable "$testdir/$g"
6700 else
6701 func_should_link
6702 if test "$copyaction" = symlink; then
6703 func_symlink "$lookedup_file" "$testdir/$g"
6704 else
6705 if test "$copyaction" = hardlink; then
6706 func_hardlink "$lookedup_file" "$testdir/$g"
6707 else
6708 cp -p "$lookedup_file" "$testdir/$g"
6709 func_ensure_writable "$testdir/$g"
6713 done
6714 exec 0<&5 5<&-
6717 # Determine include_guard_prefix and module_indicator_prefix.
6718 func_compute_include_guard_prefix
6720 # Create Makefile.ams that are for testing.
6721 for_test=true
6723 # No special edits are needed.
6724 makefile_am_edits=0
6726 # Create $sourcebase/Makefile.am.
6727 mkdir -p "$testdir/$sourcebase"
6728 destfile="$sourcebase/Makefile.am"
6729 if $single_configure; then
6730 modules="$main_modules"
6732 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
6734 # Create $m4base/Makefile.am.
6735 mkdir -p "$testdir/$m4base"
6736 (echo "## Process this file with automake to produce Makefile.in."
6737 echo
6738 echo "EXTRA_DIST ="
6739 for f in $files; do
6740 case "$f" in
6741 m4/* )
6742 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
6743 esac
6744 done
6745 ) > "$testdir/$m4base/Makefile.am"
6747 subdirs="$sourcebase $m4base"
6748 subdirs_with_configure_ac=""
6750 if false && test -f "$testdir"/$m4base/gettext.m4; then
6751 # Avoid stupid error message from automake:
6752 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
6753 mkdir -p "$testdir/po"
6754 (echo "## Process this file with automake to produce Makefile.in."
6755 ) > "$testdir/po/Makefile.am"
6756 func_append subdirs " po"
6759 if $inctests; then
6760 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
6761 if $single_configure; then
6762 # Create $testsbase/Makefile.am.
6763 destfile="$testsbase/Makefile.am"
6764 modules="$testsrelated_modules"
6765 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
6766 else
6767 # Viewed from the $testsbase subdirectory, $auxdir is different.
6768 saved_auxdir="$auxdir"
6769 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
6770 # Create $testsbase/Makefile.am.
6771 use_libtests=false
6772 destfile="$testsbase/Makefile.am"
6773 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
6774 # Create $testsbase/configure.ac.
6775 (echo "# Process this file with autoconf to produce a configure script."
6776 echo "AC_INIT([dummy], [0])"
6777 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6778 echo "AM_INIT_AUTOMAKE"
6779 echo
6780 echo "AC_CONFIG_HEADERS([config.h])"
6781 echo
6782 echo "AC_PROG_CC"
6783 echo "AC_PROG_INSTALL"
6784 echo "AC_PROG_MAKE_SET"
6786 func_emit_pre_early_macros false '' "$modules"
6788 for module in $modules; do
6789 func_verify_module
6790 if test -n "$module"; then
6791 case $module in
6792 gnumakefile | maintainer-makefile)
6793 # These modules are meant to be used only in the top-level directory.
6796 func_get_autoconf_early_snippet "$module"
6798 esac
6800 done \
6801 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)])/\1/'
6802 if test "$libtool" = true; then
6803 echo "LT_INIT([win32-dll])"
6804 echo "LT_LANG([C++])"
6805 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6806 echo "gl_cond_libtool=true"
6807 else
6808 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6809 echo "gl_cond_libtool=false"
6810 echo "gl_libdeps="
6811 echo "gl_ltlibdeps="
6813 # Wrap the set of autoconf snippets into an autoconf macro that is then
6814 # invoked. This is needed because autoconf does not support AC_REQUIRE
6815 # at the top level:
6816 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6817 # but we want the AC_REQUIRE to have its normal meaning (provide one
6818 # expansion of the required macro before the current point, and only one
6819 # expansion total).
6820 echo "AC_DEFUN([gl_INIT], ["
6821 sed_replace_build_aux='
6823 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6824 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6827 echo "gl_m4_base='../$m4base'"
6828 func_emit_initmacro_start $macro_prefix true
6829 # We don't have explicit ordering constraints between the various
6830 # autoconf snippets. It's cleanest to put those of the library before
6831 # those of the tests.
6832 func_emit_shellvars_init true "../$sourcebase"
6833 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module false false false
6834 func_emit_shellvars_init true '.'
6835 func_emit_autoconf_snippets "$modules" "$modules" func_verify_tests_module false false false
6836 func_emit_initmacro_end $macro_prefix true
6837 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6838 # created using libtool, because libtool already handles the dependencies.
6839 if test "$libtool" != true; then
6840 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6841 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6842 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6843 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6844 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6846 echo "])"
6847 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
6848 echo
6849 echo "gl_INIT"
6850 echo
6851 # Usually $testsbase/config.h will be a superset of config.h. Verify this
6852 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
6853 echo "AH_TOP([#include \"../config.h\"])"
6854 echo
6855 echo "AC_CONFIG_FILES([Makefile])"
6856 echo "AC_OUTPUT"
6857 ) > "$testdir/$testsbase/configure.ac"
6858 auxdir="$saved_auxdir"
6859 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
6861 func_append subdirs " $testsbase"
6864 # Create Makefile.am.
6865 (echo "## Process this file with automake to produce Makefile.in."
6866 echo
6867 echo "AUTOMAKE_OPTIONS = 1.14 foreign"
6868 echo
6869 echo "SUBDIRS = $subdirs"
6870 echo
6871 echo "ACLOCAL_AMFLAGS = -I $m4base"
6872 ) > "$testdir/Makefile.am"
6874 # Create configure.ac.
6875 (echo "# Process this file with autoconf to produce a configure script."
6876 echo "AC_INIT([dummy], [0])"
6877 if test "$auxdir" != "."; then
6878 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6880 echo "AM_INIT_AUTOMAKE"
6881 echo
6882 echo "AC_CONFIG_HEADERS([config.h])"
6883 echo
6884 echo "AC_PROG_CC"
6885 echo "AC_PROG_INSTALL"
6886 echo "AC_PROG_MAKE_SET"
6887 echo
6888 echo "# For autobuild."
6889 echo "AC_CANONICAL_BUILD"
6890 echo "AC_CANONICAL_HOST"
6891 echo
6892 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
6893 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
6894 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6895 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6897 func_emit_pre_early_macros false '' "$final_modules"
6899 for module in $final_modules; do
6900 if $single_configure; then
6901 func_verify_module
6902 else
6903 func_verify_nontests_module
6905 if test -n "$module"; then
6906 func_get_autoconf_early_snippet "$module"
6908 done \
6909 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)])/\1/'
6910 if test "$libtool" = true; then
6911 echo "LT_INIT([win32-dll])"
6912 echo "LT_LANG([C++])"
6913 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6914 echo "gl_cond_libtool=true"
6915 else
6916 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6917 echo "gl_cond_libtool=false"
6918 echo "gl_libdeps="
6919 echo "gl_ltlibdeps="
6921 # Wrap the set of autoconf snippets into an autoconf macro that is then
6922 # invoked. This is needed because autoconf does not support AC_REQUIRE
6923 # at the top level:
6924 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6925 # but we want the AC_REQUIRE to have its normal meaning (provide one
6926 # expansion of the required macro before the current point, and only one
6927 # expansion total).
6928 echo "AC_DEFUN([gl_INIT], ["
6929 if test "$auxdir" != "build-aux"; then
6930 sed_replace_build_aux='
6932 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6933 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6936 else
6937 sed_replace_build_aux="$sed_noop"
6939 echo "gl_m4_base='$m4base'"
6940 func_emit_initmacro_start $macro_prefix false
6941 func_emit_shellvars_init false "$sourcebase"
6942 if $single_configure; then
6943 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false false
6944 else
6945 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module true false false
6947 func_emit_initmacro_end $macro_prefix false
6948 if $single_configure; then
6949 echo " gltests_libdeps="
6950 echo " gltests_ltlibdeps="
6951 func_emit_initmacro_start ${macro_prefix}tests true
6952 func_emit_shellvars_init true "$testsbase"
6953 # Define a tests witness macro.
6954 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
6955 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6956 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6957 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6958 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true false false
6959 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6960 func_emit_initmacro_end ${macro_prefix}tests true
6962 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6963 # created using libtool, because libtool already handles the dependencies.
6964 if test "$libtool" != true; then
6965 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6966 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6967 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6968 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6969 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6971 if $single_configure; then
6972 if $use_libtests; then
6973 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6974 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6977 echo "])"
6978 func_emit_initmacro_done $macro_prefix $sourcebase
6979 if $single_configure; then
6980 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6982 echo
6983 echo "gl_INIT"
6984 echo
6985 if test -n "$subdirs_with_configure_ac"; then
6986 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6988 makefiles="Makefile"
6989 for d in $subdirs; do
6990 # For subdirs that have a configure.ac by their own, it's the subdir's
6991 # configure.ac which creates the subdir's Makefile.am, not this one.
6992 case " $subdirs_with_configure_ac " in
6993 *" $d "*) ;;
6994 *) func_append makefiles " $d/Makefile" ;;
6995 esac
6996 done
6997 echo "AC_CONFIG_FILES([$makefiles])"
6998 echo "AC_OUTPUT"
6999 ) > "$testdir/configure.ac"
7001 # Create autogenerated files.
7002 (cd "$testdir"
7003 # Do not use "${AUTORECONF} --force --install", because it may invoke
7004 # autopoint, which brings in older versions of some of our .m4 files.
7005 if test -f $m4base/gettext.m4; then
7006 func_execute_command ${AUTOPOINT} --force || func_exit 1
7007 for f in $m4base/*.m4~; do
7008 if test -f $f; then
7009 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
7011 done
7013 if test "$libtool" = true; then
7014 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
7016 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
7017 if ! test -d build-aux; then
7018 func_execute_command mkdir build-aux || func_exit 1
7020 func_execute_command ${AUTOCONF} || func_exit 1
7021 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
7022 func_execute_command ${AUTOHEADER} &&
7023 func_execute_command touch config.h.in ||
7024 func_exit 1
7025 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
7026 rm -rf autom4te.cache
7027 ) || func_exit 1
7028 if $inctests && ! $single_configure; then
7029 # Create autogenerated files.
7030 (cd "$testdir/$testsbase" || func_exit 1
7031 # Do not use "${AUTORECONF} --force --install", because it may invoke
7032 # autopoint, which brings in older versions of some of our .m4 files.
7033 if test -f ../$m4base/gettext.m4; then
7034 func_execute_command ${AUTOPOINT} --force || func_exit 1
7035 for f in ../$m4base/*.m4~; do
7036 if test -f $f; then
7037 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
7039 done
7041 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
7042 if ! test -d ../build-aux; then
7043 func_execute_command mkdir ../build-aux
7045 func_execute_command ${AUTOCONF} || func_exit 1
7046 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
7047 func_execute_command ${AUTOHEADER} &&
7048 func_execute_command touch config.h.in ||
7049 func_exit 1
7050 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
7051 rm -rf autom4te.cache
7052 ) || func_exit 1
7054 # Need to run configure and make once, to create built files that are to be
7055 # distributed (such as parse-datetime.c).
7056 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
7057 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
7058 cleaned_files=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
7059 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
7060 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
7061 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
7062 # such $(FOO_H) because they don't refer to distributed files.
7063 built_sources=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
7064 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
7065 | sed -e "$sed_remove_make_variables"`
7066 distributed_built_sources=`for file in $built_sources; do
7067 case "$cleaned_files" in
7068 *" "$file" "*) ;;
7069 *) echo $file ;;
7070 esac;
7071 done`
7072 tests_distributed_built_sources=
7073 if $inctests; then
7074 # Likewise for built files in the $testsbase directory.
7075 tests_cleaned_files=`combine_lines < "$testdir/$testsbase/Makefile.am" \
7076 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
7077 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
7078 tests_built_sources=`combine_lines < "$testdir/$testsbase/Makefile.am" \
7079 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
7080 | sed -e "$sed_remove_make_variables"`
7081 tests_distributed_built_sources=`for file in $tests_built_sources; do
7082 case "$tests_cleaned_files" in
7083 *" "$file" "*) ;;
7084 *) echo $file ;;
7085 esac;
7086 done`
7088 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
7089 (cd "$testdir"
7090 ./configure || func_exit 1
7091 if test -n "$distributed_built_sources"; then
7092 cd "$sourcebase"
7093 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
7094 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
7095 built_sources \
7096 || func_exit 1
7097 cd ..
7099 if test -n "$tests_distributed_built_sources"; then
7100 cd "$testsbase"
7101 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
7102 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
7103 built_sources \
7104 || func_exit 1
7105 cd ..
7107 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
7108 distclean \
7109 || func_exit 1
7110 ) || func_exit 1
7112 (cd "$testdir"
7113 if test -f build-aux/test-driver; then
7114 echo "patching file build-aux/test-driver"
7115 patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver.diff >/dev/null 2>&1 \
7116 || { rm -f build-aux/test-driver.orig build-aux/test-driver.rej
7117 patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver-1.16.3.diff >/dev/null 2>&1 \
7118 || { rm -f build-aux/test-driver.orig build-aux/test-driver.rej
7119 func_fatal_error "could not patch test-driver script"
7123 ) || func_exit 1
7126 # func_create_megatestdir megatestdir allmodules
7127 # Input:
7128 # - local_gnulib_path from --local-dir
7129 # - modcache true or false, from --cache-modules/--no-cache-modules
7130 # - auxdir directory relative to destdir where to place build aux files
7131 func_create_megatestdir ()
7133 megatestdir="$1"
7134 allmodules="$2"
7135 if test -z "$allmodules"; then
7136 allmodules=`func_all_modules`
7139 megasubdirs=
7140 # First, all modules one by one.
7141 for onemodule in $allmodules; do
7142 func_create_testdir "$megatestdir/$onemodule" $onemodule
7143 func_append megasubdirs "$onemodule "
7144 done
7145 # Then, all modules all together.
7146 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
7147 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
7148 func_create_testdir "$megatestdir/ALL" "$allmodules"
7149 func_append megasubdirs "ALL"
7151 # Create autobuild.
7152 cvsdate=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
7153 test -f "$vc_witness" || vc_witness="$gnulib_dir/ChangeLog"
7154 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
7155 | sed -e 's,January,01,' -e 's,Jan,01,' \
7156 -e 's,February,02,' -e 's,Feb,02,' \
7157 -e 's,March,03,' -e 's,Mar,03,' \
7158 -e 's,April,04,' -e 's,Apr,04,' \
7159 -e 's,May,05,' \
7160 -e 's,June,06,' -e 's,Jun,06,' \
7161 -e 's,July,07,' -e 's,Jul,07,' \
7162 -e 's,August,08,' -e 's,Aug,08,' \
7163 -e 's,September,09,' -e 's,Sep,09,' \
7164 -e 's,October,10,' -e 's,Oct,10,' \
7165 -e 's,November,11,' -e 's,Nov,11,' \
7166 -e 's,December,12,' -e 's,Dec,12,' \
7167 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
7168 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
7169 (echo '#!/bin/sh'
7170 echo "CVSDATE=$cvsdate"
7171 echo ": \${MAKE=make}"
7172 echo "test -d logs || mkdir logs"
7173 echo "for module in $megasubdirs; do"
7174 echo " echo \"Working on module \$module...\""
7175 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
7176 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
7177 echo " echo"
7178 echo " set -x"
7179 echo " : autobuild project... \$module"
7180 echo " : autobuild revision... cvs-\$CVSDATE-000000"
7181 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
7182 echo " : autobuild hostname... \`hostname\`"
7183 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
7184 echo " echo rc=\$?"
7185 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
7186 echo "done"
7187 ) > "$megatestdir/do-autobuild"
7188 chmod a+x "$megatestdir/do-autobuild"
7190 # Create Makefile.am.
7191 (echo "## Process this file with automake to produce Makefile.in."
7192 echo
7193 echo "AUTOMAKE_OPTIONS = 1.14 foreign"
7194 echo
7195 echo "SUBDIRS = $megasubdirs"
7196 echo
7197 echo "EXTRA_DIST = do-autobuild"
7198 ) > "$megatestdir/Makefile.am"
7200 # Create configure.ac.
7201 (echo "# Process this file with autoconf to produce a configure script."
7202 echo "AC_INIT([dummy], [0])"
7203 if test "$auxdir" != "."; then
7204 echo "AC_CONFIG_AUX_DIR([$auxdir])"
7206 echo "AM_INIT_AUTOMAKE"
7207 echo
7208 echo "AC_PROG_MAKE_SET"
7209 echo
7210 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
7211 echo "AC_CONFIG_FILES([Makefile])"
7212 echo "AC_OUTPUT"
7213 ) > "$megatestdir/configure.ac"
7215 # Create autogenerated files.
7216 (cd "$megatestdir"
7217 # Do not use "${AUTORECONF} --install", because autoreconf operates
7218 # recursively, but the subdirectories are already finished, therefore
7219 # calling autoreconf here would only waste lots of CPU time.
7220 func_execute_command ${ACLOCAL} || func_exit 1
7221 func_execute_command mkdir build-aux
7222 func_execute_command ${AUTOCONF} || func_exit 1
7223 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
7224 rm -rf autom4te.cache
7225 if test -f build-aux/test-driver; then
7226 echo "patching file build-aux/test-driver"
7227 patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver.diff >/dev/null 2>&1 \
7228 || { rm -f build-aux/test-driver.orig build-aux/test-driver.rej
7229 patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver-1.16.3.diff >/dev/null 2>&1 \
7230 || { rm -f build-aux/test-driver.orig build-aux/test-driver.rej
7231 func_fatal_error "could not patch test-driver script"
7235 ) || func_exit 1
7238 case $mode in
7239 "" )
7240 func_fatal_error "no mode specified" ;;
7242 list )
7243 func_all_modules
7246 find )
7247 # sed expression that converts a literal to a basic regular expression.
7248 # Needs to handle . [ \ * ^ $.
7249 sed_literal_to_basic_regex='s/\\/\\\\/g
7250 s/\[/\\[/g
7251 s/\^/\\^/g
7252 s/\([.*$]\)/[\1]/g'
7253 # func_prefixed_modules_in_dir dir
7254 # outputs all module files in dir to standard output, with dir as prefix.
7255 func_prefixed_modules_in_dir ()
7257 (test -d "$1" && cd "$1" && find modules -type f -print | sed -e "s|^|$1/|")
7259 for filename
7261 if test -f "$gnulib_dir/$filename" \
7262 || func_lookup_local_file "$filename"; then
7263 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
7264 filename_line_regex='^'"$filename_anywhere_regex"'$'
7265 module_candidates=`
7267 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
7268 func_path_foreach "$local_gnulib_path" func_prefixed_modules_in_dir %dir% | xargs -n 100 grep -l "$filename_anywhere_regex" /dev/null | sed -e 's,^.*/modules/,,' -e 's,\.diff$,,'
7270 | func_sanitize_modulelist \
7271 | LC_ALL=C sort -u
7273 for module in $module_candidates; do
7274 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
7275 echo $module
7277 done
7278 else
7279 func_warning "file $filename does not exist"
7281 done
7284 import | add-import | remove-import | update )
7286 # Where to import.
7287 if test -z "$destdir"; then
7288 destdir=.
7290 test -d "$destdir" \
7291 || func_fatal_error "destination directory does not exist: $destdir"
7293 # Prefer configure.ac to configure.in.
7294 if test -f "$destdir"/configure.ac; then
7295 configure_ac="$destdir/configure.ac"
7296 else
7297 if test -f "$destdir"/configure.in; then
7298 configure_ac="$destdir/configure.in"
7299 else
7300 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
7304 # Analyze configure.ac.
7305 guessed_auxdir="."
7306 guessed_libtool=false
7307 guessed_m4dirs=
7308 my_sed_traces='
7309 s,#.*$,,
7310 s,^dnl .*$,,
7311 s, dnl .*$,,
7312 /AC_CONFIG_AUX_DIR/ {
7313 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
7315 /A[CM]_PROG_LIBTOOL/ {
7316 s,^.*$,guessed_libtool=true,p
7318 /AC_CONFIG_MACRO_DIR/ {
7319 s,^.*AC_CONFIG_MACRO_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_m4dirs="${guessed_m4dirs} \1",p
7321 /AC_CONFIG_MACRO_DIRS/ {
7322 s,^.*AC_CONFIG_MACRO_DIRS([[ ]*\([^]"$`\\)]*\).*$,guessed_m4dirs="${guessed_m4dirs} \1",p
7324 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
7326 if test -z "$auxdir"; then
7327 auxdir="$guessed_auxdir"
7330 # Determine where to apply func_import.
7331 if test "$mode" = import; then
7332 # Apply func_import to a particular gnulib directory.
7333 # The command line contains the complete specification; don't look at
7334 # the contents of gnulib-cache.m4.
7335 test -n "$supplied_libname" || supplied_libname=true
7336 test -n "$sourcebase" || sourcebase="lib"
7337 test -n "$m4base" || m4base="m4"
7338 test -n "$docbase" || docbase="doc"
7339 test -n "$testsbase" || testsbase="tests"
7340 test -n "$macro_prefix" || macro_prefix="gl"
7341 func_import "$*"
7342 else
7343 if test -n "$m4base"; then
7344 # Apply func_import to a particular gnulib directory.
7345 # Any number of additional modules can be given.
7346 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
7347 # First use of gnulib in the given m4base.
7348 test -n "$supplied_libname" || supplied_libname=true
7349 test -n "$sourcebase" || sourcebase="lib"
7350 test -n "$docbase" || docbase="doc"
7351 test -n "$testsbase" || testsbase="tests"
7352 test -n "$macro_prefix" || macro_prefix="gl"
7354 func_import "$*"
7355 else
7356 # Apply func_import to all gnulib directories.
7357 # To get this list of directories, look at Makefile.am. (Not at
7358 # configure, because it may be omitted from version control. Also,
7359 # don't run "find $destdir -name gnulib-cache.m4", as it might be
7360 # too expensive.)
7361 m4dirs=
7362 m4dirs_count=0
7363 if test -f "$destdir"/Makefile.am; then
7364 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
7365 m4dir_is_next=
7366 for arg in $aclocal_amflags; do
7367 if test -n "$m4dir_is_next"; then
7368 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
7369 case "$arg" in
7370 /*) ;;
7372 if test -f "$destdir/$arg"/gnulib-cache.m4; then
7373 func_append m4dirs " $arg"
7374 m4dirs_count=`expr $m4dirs_count + 1`
7377 esac
7378 m4dir_is_next=
7379 else
7380 if test "X$arg" = "X-I"; then
7381 m4dir_is_next=yes
7382 else
7383 m4dir_is_next=
7386 done
7387 for arg in $guessed_m4dirs; do
7388 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
7389 case "$arg" in
7390 /*) ;;
7392 if test -f "$destdir/$arg"/gnulib-cache.m4; then
7393 func_append m4dirs " $arg"
7394 m4dirs_count=`expr $m4dirs_count + 1`
7397 esac
7398 done
7399 else
7400 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
7401 if test -f "$destdir"/aclocal.m4; then
7402 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
7403 sedexpr2='s,^[^/]*$,.,'
7404 sedexpr3='s,/[^/]*$,,'
7405 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
7406 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
7407 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
7410 if test $m4dirs_count = 0; then
7411 # First use of gnulib in a package.
7412 # Any number of additional modules can be given.
7413 test -n "$supplied_libname" || supplied_libname=true
7414 test -n "$sourcebase" || sourcebase="lib"
7415 m4base="m4"
7416 test -n "$docbase" || docbase="doc"
7417 test -n "$testsbase" || testsbase="tests"
7418 test -n "$macro_prefix" || macro_prefix="gl"
7419 func_import "$*"
7420 else
7421 if test $m4dirs_count = 1; then
7422 # There's only one use of gnulib here. Assume the user means it.
7423 # Any number of additional modules can be given.
7424 for m4base in $m4dirs; do
7425 func_import "$*"
7426 done
7427 else
7428 # Ambiguous - guess what the user meant.
7429 if test $# = 0; then
7430 # No further arguments. Guess the user wants to update all of them.
7431 for m4base in $m4dirs; do
7432 # Perform func_import in a subshell, so that variable values
7433 # such as
7434 # local_gnulib_path, incobsolete, inc_cxx_tests,
7435 # inc_longrunning_tests, inc_privileged_tests,
7436 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
7437 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
7438 # makefile_name, tests_makefile_name, automake_subdir, libtool,
7439 # macro_prefix, po_domain, witness_c_macro, vc_files
7440 # don't propagate from one directory to another.
7441 (func_import) || func_exit 1
7442 done
7443 else
7444 # Really ambiguous.
7445 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
7453 create-testdir )
7454 if test -z "$destdir"; then
7455 func_fatal_error "please specify --dir option"
7457 mkdir "$destdir"
7458 test -d "$destdir" \
7459 || func_fatal_error "could not create destination directory"
7460 test -n "$auxdir" || auxdir="build-aux"
7461 func_create_testdir "$destdir" "$*"
7464 create-megatestdir )
7465 if test -z "$destdir"; then
7466 func_fatal_error "please specify --dir option"
7468 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7469 test -n "$auxdir" || auxdir="build-aux"
7470 func_create_megatestdir "$destdir" "$*"
7473 test )
7474 test -n "$destdir" || destdir=testdir$$
7475 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7476 test -n "$auxdir" || auxdir="build-aux"
7477 func_create_testdir "$destdir" "$*"
7478 cd "$destdir"
7479 mkdir build
7480 cd build
7481 ../configure || func_exit 1
7482 $MAKE || func_exit 1
7483 $MAKE check || func_exit 1
7484 $MAKE distclean || func_exit 1
7485 remaining=`find . -type f -print`
7486 if test -n "$remaining"; then
7487 echo "Remaining files:" $remaining 1>&2
7488 echo "gnulib-tool: *** Stop." 1>&2
7489 func_exit 1
7491 cd ..
7492 cd ..
7493 rm -rf "$destdir"
7496 megatest )
7497 test -n "$destdir" || destdir=testdir$$
7498 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7499 test -n "$auxdir" || auxdir="build-aux"
7500 func_create_megatestdir "$destdir" "$*"
7501 cd "$destdir"
7502 mkdir build
7503 cd build
7504 ../configure || func_exit 1
7505 $MAKE || func_exit 1
7506 $MAKE check || func_exit 1
7507 $MAKE distclean || func_exit 1
7508 remaining=`find . -type f -print`
7509 if test -n "$remaining"; then
7510 echo "Remaining files:" $remaining 1>&2
7511 echo "gnulib-tool: *** Stop." 1>&2
7512 func_exit 1
7514 cd ..
7515 cd ..
7516 rm -rf "$destdir"
7519 extract-description )
7520 for module
7522 func_verify_module
7523 if test -n "$module"; then
7524 func_get_description "$module"
7526 done
7529 extract-comment )
7530 for module
7532 func_verify_module
7533 if test -n "$module"; then
7534 func_get_comment "$module"
7536 done
7539 extract-status )
7540 for module
7542 func_verify_module
7543 if test -n "$module"; then
7544 func_get_status "$module"
7546 done
7549 extract-notice )
7550 for module
7552 func_verify_module
7553 if test -n "$module"; then
7554 func_get_notice "$module"
7556 done
7559 extract-applicability )
7560 for module
7562 func_verify_module
7563 if test -n "$module"; then
7564 func_get_applicability "$module"
7566 done
7569 extract-filelist )
7570 for module
7572 func_verify_module
7573 if test -n "$module"; then
7574 func_get_filelist "$module"
7576 done
7579 extract-dependencies )
7580 if test -n "$avoidlist"; then
7581 func_fatal_error "cannot combine --avoid and --extract-dependencies"
7583 for module
7585 func_verify_module
7586 if test -n "$module"; then
7587 func_get_dependencies "$module"
7589 done
7592 extract-recursive-dependencies )
7593 if test -n "$avoidlist"; then
7594 func_fatal_error "cannot combine --avoid and --extract-recursive-dependencies"
7596 for module
7598 func_verify_module
7599 if test -n "$module"; then
7600 func_get_dependencies_recursively "$module"
7602 done
7605 extract-autoconf-snippet )
7606 for module
7608 func_verify_module
7609 if test -n "$module"; then
7610 func_get_autoconf_snippet "$module"
7612 done
7615 extract-automake-snippet )
7616 test -n "$auxdir" || auxdir="build-aux"
7617 for module
7619 func_verify_module
7620 if test -n "$module"; then
7621 func_get_automake_snippet "$module"
7623 done
7626 extract-include-directive )
7627 for module
7629 func_verify_module
7630 if test -n "$module"; then
7631 func_get_include_directive "$module"
7633 done
7636 extract-link-directive )
7637 for module
7639 func_verify_module
7640 if test -n "$module"; then
7641 func_get_link_directive "$module"
7643 done
7646 extract-recursive-link-directive )
7647 if test -n "$avoidlist"; then
7648 func_fatal_error "cannot combine --avoid and --extract-recursive-link-directive"
7650 for module
7652 func_verify_module
7653 if test -n "$module"; then
7654 func_get_link_directive_recursively "$module"
7656 done
7659 extract-license )
7660 for module
7662 func_verify_module
7663 if test -n "$module"; then
7664 func_get_license "$module"
7666 done
7669 extract-maintainer )
7670 for module
7672 func_verify_module
7673 if test -n "$module"; then
7674 func_get_maintainer "$module"
7676 done
7679 extract-tests-module )
7680 for module
7682 func_verify_module
7683 if test -n "$module"; then
7684 func_get_tests_module "$module"
7686 done
7689 copy-file )
7690 # Verify the number of arguments.
7691 if test $# -lt 1 || test $# -gt 2; then
7692 func_fatal_error "invalid number of arguments for --$mode"
7695 # The first argument is the file to be copied.
7696 f="$1"
7697 # Verify the file exists.
7698 func_lookup_file "$f"
7700 # The second argument is the destination; either a directory or a file.
7701 # It defaults to the current directory.
7702 dest="$2"
7703 test -n "$dest" || dest='.'
7704 test -n "$sourcebase" || sourcebase="lib"
7705 test -n "$m4base" || m4base="m4"
7706 test -n "$docbase" || docbase="doc"
7707 test -n "$testsbase" || testsbase="tests"
7708 test -n "$auxdir" || auxdir="build-aux"
7709 rewritten='%REWRITTEN%'
7710 sed_rewrite_files="\
7711 s,^build-aux/,$rewritten$auxdir/,
7712 s,^doc/,$rewritten$docbase/,
7713 s,^lib/,$rewritten$sourcebase/,
7714 s,^m4/,$rewritten$m4base/,
7715 s,^tests/,$rewritten$testsbase/,
7716 s,^top/,$rewritten,
7717 s,^$rewritten,,"
7718 if test -d "$dest"; then
7719 destdir="$dest"
7720 g=`echo "$f" | sed -e "$sed_rewrite_files"`
7721 else
7722 destdir=`dirname "$dest"`
7723 g=`basename "$dest"`
7726 # Create the directory for destfile.
7727 d=`dirname "$destdir/$g"`
7728 if $doit; then
7729 if test -n "$d" && test ! -d "$d"; then
7730 mkdir -p "$d" || func_fatal_error "failed"
7733 # Copy the file.
7734 func_dest_tmpfilename "$g"
7735 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
7736 func_ensure_writable "$tmpfile"
7737 already_present=true
7738 if test -f "$destdir/$g"; then
7739 # The file already exists.
7740 func_update_file
7741 else
7742 # Install the file.
7743 # Don't protest if the file should be there but isn't: it happens
7744 # frequently that developers don't put autogenerated files under version
7745 # control.
7746 func_add_file
7748 rm -f "$tmpfile"
7752 func_fatal_error "unknown operation mode --$mode" ;;
7753 esac
7755 if test "$copymode" = hardlink -o "$lcopymode" = hardlink; then
7756 # Setting hard links modifies the ctime of files in the gnulib checkout.
7757 # This disturbs the result of the next "gitk" invocation.
7758 # Workaround: Let git scan the files. This can be done through
7759 # "git update-index --refresh" or "git status" or "git diff".
7760 if test -d "$gnulib_dir"/.git \
7761 && (git --version) >/dev/null 2>/dev/null; then
7762 (cd "$gnulib_dir" && git update-index --refresh >/dev/null)
7766 rm -rf "$tmp"
7767 # Undo the effect of the previous 'trap' command. Some shellology:
7768 # We cannot use "trap - EXIT HUP INT QUIT PIPE TERM", because Solaris sh would
7769 # attempt to execute the command "-". "trap '' ..." is fine only for signal EXIT
7770 # (= normal exit); for the others we need to call 'exit' explicitly. The value
7771 # of $? is 128 + signal number and is set before the trap-registered command is
7772 # run.
7773 trap '' EXIT
7774 trap 'func_exit $?' HUP INT QUIT PIPE TERM
7776 exit 0
7778 # Local Variables:
7779 # indent-tabs-mode: nil
7780 # whitespace-check-buffer-indent: nil
7781 # End: