Ensure Automake does not drop ~~gnulib.m4.
[gnulib.git] / gnulib-tool
blobba51606b8e6be71d5277468b95fe49fb54b9ee1b
1 #! /bin/sh
3 # Copyright (C) 2002-2020 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.63 is already in your PATH.
52 AUTOCONFPATH=
53 #case $USER in
54 # bruno )
55 # AUTOCONFBINDIR=/arch/x86-linux/gnu-inst-autoconf/2.63/bin
56 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
57 # ;;
58 #esac
60 # You can set AUTOMAKEPATH to empty if automake 1.11 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 --cache-modules Enable module caching optimization.
232 --no-cache-modules Disable module caching optimization.
233 --verbose Increase verbosity. May be repeated.
234 --quiet Decrease verbosity. May be repeated.
236 Options for --import, --add/remove-import, --update:
238 --dry-run Only print what would have been done.
240 Options for --import, --add/remove-import:
242 --with-tests Include unit tests for the included modules.
244 Options for --create-[mega]testdir, --[mega]test:
246 --without-tests Don't include unit tests for the included modules.
248 Options for --import, --add/remove-import,
249 --create-[mega]testdir, --[mega]test:
251 --with-obsolete Include obsolete modules when they occur among the
252 dependencies. By default, dependencies to obsolete
253 modules are ignored.
254 --with-c++-tests Include even unit tests for C++ interoperability.
255 --without-c++-tests Exclude unit tests for C++ interoperability.
256 --with-longrunning-tests
257 Include even unit tests that are long-runners.
258 --without-longrunning-tests
259 Exclude unit tests that are long-runners.
260 --with-privileged-tests
261 Include even unit tests that require root
262 privileges.
263 --without-privileged-tests
264 Exclude unit tests that require root privileges.
265 --with-unportable-tests
266 Include even unit tests that fail on some platforms.
267 --without-unportable-tests
268 Exclude unit tests that fail on some platforms.
269 --with-all-tests Include all kinds of problematic unit tests.
270 --avoid=MODULE Avoid including the given MODULE. Useful if you
271 have code that provides equivalent functionality.
272 This option can be repeated.
273 --conditional-dependencies
274 Support conditional dependencies (may save configure
275 time and object code).
276 --no-conditional-dependencies
277 Don't use conditional dependencies.
278 --libtool Use libtool rules.
279 --no-libtool Don't use libtool rules.
281 Options for --import, --add/remove-import:
283 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
284 --source-base=DIRECTORY
285 Directory relative to --dir where source code is
286 placed (default \"lib\").
287 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
288 placed (default \"m4\").
289 --po-base=DIRECTORY Directory relative to --dir where *.po files are
290 placed (default \"po\").
291 --doc-base=DIRECTORY Directory relative to --dir where doc files are
292 placed (default \"doc\").
293 --tests-base=DIRECTORY
294 Directory relative to --dir where unit tests are
295 placed (default \"tests\").
296 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
297 tools are placed (default comes from configure.ac).
298 --gnu-make Output for GNU Make instead of for the default
299 Automake
300 --lgpl[=2|=3orGPLv2|=3]
301 Abort if modules aren't available under the LGPL.
302 Also modify license template from GPL to LGPL.
303 The version number of the LGPL can be specified;
304 the default is currently LGPLv3.
305 --makefile-name=NAME Name of makefile in the source-base and tests-base
306 directories (default \"Makefile.am\", or
307 \"Makefile.in\" if --gnu-make).
308 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
309 'gl_INIT'. Default is 'gl'.
310 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
311 the package name. A suffix '-gnulib' is appended.
312 --witness-c-macro=NAME Specify the C macro that is defined when the
313 sources in this directory are compiled or used.
314 --vc-files Update version control related files.
315 --no-vc-files Don't update version control related files
316 (.gitignore and/or .cvsignore).
318 Options for --create-[mega]testdir, --[mega]test:
320 --single-configure Generate a single configure file, not a separate
321 configure file for the tests directory.
323 Options for --import, --add/remove-import, --update,
324 --create-[mega]testdir, --[mega]test:
326 -s, --symbolic, --symlink Make symbolic links instead of copying files.
327 --local-symlink Make symbolic links instead of copying files, only
328 for files from the local override directory.
329 -h, --hardlink Make hard links instead of copying files.
330 --local-hardlink Make hard links instead of copying files, only
331 for files from the local override directory.
333 Options for --import, --add/remove-import, --update:
335 -S, --more-symlinks Make symbolic links instead of copying files, and
336 don't replace copyright notices.
337 -H, --more-hardlinks Make hard links instead of copying files, and
338 don't replace copyright notices.
340 Report bugs to <bug-gnulib@gnu.org>."
343 # func_version
344 # outputs to stdout the --version message.
345 func_version ()
347 func_gnulib_dir
348 if test -d "$gnulib_dir"/.git \
349 && (git --version) >/dev/null 2>/dev/null \
350 && (date --version) >/dev/null 2>/dev/null; then
351 # gnulib checked out from git.
352 sed_extract_first_date='/^Date/{
353 s/^Date:[ ]*//p
356 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
357 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
358 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
359 date=`echo "$date" | sed -e "$sed_year_before_time"`
360 # Use GNU date to compute the time in GMT.
361 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
362 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
363 else
364 # gnulib copy without versioning information.
365 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
366 version=
368 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
369 echo "\
370 gnulib-tool (GNU $package $date)$version
371 Copyright (C) $year Free Software Foundation, Inc.
372 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
373 This is free software: you are free to change and redistribute it.
374 There is NO WARRANTY, to the extent permitted by law.
376 printf "Written by %s, %s, and %s.\n" "Bruno Haible" "Paul Eggert" "Simon Josefsson"
379 # func_emit_copyright_notice
380 # outputs to stdout a header for a generated file.
381 func_emit_copyright_notice ()
383 sed -n -e '/Copyright/ {
386 }' < "$self_abspathname"
387 echo "#"
388 echo "# This file is free software; you can redistribute it and/or modify"
389 echo "# it under the terms of the GNU General Public License as published by"
390 echo "# the Free Software Foundation; either version 3 of the License, or"
391 echo "# (at your option) any later version."
392 echo "#"
393 echo "# This file is distributed in the hope that it will be useful,"
394 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
395 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
396 echo "# GNU General Public License for more details."
397 echo "#"
398 echo "# You should have received a copy of the GNU General Public License"
399 echo "# along with this file. If not, see <https://www.gnu.org/licenses/>."
400 echo "#"
401 echo "# As a special exception to the GNU General Public License,"
402 echo "# this file may be distributed as part of a program that"
403 echo "# contains a configuration script generated by Autoconf, under"
404 echo "# the same distribution terms as the rest of that program."
405 echo "#"
406 echo "# Generated by gnulib-tool."
409 # func_exit STATUS
410 # exits with a given status.
411 # This function needs to be used, rather than 'exit', when a 'trap' handler is
412 # in effect that refers to $?.
413 func_exit ()
415 (exit $1); exit $1
418 # func_gnulib_dir
419 # locates the directory where the gnulib repository lives
420 # Input:
421 # - progname name of this program
422 # Sets variables
423 # - self_abspathname absolute pathname of gnulib-tool
424 # - gnulib_dir absolute pathname of gnulib repository
425 func_gnulib_dir ()
427 case "$progname" in
428 /* | ?:*) self_abspathname="$progname" ;;
429 */*) self_abspathname=`pwd`/"$progname" ;;
431 # Look in $PATH.
432 # Iterate through the elements of $PATH.
433 # We use IFS=: instead of
434 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
435 # because the latter does not work when some PATH element contains spaces.
436 # We use a canonicalized $pathx instead of $PATH, because empty PATH
437 # elements are by definition equivalent to '.', however field splitting
438 # according to IFS=: loses empty fields in many shells:
439 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
440 # beginning, at the end, and in the middle),
441 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
442 # at the beginning and at the end,
443 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
444 # Solaris lose empty fields at the end.
445 # The 'case' statement is an optimization, to avoid evaluating the
446 # explicit canonicalization command when $PATH contains no empty fields.
447 self_abspathname=
448 if test "$PATH_SEPARATOR" = ";"; then
449 # On Windows, programs are searched in "." before $PATH.
450 pathx=".;$PATH"
451 else
452 # On Unix, we have to convert empty PATH elements to ".".
453 pathx="$PATH"
454 case :$PATH: in
455 *::*)
456 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
458 esac
460 save_IFS="$IFS"
461 IFS="$PATH_SEPARATOR"
462 for d in $pathx; do
463 IFS="$save_IFS"
464 test -z "$d" && d=.
465 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
466 self_abspathname="$d/$progname"
467 break
469 done
470 IFS="$save_IFS"
471 if test -z "$self_abspathname"; then
472 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
475 esac
476 while test -h "$self_abspathname"; do
477 # Resolve symbolic link.
478 linkval=`func_readlink "$self_abspathname"`
479 test -n "$linkval" || break
480 case "$linkval" in
481 /* | ?:* ) self_abspathname="$linkval" ;;
482 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
483 esac
484 done
485 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
488 # func_tmpdir
489 # creates a temporary directory.
490 # Input:
491 # - progname name of this program
492 # Sets variable
493 # - tmp pathname of freshly created temporary directory
494 func_tmpdir ()
496 # Use the environment variable TMPDIR, falling back to /tmp. This allows
497 # users to specify a different temporary directory, for example, if their
498 # /tmp is filled up or too small.
499 : ${TMPDIR=/tmp}
501 # Use the mktemp program if available. If not available, hide the error
502 # message.
503 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
504 test -n "$tmp" && test -d "$tmp"
505 } ||
507 # Use a simple mkdir command. It is guaranteed to fail if the directory
508 # already exists. $RANDOM is bash specific and expands to empty in shells
509 # other than bash, ksh and zsh. Its use does not increase security;
510 # rather, it minimizes the probability of failure in a very cluttered /tmp
511 # directory.
512 tmp=$TMPDIR/gl$$-$RANDOM
513 (umask 077 && mkdir "$tmp")
514 } ||
516 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
517 func_exit 1
521 # func_append var value
522 # appends the given value to the shell variable var.
523 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
524 # Use bash's += operator. It reduces complexity of appending repeatedly to
525 # a single variable from O(n^2) to O(n).
526 func_append ()
528 eval "$1+=\"\$2\""
530 fast_func_append=true
531 else
532 func_append ()
534 eval "$1=\"\$$1\$2\""
536 fast_func_append=false
539 # func_remove_prefix var prefix
540 # removes the given prefix from the value of the shell variable var.
541 # var should be the name of a shell variable.
542 # Its value should not contain a newline and not start or end with whitespace.
543 # prefix should not contain the characters "$`\{}[]^|.
544 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
545 func_remove_prefix ()
547 eval "$1=\${$1#\$2}"
549 fast_func_remove_prefix=true
550 else
551 func_remove_prefix ()
553 eval "value=\"\$$1\""
554 prefix="$2"
555 case "$prefix" in
556 *.*)
557 sed_escape_dots='s/\([.]\)/\\\1/g'
558 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
560 esac
561 value=`echo "$value" | sed -e "s|^${prefix}||"`
562 eval "$1=\"\$value\""
564 fast_func_remove_prefix=false
567 # Determine whether we should use ':' or ';' as PATH_SEPARATOR.
568 func_determine_path_separator ()
570 if test "${PATH_SEPARATOR+set}" != set; then
571 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
572 # contains only /bin. Note that ksh looks also at the FPATH variable,
573 # so we have to set that as well for the test.
574 PATH_SEPARATOR=:
575 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
576 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
577 || PATH_SEPARATOR=';'
582 # func_path_append pathvar directory
583 # appends directory to pathvar, delimiting directories by PATH_SEPARATOR.
584 func_path_append ()
586 if eval "test -n \"\$$1\""; then
587 func_append "$1" "$PATH_SEPARATOR$2"
588 else
589 eval "$1=\$2"
593 # func_path_foreach_inner
594 # helper for func_path_foreach because we need new 'args' array
595 # Input:
596 # - fpf_dir directory from local_gnulib_path
597 # - fpf_cb callback to be run for fpf_dir
598 func_path_foreach_inner ()
600 set %start% "$@"
601 for _fpf_arg
603 case "$_fpf_arg" in
604 %start%)
605 set dummy
607 %dir%)
608 set "$@" "$fpf_dir"
611 set "$@" "$_fpf_arg"
613 esac
614 done
615 shift
617 "$fpf_cb" "$@"
620 # func_path_foreach path method args
621 # Execute method for each directory in path. The method will be called
622 # like `method args` while any argument '%dir%' within args will be replaced
623 # with processed directory from path.
624 func_path_foreach ()
626 fpf_dirs="$1"; shift
627 fpf_cb="$1"; shift
628 fpf_rc=false
630 fpf_save_IFS="$IFS"
631 IFS="$PATH_SEPARATOR"
632 for fpf_dir in $fpf_dirs
634 IFS="$fpf_save_IFS"
635 func_path_foreach_inner "$@" && fpf_rc=:
636 done
637 IFS="$fpf_save_IFS"
638 $fpf_rc
641 # func_remove_suffix var suffix
642 # removes the given suffix from the value of the shell variable var.
643 # var should be the name of a shell variable.
644 # Its value should not contain a newline and not start or end with whitespace.
645 # suffix should not contain the characters "$`\{}[]^|.
646 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
647 func_remove_suffix ()
649 eval "$1=\${$1%\$2}"
651 fast_func_remove_suffix=true
652 else
653 func_remove_suffix ()
655 eval "value=\"\$$1\""
656 suffix="$2"
657 case "$suffix" in
658 *.*)
659 sed_escape_dots='s/\([.]\)/\\\1/g'
660 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
662 esac
663 value=`echo "$value" | sed -e "s|${suffix}\$||"`
664 eval "$1=\"\$value\""
666 fast_func_remove_suffix=false
669 # func_fatal_error message
670 # outputs to stderr a fatal error message, and terminates the program.
671 # Input:
672 # - progname name of this program
673 func_fatal_error ()
675 echo "$progname: *** $1" 1>&2
676 echo "$progname: *** Stop." 1>&2
677 func_exit 1
680 # func_warning message
681 # Outputs to stderr a warning message,
682 func_warning ()
684 echo "gnulib-tool: warning: $1" 1>&2
687 # func_readlink SYMLINK
688 # outputs the target of the given symlink.
689 if (type readlink) > /dev/null 2>&1; then
690 func_readlink ()
692 # Use the readlink program from GNU coreutils.
693 readlink "$1"
695 else
696 func_readlink ()
698 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
699 # would do the wrong thing if the link target contains " -> ".
700 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
704 # func_relativize DIR1 DIR2
705 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
706 # Input:
707 # - DIR1 relative pathname, relative to the current directory
708 # - DIR2 relative pathname, relative to the current directory
709 # Output:
710 # - reldir relative pathname of DIR2, relative to DIR1
711 func_relativize ()
713 dir0=`pwd`
714 dir1="$1"
715 dir2="$2"
716 sed_first='s,^\([^/]*\)/.*$,\1,'
717 sed_rest='s,^[^/]*/*,,'
718 sed_last='s,^.*/\([^/]*\)$,\1,'
719 sed_butlast='s,/*[^/]*$,,'
720 while test -n "$dir1"; do
721 first=`echo "$dir1" | sed -e "$sed_first"`
722 if test "$first" != "."; then
723 if test "$first" = ".."; then
724 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
725 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
726 else
727 first2=`echo "$dir2" | sed -e "$sed_first"`
728 if test "$first2" = "$first"; then
729 dir2=`echo "$dir2" | sed -e "$sed_rest"`
730 else
731 dir2="../$dir2"
733 dir0="$dir0"/"$first"
736 dir1=`echo "$dir1" | sed -e "$sed_rest"`
737 done
738 reldir="$dir2"
741 # func_relconcat DIR1 DIR2
742 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
743 # Input:
744 # - DIR1 relative pathname, relative to the current directory
745 # - DIR2 relative pathname, relative to DIR1
746 # Output:
747 # - relconcat DIR1/DIR2, relative to the current directory
748 func_relconcat ()
750 dir1="$1"
751 dir2="$2"
752 sed_first='s,^\([^/]*\)/.*$,\1,'
753 sed_rest='s,^[^/]*/*,,'
754 sed_last='s,^.*/\([^/]*\)$,\1,'
755 sed_butlast='s,/*[^/]*$,,'
756 while true; do
757 first=`echo "$dir2" | sed -e "$sed_first"`
758 if test "$first" = "."; then
759 dir2=`echo "$dir2" | sed -e "$sed_rest"`
760 if test -z "$dir2"; then
761 relconcat="$dir1"
762 break
764 else
765 last=`echo "$dir1" | sed -e "$sed_last"`
766 while test "$last" = "."; do
767 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
768 last=`echo "$dir1" | sed -e "$sed_last"`
769 done
770 if test -z "$dir1"; then
771 relconcat="$dir2"
772 break
774 if test "$first" = ".."; then
775 if test "$last" = ".."; then
776 relconcat="$dir1/$dir2"
777 break
779 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
780 dir2=`echo "$dir2" | sed -e "$sed_rest"`
781 if test -z "$dir1"; then
782 relconcat="$dir2"
783 break
785 if test -z "$dir2"; then
786 relconcat="$dir1"
787 break
789 else
790 relconcat="$dir1/$dir2"
791 break
794 done
797 # func_ln_s SRC DEST
798 # Like ln -s, except use cp -p if ln -s fails.
799 func_ln_s ()
801 ln -s "$1" "$2" || {
802 echo "$progname: ln -s failed; falling back on cp -p" >&2
804 case "$1" in
805 /* | ?:*) # SRC is absolute.
806 cp_src="$1" ;;
807 *) # SRC is relative to the directory of DEST.
808 case "$2" in
809 */*) cp_src="${2%/*}/$1" ;;
810 *) cp_src="$1" ;;
811 esac
813 esac
815 cp -p "$cp_src" "$2"
819 # func_symlink_target SRC DEST
820 # Determines LINK_TARGET such that "ln -s LINK_TARGET DEST" will create a
821 # symbolic link DEST that points to SRC.
822 # Output:
823 # - link_target link target, relative to the directory of DEST
824 func_symlink_target ()
826 case "$1" in
827 /* | ?:*)
828 link_target="$1" ;;
829 *) # SRC is relative.
830 case "$2" in
831 /* | ?:*)
832 link_target="`pwd`/$1" ;;
833 *) # DEST is relative too.
834 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
835 test -n "$ln_destdir" || ln_destdir="."
836 func_relativize "$ln_destdir" "$1"
837 link_target="$reldir"
839 esac
841 esac
844 # func_symlink SRC DEST
845 # Like func_ln_s, except that SRC is given relative to the current directory (or
846 # absolute), not given relative to the directory of DEST.
847 func_symlink ()
849 func_symlink_target "$1" "$2"
850 func_ln_s "$link_target" "$2"
853 # func_symlink_if_changed SRC DEST
854 # Like func_symlink, but avoids munging timestamps if the link is correct.
855 # SRC is given relative to the current directory (or absolute).
856 func_symlink_if_changed ()
858 if test $# -ne 2; then
859 echo "usage: func_symlink_if_changed SRC DEST" >&2
861 func_symlink_target "$1" "$2"
862 ln_target=`func_readlink "$2"`
863 if test -h "$2" && test "$link_target" = "$ln_target"; then
865 else
866 rm -f "$2"
867 func_ln_s "$link_target" "$2"
871 # func_hardlink SRC DEST
872 # Like ln, except use cp -p if ln fails.
873 # SRC is given relative to the current directory (or absolute).
874 func_hardlink ()
876 ln "$1" "$2" || {
877 echo "$progname: ln failed; falling back on cp -p" >&2
878 cp -p "$1" "$2"
882 # Ensure an 'echo' command that
883 # 1. does not interpret backslashes and
884 # 2. does not print an error message "broken pipe" when writing into a pipe
885 # with no writers.
887 # Test cases for problem 1:
888 # echo '\n' | wc -l prints 1 when OK, 2 when KO
889 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
890 # Test cases for problem 2:
891 # echo hi | true frequently prints
892 # "bash: echo: write error: Broken pipe"
893 # to standard error in bash 3.2.
895 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
896 # BSD echo interprets '-n' as an option, which is also not desirable).
897 # Nowadays the problem occurs in 4 situations:
898 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
899 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
900 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
901 # - in zsh, when sh-emulation is not set,
902 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
903 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
904 # - in Solaris /bin/sh and OSF/1 /bin/sh.
905 # We try the following workarounds:
906 # - for all: respawn using $CONFIG_SHELL if that is set and works.
907 # - for bash >= 2.04: unset the shell option xpg_echo.
908 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
909 # - for bash < 2.0: define echo to a function that uses cat of a here document.
910 # - for zsh: turn sh-emulation on.
911 # - for ksh: alias echo to 'print -r'.
912 # - for ksh: alias echo to a function that uses cat of a here document.
913 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
914 # the ksh workaround.
915 # - otherwise: respawn using /bin/sh and rely on the workarounds.
916 # When respawning, we pass --no-reexec as first argument, so as to avoid
917 # turning this script into a fork bomb in unlucky situations.
919 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
920 # the 'printf' built-in. See
921 # <https://lists.gnu.org/r/bug-bash/2008-12/msg00050.html>
922 # <https://lists.gnu.org/r/bug-gnulib/2010-02/msg00154.html>
923 # The workaround is: define echo to a function that uses the printf built-in.
924 have_echo=
925 if echo '\t' | grep t > /dev/null; then
926 have_echo=yes # Lucky!
928 # Try the workarounds.
929 # Respawn using $CONFIG_SHELL if that is set and works.
930 if test -z "$have_echo" \
931 && test "X$1" != "X--no-reexec" \
932 && test -n "$CONFIG_SHELL" \
933 && test -f "$CONFIG_SHELL" \
934 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
935 exec $CONFIG_SHELL "$0" --no-reexec "$@"
936 exit 127
938 # For bash >= 2.04: unset the shell option xpg_echo.
939 if test -z "$have_echo" \
940 && test -n "$BASH_VERSION" \
941 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
942 shopt -o xpg_echo
943 have_echo=yes
945 # For bash >= 2.0: define echo to a function that uses the printf built-in.
946 # For bash < 2.0: define echo to a function that uses cat of a here document.
947 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
948 # Also handle problem 2, specific to bash 3.2, here.
949 if { test -z "$have_echo" \
950 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
952 && test -n "$BASH_VERSION"; then \
953 if type printf 2>/dev/null | grep / > /dev/null; then
954 # 'printf' is not a shell built-in.
955 echo ()
957 cat <<EOF
961 else
962 # 'printf' is a shell built-in.
963 echo ()
965 printf '%s\n' "$*"
968 if echo '\t' | grep t > /dev/null; then
969 have_echo=yes
972 # For zsh: turn sh-emulation on.
973 if test -z "$have_echo" \
974 && test -n "$ZSH_VERSION" \
975 && (emulate sh) >/dev/null 2>&1; then
976 emulate sh
978 # For ksh: alias echo to 'print -r'.
979 if test -z "$have_echo" \
980 && (type print) >/dev/null 2>&1; then
981 # A 'print' command exists.
982 if type print 2>/dev/null | grep / > /dev/null; then
984 else
985 # 'print' is a shell built-in.
986 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
987 # 'print' is the ksh shell built-in.
988 alias echo='print -r'
992 if test -z "$have_echo" \
993 && echo '\t' | grep t > /dev/null; then
994 have_echo=yes
996 # For ksh: alias echo to a function that uses cat of a here document.
997 # The ksh manual page says:
998 # "Aliasing is performed when scripts are read, not while they are executed.
999 # Therefore, for an alias to take effect, the alias definition command has
1000 # to be executed before the command which references the alias is read."
1001 # Because of this, we have to play strange tricks with have_echo, to ensure
1002 # that the top-level statement containing the test starts after the 'alias'
1003 # command.
1004 if test -z "$have_echo"; then
1005 bsd_echo ()
1007 cat <<EOF
1011 if (alias echo=bsd_echo) 2>/dev/null; then
1012 alias echo=bsd_echo 2>/dev/null
1015 if test -z "$have_echo" \
1016 && echo '\t' | grep t > /dev/null; then
1017 have_echo=yes
1019 if test -z "$have_echo"; then
1020 if (alias echo=bsd_echo) 2>/dev/null; then
1021 unalias echo 2>/dev/null
1024 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
1025 if test -z "$have_echo" \
1026 && test "X$1" != "X--no-reexec" \
1027 && test -f /bin/ksh; then
1028 exec /bin/ksh "$0" --no-reexec "$@"
1029 exit 127
1031 # Otherwise: respawn using /bin/sh.
1032 if test -z "$have_echo" \
1033 && test "X$1" != "X--no-reexec" \
1034 && test -f /bin/sh; then
1035 exec /bin/sh "$0" --no-reexec "$@"
1036 exit 127
1038 if test -z "$have_echo"; then
1039 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
1041 if echo '\t' | grep t > /dev/null; then
1042 : # Works fine now.
1043 else
1044 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
1046 if test "X$1" = "X--no-reexec"; then
1047 shift
1050 # Unset CDPATH. Otherwise, output from 'cd dir' can surprise callers.
1051 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1053 # Determine the path separator early because the following option parsing code
1054 # requires that.
1055 func_determine_path_separator
1057 # Command-line option processing.
1058 # Removes the OPTIONS from the arguments. Sets the variables:
1059 # - mode one of: list, find, import, add-import, remove-import,
1060 # update, create-testdir, create-megatestdir, test, megatest,
1061 # copy-file
1062 # - destdir from --dir
1063 # - local_gnulib_path from --local-dir, highest priority dir comes first
1064 # - modcache true or false, from --cache-modules/--no-cache-modules
1065 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1066 # - libname, supplied_libname from --lib
1067 # - sourcebase from --source-base
1068 # - m4base from --m4-base
1069 # - pobase from --po-base
1070 # - docbase from --doc-base
1071 # - testsbase from --tests-base
1072 # - auxdir from --aux-dir
1073 # - inctests true if --with-tests was given, false if --without-tests
1074 # was given, blank otherwise
1075 # - incobsolete true if --with-obsolete was given, blank otherwise
1076 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
1077 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
1078 # otherwise
1079 # - inc_privileged_tests true if --with-privileged-tests was given, blank
1080 # otherwise
1081 # - inc_unportable_tests true if --with-unportable-tests was given, blank
1082 # otherwise
1083 # - inc_all_tests true if --with-all-tests was given, blank otherwise
1084 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
1085 # - excl_longrunning_tests true if --without-longrunning-tests was given,
1086 # blank otherwise
1087 # - excl_privileged_tests true if --without-privileged-tests was given, blank
1088 # otherwise
1089 # - excl_unportable_tests true if --without-unportable-tests was given, blank
1090 # otherwise
1091 # - single_configure true if --single-configure was given, false otherwise
1092 # - avoidlist list of modules to avoid, from --avoid
1093 # - cond_dependencies true if --conditional-dependencies was given, false if
1094 # --no-conditional-dependencies was given, blank otherwise
1095 # - lgpl yes or a number if --lgpl was given, blank otherwise
1096 # - gnu_make true if --gnu-make was given, false otherwise
1097 # - makefile_name from --makefile-name
1098 # - libtool true if --libtool was given, false if --no-libtool was
1099 # given, blank otherwise
1100 # - macro_prefix from --macro-prefix
1101 # - po_domain from --po-domain
1102 # - witness_c_macro from --witness-c-macro
1103 # - vc_files true if --vc-files was given, false if --no-vc-files was
1104 # given, blank otherwise
1105 # - autoconf_minversion minimum supported autoconf version
1106 # - doit : if actions shall be executed, false if only to be printed
1107 # - copymode symlink if --symlink or --more-symlinks was given,
1108 # hardlink if --hardlink or --more-hardlinks was given,
1109 # blank otherwise
1110 # - lcopymode symlink if --local-symlink was given,
1111 # hardlink if --local-hardlink was given,
1112 # blank otherwise
1113 # - do_copyrights blank if --more-symlinks or --more-hardlinks was given,
1114 # true otherwise
1116 mode=
1117 destdir=
1118 local_gnulib_path=
1119 modcache=true
1120 verbose=0
1121 libname=libgnu
1122 supplied_libname=
1123 sourcebase=
1124 m4base=
1125 pobase=
1126 docbase=
1127 testsbase=
1128 auxdir=
1129 inctests=
1130 incobsolete=
1131 inc_cxx_tests=
1132 inc_longrunning_tests=
1133 inc_privileged_tests=
1134 inc_unportable_tests=
1135 inc_all_tests=
1136 excl_cxx_tests=
1137 excl_longrunning_tests=
1138 excl_privileged_tests=
1139 excl_unportable_tests=
1140 single_configure=false
1141 avoidlist=
1142 cond_dependencies=
1143 lgpl=
1144 gnu_make=false
1145 makefile_name=
1146 libtool=
1147 macro_prefix=
1148 po_domain=
1149 witness_c_macro=
1150 vc_files=
1151 doit=:
1152 copymode=
1153 lcopymode=
1154 do_copyrights=true
1156 supplied_opts="$@"
1158 while test $# -gt 0; do
1159 case "$1" in
1160 --list | --lis )
1161 mode=list
1162 shift ;;
1163 --find | --fin | --fi | --f )
1164 mode=find
1165 shift ;;
1166 --import | --impor | --impo | --imp | --im | --i )
1167 mode=import
1168 shift ;;
1169 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1170 mode=add-import
1171 shift ;;
1172 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1173 mode=remove-import
1174 shift ;;
1175 --update | --updat | --upda | --upd | --up | --u )
1176 mode=update
1177 shift ;;
1178 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1179 mode=create-testdir
1180 shift ;;
1181 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1182 mode=create-megatestdir
1183 shift ;;
1184 --test | --tes | --te | --t )
1185 mode=test
1186 shift ;;
1187 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1188 mode=megatest
1189 shift ;;
1190 --extract-* )
1191 mode=`echo "X$1" | sed -e 's/^X--//'`
1192 shift ;;
1193 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1194 mode=copy-file
1195 shift ;;
1196 --dir )
1197 shift
1198 if test $# = 0; then
1199 func_fatal_error "missing argument for --dir"
1201 destdir=$1
1202 shift ;;
1203 --dir=* )
1204 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1205 shift ;;
1206 --local-dir )
1207 shift
1208 if test $# = 0; then
1209 func_fatal_error "missing argument for --local-dir"
1211 func_path_append local_gnulib_path "$1"
1212 shift ;;
1213 --local-dir=* )
1214 local_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1215 func_path_append local_gnulib_path "$local_dir"
1216 shift ;;
1217 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1218 modcache=true
1219 shift ;;
1220 --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 )
1221 modcache=false
1222 shift ;;
1223 --verbose | --verbos | --verbo | --verb )
1224 verbose=`expr $verbose + 1`
1225 shift ;;
1226 --quiet | --quie | --qui | --qu | --q )
1227 verbose=`expr $verbose - 1`
1228 shift ;;
1229 --lib )
1230 shift
1231 if test $# = 0; then
1232 func_fatal_error "missing argument for --lib"
1234 libname=$1
1235 supplied_libname=true
1236 shift ;;
1237 --lib=* )
1238 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1239 supplied_libname=true
1240 shift ;;
1241 --source-base )
1242 shift
1243 if test $# = 0; then
1244 func_fatal_error "missing argument for --source-base"
1246 sourcebase=$1
1247 shift ;;
1248 --source-base=* )
1249 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1250 shift ;;
1251 --m4-base )
1252 shift
1253 if test $# = 0; then
1254 func_fatal_error "missing argument for --m4-base"
1256 m4base=$1
1257 shift ;;
1258 --m4-base=* )
1259 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1260 shift ;;
1261 --po-base )
1262 shift
1263 if test $# = 0; then
1264 func_fatal_error "missing argument for --po-base"
1266 pobase=$1
1267 shift ;;
1268 --po-base=* )
1269 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1270 shift ;;
1271 --doc-base )
1272 shift
1273 if test $# = 0; then
1274 func_fatal_error "missing argument for --doc-base"
1276 docbase=$1
1277 shift ;;
1278 --doc-base=* )
1279 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1280 shift ;;
1281 --tests-base )
1282 shift
1283 if test $# = 0; then
1284 func_fatal_error "missing argument for --tests-base"
1286 testsbase=$1
1287 shift ;;
1288 --tests-base=* )
1289 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1290 shift ;;
1291 --aux-dir )
1292 shift
1293 if test $# = 0; then
1294 func_fatal_error "missing argument for --aux-dir"
1296 auxdir=$1
1297 shift ;;
1298 --aux-dir=* )
1299 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1300 shift ;;
1301 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1302 inctests=true
1303 shift ;;
1304 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1305 incobsolete=true
1306 shift ;;
1307 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1308 inc_cxx_tests=true
1309 shift ;;
1310 --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)
1311 inc_longrunning_tests=true
1312 shift ;;
1313 --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)
1314 inc_privileged_tests=true
1315 shift ;;
1316 --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)
1317 inc_unportable_tests=true
1318 shift ;;
1319 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1320 inc_all_tests=true
1321 shift ;;
1322 --without-tests | --without-test | --without-tes | --without-te | --without-t)
1323 inctests=false
1324 shift ;;
1325 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1326 excl_cxx_tests=true
1327 shift ;;
1328 --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)
1329 excl_longrunning_tests=true
1330 shift ;;
1331 --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)
1332 excl_privileged_tests=true
1333 shift ;;
1334 --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)
1335 excl_unportable_tests=true
1336 shift ;;
1337 --single-configure | --single-configur | --single-configu | --single-config | --single-confi | --single-conf | --single-con | --single-con | --single-co | --single-c | --single- | --single | --singl | --sing | --sin | --si)
1338 single_configure=true
1339 shift ;;
1340 --avoid )
1341 shift
1342 if test $# = 0; then
1343 func_fatal_error "missing argument for --avoid"
1345 func_append avoidlist " $1"
1346 shift ;;
1347 --avoid=* )
1348 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1349 func_append avoidlist " $arg"
1350 shift ;;
1351 --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)
1352 cond_dependencies=true
1353 shift ;;
1354 --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)
1355 cond_dependencies=false
1356 shift ;;
1357 --lgpl )
1358 lgpl=yes
1359 shift ;;
1360 --lgpl=* )
1361 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1362 case "$arg" in
1363 2 | 3orGPLv2 | 3) ;;
1364 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1365 esac
1366 lgpl=$arg
1367 shift ;;
1368 --gnu-make )
1369 gnu_make=true
1370 shift ;;
1371 --makefile-name )
1372 shift
1373 if test $# = 0; then
1374 func_fatal_error "missing argument for --makefile-name"
1376 makefile_name="$1"
1377 shift ;;
1378 --makefile-name=* )
1379 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1380 shift ;;
1381 --libtool )
1382 libtool=true
1383 shift ;;
1384 --no-libtool )
1385 libtool=false
1386 shift ;;
1387 --macro-prefix )
1388 shift
1389 if test $# = 0; then
1390 func_fatal_error "missing argument for --macro-prefix"
1392 macro_prefix="$1"
1393 shift ;;
1394 --macro-prefix=* )
1395 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1396 shift ;;
1397 --po-domain )
1398 shift
1399 if test $# = 0; then
1400 func_fatal_error "missing argument for --po-domain"
1402 po_domain="$1"
1403 shift ;;
1404 --po-domain=* )
1405 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1406 shift ;;
1407 --witness-c-macro )
1408 shift
1409 if test $# = 0; then
1410 func_fatal_error "missing argument for --witness-c-macro"
1412 witness_c_macro="$1"
1413 shift ;;
1414 --witness-c-macro=* )
1415 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1416 shift ;;
1417 --vc-files )
1418 vc_files=true
1419 shift ;;
1420 --no-vc-files )
1421 vc_files=false
1422 shift ;;
1423 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1424 # A no-op for backward compatibility.
1425 shift ;;
1426 --dry-run )
1427 doit=false
1428 shift ;;
1429 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1430 copymode=symlink
1431 shift ;;
1432 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1433 lcopymode=symlink
1434 shift ;;
1435 -h | --hardlink | --hardlin | --hardli | --hardl | --hard | --har | --ha )
1436 copymode=hardlink
1437 shift ;;
1438 --local-hardlink | --local-hardlin | --local-hardli | --local-hardl | --local-hard | --local-har | --local-ha | --local-h )
1439 lcopymode=hardlink
1440 shift ;;
1441 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s )
1442 copymode=symlink
1443 do_copyrights=
1444 shift ;;
1445 -H | --more-hardlinks | --more-hardlink | --more-hardlin | --more-hardli | --more-hardl | --more-hard | --more-har | --more-ha | --more-h )
1446 copymode=hardlink
1447 do_copyrights=
1448 shift ;;
1449 --help | --hel | --he )
1450 func_usage
1451 func_exit $? ;;
1452 --version | --versio | --versi | --vers )
1453 func_version
1454 func_exit $? ;;
1455 -- )
1456 # Stop option processing
1457 shift
1458 break ;;
1459 -* )
1460 echo "gnulib-tool: unknown option $1" 1>&2
1461 echo "Try 'gnulib-tool --help' for more information." 1>&2
1462 func_exit 1 ;;
1464 break ;;
1465 esac
1466 done
1468 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1469 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1470 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1471 || test "$single_configure" != false; then
1472 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1473 echo "Try 'gnulib-tool --help' for more information." 1>&2
1474 func_exit 1
1477 if test "$mode" = update; then
1478 if test $# != 0; then
1479 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1480 echo "Try 'gnulib-tool --help' for more information." 1>&2
1481 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1482 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1483 func_exit 1
1485 if test -n "$local_gnulib_path" || test -n "$supplied_libname" \
1486 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1487 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1488 || test -n "$inctests" || test -n "$incobsolete" \
1489 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1490 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1491 || test -n "$inc_all_tests" \
1492 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1493 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1494 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1495 || test -n "$macro_prefix" || test -n "$po_domain" \
1496 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1497 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1498 echo "Try 'gnulib-tool --help' for more information." 1>&2
1499 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1500 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1501 func_exit 1
1504 if test -n "$pobase" && test -z "$po_domain"; then
1505 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1506 echo "Try 'gnulib-tool --help' for more information." 1>&2
1507 func_exit 1
1509 if test -z "$pobase" && test -n "$po_domain"; then
1510 func_warning "--po-domain has no effect without a --po-base option"
1512 case $mode,$gnu_make in
1513 *test*,true)
1514 echo "gnulib-tool: --gnu-make not supported when including tests"
1515 func_exit 1;;
1516 esac
1517 # Canonicalize the inctests variable.
1518 case "$mode" in
1519 import | add-import | remove-import | update)
1520 if test -z "$inctests"; then
1521 inctests=false
1524 create-testdir | create-megatestdir | test | megatest)
1525 if test -z "$inctests"; then
1526 inctests=true
1529 esac
1530 # Now the only possible values of "$inctests" are true and false
1531 # (or blank but then it is irrelevant).
1533 # Determine the minimum supported autoconf version from the project's
1534 # configure.ac.
1535 DEFAULT_AUTOCONF_MINVERSION="2.63"
1536 autoconf_minversion=
1537 configure_ac=
1538 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1539 && test -n "$destdir"; then
1540 if test -f "$destdir"/configure.ac; then
1541 configure_ac="$destdir/configure.ac"
1542 else
1543 if test -f "$destdir"/configure.in; then
1544 configure_ac="$destdir/configure.in"
1547 else
1548 if test -f configure.ac; then
1549 configure_ac="configure.ac"
1550 else
1551 if test -f configure.in; then
1552 configure_ac="configure.in"
1556 if test -n "$configure_ac"; then
1557 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1558 # because when some m4 files are omitted from a version control repository,
1559 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1560 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1561 # autom4te: m4 failed with exit status: 1
1562 prereqs=
1563 my_sed_traces='
1564 s,#.*$,,
1565 s,^dnl .*$,,
1566 s, dnl .*$,,
1567 /AC_PREREQ/ {
1568 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1570 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1571 if test -n "$prereqs"; then
1572 autoconf_minversion=`
1573 for version in $prereqs; do echo $version; done |
1574 LC_ALL=C sort -nru | sed -e 1q
1578 if test -z "$autoconf_minversion"; then
1579 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1581 case "$autoconf_minversion" in
1582 1.* | 2.[0-5]* | 2.6[0-2]*)
1583 func_fatal_error "minimum supported autoconf version is 2.63. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1584 esac
1586 # Remove trailing slashes from the directory names. This is necessary for
1587 # m4base (to avoid an error in func_import) and optional for the others.
1588 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1589 old_local_gnulib_path="$local_gnulib_path"
1590 local_gnulib_path=
1591 save_IFS="$IFS"
1592 IFS=:
1593 for dir in $old_local_gnulib_path
1595 IFS="$save_IFS"
1596 case "$dir" in
1597 */ ) dir=`echo "$dir" | sed -e "$sed_trimtrailingslashes"` ;;
1598 esac
1599 func_path_append local_gnulib_path "$dir"
1600 done
1601 IFS="$save_IFS"
1602 case "$sourcebase" in
1603 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1604 esac
1605 case "$m4base" in
1606 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1607 esac
1608 case "$pobase" in
1609 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1610 esac
1611 case "$docbase" in
1612 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1613 esac
1614 case "$testsbase" in
1615 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1616 esac
1617 case "$auxdir" in
1618 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1619 esac
1622 func_gnulib_dir
1623 func_tmpdir
1624 trap 'exit_status=$?
1625 if test "$signal" != 0; then
1626 echo "caught signal $signal" >&2
1628 rm -rf "$tmp"
1629 exit $exit_status' 0
1630 for signal in 1 2 3 13 15; do
1631 trap '{ signal='$signal'; func_exit 1; }' $signal
1632 done
1633 signal=0
1635 # Note: The 'eval' silences stderr output in dash.
1636 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1637 # Zsh 4 and Bash 4 have associative arrays.
1638 have_associative=true
1639 else
1640 # For other shells, use 'eval' with computed shell variable names.
1641 have_associative=false
1644 # func_lookup_local_file_cb dir file
1645 # returns true and sets func_lookup_local_file_result if the file $dir/$file
1646 # exists.
1647 func_lookup_local_file_cb ()
1649 test -n "$func_lookup_local_file_result" && return 1 # already found?
1650 test -f "$1/$2" || return 1
1651 func_lookup_local_file_result=$1/$2
1655 # func_lookup_local_file file
1656 # looks up a file in $local_gnulib_path.
1657 # Input:
1658 # - local_gnulib_path from --local-dir
1659 # Output:
1660 # - func_lookup_local_file_result name of the file, valid only when the
1661 # function succeeded.
1662 func_lookup_local_file ()
1664 func_lookup_local_file_result=
1665 func_path_foreach "$local_gnulib_path" func_lookup_local_file_cb %dir% "$1"
1668 # func_lookup_file_cb dir
1669 # does one step in processing the $local_gnulib_path, looking for $dir/$lkfile
1670 # and $dir/$lkfile.diff.
1671 func_lookup_file_cb ()
1673 # If we found the file already in a --local-dir of higher priority, nothing
1674 # more to do.
1675 if test -z "$lookedup_file"; then
1676 # Otherwise, look for $dir/$lkfile and $dir/$lkfile.diff.
1677 if test -f "$1/$lkfile"; then
1678 lookedup_file="$1/$lkfile"
1679 else
1680 if test -f "$1/$lkfile.diff"; then
1681 lkpatches="$1/$lkfile.diff${lkpatches:+$PATH_SEPARATOR$lkpatches}"
1687 # func_lookup_file file
1688 # looks up a file in $local_gnulib_path or $gnulib_dir, or combines it through
1689 # 'patch'.
1690 # Input:
1691 # - local_gnulib_path from --local-dir
1692 # Output:
1693 # - lookedup_file name of the merged (combined) file
1694 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1695 func_lookup_file ()
1697 lkfile="$1"
1698 # Each element in $local_gnulib_path is a directory whose contents overrides
1699 # or amends the result of the lookup in the rest of $local_gnulib_path and
1700 # $gnulib_dir. So, the first element of $local_gnulib_path is the highest
1701 # priority one.
1702 lookedup_file=
1703 lkpatches=
1704 func_path_foreach "$local_gnulib_path" func_lookup_file_cb %dir%
1705 # Treat $gnulib_dir like a lowest-priority --local-dir, except that here we
1706 # don't look for .diff files.
1707 if test -z "$lookedup_file"; then
1708 if test -f "$gnulib_dir/$lkfile"; then
1709 lookedup_file="$gnulib_dir/$lkfile"
1710 else
1711 func_fatal_error "file $gnulib_dir/$lkfile not found"
1714 # Now apply the patches, from lowest-priority to highest-priority.
1715 lookedup_tmp=
1716 if test -n "$lkpatches"; then
1717 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1718 rm -f "$tmp/$lkbase"
1719 cp "$lookedup_file" "$tmp/$lkbase"
1720 save_IFS="$IFS"
1721 IFS="$PATH_SEPARATOR"
1722 for patchfile in $lkpatches; do
1723 IFS="$save_IFS"
1724 patch -s "$tmp/$lkbase" < "$patchfile" >&2 \
1725 || func_fatal_error "patch file $patchfile didn't apply cleanly"
1726 done
1727 IFS="$save_IFS"
1728 lookedup_file="$tmp/$lkbase"
1729 lookedup_tmp=true
1733 # func_sanitize_modulelist
1734 # receives a list of possible module names on standard input, one per line.
1735 # It removes those which are just file names unrelated to modules, and outputs
1736 # the resulting list to standard output, one per line.
1737 func_sanitize_modulelist ()
1739 sed -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1740 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1741 -e '/^README$/d' -e '/\/README$/d' \
1742 -e '/^TEMPLATE$/d' \
1743 -e '/^TEMPLATE-EXTENDED$/d' \
1744 -e '/^TEMPLATE-TESTS$/d' \
1745 -e '/^\..*/d' \
1746 -e '/~$/d'
1750 # func_modules_in_dir dir
1751 # outputs all module files in dir to standard output.
1752 func_modules_in_dir ()
1754 (test -d "$1" && cd "$1" && find modules -type f -print)
1757 # func_all_modules
1758 # Input:
1759 # - local_gnulib_path from --local-dir
1760 func_all_modules ()
1762 # Filter out metainformation files like README, which are not modules.
1763 # Filter out unit test modules; they can be retrieved through
1764 # --extract-tests-module if desired.
1766 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1767 func_path_foreach "$local_gnulib_path" func_modules_in_dir %dir% | sed -e 's,^modules/,,' -e 's,\.diff$,,'
1769 | func_sanitize_modulelist \
1770 | sed -e '/-tests$/d' \
1771 | LC_ALL=C sort -u
1774 # func_exists_local_module dir module
1775 # returns true if module exists in dir
1776 func_exists_local_module ()
1778 test -d "$1/modules" && test -f "$1/modules/$2";
1781 # func_exists_module module
1782 # tests whether a module, given by name, exists
1783 # Input:
1784 # - local_gnulib_path from --local-dir
1785 func_exists_module ()
1787 { test -f "$gnulib_dir/modules/$1" \
1788 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1" ; } \
1789 && test "ChangeLog" != "$1" \
1790 && test "COPYING" != "$1" \
1791 && test "README" != "$1" \
1792 && test "TEMPLATE" != "$1" \
1793 && test "TEMPLATE-EXTENDED" != "$1" \
1794 && test "TEMPLATE-TESTS" != "$1"
1797 # func_verify_module
1798 # verifies a module name
1799 # Input:
1800 # - local_gnulib_path from --local-dir
1801 # - module module name argument
1802 # Output:
1803 # - module unchanged if OK, empty if not OK
1804 # - lookedup_file if OK: name of the merged (combined) module description file
1805 # - lookedup_tmp if OK: true if it is located in the tmp directory, blank otherwise
1806 func_verify_module ()
1808 if func_exists_module "$module"; then
1809 # OK, $module is a correct module name.
1810 # Verify that building the module description with 'patch' succeeds.
1811 func_lookup_file "modules/$module"
1812 else
1813 func_warning "module $module doesn't exist"
1814 module=
1818 # func_verify_nontests_module
1819 # verifies a module name, excluding tests modules
1820 # Input:
1821 # - local_gnulib_path from --local-dir
1822 # - module module name argument
1823 func_verify_nontests_module ()
1825 case "$module" in
1826 *-tests ) module= ;;
1827 * ) func_verify_module ;;
1828 esac
1831 # func_verify_tests_module
1832 # verifies a module name, considering only tests modules
1833 # Input:
1834 # - local_gnulib_path from --local-dir
1835 # - module module name argument
1836 func_verify_tests_module ()
1838 case "$module" in
1839 *-tests ) func_verify_module ;;
1840 * ) module= ;;
1841 esac
1844 # Suffix of a sed expression that extracts a particular field from a
1845 # module description.
1846 # A field starts with a line that contains a keyword, such as 'Description',
1847 # followed by a colon and optional whitespace. All following lines, up to
1848 # the next field (or end of file if there is none) form the contents of the
1849 # field.
1850 # An absent field is equivalent to a field with empty contents.
1851 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1852 sed_extract_prog=':[ ]*$/ {
1855 s/^Description:[ ]*$//
1856 s/^Comment:[ ]*$//
1857 s/^Status:[ ]*$//
1858 s/^Notice:[ ]*$//
1859 s/^Applicability:[ ]*$//
1860 s/^Files:[ ]*$//
1861 s/^Depends-on:[ ]*$//
1862 s/^configure\.ac-early:[ ]*$//
1863 s/^configure\.ac:[ ]*$//
1864 s/^Makefile\.am:[ ]*$//
1865 s/^Include:[ ]*$//
1866 s/^Link:[ ]*$//
1867 s/^License:[ ]*$//
1868 s/^Maintainer:[ ]*$//
1875 # Piece of a sed expression that converts a field header line to a shell
1876 # variable name,
1877 # NOTE: Keep this in sync with sed_extract_prog above!
1878 sed_extract_field_header='
1879 s/^Description:[ ]*$/description/
1880 s/^Comment:[ ]*$/comment/
1881 s/^Status:[ ]*$/status/
1882 s/^Notice:[ ]*$/notice/
1883 s/^Applicability:[ ]*$/applicability/
1884 s/^Files:[ ]*$/files/
1885 s/^Depends-on:[ ]*$/dependson/
1886 s/^configure\.ac-early:[ ]*$/configureac_early/
1887 s/^configure\.ac:[ ]*$/configureac/
1888 s/^Makefile\.am:[ ]*$/makefile/
1889 s/^Include:[ ]*$/include/
1890 s/^Link:[ ]*$/link/
1891 s/^License:[ ]*$/license/
1892 s/^Maintainer:[ ]*$/maintainer/'
1894 if $modcache; then
1896 if $have_associative; then
1898 # Declare the associative arrays.
1899 declare -A modcache_cached
1900 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1901 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1902 eval "$declare_script"
1904 else
1906 # func_cache_var module
1907 # computes the cache variable name corresponding to $module.
1908 # Note: This computation can map different module names to the same
1909 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1910 # to protect against this case.
1911 # Output:
1912 # - cachevar a shell variable name
1913 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1914 # Bash 2.0 and newer, ksh, and zsh support the syntax
1915 # ${param//pattern/replacement}
1916 # as a shorthand for
1917 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1918 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1919 eval 'func_cache_var ()
1921 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1923 else
1924 func_cache_var ()
1926 case $1 in
1927 *[!a-zA-Z0-9_]*)
1928 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1930 cachevar=c_$1 ;;
1931 esac
1937 # func_init_sed_convert_to_cache_statements
1938 # Input:
1939 # - modcachevar_assignment
1940 # Output:
1941 # - sed_convert_to_cache_statements
1942 func_init_sed_convert_to_cache_statements ()
1944 # 'sed' script that turns a module description into shell script
1945 # assignments, suitable to be eval'ed. All active characters are escaped.
1946 # This script turns
1947 # Description:
1948 # Some module's description
1950 # Files:
1951 # lib/file.h
1952 # into:
1953 # modcache_description[$1]=\
1954 # 'Some module'"'"'s description
1956 # modcache_files[$1]=\
1957 # 'lib/file.h'
1958 # or:
1959 # c_MODULE_description_set=set; c_MODULE_description=\
1960 # 'Some module'"'"'s description
1962 # c_MODULE_files_set=set; c_MODULE_files=\
1963 # 'lib/file.h'
1964 # The script consists of two parts:
1965 # 1) Ignore the lines before the first field header.
1966 # 2) A loop, treating non-field-header lines by escaping single quotes
1967 # and adding a closing quote in the last line,
1968 sed_convert_to_cache_statements="
1969 :llla
1970 # Here we have not yet seen a field header.
1972 # See if the current line contains a field header.
1973 t llla1
1974 :llla1
1975 ${sed_extract_field_header}
1976 t lllb
1978 # No field header. Ignore the line.
1980 # Read the next line. Upon EOF, just exit.
1982 b llla
1984 :lllb
1985 # The current line contains a field header.
1987 # Turn it into the beginning of an assignment.
1988 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1990 # Move it to the hold space. Don't print it yet,
1991 # because we want no assignment if the field is empty.
1994 # Read the next line.
1995 # Upon EOF, the field was empty. Print no assignment. Just exit.
1998 # See if the current line contains a field header.
1999 t lllb1
2000 :lllb1
2001 ${sed_extract_field_header}
2002 # If it is, the previous field was empty. Print no assignment.
2003 t lllb
2005 # Not a field header.
2007 # Print the previous line, held in the hold space.
2012 # Transform single quotes.
2013 s/'/'\"'\"'/g
2015 # Prepend a single quote.
2016 s/^/'/
2018 :lllc
2020 # Move it to the hold space.
2023 # Read the next line.
2024 # Upon EOF, branch.
2026 b llle
2030 # See if the current line contains a field header.
2031 t lllc1
2032 :lllc1
2033 ${sed_extract_field_header}
2034 t llld
2036 # Print the previous line, held in the hold space.
2041 # Transform single quotes.
2042 s/'/'\"'\"'/g
2044 b lllc
2046 :llld
2047 # A field header.
2048 # Print the previous line, held in the hold space, with a single quote
2049 # to end the assignment.
2051 s/\$/'/
2055 b lllb
2057 :llle
2058 # EOF seen.
2059 # Print the previous line, held in the hold space, with a single quote
2060 # to end the assignment.
2062 s/\$/'/
2064 # Exit.
2067 if ! $sed_comments; then
2068 # Remove comments.
2069 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
2070 | sed -e 's/^ *//' -e 's/^#.*//'`
2074 if $have_associative; then
2075 # sed_convert_to_cache_statements does not depend on the module.
2076 modcachevar_assignment='modcache_\1[$1]='
2077 func_init_sed_convert_to_cache_statements
2080 # func_cache_lookup_module module
2082 # looks up a module, like 'func_lookup_file modules/$module', and stores all
2083 # of its relevant data in a cache in the memory of the processing shell. If
2084 # already cached, it does not look it up again, thus saving file access time.
2085 # Parameters:
2086 # - module non-empty string
2087 # Output if $have_associative:
2088 # - modcache_cached[$module] set to yes
2089 # - modcache_description[$module] ==
2090 # - modcache_status[$module] \ set to the field's value, minus the
2091 # - ... / final newline,
2092 # - modcache_maintainer[$module] == or unset if the field's value is empty
2093 # Output if ! $have_associative:
2094 # - cachevar a shell variable name
2095 # - ${cachevar}_cached set to $module
2096 # - ${cachevar}_description ==
2097 # - ${cachevar}_status \ set to the field's value, minus the
2098 # - ... / final newline,
2099 # - ${cachevar}_maintainer == or unset if the field's value is empty
2100 # - ${cachevar}_description_set ==
2101 # - ${cachevar}_status_set \ set to non-empty if the field's value
2102 # - ... / is non-empty,
2103 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
2104 func_cache_lookup_module ()
2106 if $have_associative; then
2107 eval 'cached=${modcache_cached[$1]}'
2108 else
2109 func_cache_var "$1"
2110 eval "cached=\"\$${cachevar}_cached\""
2112 if test -z "$cached"; then
2113 # Not found in cache. Look it up on the file system.
2114 func_lookup_file "modules/$1"
2115 if $have_associative; then
2116 eval 'modcache_cached[$1]=yes'
2117 else
2118 eval "${cachevar}_cached=\"\$1\""
2120 if ! $have_associative; then
2121 # sed_convert_to_cache_statements depends on the module.
2122 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
2123 func_init_sed_convert_to_cache_statements
2125 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
2126 eval "$cache_statements"
2127 else
2128 if ! $have_associative; then
2129 if test "$1" != "$cached"; then
2130 func_fatal_error "cache variable collision between $1 and $cached"
2138 # func_get_description module
2139 # Input:
2140 # - local_gnulib_path from --local-dir
2141 # - modcache true or false, from --cache-modules/--no-cache-modules
2142 func_get_description ()
2144 if ! $modcache; then
2145 func_lookup_file "modules/$1"
2146 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
2147 else
2148 func_cache_lookup_module "$1"
2149 # Output the field's value, including the final newline (if any).
2150 if $have_associative; then
2151 if eval 'test -n "${modcache_description[$1]+set}"'; then
2152 eval 'echo "${modcache_description[$1]}"'
2154 else
2155 eval "field_set=\"\$${cachevar}_description_set\""
2156 if test -n "$field_set"; then
2157 eval "field_value=\"\$${cachevar}_description\""
2158 echo "${field_value}"
2164 # func_get_comment module
2165 # Input:
2166 # - local_gnulib_path from --local-dir
2167 # - modcache true or false, from --cache-modules/--no-cache-modules
2168 func_get_comment ()
2170 if ! $modcache; then
2171 func_lookup_file "modules/$1"
2172 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
2173 else
2174 func_cache_lookup_module "$1"
2175 # Output the field's value, including the final newline (if any).
2176 if $have_associative; then
2177 if eval 'test -n "${modcache_comment[$1]+set}"'; then
2178 eval 'echo "${modcache_comment[$1]}"'
2180 else
2181 eval "field_set=\"\$${cachevar}_comment_set\""
2182 if test -n "$field_set"; then
2183 eval "field_value=\"\$${cachevar}_comment\""
2184 echo "${field_value}"
2190 # func_get_status module
2191 # Input:
2192 # - local_gnulib_path from --local-dir
2193 # - modcache true or false, from --cache-modules/--no-cache-modules
2194 func_get_status ()
2196 if ! $modcache; then
2197 func_lookup_file "modules/$1"
2198 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
2199 else
2200 func_cache_lookup_module "$1"
2201 # Output the field's value, including the final newline (if any).
2202 if $have_associative; then
2203 if eval 'test -n "${modcache_status[$1]+set}"'; then
2204 eval 'echo "${modcache_status[$1]}"'
2206 else
2207 eval "field_set=\"\$${cachevar}_status_set\""
2208 if test -n "$field_set"; then
2209 eval "field_value=\"\$${cachevar}_status\""
2210 echo "${field_value}"
2216 # func_get_notice module
2217 # Input:
2218 # - local_gnulib_path from --local-dir
2219 # - modcache true or false, from --cache-modules/--no-cache-modules
2220 func_get_notice ()
2222 if ! $modcache; then
2223 func_lookup_file "modules/$1"
2224 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
2225 else
2226 func_cache_lookup_module "$1"
2227 # Output the field's value, including the final newline (if any).
2228 if $have_associative; then
2229 if eval 'test -n "${modcache_notice[$1]+set}"'; then
2230 eval 'echo "${modcache_notice[$1]}"'
2232 else
2233 eval "field_set=\"\$${cachevar}_notice_set\""
2234 if test -n "$field_set"; then
2235 eval "field_value=\"\$${cachevar}_notice\""
2236 echo "${field_value}"
2242 # func_get_applicability module
2243 # Input:
2244 # - local_gnulib_path from --local-dir
2245 # - modcache true or false, from --cache-modules/--no-cache-modules
2246 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
2247 func_get_applicability ()
2249 if ! $modcache; then
2250 func_lookup_file "modules/$1"
2251 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2252 else
2253 func_cache_lookup_module "$1"
2254 # Get the field's value, without the final newline.
2255 if $have_associative; then
2256 eval 'my_applicability="${modcache_applicability[$1]}"'
2257 else
2258 eval "my_applicability=\"\$${cachevar}_applicability\""
2261 if test -n "$my_applicability"; then
2262 echo $my_applicability
2263 else
2264 # The default is 'main' or 'tests', depending on the module's name.
2265 case $1 in
2266 *-tests) echo "tests";;
2267 *) echo "main";;
2268 esac
2272 # func_get_filelist module
2273 # Input:
2274 # - local_gnulib_path from --local-dir
2275 # - modcache true or false, from --cache-modules/--no-cache-modules
2276 func_get_filelist ()
2278 if ! $modcache; then
2279 func_lookup_file "modules/$1"
2280 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2281 else
2282 func_cache_lookup_module "$1"
2283 # Output the field's value, including the final newline (if any).
2284 if $have_associative; then
2285 if eval 'test -n "${modcache_files[$1]+set}"'; then
2286 eval 'echo "${modcache_files[$1]}"'
2288 else
2289 eval "field_set=\"\$${cachevar}_files_set\""
2290 if test -n "$field_set"; then
2291 eval "field_value=\"\$${cachevar}_files\""
2292 echo "${field_value}"
2296 echo m4/00gnulib.m4
2297 echo 'm4/~~gnulib.m4'
2298 echo m4/gnulib-common.m4
2301 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2302 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2303 # elements starting with prefix and ending with suffix are considered.
2304 # Processing: removed_prefix and removed_suffix are removed from each element,
2305 # added_prefix and added_suffix are added to each element.
2306 # prefix, suffix should not contain shell-special characters.
2307 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2308 # added_prefix, added_suffix should not contain the characters \|&.
2309 func_filter_filelist ()
2311 if test "$2" != "$nl" \
2312 || { $fast_func_append \
2313 && { test -z "$6" || $fast_func_remove_prefix; } \
2314 && { test -z "$7" || $fast_func_remove_suffix; }; \
2315 }; then
2316 ffflist=
2317 for fff in $3; do
2318 # Do not quote possibly-empty parameters in case patterns,
2319 # AIX and HP-UX ksh won't match them if they are empty.
2320 case "$fff" in
2321 $4*$5)
2322 if test -n "$6"; then
2323 func_remove_prefix fff "$6"
2325 if test -n "$7"; then
2326 func_remove_suffix fff "$7"
2328 fff="$8${fff}$9"
2329 if test -z "$ffflist"; then
2330 ffflist="${fff}"
2331 else
2332 func_append ffflist "$2${fff}"
2335 esac
2336 done
2337 else
2338 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2339 ffflist=`for fff in $3; do
2340 case "$fff" in
2341 $4*$5) echo "$fff" ;;
2342 esac
2343 done | sed -e "$sed_fff_filter"`
2345 eval "$1=\"\$ffflist\""
2348 # func_get_dependencies module
2349 # Input:
2350 # - local_gnulib_path from --local-dir
2351 # - modcache true or false, from --cache-modules/--no-cache-modules
2352 func_get_dependencies ()
2354 # ${module}-tests implicitly depends on ${module}, if that module exists.
2355 case "$1" in
2356 *-tests)
2357 fgd1="$1"
2358 func_remove_suffix fgd1 '-tests'
2359 if func_exists_module "$fgd1"; then
2360 echo "$fgd1"
2363 esac
2364 # Then the explicit dependencies listed in the module description.
2365 { if ! $modcache; then
2366 func_lookup_file "modules/$1"
2367 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2368 else
2369 func_cache_lookup_module "$1"
2370 # Output the field's value, including the final newline (if any).
2371 if $have_associative; then
2372 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2373 eval 'echo "${modcache_dependson[$1]}"'
2375 else
2376 eval "field_set=\"\$${cachevar}_dependson_set\""
2377 if test -n "$field_set"; then
2378 eval "field_value=\"\$${cachevar}_dependson\""
2379 echo "${field_value}"
2384 | sed -e '/^#/d'
2387 sed_dependencies_without_conditions='s/ *\[.*//'
2389 # func_get_autoconf_early_snippet module
2390 # Input:
2391 # - local_gnulib_path from --local-dir
2392 # - modcache true or false, from --cache-modules/--no-cache-modules
2393 func_get_autoconf_early_snippet ()
2395 if ! $modcache; then
2396 func_lookup_file "modules/$1"
2397 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2398 else
2399 func_cache_lookup_module "$1"
2400 # Output the field's value, including the final newline (if any).
2401 if $have_associative; then
2402 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2403 eval 'echo "${modcache_configureac_early[$1]}"'
2405 else
2406 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2407 if test -n "$field_set"; then
2408 eval "field_value=\"\$${cachevar}_configureac_early\""
2409 echo "${field_value}"
2415 # func_get_autoconf_snippet module
2416 # Input:
2417 # - local_gnulib_path from --local-dir
2418 # - modcache true or false, from --cache-modules/--no-cache-modules
2419 func_get_autoconf_snippet ()
2421 if ! $modcache; then
2422 func_lookup_file "modules/$1"
2423 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2424 else
2425 func_cache_lookup_module "$1"
2426 # Output the field's value, including the final newline (if any).
2427 if $have_associative; then
2428 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2429 eval 'echo "${modcache_configureac[$1]}"'
2431 else
2432 eval "field_set=\"\$${cachevar}_configureac_set\""
2433 if test -n "$field_set"; then
2434 eval "field_value=\"\$${cachevar}_configureac\""
2435 echo "${field_value}"
2441 # Concatenate lines with trailing slash.
2442 # $1 is an optional filter to restrict the
2443 # concatenation to groups starting with that expression
2444 combine_lines() {
2445 sed -e "/$1.*"'\\$/{
2448 s/\\\n/ /
2449 s/\\$/\\/
2454 # func_get_automake_snippet_conditional module
2455 # returns the part of the Makefile.am snippet that can be put inside Automake
2456 # conditionals.
2457 # Input:
2458 # - local_gnulib_path from --local-dir
2459 # - modcache true or false, from --cache-modules/--no-cache-modules
2460 func_get_automake_snippet_conditional ()
2462 if ! $modcache; then
2463 func_lookup_file "modules/$1"
2464 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2465 else
2466 func_cache_lookup_module "$1"
2467 # Output the field's value, including the final newline (if any).
2468 if $have_associative; then
2469 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2470 eval 'echo "${modcache_makefile[$1]}"'
2472 else
2473 eval "field_set=\"\$${cachevar}_makefile_set\""
2474 if test -n "$field_set"; then
2475 eval "field_value=\"\$${cachevar}_makefile\""
2476 echo "${field_value}"
2482 # func_get_automake_snippet_unconditional module
2483 # returns the part of the Makefile.am snippet that must stay outside of
2484 # Automake conditionals.
2485 # Input:
2486 # - local_gnulib_path from --local-dir
2487 # - modcache true or false, from --cache-modules/--no-cache-modules
2488 func_get_automake_snippet_unconditional ()
2490 case "$1" in
2491 *-tests)
2492 # *-tests module live in tests/, not lib/.
2493 # Synthesize an EXTRA_DIST augmentation.
2494 all_files=`func_get_filelist $1`
2495 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2496 extra_files="$tests_files"
2497 if test -n "$extra_files"; then
2498 echo "EXTRA_DIST +=" $extra_files
2499 echo
2503 # Synthesize an EXTRA_DIST augmentation.
2504 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2505 already_mentioned_files=` \
2506 { if ! $modcache; then
2507 func_lookup_file "modules/$1"
2508 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2509 else
2510 func_cache_lookup_module "$1"
2511 if $have_associative; then
2512 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2513 eval 'echo "${modcache_makefile[$1]}"'
2515 else
2516 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2517 if test -n "$field_set"; then
2518 eval 'field_value="$'"${cachevar}"'_makefile"'
2519 echo "${field_value}"
2524 | combine_lines \
2525 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2526 all_files=`func_get_filelist $1`
2527 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2528 # Remove $already_mentioned_files from $lib_files.
2529 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2530 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2531 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2532 if test -n "$extra_files"; then
2533 echo "EXTRA_DIST +=" $extra_files
2534 echo
2536 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2537 # This is necessary so that automake can generate the right list of
2538 # dependency rules.
2539 # A possible approach would be to use autom4te --trace of the redefined
2540 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2541 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2542 # inside autoconf's built-in macros are not missed).
2543 # But it's simpler and more robust to do it here, based on the file list.
2544 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2545 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2546 # automake will generate a useless dependency; this is harmless.
2547 case "$1" in
2548 relocatable-prog-wrapper) ;;
2549 pt_chown) ;;
2551 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2552 if test -n "$extra_files"; then
2553 echo "EXTRA_lib_SOURCES +=" $extra_files
2554 echo
2557 esac
2558 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2559 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2560 if test -n "$buildaux_files"; then
2561 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2562 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2563 echo
2566 esac
2569 # func_get_automake_snippet module
2570 # Input:
2571 # - local_gnulib_path from --local-dir
2572 # - modcache true or false, from --cache-modules/--no-cache-modules
2573 func_get_automake_snippet ()
2575 func_get_automake_snippet_conditional "$1"
2576 func_get_automake_snippet_unconditional "$1"
2579 # func_get_include_directive module
2580 # Input:
2581 # - local_gnulib_path from --local-dir
2582 # - modcache true or false, from --cache-modules/--no-cache-modules
2583 func_get_include_directive ()
2586 if ! $modcache; then
2587 func_lookup_file "modules/$1"
2588 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2589 else
2590 func_cache_lookup_module "$1"
2591 # Output the field's value, including the final newline (if any).
2592 if $have_associative; then
2593 if eval 'test -n "${modcache_include[$1]+set}"'; then
2594 eval 'echo "${modcache_include[$1]}"'
2596 else
2597 eval "field_set=\"\$${cachevar}_include_set\""
2598 if test -n "$field_set"; then
2599 eval "field_value=\"\$${cachevar}_include\""
2600 echo "${field_value}"
2604 } | sed -e 's/^\(["<]\)/#include \1/'
2607 # func_get_link_directive module
2608 # Input:
2609 # - local_gnulib_path from --local-dir
2610 # - modcache true or false, from --cache-modules/--no-cache-modules
2611 func_get_link_directive ()
2613 if ! $modcache; then
2614 func_lookup_file "modules/$1"
2615 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2616 else
2617 func_cache_lookup_module "$1"
2618 # Output the field's value, including the final newline (if any).
2619 if $have_associative; then
2620 if eval 'test -n "${modcache_link[$1]+set}"'; then
2621 eval 'echo "${modcache_link[$1]}"'
2623 else
2624 eval "field_set=\"\$${cachevar}_link_set\""
2625 if test -n "$field_set"; then
2626 eval "field_value=\"\$${cachevar}_link\""
2627 echo "${field_value}"
2633 # func_get_license_raw module
2634 # Input:
2635 # - local_gnulib_path from --local-dir
2636 # - modcache true or false, from --cache-modules/--no-cache-modules
2637 func_get_license_raw ()
2639 if ! $modcache; then
2640 func_lookup_file "modules/$1"
2641 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2642 else
2643 func_cache_lookup_module "$1"
2644 # Output the field's value, including the final newline (if any).
2645 if $have_associative; then
2646 if eval 'test -n "${modcache_license[$1]+set}"'; then
2647 eval 'echo "${modcache_license[$1]}"'
2649 else
2650 eval "field_set=\"\$${cachevar}_license_set\""
2651 if test -n "$field_set"; then
2652 eval "field_value=\"\$${cachevar}_license\""
2653 echo "${field_value}"
2659 # func_get_license module
2660 # Input:
2661 # - local_gnulib_path from --local-dir
2662 # - modcache true or false, from --cache-modules/--no-cache-modules
2663 func_get_license ()
2665 # Warn if the License field is missing.
2666 case "$1" in
2667 *-tests ) ;;
2669 license=`func_get_license_raw "$1"`
2670 if test -z "$license"; then
2671 func_warning "module $1 lacks a License"
2674 esac
2675 case "$1" in
2676 parse-datetime )
2677 # These modules are under a weaker license only for the purpose of some
2678 # users who hand-edit it and don't use gnulib-tool. For the regular
2679 # gnulib users they are under a stricter license.
2680 echo "GPL"
2684 func_get_license_raw "$1"
2685 # The default is GPL.
2686 echo "GPL"
2687 } | sed -e 's,^ *$,,' | sed -e 1q
2689 esac
2692 # func_get_maintainer module
2693 # Input:
2694 # - local_gnulib_path from --local-dir
2695 # - modcache true or false, from --cache-modules/--no-cache-modules
2696 func_get_maintainer ()
2698 if ! $modcache; then
2699 func_lookup_file "modules/$1"
2700 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2701 else
2702 func_cache_lookup_module "$1"
2703 # Output the field's value, including the final newline (if any).
2704 if $have_associative; then
2705 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2706 eval 'echo "${modcache_maintainer[$1]}"'
2708 else
2709 eval "field_set=\"\$${cachevar}_maintainer_set\""
2710 if test -n "$field_set"; then
2711 eval "field_value=\"\$${cachevar}_maintainer\""
2712 echo "${field_value}"
2718 # func_get_tests_module module
2719 # Input:
2720 # - local_gnulib_path from --local-dir
2721 func_get_tests_module ()
2723 # The naming convention for tests modules is hardwired: ${module}-tests.
2724 if test -f "$gnulib_dir/modules/$1"-tests \
2725 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1-tests"; then
2726 echo "$1"-tests
2730 # func_get_dependencies_recursively module
2731 # Input:
2732 # - local_gnulib_path from --local-dir
2733 # - modcache true or false, from --cache-modules/--no-cache-modules
2734 func_get_dependencies_recursively ()
2736 # In order to process every module only once (for speed), process an "input
2737 # list" of modules, producing an "output list" of modules. During each round,
2738 # more modules can be queued in the input list. Once a module on the input
2739 # list has been processed, it is added to the "handled list", so we can avoid
2740 # to process it again.
2741 handledmodules=
2742 inmodules="$1"
2743 outmodules=
2744 while test -n "$inmodules"; do
2745 inmodules_this_round="$inmodules"
2746 inmodules= # Accumulator, queue for next round
2747 for module in $inmodules_this_round; do
2748 func_verify_module
2749 if test -n "$module"; then
2750 func_append outmodules " $module"
2751 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2752 for dep in $deps; do
2753 func_append inmodules " $dep"
2754 done
2756 done
2757 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2758 # Remove $handledmodules from $inmodules.
2759 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2760 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2761 done
2762 rm -f "$tmp"/queued-modules
2763 for m in $outmodules; do echo $m; done | LC_ALL=C sort -u
2766 # func_get_link_directive_recursively module
2767 # Input:
2768 # - local_gnulib_path from --local-dir
2769 # - modcache true or false, from --cache-modules/--no-cache-modules
2770 func_get_link_directive_recursively ()
2772 # In order to process every module only once (for speed), process an "input
2773 # list" of modules, producing an "output list" of modules. During each round,
2774 # more modules can be queued in the input list. Once a module on the input
2775 # list has been processed, it is added to the "handled list", so we can avoid
2776 # to process it again.
2777 handledmodules=
2778 inmodules="$1"
2779 outmodules=
2780 while test -n "$inmodules"; do
2781 inmodules_this_round="$inmodules"
2782 inmodules= # Accumulator, queue for next round
2783 for module in $inmodules_this_round; do
2784 func_verify_module
2785 if test -n "$module"; then
2786 if grep '^Link:[ ]*$' "$lookedup_file" >/dev/null; then
2787 # The module description has a 'Link:' field. Ignore the dependencies.
2788 func_append outmodules " $module"
2789 else
2790 # The module description has no 'Link:' field. Recurse through the dependencies.
2791 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2792 for dep in $deps; do
2793 func_append inmodules " $dep"
2794 done
2797 done
2798 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2799 # Remove $handledmodules from $inmodules.
2800 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2801 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2802 done
2803 rm -f "$tmp"/queued-modules
2804 for m in $outmodules; do func_get_link_directive "$m"; done | LC_ALL=C sort -u | sed -e '/^$/d'
2807 # func_acceptable module
2808 # tests whether a module is acceptable.
2809 # Input:
2810 # - avoidlist list of modules to avoid
2811 func_acceptable ()
2813 for avoid in $avoidlist; do
2814 if test "$avoid" = "$1"; then
2815 return 1
2817 done
2818 return 0
2821 # sed expression to keep the first 32 characters of each line.
2822 sed_first_32_chars='s/^\(................................\).*/\1/'
2824 # func_module_shellfunc_name module
2825 # computes the shell function name that will contain the m4 macros for the module.
2826 # Input:
2827 # - macro_prefix prefix to use
2828 # Output:
2829 # - shellfunc shell function name
2830 func_module_shellfunc_name ()
2832 case $1 in
2833 *[!a-zA-Z0-9_]*)
2834 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2836 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2837 esac
2840 # func_module_shellvar_name module
2841 # computes the shell variable name the will be set to true once the m4 macros
2842 # for the module have been executed.
2843 # Output:
2844 # - shellvar shell variable name
2845 func_module_shellvar_name ()
2847 case $1 in
2848 *[!a-zA-Z0-9_]*)
2849 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2851 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2852 esac
2855 # func_module_conditional_name module
2856 # computes the automake conditional name for the module.
2857 # Output:
2858 # - conditional name of automake conditional
2859 func_module_conditional_name ()
2861 case $1 in
2862 *[!a-zA-Z0-9_]*)
2863 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2865 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2866 esac
2869 # func_uncond_add_module B
2870 # notes the presence of B as an unconditional module.
2872 # func_conddep_add_module A B cond
2873 # notes the presence of a conditional dependency from module A to module B,
2874 # subject to the condition that A is enabled and cond is true.
2876 # func_cond_module_p B
2877 # tests whether module B is conditional.
2879 # func_cond_module_condition A B
2880 # returns the condition when B should be enabled as a dependency of A, once the
2881 # m4 code for A has been executed.
2882 # Output: - condition
2884 if $have_associative; then
2885 declare -A conddep_isuncond
2886 declare -A conddep_dependers
2887 declare -A conddep_condition
2888 func_uncond_add_module ()
2890 eval 'conddep_isuncond[$1]=true'
2891 eval 'unset conddep_dependers[$1]'
2893 func_conddep_add_module ()
2895 eval 'isuncond="${conddep_isuncond[$2]}"'
2896 if test -z "$isuncond"; then
2897 # No unconditional dependency to B known at this point.
2898 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2899 eval 'conddep_condition[$1---$2]="$3"'
2902 func_cond_module_p ()
2904 eval 'previous_dependers="${conddep_dependers[$1]}"'
2905 test -n "$previous_dependers"
2907 func_cond_module_condition ()
2909 eval 'condition="${conddep_condition[$1---$2]}"'
2911 else
2912 func_uncond_add_module ()
2914 case $1 in
2915 *[!a-zA-Z0-9_]*)
2916 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2918 suffix=$1 ;;
2919 esac
2920 eval 'conddep_isuncond_'"$suffix"'=true'
2921 eval 'unset conddep_dependers_'"$suffix"
2923 func_conddep_add_module ()
2925 case $2 in
2926 *[!a-zA-Z0-9_]*)
2927 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2929 suffix=$2 ;;
2930 esac
2931 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2932 if test -z "$isuncond"; then
2933 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2934 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2935 eval 'conddep_condition_'"$suffix"'="$3"'
2938 func_cond_module_p ()
2940 case $1 in
2941 *[!a-zA-Z0-9_]*)
2942 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2944 suffix=$1 ;;
2945 esac
2946 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2947 test -n "$previous_dependers"
2949 func_cond_module_condition ()
2951 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2952 eval 'condition="${conddep_condition_'"$suffix"'}"'
2956 # func_modules_transitive_closure
2957 # Input:
2958 # - local_gnulib_path from --local-dir
2959 # - gnu_make true if --gnu-make was given, false otherwise
2960 # - modcache true or false, from --cache-modules/--no-cache-modules
2961 # - modules list of specified modules
2962 # - inctests true if tests should be included, false otherwise
2963 # - incobsolete true if obsolete modules among dependencies should be
2964 # included, blank otherwise
2965 # - inc_cxx_tests true if C++ interoperability tests should be included,
2966 # blank otherwise
2967 # - inc_longrunning_tests true if long-runnings tests should be included,
2968 # blank otherwise
2969 # - inc_privileged_tests true if tests that require root privileges should be
2970 # included, blank otherwise
2971 # - inc_unportable_tests true if tests that fail on some platforms should be
2972 # included, blank otherwise
2973 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2974 # the unit tests of the specified modules should be
2975 # included, blank otherwise
2976 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2977 # the unit tests of the dependencies should be
2978 # included, blank otherwise
2979 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2980 # blank otherwise
2981 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2982 # blank otherwise
2983 # - excl_privileged_tests true if tests that require root privileges should be
2984 # excluded, blank otherwise
2985 # - excl_unportable_tests true if tests that fail on some platforms should be
2986 # excluded, blank otherwise
2987 # - avoidlist list of modules to avoid
2988 # - cond_dependencies true if conditional dependencies shall be supported,
2989 # blank otherwise
2990 # - tmp pathname of a temporary directory
2991 # Output:
2992 # - modules list of modules, including dependencies
2993 # - conddep_dependers, conddep_condition information about conditionally
2994 # enabled modules
2995 func_modules_transitive_closure ()
2997 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2998 # In order to process every module only once (for speed), process an "input
2999 # list" of modules, producing an "output list" of modules. During each round,
3000 # more modules can be queued in the input list. Once a module on the input
3001 # list has been processed, it is added to the "handled list", so we can avoid
3002 # to process it again.
3003 handledmodules=
3004 inmodules="$modules"
3005 outmodules=
3006 fmtc_inc_all_tests="$inc_all_direct_tests"
3007 if test "$cond_dependencies" = true; then
3008 for module in $inmodules; do
3009 func_verify_module
3010 if test -n "$module"; then
3011 if func_acceptable $module; then
3012 func_uncond_add_module $module
3015 done
3017 while test -n "$inmodules"; do
3018 inmodules_this_round="$inmodules"
3019 inmodules= # Accumulator, queue for next round
3020 for module in $inmodules_this_round; do
3021 func_verify_module
3022 if test -n "$module"; then
3023 if func_acceptable $module; then
3024 func_append outmodules " $module"
3025 if test "$cond_dependencies" = true; then
3026 if ! $gnu_make \
3027 && func_get_automake_snippet_conditional $module \
3028 | grep '^if ' > /dev/null; then
3029 # A module whose Makefile.am snippet contains a reference to an
3030 # automake conditional. If we were to use it conditionally, we
3031 # would get an error
3032 # configure: error: conditional "..." was never defined.
3033 # because automake 1.11.1 does not handle nested conditionals
3034 # correctly. As a workaround, make the module unconditional.
3035 func_uncond_add_module $module
3037 if func_cond_module_p $module; then
3038 conditional=true
3039 else
3040 conditional=false
3043 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3044 # Duplicate dependencies are harmless, but Jim wants a warning.
3045 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
3046 if test -n "$duplicated_deps"; then
3047 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
3049 if $inctests; then
3050 testsmodule=`func_get_tests_module $module`
3051 if test -n "$testsmodule"; then
3052 deps="$deps $testsmodule"
3055 for dep in $deps; do
3056 # Determine whether to include the dependency or tests module.
3057 inc=true
3058 for word in `func_get_status $dep`; do
3059 case "$word" in
3060 obsolete)
3061 test -n "$incobsolete" \
3062 || inc=false
3064 c++-test)
3065 test -z "$excl_cxx_tests" \
3066 || inc=false
3067 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
3068 || inc=false
3070 longrunning-test)
3071 test -z "$excl_longrunning_tests" \
3072 || inc=false
3073 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
3074 || inc=false
3076 privileged-test)
3077 test -z "$excl_privileged_tests" \
3078 || inc=false
3079 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
3080 || inc=false
3082 unportable-test)
3083 test -z "$excl_unportable_tests" \
3084 || inc=false
3085 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
3086 || inc=false
3088 *-test)
3089 test -n "$fmtc_inc_all_tests" \
3090 || inc=false
3092 esac
3093 done
3094 if $inc && func_acceptable "$dep"; then
3095 func_append inmodules " $dep"
3096 if test "$cond_dependencies" = true; then
3097 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
3098 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
3099 s/^.*$/true/p
3101 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
3102 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
3104 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
3105 if test "$condition" = true; then
3106 condition=
3108 if test -n "$condition"; then
3109 func_conddep_add_module "$module" "$dep" "$condition"
3110 else
3111 if $conditional; then
3112 func_conddep_add_module "$module" "$dep" true
3113 else
3114 func_uncond_add_module "$dep"
3119 done
3122 done
3123 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
3124 # Remove $handledmodules from $inmodules.
3125 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
3126 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
3127 fmtc_inc_all_tests="$inc_all_indirect_tests"
3128 done
3129 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
3130 rm -f "$tmp"/queued-modules
3133 # func_show_module_list
3134 # Input:
3135 # - specified_modules list of specified modules (one per line, sorted)
3136 # - modules complete list of modules (one per line, sorted)
3137 # - tmp pathname of a temporary directory
3138 func_show_module_list ()
3140 if case "$TERM" in
3141 xterm*) test -t 1;;
3142 *) false;;
3143 esac; then
3144 # Assume xterm compatible escape sequences.
3145 bold_on=`printf '\033[1m'`
3146 bold_off=`printf '\033[0m'`
3147 else
3148 bold_on=
3149 bold_off=
3151 echo "Module list with included dependencies (indented):"
3152 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
3153 echo "$modules" | sed -e '/^$/d' \
3154 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
3155 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
3158 # func_modules_transitive_closure_separately
3159 # Determine main module list and tests-related module list separately.
3160 # The main module list is the transitive closure of the specified modules,
3161 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3162 # is specified, it will consist only of LGPLed source.
3163 # The tests-related module list is the transitive closure of the specified
3164 # modules, including tests modules, minus the main module list excluding
3165 # modules of applicability 'all'. Its lib/* sources (brought in through
3166 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3167 # source, even if --lgpl is specified.
3168 # Input:
3169 # - local_gnulib_path from --local-dir
3170 # - modcache true or false, from --cache-modules/--no-cache-modules
3171 # - specified_modules list of specified modules
3172 # - inctests true if tests should be included, false otherwise
3173 # - incobsolete true if obsolete modules among dependencies should be
3174 # included, blank otherwise
3175 # - inc_cxx_tests true if C++ interoperability tests should be included,
3176 # blank otherwise
3177 # - inc_longrunning_tests true if long-runnings tests should be included,
3178 # blank otherwise
3179 # - inc_privileged_tests true if tests that require root privileges should be
3180 # included, blank otherwise
3181 # - inc_unportable_tests true if tests that fail on some platforms should be
3182 # included, blank otherwise
3183 # - inc_all_direct_tests true if all kinds of problematic unit tests among
3184 # the unit tests of the specified modules should be
3185 # included, blank otherwise
3186 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
3187 # the unit tests of the dependencies should be
3188 # included, blank otherwise
3189 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
3190 # blank otherwise
3191 # - excl_longrunning_tests true if long-runnings tests should be excluded,
3192 # blank otherwise
3193 # - excl_privileged_tests true if tests that require root privileges should be
3194 # excluded, blank otherwise
3195 # - excl_unportable_tests true if tests that fail on some platforms should be
3196 # excluded, blank otherwise
3197 # - avoidlist list of modules to avoid
3198 # - cond_dependencies true if conditional dependencies shall be supported,
3199 # blank otherwise
3200 # - tmp pathname of a temporary directory
3201 # Output:
3202 # - main_modules list of modules, including dependencies
3203 # - testsrelated_modules list of tests-related modules, including dependencies
3204 # - conddep_dependers, conddep_condition information about conditionally
3205 # enabled modules
3206 func_modules_transitive_closure_separately ()
3208 # Determine main module list.
3209 saved_inctests="$inctests"
3210 inctests=false
3211 modules="$specified_modules"
3212 func_modules_transitive_closure
3213 main_modules="$modules"
3214 inctests="$saved_inctests"
3215 if test $verbose -ge 1; then
3216 echo "Main module list:"
3217 echo "$main_modules" | sed -e 's/^/ /'
3219 # Determine tests-related module list.
3220 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3221 testsrelated_modules=`for module in $main_modules; do
3222 if test \`func_get_applicability $module\` = main; then
3223 echo $module
3225 done \
3226 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3227 # If testsrelated_modules consists only of modules with applicability 'all',
3228 # set it to empty (because such modules are only helper modules for other modules).
3229 have_nontrivial_testsrelated_modules=
3230 for module in $testsrelated_modules; do
3231 if test `func_get_applicability $module` != all; then
3232 have_nontrivial_testsrelated_modules=yes
3233 break
3235 done
3236 if test -z "$have_nontrivial_testsrelated_modules"; then
3237 testsrelated_modules=
3239 if test $verbose -ge 1; then
3240 echo "Tests-related module list:"
3241 echo "$testsrelated_modules" | sed -e 's/^/ /'
3245 # func_determine_use_libtests
3246 # Determines whether a $testsbase/libtests.a is needed.
3247 # Input:
3248 # - local_gnulib_path from --local-dir
3249 # - modcache true or false, from --cache-modules/--no-cache-modules
3250 # - testsrelated_modules list of tests-related modules, including dependencies
3251 # Output:
3252 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3253 func_determine_use_libtests ()
3255 use_libtests=false
3256 for module in $testsrelated_modules; do
3257 func_verify_nontests_module
3258 if test -n "$module"; then
3259 all_files=`func_get_filelist $module`
3260 # Test whether some file in $all_files lies in lib/.
3261 for f in $all_files; do
3262 case $f in
3263 lib/*)
3264 use_libtests=true
3265 break 2
3267 esac
3268 done
3270 done
3273 # func_modules_add_dummy
3274 # Input:
3275 # - local_gnulib_path from --local-dir
3276 # - modcache true or false, from --cache-modules/--no-cache-modules
3277 # - modules list of modules, including dependencies
3278 # Output:
3279 # - modules list of modules, including 'dummy' if needed
3280 func_modules_add_dummy ()
3282 # Determine whether any module provides a lib_SOURCES augmentation.
3283 have_lib_SOURCES=
3284 for module in $modules; do
3285 func_verify_nontests_module
3286 if test -n "$module"; then
3287 if test "$cond_dependencies" = true && func_cond_module_p $module; then
3288 # Ignore conditional modules, since they are not guaranteed to
3289 # contribute to lib_SOURCES.
3291 else
3292 # Extract the value of "lib_SOURCES += ...".
3293 for file in `func_get_automake_snippet "$module" | combine_lines |
3294 sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
3295 # Ignore .h files since they are not compiled.
3296 case "$file" in
3297 *.h) ;;
3299 have_lib_SOURCES=yes
3300 break 2
3302 esac
3303 done
3306 done
3307 # Add the dummy module, to make sure the library will be non-empty.
3308 if test -z "$have_lib_SOURCES"; then
3309 if func_acceptable "dummy"; then
3310 func_append modules " dummy"
3315 # func_modules_add_dummy_separately
3316 # Input:
3317 # - local_gnulib_path from --local-dir
3318 # - modcache true or false, from --cache-modules/--no-cache-modules
3319 # - main_modules list of modules, including dependencies
3320 # - testsrelated_modules list of tests-related modules, including dependencies
3321 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3322 # Output:
3323 # - main_modules list of modules, including 'dummy' if needed
3324 # - testsrelated_modules list of tests-related modules, including 'dummy' if
3325 # needed
3326 func_modules_add_dummy_separately ()
3328 # Add the dummy module to the main module list if needed.
3329 modules="$main_modules"
3330 func_modules_add_dummy
3331 main_modules="$modules"
3333 # Add the dummy module to the tests-related module list if needed.
3334 if $use_libtests; then
3335 modules="$testsrelated_modules"
3336 func_modules_add_dummy
3337 testsrelated_modules="$modules"
3341 # func_modules_notice
3342 # Input:
3343 # - local_gnulib_path from --local-dir
3344 # - modcache true or false, from --cache-modules/--no-cache-modules
3345 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3346 # - modules list of modules, including dependencies
3347 func_modules_notice ()
3349 if test $verbose -ge -1; then
3350 for module in $modules; do
3351 func_verify_module
3352 if test -n "$module"; then
3353 msg=`func_get_notice $module`
3354 if test -n "$msg"; then
3355 echo "Notice from module $module:"
3356 echo "$msg" | sed -e 's/^/ /'
3359 done
3363 # func_modules_to_filelist
3364 # Input:
3365 # - local_gnulib_path from --local-dir
3366 # - modcache true or false, from --cache-modules/--no-cache-modules
3367 # - modules list of modules, including dependencies
3368 # Output:
3369 # - files list of files
3370 func_modules_to_filelist ()
3372 files=
3373 for module in $modules; do
3374 func_verify_module
3375 if test -n "$module"; then
3376 fs=`func_get_filelist $module`
3377 func_append files " $fs"
3379 done
3380 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3383 # func_modules_to_filelist_separately
3384 # Determine the final file lists.
3385 # They must be computed separately, because files in lib/* go into
3386 # $sourcebase/ if they are in the main file list but into $testsbase/
3387 # if they are in the tests-related file list. Furthermore lib/dummy.c
3388 # can be in both.
3389 # Input:
3390 # - local_gnulib_path from --local-dir
3391 # - modcache true or false, from --cache-modules/--no-cache-modules
3392 # - main_modules list of modules, including dependencies
3393 # - testsrelated_modules list of tests-related modules, including dependencies
3394 func_modules_to_filelist_separately ()
3396 # Determine final main file list.
3397 modules="$main_modules"
3398 func_modules_to_filelist
3399 main_files="$files"
3400 # Determine final tests-related file list.
3401 modules="$testsrelated_modules"
3402 func_modules_to_filelist
3403 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3404 # Merge both file lists.
3405 sed_remove_empty_lines='/^$/d'
3406 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3407 if test $verbose -ge 0; then
3408 echo "File list:"
3409 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3410 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3414 # func_compute_include_guard_prefix
3415 # Determine include_guard_prefix.
3416 # Input:
3417 # - macro_prefix prefix of gl_LIBOBJS macros to use
3418 # Output:
3419 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3420 # - sed_replace_include_guard_prefix
3421 # sed expression for resolving ${gl_include_guard_prefix}
3422 func_compute_include_guard_prefix ()
3424 if test "$macro_prefix" = gl; then
3425 include_guard_prefix='GL'
3426 else
3427 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3429 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3432 # func_execute_command command [args...]
3433 # Executes a command.
3434 # Uses also the variables
3435 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3436 func_execute_command ()
3438 if test $verbose -ge 0; then
3439 echo "executing $*"
3440 "$@"
3441 else
3442 # Commands like automake produce output to stderr even when they succeed.
3443 # Turn this output off if the command succeeds.
3444 "$@" > "$tmp"/cmdout 2>&1
3445 cmdret=$?
3446 if test $cmdret = 0; then
3447 rm -f "$tmp"/cmdout
3448 else
3449 echo "executing $*"
3450 cat "$tmp"/cmdout 1>&2
3451 rm -f "$tmp"/cmdout
3452 (exit $cmdret)
3457 # func_dest_tmpfilename file
3458 # determines the name of a temporary file (file is relative to destdir).
3459 # Input:
3460 # - destdir target directory
3461 # - doit : if actions shall be executed, false if only to be printed
3462 # - tmp pathname of a temporary directory
3463 # Sets variable:
3464 # - tmpfile absolute filename of the temporary file
3465 func_dest_tmpfilename ()
3467 if $doit; then
3468 # Put the new contents of $file in a file in the same directory (needed
3469 # to guarantee that an 'mv' to "$destdir/$file" works).
3470 tmpfile="$destdir/$1.tmp"
3471 else
3472 # Put the new contents of $file in a file in a temporary directory
3473 # (because the directory of "$file" might not exist).
3474 tmpfile="$tmp"/`basename "$1"`.tmp
3478 # func_is_local_file lookedup_file file
3479 # check whether file should be instantiated from local gnulib directory
3480 func_is_local_file ()
3482 dname=$1
3483 func_remove_suffix dname "/$2"
3484 func_path_foreach "$local_gnulib_path" test %dir% = "$dname"
3487 # func_should_link
3488 # determines whether the file $f should be copied, symlinked, or hardlinked.
3489 # Input:
3490 # - copymode copy mode for files in general
3491 # - lcopymode copy mode for files from local_gnulib_path
3492 # - f the original file name
3493 # - lookedup_file name of the merged (combined) file
3494 # Sets variable:
3495 # - copyaction copy or symlink or hardlink
3496 func_should_link ()
3498 if test -n "$lcopymode" && func_is_local_file "$lookedup_file" "$f"; then
3499 copyaction="$lcopymode"
3500 else
3501 if test -n "$copymode"; then
3502 copyaction="$copymode"
3503 else
3504 copyaction=copy
3509 # func_add_file
3510 # copies a file from gnulib into the destination directory. The destination
3511 # is known to not exist.
3512 # Input:
3513 # - destdir target directory
3514 # - local_gnulib_path from --local-dir
3515 # - modcache true or false, from --cache-modules/--no-cache-modules
3516 # - f the original file name
3517 # - lookedup_file name of the merged (combined) file
3518 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3519 # - g the rewritten file name
3520 # - tmpfile absolute filename of the temporary file
3521 # - doit : if actions shall be executed, false if only to be printed
3522 # - copymode copy mode for files in general
3523 # - lcopymode copy mode for files from local_gnulib_path
3524 func_add_file ()
3526 if $doit; then
3527 echo "Copying file $g"
3528 func_should_link
3529 if test "$copyaction" = symlink \
3530 && test -z "$lookedup_tmp" \
3531 && cmp -s "$lookedup_file" "$tmpfile"; then
3532 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3533 else
3534 if test "$copyaction" = hardlink \
3535 && test -z "$lookedup_tmp" \
3536 && cmp -s "$lookedup_file" "$tmpfile"; then
3537 func_hardlink "$lookedup_file" "$destdir/$g"
3538 else
3539 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3542 else
3543 echo "Copy file $g"
3547 # func_update_file
3548 # copies a file from gnulib into the destination directory. The destination
3549 # is known to exist.
3550 # Input:
3551 # - destdir target directory
3552 # - local_gnulib_path from --local-dir
3553 # - modcache true or false, from --cache-modules/--no-cache-modules
3554 # - f the original file name
3555 # - lookedup_file name of the merged (combined) file
3556 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3557 # - g the rewritten file name
3558 # - tmpfile absolute filename of the temporary file
3559 # - doit : if actions shall be executed, false if only to be printed
3560 # - copymode copy mode for files in general
3561 # - lcopymode copy mode for files from local_gnulib_path
3562 # - already_present nonempty if the file should already exist, empty otherwise
3563 func_update_file ()
3565 if cmp -s "$destdir/$g" "$tmpfile"; then
3566 : # The file has not changed.
3567 else
3568 # Replace the file.
3569 if $doit; then
3570 if test -n "$already_present"; then
3571 echo "Updating file $g (backup in ${g}~)"
3572 else
3573 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3575 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3576 func_should_link
3577 if test "$copyaction" = symlink \
3578 && test -z "$lookedup_tmp" \
3579 && cmp -s "$lookedup_file" "$tmpfile"; then
3580 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3581 else
3582 if test "$copyaction" = hardlink \
3583 && test -z "$lookedup_tmp" \
3584 && cmp -s "$lookedup_file" "$tmpfile"; then
3585 func_hardlink "$lookedup_file" "$destdir/$g"
3586 else
3587 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3590 else
3591 if test -n "$already_present"; then
3592 echo "Update file $g (backup in ${g}~)"
3593 else
3594 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3600 # func_emit_lib_Makefile_am
3601 # emits the contents of library makefile to standard output.
3602 # Input:
3603 # - local_gnulib_path from --local-dir
3604 # - modcache true or false, from --cache-modules/--no-cache-modules
3605 # - modules list of modules, including dependencies
3606 # - libname library name
3607 # - pobase directory relative to destdir where to place *.po files
3608 # - auxdir directory relative to destdir where to place build aux files
3609 # - gnu_make true if --gnu-make was given, false otherwise
3610 # - makefile_name from --makefile-name
3611 # - libtool true if libtool will be used, false or blank otherwise
3612 # - macro_prefix prefix of gl_LIBOBJS macros to use
3613 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3614 # - witness_c_macro from --witness-c-macro
3615 # - actioncmd (optional) command that will reproduce this invocation
3616 # - for_test true if creating a package for testing, false otherwise
3617 # - sed_replace_include_guard_prefix
3618 # sed expression for resolving ${gl_include_guard_prefix}
3619 # - destfile filename relative to destdir of makefile being generated
3620 # Input/Output:
3621 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
3622 # list of edits to be done to Makefile.am variables
3623 # Output:
3624 # - uses_subdirs nonempty if object files in subdirs exist
3625 func_emit_lib_Makefile_am ()
3628 # When using GNU make, or when creating an includable Makefile.am snippet,
3629 # augment variables with += instead of assigning them.
3630 if $gnu_make || test -n "$makefile_name"; then
3631 assign='+='
3632 else
3633 assign='='
3635 if test "$libtool" = true; then
3636 libext=la
3637 perhapsLT=LT
3638 sed_eliminate_LDFLAGS="$sed_noop"
3639 else
3640 libext=a
3641 perhapsLT=
3642 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3644 if $for_test; then
3645 # When creating a package for testing: Attempt to provoke failures,
3646 # especially link errors, already during "make" rather than during
3647 # "make check", because "make check" is not possible in a cross-compiling
3648 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3649 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3650 else
3651 sed_transform_check_PROGRAMS="$sed_noop"
3653 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3654 $gnu_make ||
3655 echo "## Process this file with automake to produce Makefile.in."
3656 func_emit_copyright_notice
3657 if test -n "$actioncmd"; then
3658 printf '# Reproduce by:\n%s\n' "$actioncmd"
3660 echo
3661 uses_subdirs=
3663 for module in $modules; do
3664 func_verify_nontests_module
3665 if test -n "$module"; then
3667 func_get_automake_snippet_conditional "$module" |
3668 LC_ALL=C \
3669 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3670 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3671 -e "$sed_eliminate_LDFLAGS" \
3672 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3673 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3674 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3675 -e "$sed_transform_check_PROGRAMS" \
3676 -e "$sed_replace_include_guard_prefix"
3677 if test "$module" = 'alloca'; then
3678 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3679 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3681 } | combine_lines "${libname}_${libext}_SOURCES" > "$tmp"/amsnippet1
3683 func_get_automake_snippet_unconditional "$module" |
3684 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3685 } > "$tmp"/amsnippet2
3686 # Skip the contents if it's entirely empty.
3687 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3688 echo "## begin gnulib module $module"
3689 if $gnu_make; then
3690 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
3691 convert_to_gnu_make='s/^if \(.*\)/ifneq (,$(\1))/'
3692 else
3693 convert_to_gnu_make=
3695 echo
3696 if test "$cond_dependencies" = true; then
3697 if func_cond_module_p "$module"; then
3698 func_module_conditional_name "$module"
3699 if $gnu_make; then
3700 echo "ifneq (,\$($conditional))"
3701 else
3702 echo "if $conditional"
3706 sed "$convert_to_gnu_make" "$tmp"/amsnippet1
3707 if test "$cond_dependencies" = true; then
3708 if func_cond_module_p "$module"; then
3709 echo "endif"
3712 sed "$convert_to_gnu_make" "$tmp"/amsnippet2
3713 if $gnu_make; then
3714 echo "endif"
3716 echo "## end gnulib module $module"
3717 echo
3719 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3720 # Test whether there are some source files in subdirectories.
3721 for f in `func_get_filelist "$module"`; do
3722 case $f in
3723 lib/*/*.c)
3724 uses_subdirs=yes
3725 break
3727 esac
3728 done
3730 done
3731 } > "$tmp"/allsnippets
3732 if test -z "$makefile_name"; then
3733 # If there are source files in subdirectories, prevent collision of the
3734 # object files (example: hash.c and libxml/hash.c).
3735 subdir_options=
3736 if test -n "$uses_subdirs"; then
3737 subdir_options=' subdir-objects'
3739 echo "AUTOMAKE_OPTIONS = 1.11 gnits${subdir_options}"
3741 echo
3742 if test -z "$makefile_name"; then
3743 echo "SUBDIRS ="
3744 echo "noinst_HEADERS ="
3745 echo "noinst_LIBRARIES ="
3746 echo "noinst_LTLIBRARIES ="
3747 # Automake versions < 1.11.4 create an empty pkgdatadir at
3748 # installation time if you specify pkgdata_DATA to empty.
3749 # See automake bugs #10997 and #11030:
3750 # * https://debbugs.gnu.org/10997
3751 # * https://debbugs.gnu.org/11030
3752 # So we need this workaround.
3753 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3754 echo "pkgdata_DATA ="
3756 echo "EXTRA_DIST ="
3757 echo "BUILT_SOURCES ="
3758 echo "SUFFIXES ="
3760 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3761 if test -z "$makefile_name"; then
3762 echo "MOSTLYCLEANDIRS ="
3763 echo "CLEANFILES ="
3764 echo "DISTCLEANFILES ="
3765 echo "MAINTAINERCLEANFILES ="
3767 if $gnu_make; then
3768 echo "# Start of GNU Make output."
3770 # Put autoconf output into a temporary file, so that its exit status
3771 # can be checked from the shell. Signal any error by putting a
3772 # syntax error into the output makefile.
3773 ${AUTOCONF} -t 'AC_SUBST:$1 = @$1@' "$configure_ac" \
3774 >"$tmp"/makeout 2>"$tmp"/makeout2 &&
3775 LC_ALL=C sort -u "$tmp"/makeout || {
3776 echo "== gnulib-tool GNU Make output failed as follows =="
3777 sed 's/^/# stderr: /' "$tmp"/makeout2
3779 rm -f "$tmp"/makeout "$tmp"/makeout2
3781 echo "# End of GNU Make output."
3782 else
3783 echo "# No GNU Make output."
3785 # Execute edits that apply to the Makefile.am being generated.
3786 edit=0
3787 while test $edit != $makefile_am_edits; do
3788 edit=`expr $edit + 1`
3789 eval dir=\"\$makefile_am_edit${edit}_dir\"
3790 eval var=\"\$makefile_am_edit${edit}_var\"
3791 eval val=\"\$makefile_am_edit${edit}_val\"
3792 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
3793 if test -n "$var"; then
3794 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3795 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
3796 # The added subdirectory ${val} needs to be mentioned after '.'.
3797 # Since we don't have '.' among SUBDIRS so far, add it now.
3798 val=". ${val}"
3800 echo "${var} += ${val}"
3801 eval "makefile_am_edit${edit}_var="
3804 done
3805 if test -n "$witness_c_macro"; then
3806 cppflags_part1=" -D$witness_c_macro=1"
3807 else
3808 cppflags_part1=
3810 if $for_test; then
3811 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3812 else
3813 cppflags_part2=
3815 if test -z "$makefile_name"; then
3816 echo
3817 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3818 echo "AM_CFLAGS ="
3819 else
3820 if test -n "$cppflags_part1$cppflags_part2"; then
3821 echo
3822 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3825 echo
3826 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3827 || { test -n "$makefile_name" \
3828 && test -f "$sourcebase/Makefile.am" \
3829 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3830 }; then
3831 # One of the snippets or the user's Makefile.am already specifies an
3832 # installation location for the library. Don't confuse automake by saying
3833 # it should not be installed.
3835 else
3836 # By default, the generated library should not be installed.
3837 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3839 echo
3840 echo "${libname}_${libext}_SOURCES ="
3841 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3842 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3843 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3844 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3845 echo "EXTRA_${libname}_${libext}_SOURCES ="
3846 if test "$libtool" = true; then
3847 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3848 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3849 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3850 # the link dependencies of all modules.
3851 for module in $modules; do
3852 func_verify_nontests_module
3853 if test -n "$module"; then
3854 func_get_link_directive "$module"
3856 done \
3857 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3858 | LC_ALL=C sort -u \
3859 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3861 echo
3862 if test -n "$pobase"; then
3863 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3864 echo
3866 cat "$tmp"/allsnippets \
3867 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3868 echo
3869 echo "mostlyclean-local: mostlyclean-generic"
3870 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3871 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3872 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3873 echo " fi; \\"
3874 echo " done; \\"
3875 echo " :"
3876 rm -f "$tmp"/allsnippets
3879 # func_emit_po_Makevars
3880 # emits the contents of po/ makefile parameterization to standard output.
3881 # Input:
3882 # - local_gnulib_path from --local-dir
3883 # - modcache true or false, from --cache-modules/--no-cache-modules
3884 # - sourcebase directory relative to destdir where to place source code
3885 # - pobase directory relative to destdir where to place *.po files
3886 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3887 func_emit_po_Makevars ()
3889 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3890 func_emit_copyright_notice
3891 echo
3892 echo "# Usually the message domain is the same as the package name."
3893 echo "# But here it has a '-gnulib' suffix."
3894 echo "DOMAIN = ${po_domain}-gnulib"
3895 echo
3896 echo "# These two variables depend on the location of this directory."
3897 echo "subdir = ${pobase}"
3898 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3899 echo
3900 cat <<\EOF
3901 # These options get passed to xgettext.
3902 XGETTEXT_OPTIONS = \
3903 --keyword=_ --flag=_:1:pass-c-format \
3904 --keyword=N_ --flag=N_:1:pass-c-format \
3905 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3906 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3907 --flag=error:3:c-format --flag=error_at_line:5:c-format
3909 # This is the copyright holder that gets inserted into the header of the
3910 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3911 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3913 # This is the email address or URL to which the translators shall report
3914 # bugs in the untranslated strings:
3915 # - Strings which are not entire sentences, see the maintainer guidelines
3916 # in the GNU gettext documentation, section 'Preparing Strings'.
3917 # - Strings which use unclear terms or require additional context to be
3918 # understood.
3919 # - Strings which make invalid assumptions about notation of date, time or
3920 # money.
3921 # - Pluralisation problems.
3922 # - Incorrect English spelling.
3923 # - Incorrect formatting.
3924 # It can be your email address, or a mailing list address where translators
3925 # can write to without being subscribed, or the URL of a web page through
3926 # which the translators can contact you.
3927 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3929 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3930 # message catalogs shall be used. It is usually empty.
3931 EXTRA_LOCALE_CATEGORIES =
3933 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3934 # context. Possible values are "yes" and "no". Set this to yes if the
3935 # package uses functions taking also a message context, like pgettext(), or
3936 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3937 USE_MSGCTXT = no
3941 # func_emit_po_POTFILES_in
3942 # emits the file list to be passed to xgettext to standard output.
3943 # Input:
3944 # - local_gnulib_path from --local-dir
3945 # - modcache true or false, from --cache-modules/--no-cache-modules
3946 # - sourcebase directory relative to destdir where to place source code
3947 # - files list of new files
3948 func_emit_po_POTFILES_in ()
3950 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3951 func_emit_copyright_notice
3952 echo
3953 echo "# List of files which contain translatable strings."
3954 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3957 # func_emit_tests_Makefile_am witness_macro
3958 # emits the contents of tests makefile to standard output.
3959 # Input:
3960 # - local_gnulib_path from --local-dir
3961 # - modcache true or false, from --cache-modules/--no-cache-modules
3962 # - modules list of modules, including dependencies
3963 # - libname library name
3964 # - auxdir directory relative to destdir where to place build aux files
3965 # - gnu_make true if --gnu-make was given, false otherwise
3966 # - makefile_name from --makefile-name
3967 # - libtool true if libtool will be used, false or blank otherwise
3968 # - sourcebase relative directory containing lib source code
3969 # - m4base relative directory containing autoconf macros
3970 # - testsbase relative directory containing unit test code
3971 # - macro_prefix prefix of gl_LIBOBJS macros to use
3972 # - witness_c_macro from --witness-c-macro
3973 # - for_test true if creating a package for testing, false otherwise
3974 # - single_configure true if a single configure file should be generated,
3975 # false for a separate configure file for the tests
3976 # - use_libtests true if a libtests.a should be built, false otherwise
3977 # - sed_replace_include_guard_prefix
3978 # sed expression for resolving ${gl_include_guard_prefix}
3979 # - destfile filename relative to destdir of makefile being generated
3980 # Input/Output:
3981 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
3982 # list of edits to be done to Makefile.am variables
3983 # Output:
3984 # - uses_subdirs nonempty if object files in subdirs exist
3985 func_emit_tests_Makefile_am ()
3987 witness_macro="$1"
3988 if test "$libtool" = true; then
3989 libext=la
3990 perhapsLT=LT
3991 sed_eliminate_LDFLAGS="$sed_noop"
3992 else
3993 libext=a
3994 perhapsLT=
3995 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3997 if $for_test; then
3998 # When creating a package for testing: Attempt to provoke failures,
3999 # especially link errors, already during "make" rather than during
4000 # "make check", because "make check" is not possible in a cross-compiling
4001 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
4002 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
4003 else
4004 sed_transform_check_PROGRAMS="$sed_noop"
4006 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
4007 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
4008 echo "## Process this file with automake to produce Makefile.in."
4009 func_emit_copyright_notice
4010 echo
4011 uses_subdirs=
4013 for module in $modules; do
4014 if $for_test && ! $single_configure; then
4015 func_verify_tests_module
4016 else
4017 func_verify_module
4019 if test -n "$module"; then
4021 func_get_automake_snippet "$module" |
4022 LC_ALL=C \
4023 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
4024 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
4025 -e "$sed_eliminate_LDFLAGS" \
4026 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
4027 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
4028 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
4029 -e "$sed_transform_check_PROGRAMS" \
4030 -e "$sed_replace_include_guard_prefix"
4031 if $use_libtests && test "$module" = 'alloca'; then
4032 echo "libtests_a_LIBADD += @ALLOCA@"
4033 echo "libtests_a_DEPENDENCIES += @ALLOCA@"
4035 } > "$tmp"/amsnippet
4036 # Skip the contents if it's entirely empty.
4037 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
4038 # Mention long-running tests at the end.
4039 ofd=3
4040 for word in `func_get_status "$module"`; do
4041 if test "$word" = 'longrunning-test'; then
4042 ofd=4
4043 break
4045 done
4046 { echo "## begin gnulib module $module"
4047 if $gnu_make; then
4048 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
4050 echo
4051 cat "$tmp"/amsnippet
4052 if $gnu_make; then
4053 echo "endif"
4055 echo "## end gnulib module $module"
4056 echo
4057 } >&$ofd
4059 rm -f "$tmp"/amsnippet
4060 # Test whether there are some source files in subdirectories.
4061 for f in `func_get_filelist "$module"`; do
4062 case $f in
4063 lib/*/*.c | tests/*/*.c)
4064 uses_subdirs=yes
4065 break
4067 esac
4068 done
4070 done
4071 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
4072 # Generate dependencies here, since it eases the debugging of test failures.
4073 # If there are source files in subdirectories, prevent collision of the
4074 # object files (example: hash.c and libxml/hash.c).
4075 subdir_options=
4076 if test -n "$uses_subdirs"; then
4077 subdir_options=' subdir-objects'
4079 echo "AUTOMAKE_OPTIONS = 1.11 foreign${subdir_options}"
4080 echo
4081 if $for_test && ! $single_configure; then
4082 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
4083 echo
4085 # Nothing is being added to SUBDIRS; nevertheless the existence of this
4086 # variable is needed to avoid an error from automake:
4087 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
4088 echo "SUBDIRS = ."
4089 echo "TESTS ="
4090 echo "XFAIL_TESTS ="
4091 echo "TESTS_ENVIRONMENT ="
4092 echo "noinst_PROGRAMS ="
4093 if ! $for_test; then
4094 echo "check_PROGRAMS ="
4096 echo "EXTRA_PROGRAMS ="
4097 echo "noinst_HEADERS ="
4098 echo "noinst_LIBRARIES ="
4099 if $use_libtests; then
4100 if $for_test; then
4101 echo "noinst_LIBRARIES += libtests.a"
4102 else
4103 echo "check_LIBRARIES = libtests.a"
4106 # Automake versions < 1.11.4 create an empty pkgdatadir at
4107 # installation time if you specify pkgdata_DATA to empty.
4108 # See automake bugs #10997 and #11030:
4109 # * https://debbugs.gnu.org/10997
4110 # * https://debbugs.gnu.org/11030
4111 # So we need this workaround.
4112 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
4113 echo "pkgdata_DATA ="
4115 echo "EXTRA_DIST ="
4116 echo "BUILT_SOURCES ="
4117 echo "SUFFIXES ="
4118 echo "MOSTLYCLEANFILES = core *.stackdump"
4119 echo "MOSTLYCLEANDIRS ="
4120 echo "CLEANFILES ="
4121 echo "DISTCLEANFILES ="
4122 echo "MAINTAINERCLEANFILES ="
4123 # Execute edits that apply to the Makefile.am being generated.
4124 edit=0
4125 while test $edit != $makefile_am_edits; do
4126 edit=`expr $edit + 1`
4127 eval dir=\"\$makefile_am_edit${edit}_dir\"
4128 eval var=\"\$makefile_am_edit${edit}_var\"
4129 eval val=\"\$makefile_am_edit${edit}_val\"
4130 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
4131 if test -n "$var"; then
4132 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
4133 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
4134 # The added subdirectory ${val} needs to be mentioned after '.'.
4135 # But we have '.' among SUBDIRS already, so do nothing.
4138 echo "${var} += ${val}"
4139 eval "makefile_am_edit${edit}_var="
4142 done
4143 echo
4144 echo "AM_CPPFLAGS = \\"
4145 if $for_test; then
4146 echo " -DGNULIB_STRICT_CHECKING=1 \\"
4148 if test -n "$witness_c_macro"; then
4149 echo " -D$witness_c_macro=1 \\"
4151 if test -n "${witness_macro}"; then
4152 echo " -D@${witness_macro}@=1 \\"
4154 echo " -I. -I\$(srcdir) \\"
4155 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
4156 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
4157 echo
4158 local_ldadd_before=''
4159 local_ldadd_after=''
4160 if $use_libtests; then
4161 # All test programs need to be linked with libtests.a.
4162 # It needs to be passed to the linker before ${libname}.${libext}, since
4163 # the tests-related modules depend on the main modules.
4164 # It also needs to be passed to the linker after ${libname}.${libext}
4165 # because the latter might contain incomplete modules (such as the 'error'
4166 # module whose dependency to 'progname' is voluntarily omitted).
4167 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
4168 # not matter.
4169 local_ldadd_before=' libtests.a'
4170 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
4172 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
4173 echo
4174 if $use_libtests; then
4175 echo "libtests_a_SOURCES ="
4176 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
4177 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
4178 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
4179 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
4180 echo "EXTRA_libtests_a_SOURCES ="
4181 # The circular dependency in LDADD requires this.
4182 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
4183 echo
4185 # Many test scripts use ${EXEEXT} or ${srcdir}.
4186 # EXEEXT is defined by AC_PROG_CC through autoconf.
4187 # srcdir is defined by autoconf and automake.
4188 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
4189 echo
4190 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
4191 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
4192 echo "# Clean up after Solaris cc."
4193 echo "clean-local:"
4194 echo " rm -rf SunWS_cache"
4195 echo
4196 echo "mostlyclean-local: mostlyclean-generic"
4197 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
4198 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
4199 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
4200 echo " fi; \\"
4201 echo " done; \\"
4202 echo " :"
4203 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
4206 # func_emit_initmacro_start macro_prefix
4207 # emits the first few statements of the gl_INIT macro to standard output.
4208 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4209 func_emit_initmacro_start ()
4211 macro_prefix_arg="$1"
4212 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
4213 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
4214 # LIBOBJS. The purpose is to allow several gnulib instantiations under
4215 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
4216 # flexibility.)
4217 # Furthermore it avoids an automake error like this when a Makefile.am
4218 # that uses pieces of gnulib also uses $(LIBOBJ):
4219 # automatically discovered file `error.c' should not be explicitly mentioned
4220 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
4221 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
4222 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
4223 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
4224 # automatically discovered file `error.c' should not be explicitly mentioned
4225 # We let automake know about the files to be distributed through the
4226 # EXTRA_lib_SOURCES variable.
4227 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
4228 # Create data variables for checking the presence of files that are mentioned
4229 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
4230 # because we want the check to happen when the configure file is created,
4231 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
4232 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
4233 # in which to expect them.
4234 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
4235 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
4236 echo " gl_COMMON"
4239 # func_emit_initmacro_end macro_prefix
4240 # emits the last few statements of the gl_INIT macro to standard output.
4241 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4242 func_emit_initmacro_end ()
4244 macro_prefix_arg="$1"
4245 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
4246 # The check is performed only when autoconf is run from the directory where
4247 # the configure.ac resides; if it is run from a different directory, the
4248 # check is skipped.
4249 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
4250 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
4251 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
4252 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
4253 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
4254 echo " exit 1"
4255 echo " fi"
4256 echo " done])dnl"
4257 echo " m4_if(m4_sysval, [0], [],"
4258 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
4259 echo " ])"
4260 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
4261 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
4262 echo " m4_popdef([AC_LIBSOURCES])"
4263 echo " m4_popdef([AC_REPLACE_FUNCS])"
4264 echo " m4_popdef([AC_LIBOBJ])"
4265 echo " AC_CONFIG_COMMANDS_PRE(["
4266 echo " ${macro_prefix_arg}_libobjs="
4267 echo " ${macro_prefix_arg}_ltlibobjs="
4268 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
4269 echo " # Remove the extension."
4270 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
4271 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
4272 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
4273 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
4274 echo " done"
4275 echo " fi"
4276 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
4277 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
4278 echo " ])"
4281 # func_emit_initmacro_done macro_prefix sourcebase
4282 # emits a few statements after the gl_INIT macro to standard output.
4283 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4284 # - sourcebase directory relative to destdir where to place source code
4285 func_emit_initmacro_done ()
4287 macro_prefix_arg="$1"
4288 sourcebase_arg="$2"
4289 echo
4290 echo "# Like AC_LIBOBJ, except that the module name goes"
4291 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4292 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
4293 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
4294 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
4295 echo "])"
4296 echo
4297 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
4298 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4299 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
4300 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
4301 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
4302 echo "])"
4303 echo
4304 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
4305 echo "# expected is derived from the gnulib-tool parameterization,"
4306 echo "# and alloca is special cased (for the alloca-opt module)."
4307 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
4308 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
4309 echo " m4_foreach([_gl_NAME], [\$1], ["
4310 echo " m4_if(_gl_NAME, [alloca.c], [], ["
4311 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
4312 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
4313 echo " ])"
4314 echo " ])"
4315 echo "])"
4318 # func_emit_autoconf_snippet indentation
4319 # emits the autoconf snippet of a module.
4320 # Input:
4321 # - indentation spaces to prepend on each line
4322 # - local_gnulib_path from --local-dir
4323 # - modcache true or false, from --cache-modules/--no-cache-modules
4324 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4325 # - sed_replace_include_guard_prefix
4326 # sed expression for resolving ${gl_include_guard_prefix}
4327 # - module the module name
4328 # - toplevel true or false. 'false' means a subordinate use of
4329 # gnulib-tool.
4330 # - disable_libtool true or false. It tells whether to disable libtool
4331 # handling even if it has been specified through the
4332 # command line options.
4333 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4334 # invocations.
4335 func_emit_autoconf_snippet ()
4337 indentation="$1"
4338 if { case $module in
4339 gnumakefile | maintainer-makefile)
4340 # These modules are meant to be used only in the top-level directory.
4341 $toplevel ;;
4343 true ;;
4344 esac
4345 }; then
4346 func_get_autoconf_snippet "$module" \
4347 | sed -e '/^$/d;' -e "s/^/$indentation/" \
4348 -e "$sed_replace_build_aux" \
4349 -e "$sed_replace_include_guard_prefix" \
4350 | { if $disable_libtool; then
4351 sed -e 's/\$gl_cond_libtool/false/g' \
4352 -e 's/gl_libdeps/gltests_libdeps/g' \
4353 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4354 else
4358 | { if $disable_gettext; then
4359 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
4360 else
4361 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
4362 # autopoint through at least GNU gettext version 0.18.2.
4363 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
4366 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
4367 echo 'changequote(,)dnl'
4368 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4369 echo 'changequote([, ])dnl'
4370 echo 'AC_SUBST([LTALLOCA])'
4375 # func_emit_autoconf_snippets modules referenceable_modules verifier toplevel disable_libtool disable_gettext
4376 # collects and emit the autoconf snippets of a set of modules.
4377 # Input:
4378 # - local_gnulib_path from --local-dir
4379 # - modcache true or false, from --cache-modules/--no-cache-modules
4380 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4381 # - sed_replace_include_guard_prefix
4382 # sed expression for resolving ${gl_include_guard_prefix}
4383 # - modules the list of modules.
4384 # - referenceable_modules the list of modules which may be referenced as dependencies.
4385 # - verifier one of func_verify_module, func_verify_nontests_module,
4386 # func_verify_tests_module. It selects the subset of
4387 # $modules to consider.
4388 # - toplevel true or false. 'false' means a subordinate use of
4389 # gnulib-tool.
4390 # - disable_libtool true or false. It tells whether to disable libtool
4391 # handling even if it has been specified through the
4392 # command line options.
4393 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4394 # invocations.
4395 func_emit_autoconf_snippets ()
4397 referenceable_modules="$2"
4398 verifier="$3"
4399 toplevel="$4"
4400 disable_libtool="$5"
4401 disable_gettext="$6"
4402 if test "$cond_dependencies" = true; then
4403 for m in $referenceable_modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
4404 # Emit the autoconf code for the unconditional modules.
4405 for module in $1; do
4406 eval $verifier
4407 if test -n "$module"; then
4408 if func_cond_module_p "$module"; then
4410 else
4411 func_emit_autoconf_snippet " "
4414 done
4415 # Initialize the shell variables indicating that the modules are enabled.
4416 for module in $1; do
4417 eval $verifier
4418 if test -n "$module"; then
4419 if func_cond_module_p "$module"; then
4420 func_module_shellvar_name "$module"
4421 echo " $shellvar=false"
4424 done
4425 # Emit the autoconf code for the conditional modules, each in a separate
4426 # function. This makes it possible to support cycles among conditional
4427 # modules.
4428 for module in $1; do
4429 eval $verifier
4430 if test -n "$module"; then
4431 if func_cond_module_p "$module"; then
4432 func_module_shellfunc_name "$module"
4433 func_module_shellvar_name "$module"
4434 echo " $shellfunc ()"
4435 echo ' {'
4436 echo " if ! \$$shellvar; then"
4437 func_emit_autoconf_snippet " "
4438 echo " $shellvar=true"
4439 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4440 # Intersect $deps with the modules list $1.
4441 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4442 for dep in $deps; do
4443 if func_cond_module_p "$dep"; then
4444 func_module_shellfunc_name "$dep"
4445 func_cond_module_condition "$module" "$dep"
4446 if test "$condition" != true; then
4447 echo " if $condition; then"
4448 echo " $shellfunc"
4449 echo ' fi'
4450 else
4451 echo " $shellfunc"
4453 else
4454 # The autoconf code for $dep has already been emitted above and
4455 # therefore is already executed when this function is run.
4458 done
4459 echo ' fi'
4460 echo ' }'
4463 done
4464 # Emit the dependencies from the unconditional to the conditional modules.
4465 for module in $1; do
4466 eval $verifier
4467 if test -n "$module"; then
4468 if func_cond_module_p "$module"; then
4470 else
4471 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4472 # Intersect $deps with the modules list $1.
4473 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4474 for dep in $deps; do
4475 if func_cond_module_p "$dep"; then
4476 func_module_shellfunc_name "$dep"
4477 func_cond_module_condition "$module" "$dep"
4478 if test "$condition" != true; then
4479 echo " if $condition; then"
4480 echo " $shellfunc"
4481 echo ' fi'
4482 else
4483 echo " $shellfunc"
4485 else
4486 # The autoconf code for $dep has already been emitted above and
4487 # therefore is already executed when this code is run.
4490 done
4493 done
4494 # Define the Automake conditionals.
4495 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4496 for module in $1; do
4497 eval $verifier
4498 if test -n "$module"; then
4499 if func_cond_module_p "$module"; then
4500 func_module_conditional_name "$module"
4501 func_module_shellvar_name "$module"
4502 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4505 done
4506 else
4507 # Ignore the conditions, and enable all modules unconditionally.
4508 for module in $1; do
4509 eval $verifier
4510 if test -n "$module"; then
4511 func_emit_autoconf_snippet " "
4513 done
4517 # func_emit_pre_early_macros require indentation modules
4518 # The require parameter can be ':' (AC_REQUIRE) or 'false' (direct call).
4519 func_emit_pre_early_macros ()
4521 echo
4522 echo "${2}# Pre-early section."
4523 if $1; then
4524 _pre_early_snippet="echo \"${2}AC_REQUIRE([\$_pre_early_macro])\""
4525 else
4526 _pre_early_snippet="echo \"${2}\$_pre_early_macro\""
4529 # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB. Doing
4530 # AC_REQUIRE in configure-ac.early is not early enough.
4531 _pre_early_macro="gl_USE_SYSTEM_EXTENSIONS"
4532 case "${nl}${3}${nl}" in
4533 *${nl}extensions${nl}*) eval "$_pre_early_snippet" ;;
4534 esac
4536 _pre_early_macro="gl_PROG_AR_RANLIB"
4537 eval "$_pre_early_snippet"
4538 echo
4541 # func_reconstruct_cached_dir
4542 # callback for func_reconstruct_cached_local_gnulib_path
4543 # Input:
4544 # - destdir from --dir
4545 # Output:
4546 # - local_gnulib_path restored '--local-dir' path from cache
4547 func_reconstruct_cached_dir ()
4549 cached_dir=$1
4550 if test -n "$cached_dir"; then
4551 case "$destdir" in
4553 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4555 case "$cached_dir" in
4557 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4559 func_relconcat "$destdir" "$cached_dir"
4560 func_path_append local_gnulib_path "$relconcat" ;;
4561 esac ;;
4562 esac
4566 # func_reconstruct_cached_local_gnulib_path
4567 # reconstruct local_gnulib_path from cached_local_gnulib_path to be set
4568 # relatively to $destdir again.
4569 # Input:
4570 # - cached_local_gnulib_path local_gnulib_path stored within gnulib-cache.m4
4571 # - destdir from --dir
4572 # Output:
4573 # - local_gnulib_path restored '--local-dir' path from cache
4574 func_reconstruct_cached_local_gnulib_path ()
4576 func_path_foreach "$cached_local_gnulib_path" func_reconstruct_cached_dir %dir%
4579 # func_import modules
4580 # Uses also the variables
4581 # - mode import or add-import or remove-import or update
4582 # - destdir target directory
4583 # - local_gnulib_path from --local-dir
4584 # - modcache true or false, from --cache-modules/--no-cache-modules
4585 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4586 # - libname library name
4587 # - supplied_libname true if --lib was given, blank otherwise
4588 # - sourcebase directory relative to destdir where to place source code
4589 # - m4base directory relative to destdir where to place *.m4 macros
4590 # - pobase directory relative to destdir where to place *.po files
4591 # - docbase directory relative to destdir where to place doc files
4592 # - testsbase directory relative to destdir where to place unit test code
4593 # - auxdir directory relative to destdir where to place build aux files
4594 # - inctests true if --with-tests was given, false otherwise
4595 # - incobsolete true if --with-obsolete was given, blank otherwise
4596 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4597 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4598 # otherwise
4599 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4600 # otherwise
4601 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4602 # otherwise
4603 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4604 # - avoidlist list of modules to avoid, from --avoid
4605 # - cond_dependencies true if --conditional-dependencies was given, false if
4606 # --no-conditional-dependencies was given, blank otherwise
4607 # - lgpl yes or a number if library's license shall be LGPL,
4608 # blank otherwise
4609 # - makefile_name from --makefile-name
4610 # - libtool true if --libtool was given, false if --no-libtool was
4611 # given, blank otherwise
4612 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4613 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4614 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4615 # - witness_c_macro from --witness-c-macro
4616 # - vc_files true if --vc-files was given, false if --no-vc-files was
4617 # given, blank otherwise
4618 # - autoconf_minversion minimum supported autoconf version
4619 # - doit : if actions shall be executed, false if only to be printed
4620 # - copymode copy mode for files in general
4621 # - lcopymode copy mode for files from local_gnulib_path
4622 # - do_copyrights true if copyright notices in files should be replaced,
4623 # blank otherwise
4624 func_import ()
4626 # Get the cached settings.
4627 # In 'import' mode, we read them only for the purpose of knowing the old
4628 # installed file list, and don't use them as defaults.
4629 cached_local_gnulib_path=
4630 cached_specified_modules=
4631 cached_incobsolete=
4632 cached_inc_cxx_tests=
4633 cached_inc_longrunning_tests=
4634 cached_inc_privileged_tests=
4635 cached_inc_unportable_tests=
4636 cached_inc_all_tests=
4637 cached_avoidlist=
4638 cached_sourcebase=
4639 cached_m4base=
4640 cached_pobase=
4641 cached_docbase=
4642 cached_testsbase=
4643 cached_inctests=
4644 cached_libname=
4645 cached_lgpl=
4646 cached_makefile_name=
4647 cached_cond_dependencies=
4648 cached_libtool=
4649 cached_macro_prefix=
4650 cached_po_domain=
4651 cached_witness_c_macro=
4652 cached_vc_files=
4653 cached_files=
4654 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4655 cached_libtool=false
4656 my_sed_traces='
4657 s,#.*$,,
4658 s,^dnl .*$,,
4659 s, dnl .*$,,
4660 /gl_LOCAL_DIR(/ {
4661 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_path="\1",p
4663 /gl_MODULES(/ {
4666 s/)/)/
4671 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4673 /gl_WITH_OBSOLETE/ {
4674 s,^.*$,cached_incobsolete=true,p
4676 /gl_WITH_CXX_TESTS/ {
4677 s,^.*$,cached_inc_cxx_tests=true,p
4679 /gl_WITH_LONGRUNNING_TESTS/ {
4680 s,^.*$,cached_inc_longrunning_tests=true,p
4682 /gl_WITH_PRIVILEGED_TESTS/ {
4683 s,^.*$,cached_inc_privileged_tests=true,p
4685 /gl_WITH_UNPORTABLE_TESTS/ {
4686 s,^.*$,cached_inc_unportable_tests=true,p
4688 /gl_WITH_ALL_TESTS/ {
4689 s,^.*$,cached_inc_all_tests=true,p
4691 /gl_AVOID(/ {
4692 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4694 /gl_SOURCE_BASE(/ {
4695 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4697 /gl_M4_BASE(/ {
4698 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4700 /gl_PO_BASE(/ {
4701 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4703 /gl_DOC_BASE(/ {
4704 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4706 /gl_TESTS_BASE(/ {
4707 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4709 /gl_WITH_TESTS/ {
4710 s,^.*$,cached_inctests=true,p
4712 /gl_LIB(/ {
4713 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4715 /gl_LGPL(/ {
4716 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4718 /gl_LGPL/ {
4719 s,^.*$,cached_lgpl=yes,p
4721 /gl_MAKEFILE_NAME(/ {
4722 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4724 /gl_CONDITIONAL_DEPENDENCIES/ {
4725 s,^.*$,cached_cond_dependencies=true,p
4727 /gl_LIBTOOL/ {
4728 s,^.*$,cached_libtool=true,p
4730 /gl_MACRO_PREFIX(/ {
4731 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4733 /gl_PO_DOMAIN(/ {
4734 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4736 /gl_WITNESS_C_MACRO(/ {
4737 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4739 /gl_VC_FILES(/ {
4740 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4742 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4743 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4744 my_sed_traces='
4745 s,#.*$,,
4746 s,^dnl .*$,,
4747 s, dnl .*$,,
4748 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4749 s,^.*$,cached_files=",p
4753 s,^\]).*$,",
4755 s,["$`\\],,g
4762 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4766 if test "$mode" = import; then
4767 # In 'import' mode, the new set of specified modules overrides the cached
4768 # set of modules. Ignore the cached settings.
4769 specified_modules="$1"
4770 else
4771 # Merge the cached settings with the specified ones.
4772 # The m4base must be the same as expected from the pathname.
4773 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4774 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4776 # The local_gnulib_path defaults to the cached one. Recall that the cached one
4777 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4778 if test -z "$local_gnulib_path"; then
4779 func_reconstruct_cached_local_gnulib_path
4781 case $mode in
4782 add-import)
4783 # Append the cached and the specified module names. So that
4784 # "gnulib-tool --add-import foo" means to add the module foo.
4785 specified_modules="$cached_specified_modules $1"
4787 remove-import)
4788 # Take the cached module names, minus the specified module names.
4789 specified_modules=
4790 if $have_associative; then
4791 # Use an associative array, for O(N) worst-case run time.
4792 declare -A to_remove
4793 for m in $1; do
4794 eval 'to_remove[$m]=yes'
4795 done
4796 for module in $cached_specified_modules; do
4797 if eval 'test -z "${to_remove[$module]}"'; then
4798 func_append specified_modules "$module "
4800 done
4801 else
4802 # This loop has O(N**2) worst-case run time.
4803 for module in $cached_specified_modules; do
4804 to_remove=
4805 for m in $1; do
4806 if test "$m" = "$module"; then
4807 to_remove=yes
4808 break
4810 done
4811 if test -z "$to_remove"; then
4812 func_append specified_modules "$module "
4814 done
4817 update)
4818 # Take the cached module names. There are no specified module names.
4819 specified_modules="$cached_specified_modules"
4821 esac
4822 # Included obsolete modules among the dependencies if specified either way.
4823 if test -z "$incobsolete"; then
4824 incobsolete="$cached_incobsolete"
4826 # Included special kinds of tests modules among the dependencies if specified
4827 # either way.
4828 if test -z "$inc_cxx_tests"; then
4829 inc_cxx_tests="$cached_inc_cxx_tests"
4831 if test -z "$inc_longrunning_tests"; then
4832 inc_longrunning_tests="$cached_inc_longrunning_tests"
4834 if test -z "$inc_privileged_tests"; then
4835 inc_privileged_tests="$cached_inc_privileged_tests"
4837 if test -z "$inc_unportable_tests"; then
4838 inc_unportable_tests="$cached_inc_unportable_tests"
4840 if test -z "$inc_all_tests"; then
4841 inc_all_tests="$cached_inc_all_tests"
4843 # Append the cached and the specified avoidlist. This is probably better
4844 # than dropping the cached one when --avoid is specified at least once.
4845 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4846 avoidlist=`echo $avoidlist`
4848 # The sourcebase defaults to the cached one.
4849 if test -z "$sourcebase"; then
4850 sourcebase="$cached_sourcebase"
4851 if test -z "$sourcebase"; then
4852 func_fatal_error "missing --source-base option"
4855 # The pobase defaults to the cached one.
4856 if test -z "$pobase"; then
4857 pobase="$cached_pobase"
4859 # The docbase defaults to the cached one.
4860 if test -z "$docbase"; then
4861 docbase="$cached_docbase"
4862 if test -z "$docbase"; then
4863 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."
4866 # The testsbase defaults to the cached one.
4867 if test -z "$testsbase"; then
4868 testsbase="$cached_testsbase"
4869 if test -z "$testsbase"; then
4870 func_fatal_error "missing --tests-base option"
4873 # Require the tests if specified either way.
4874 if ! $inctests; then
4875 inctests="$cached_inctests"
4876 if test -z "$inctests"; then
4877 inctests=false
4880 # The libname defaults to the cached one.
4881 if test -z "$supplied_libname"; then
4882 libname="$cached_libname"
4883 if test -z "$libname"; then
4884 func_fatal_error "missing --lib option"
4887 # Require LGPL if specified either way.
4888 if test -z "$lgpl"; then
4889 lgpl="$cached_lgpl"
4891 # The makefile_name defaults to the cached one.
4892 if test -z "$makefile_name"; then
4893 makefile_name="$cached_makefile_name"
4895 # Use conditional dependencies if specified either way.
4896 if test -z "$cond_dependencies"; then
4897 cond_dependencies="$cached_cond_dependencies"
4899 # Use libtool if specified either way, or if guessed.
4900 if test -z "$libtool"; then
4901 if test -n "$cached_m4base"; then
4902 libtool="$cached_libtool"
4903 else
4904 libtool="$guessed_libtool"
4907 # The macro_prefix defaults to the cached one.
4908 if test -z "$macro_prefix"; then
4909 macro_prefix="$cached_macro_prefix"
4910 if test -z "$macro_prefix"; then
4911 func_fatal_error "missing --macro-prefix option"
4914 # The po_domain defaults to the cached one.
4915 if test -z "$po_domain"; then
4916 po_domain="$cached_po_domain"
4918 # The witness_c_macro defaults to the cached one.
4919 if test -z "$witness_c_macro"; then
4920 witness_c_macro="$cached_witness_c_macro"
4922 # The vc_files defaults to the cached one.
4923 if test -z "$vc_files"; then
4924 vc_files="$cached_vc_files"
4926 # Ensure constraints.
4927 if test "$cond_dependencies" = true && $inctests; then
4928 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4929 func_exit 1
4932 # --without-*-tests options are not supported here.
4933 excl_cxx_tests=
4934 excl_longrunning_tests=
4935 excl_privileged_tests=
4936 excl_unportable_tests=
4938 # Canonicalize the list of specified modules.
4939 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4941 # Include all kinds of tests modules if --with-all-tests was specified.
4942 inc_all_direct_tests="$inc_all_tests"
4943 inc_all_indirect_tests="$inc_all_tests"
4945 # Determine final module list.
4946 modules="$specified_modules"
4947 func_modules_transitive_closure
4948 if test $verbose -ge 0; then
4949 func_show_module_list
4951 final_modules="$modules"
4953 # Determine main module list and tests-related module list separately.
4954 func_modules_transitive_closure_separately
4956 # Determine whether a $testsbase/libtests.a is needed.
4957 func_determine_use_libtests
4959 # Add the dummy module to the main module list or to the tests-related module
4960 # list if needed.
4961 func_modules_add_dummy_separately
4963 # If --lgpl, verify that the licenses of modules are compatible.
4964 if test -n "$lgpl"; then
4965 license_incompatibilities=
4966 for module in $main_modules; do
4967 license=`func_get_license $module`
4968 case $license in
4969 'GPLed build tool') ;;
4970 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4972 case "$lgpl" in
4973 yes | 3)
4974 case $license in
4975 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
4976 *) func_append license_incompatibilities "$module $license$nl" ;;
4977 esac
4979 3orGPLv2)
4980 case $license in
4981 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
4982 *) func_append license_incompatibilities "$module $license$nl" ;;
4983 esac
4986 case $license in
4987 LGPLv2+) ;;
4988 *) func_append license_incompatibilities "$module $license$nl" ;;
4989 esac
4991 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4992 esac
4994 esac
4995 done
4996 if test -n "$license_incompatibilities"; then
4997 # Format the license incompatibilities as a table.
4998 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4999 s,^\(.................................................[^ ]*\) *, \1 ,'
5000 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
5001 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
5005 # Show banner notice of every module.
5006 modules="$main_modules"
5007 func_modules_notice
5009 # Determine script to apply to imported library files.
5010 sed_transform_lib_file=
5011 for module in $main_modules; do
5012 if test $module = config-h; then
5013 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
5014 sed_transform_lib_file=$sed_transform_lib_file'
5015 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
5017 break
5019 done
5020 sed_transform_main_lib_file="$sed_transform_lib_file"
5021 if test -n "$do_copyrights"; then
5022 if test -n "$lgpl"; then
5023 # Update license.
5024 case "$lgpl" in
5025 yes | 3)
5026 sed_transform_main_lib_file=$sed_transform_main_lib_file'
5027 s/GNU General/GNU Lesser General/g
5028 s/General Public License/Lesser General Public License/g
5029 s/Lesser Lesser General Public License/Lesser General Public License/g
5032 3orGPLv2)
5033 sed_transform_main_lib_file=$sed_transform_main_lib_file'
5034 /^ *This program is free software/i\
5035 This program is free software: you can redistribute it and\/or\
5036 modify it under the terms of either:\
5038 * the GNU Lesser General Public License as published by the Free\
5039 Software Foundation; either version 3 of the License, or (at your\
5040 option) any later version.\
5044 * the GNU General Public License as published by the Free\
5045 Software Foundation; either version 2 of the License, or (at your\
5046 option) any later version.\
5048 or both in parallel, as here.
5049 /^ *This program is free software/,/^$/d
5053 sed_transform_main_lib_file=$sed_transform_main_lib_file'
5054 s/GNU General/GNU Lesser General/g
5055 s/General Public License/Lesser General Public License/g
5056 s/Lesser Lesser General Public License/Lesser General Public License/g
5058 s/version [23]\([ ,]\)/version 2.1\1/g
5061 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
5062 esac
5063 else
5064 # Update license.
5065 sed_transform_main_lib_file=$sed_transform_main_lib_file'
5066 s/GNU Lesser General/GNU General/g
5067 s/Lesser General Public License/General Public License/g
5069 s/GNU Library General/GNU General/g
5070 s/Library General Public License/General Public License/g
5072 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
5077 # Determine script to apply to auxiliary files that go into $auxdir/.
5078 sed_transform_build_aux_file=
5079 if test -n "$do_copyrights"; then
5080 # Update license.
5081 sed_transform_build_aux_file=$sed_transform_build_aux_file'
5082 s/GNU Lesser General/GNU General/g
5083 s/Lesser General Public License/General Public License/g
5085 s/GNU Library General/GNU General/g
5086 s/Library General Public License/General Public License/g
5088 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
5092 # Determine script to apply to library files that go into $testsbase/.
5093 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
5094 if test -n "$do_copyrights"; then
5095 # Update license.
5096 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
5097 s/GNU Lesser General/GNU General/g
5098 s/Lesser General Public License/General Public License/g
5100 s/GNU Library General/GNU General/g
5101 s/Library General Public License/General Public License/g
5103 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
5107 # Determine the final file lists.
5108 func_modules_to_filelist_separately
5110 test -n "$files" \
5111 || func_fatal_error "refusing to do nothing"
5113 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
5114 new_files="$files m4/gnulib-tool.m4"
5115 old_files="$cached_files"
5116 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
5117 func_append old_files " m4/gnulib-tool.m4"
5120 rewritten='%REWRITTEN%'
5121 sed_rewrite_old_files="\
5122 s,^build-aux/,$rewritten$auxdir/,
5123 s,^doc/,$rewritten$cached_docbase/,
5124 s,^lib/,$rewritten$cached_sourcebase/,
5125 s,^m4/,$rewritten$cached_m4base/,
5126 s,^tests/,$rewritten$cached_testsbase/,
5127 s,^tests=lib/,$rewritten$cached_testsbase/,
5128 s,^top/,$rewritten,
5129 s,^$rewritten,,"
5130 sed_rewrite_new_files="\
5131 s,^build-aux/,$rewritten$auxdir/,
5132 s,^doc/,$rewritten$docbase/,
5133 s,^lib/,$rewritten$sourcebase/,
5134 s,^m4/,$rewritten$m4base/,
5135 s,^tests/,$rewritten$testsbase/,
5136 s,^tests=lib/,$rewritten$testsbase/,
5137 s,^top/,$rewritten,
5138 s,^$rewritten,,"
5140 # Determine whether to put anything into $testsbase.
5141 testsfiles=`echo "$files" | sed -n -e 's,^tests/,,p' -e 's,^tests=lib/,,p'`
5142 if test -n "$testsfiles"; then
5143 gentests=true
5144 else
5145 gentests=false
5148 # Create directories.
5149 { echo "$sourcebase"
5150 echo "$m4base"
5151 if test -n "$pobase"; then
5152 echo "$pobase"
5154 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
5155 if test -n "$docfiles"; then
5156 echo "$docbase"
5158 if $gentests; then
5159 echo "$testsbase"
5161 echo "$auxdir"
5162 for f in $files; do echo $f; done \
5163 | sed -e "$sed_rewrite_new_files" \
5164 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5165 | LC_ALL=C sort -u
5166 } > "$tmp"/dirs
5167 { # Rearrange file descriptors. Needed because "while ... done < ..."
5168 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5169 exec 5<&0 < "$tmp"/dirs
5170 while read d; do
5171 if test ! -d "$destdir/$d"; then
5172 if $doit; then
5173 echo "Creating directory $destdir/$d"
5174 mkdir -p "$destdir/$d" || func_fatal_error "failed"
5175 else
5176 echo "Create directory $destdir/$d"
5179 done
5180 exec 0<&5 5<&-
5183 # Copy files or make symbolic links or hard links. Remove obsolete files.
5184 added_files=''
5185 removed_files=''
5186 delimiter=' '
5187 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5188 # representing the files according to the last gnulib-tool invocation.
5189 for f in $old_files; do echo $f; done \
5190 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
5191 | LC_ALL=C sort \
5192 > "$tmp"/old-files
5193 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5194 # representing the files after this gnulib-tool invocation.
5195 for f in $new_files; do echo $f; done \
5196 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
5197 | LC_ALL=C sort \
5198 > "$tmp"/new-files
5199 # First the files that are in old-files, but not in new-files:
5200 sed_take_first_column='s,'"$delimiter"'.*,,'
5201 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
5202 # Remove the file. Do nothing if the user already removed it.
5203 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
5204 if $doit; then
5205 echo "Removing file $g (backup in ${g}~)"
5206 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
5207 else
5208 echo "Remove file $g (backup in ${g}~)"
5210 func_append removed_files "$g$nl"
5212 done
5213 # func_add_or_update handles a file that ought to be present afterwards.
5214 # Uses parameters
5215 # - f the original file name
5216 # - g the rewritten file name
5217 # - already_present nonempty if the file should already exist, empty
5218 # otherwise
5219 func_add_or_update ()
5221 of="$f"
5222 case "$f" in
5223 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5224 esac
5225 func_dest_tmpfilename "$g"
5226 func_lookup_file "$f"
5227 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5228 case "$f" in
5229 *.class | *.mo )
5230 # Don't process binary files with sed.
5233 if test -n "$sed_transform_main_lib_file"; then
5234 case "$of" in
5235 lib/*)
5236 sed -e "$sed_transform_main_lib_file" \
5237 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5239 esac
5241 if test -n "$sed_transform_build_aux_file"; then
5242 case "$of" in
5243 build-aux/*)
5244 sed -e "$sed_transform_build_aux_file" \
5245 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5247 esac
5249 if test -n "$sed_transform_testsrelated_lib_file"; then
5250 case "$of" in
5251 tests=lib/*)
5252 sed -e "$sed_transform_testsrelated_lib_file" \
5253 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5255 esac
5258 esac
5259 if test -f "$destdir/$g"; then
5260 # The file already exists.
5261 func_update_file
5262 else
5263 # Install the file.
5264 # Don't protest if the file should be there but isn't: it happens
5265 # frequently that developers don't put autogenerated files under version control.
5266 func_add_file
5267 func_append added_files "$g$nl"
5269 rm -f "$tmpfile"
5271 # Then the files that are in new-files, but not in old-files:
5272 sed_take_last_column='s,^.*'"$delimiter"',,'
5273 already_present=
5274 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
5275 | sed -e "$sed_take_last_column" \
5276 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
5277 { # Rearrange file descriptors. Needed because "while ... done < ..."
5278 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5279 exec 5<&0 < "$tmp"/added-files
5280 while read g f; do
5281 func_add_or_update
5282 done
5283 exec 0<&5 5<&-
5285 # Then the files that are in new-files and in old-files:
5286 already_present=true
5287 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
5288 | sed -e "$sed_take_last_column" \
5289 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
5290 { # Rearrange file descriptors. Needed because "while ... done < ..."
5291 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5292 exec 5<&0 < "$tmp"/kept-files
5293 while read g f; do
5294 func_add_or_update
5295 done
5296 exec 0<&5 5<&-
5299 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
5300 actioncmd="# gnulib-tool --import"
5302 # Local helper.
5303 func_append_local_dir ()
5305 func_append "$1" " --local-dir=$2"
5307 func_path_foreach "$local_gnulib_path" func_append_local_dir actioncmd %dir%
5309 # Break the action command log into multiple lines.
5310 # Emacs puts some gnulib-tool log lines in its source repository, and
5311 # git send-email rejects patch lines longer than 998 characters.
5312 # Also, config.status uses awk, and the HP-UX 11.00 awk fails if a
5313 # line has length >= 3071; similarly, the IRIX 6.5 awk fails if a
5314 # line has length >= 3072.
5315 func_append_actionarg ()
5317 func_append actioncmd " \\$nl# $1"
5319 func_append_actionarg "--lib=$libname"
5320 func_append_actionarg "--source-base=$sourcebase"
5321 func_append_actionarg "--m4-base=$m4base"
5322 if test -n "$pobase"; then
5323 func_append_actionarg "--po-base=$pobase"
5325 func_append_actionarg "--doc-base=$docbase"
5326 func_append_actionarg "--tests-base=$testsbase"
5327 func_append_actionarg "--aux-dir=$auxdir"
5328 if $inctests; then
5329 func_append_actionarg "--with-tests"
5331 if test -n "$incobsolete"; then
5332 func_append_actionarg "--with-obsolete"
5334 if test -n "$inc_cxx_tests"; then
5335 func_append_actionarg "--with-c++-tests"
5337 if test -n "$inc_longrunning_tests"; then
5338 func_append_actionarg "--with-longrunning-tests"
5340 if test -n "$inc_privileged_tests"; then
5341 func_append_actionarg "--with-privileged-tests"
5343 if test -n "$inc_unportable_tests"; then
5344 func_append_actionarg "--with-unportable-tests"
5346 if test -n "$inc_all_tests"; then
5347 func_append_actionarg "--with-all-tests"
5349 if test -n "$lgpl"; then
5350 if test "$lgpl" = yes; then
5351 func_append_actionarg "--lgpl"
5352 else
5353 func_append_actionarg "--lgpl=$lgpl"
5356 if $gnu_make; then
5357 func_append_actionarg "--gnu-make"
5359 if test -n "$makefile_name"; then
5360 func_append_actionarg "--makefile-name=$makefile_name"
5362 if test "$cond_dependencies" = true; then
5363 func_append_actionarg "--conditional-dependencies"
5364 else
5365 func_append_actionarg "--no-conditional-dependencies"
5367 if test "$libtool" = true; then
5368 func_append_actionarg "--libtool"
5369 else
5370 func_append_actionarg "--no-libtool"
5372 func_append_actionarg "--macro-prefix=$macro_prefix"
5373 if test -n "$po_domain"; then
5374 func_append_actionarg "--po-domain=$po_domain"
5376 if test -n "$witness_c_macro"; then
5377 func_append_actionarg "--witness-c-macro=$witness_c_macro"
5379 if test -n "$vc_files"; then
5380 if test "$vc_files" = true; then
5381 func_append_actionarg "--vc-files"
5382 else
5383 func_append_actionarg "--no-vc-files"
5386 for module in $avoidlist; do
5387 func_append_actionarg "--avoid=$module"
5388 done
5389 for module in $specified_modules; do
5390 func_append_actionarg "$module"
5391 done
5393 # Determine include_guard_prefix.
5394 func_compute_include_guard_prefix
5396 # Default the makefile name to Makefile.am.
5397 if test -n "$makefile_name"; then
5398 makefile_am=$makefile_name
5399 else
5400 makefile_am=Makefile.am
5403 # Create normal Makefile.ams.
5404 for_test=false
5406 # Setup list of Makefile.am edits that are to be performed afterwards.
5407 # Some of these edits apply to files that we will generate; others are
5408 # under the responsibility of the developer.
5409 makefile_am_edits=0
5410 # func_note_Makefile_am_edit dir var value [dotfirst]
5411 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
5412 # ${value}.
5413 # If ${dotfirst} is non-empty, this mention needs to be present after '.'.
5414 # This is a special hack for the SUBDIRS variable, cf.
5415 # <https://www.gnu.org/software/automake/manual/html_node/Subdirectories.html>.
5416 func_note_Makefile_am_edit ()
5418 makefile_am_edits=`expr $makefile_am_edits + 1`
5419 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
5420 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
5421 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
5422 eval makefile_am_edit${makefile_am_edits}_dotfirst=\"\$4\"
5424 if test "$makefile_am" = Makefile.am; then
5425 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
5426 sourcebase_base=`basename "$sourcebase"`
5427 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
5429 if test -n "$pobase"; then
5430 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
5431 pobase_base=`basename "$pobase"`
5432 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
5434 if $inctests; then
5435 if test "$makefile_am" = Makefile.am; then
5436 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
5437 testsbase_base=`basename "$testsbase"`
5438 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base" true
5441 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
5443 # Find the first parent directory of $m4base that contains or will contain
5444 # a Makefile.am.
5445 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
5446 s,//*$,/,'
5447 sed_butlast='s,[^/][^/]*//*$,,'
5448 dir1="${m4base}/"; dir2=""
5449 while test -n "$dir1" \
5450 && ! { test -f "${destdir}/${dir1}Makefile.am" \
5451 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5452 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5453 || { $gentests \
5454 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
5455 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
5456 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
5457 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
5458 done
5459 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
5462 # Create library makefile.
5463 func_dest_tmpfilename $sourcebase/$makefile_am
5464 destfile="$sourcebase/$makefile_am"
5465 modules="$main_modules"
5466 func_emit_lib_Makefile_am > "$tmpfile"
5467 if test -f "$destdir"/$sourcebase/$makefile_am; then
5468 if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
5469 rm -f "$tmpfile"
5470 else
5471 if $doit; then
5472 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5473 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
5474 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5475 else
5476 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5477 rm -f "$tmpfile"
5480 else
5481 if $doit; then
5482 echo "Creating $sourcebase/$makefile_am"
5483 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5484 else
5485 echo "Create $sourcebase/$makefile_am"
5486 rm -f "$tmpfile"
5488 func_append added_files "$sourcebase/$makefile_am$nl"
5491 # Create po/ directory.
5492 if test -n "$pobase"; then
5493 # Create po makefile and auxiliary files.
5494 for file in Makefile.in.in remove-potcdate.sin; do
5495 func_dest_tmpfilename $pobase/$file
5496 func_lookup_file build-aux/po/$file
5497 cat "$lookedup_file" > "$tmpfile"
5498 if test -f "$destdir"/$pobase/$file; then
5499 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
5500 rm -f "$tmpfile"
5501 else
5502 if $doit; then
5503 echo "Updating $pobase/$file (backup in $pobase/$file~)"
5504 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
5505 mv -f "$tmpfile" "$destdir"/$pobase/$file
5506 else
5507 echo "Update $pobase/$file (backup in $pobase/$file~)"
5508 rm -f "$tmpfile"
5511 else
5512 if $doit; then
5513 echo "Creating $pobase/$file"
5514 mv -f "$tmpfile" "$destdir"/$pobase/$file
5515 else
5516 echo "Create $pobase/$file"
5517 rm -f "$tmpfile"
5519 func_append added_files "$pobase/$file$nl"
5521 done
5522 # Create po makefile parameterization, part 1.
5523 func_dest_tmpfilename $pobase/Makevars
5524 func_emit_po_Makevars > "$tmpfile"
5525 if test -f "$destdir"/$pobase/Makevars; then
5526 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
5527 rm -f "$tmpfile"
5528 else
5529 if $doit; then
5530 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
5531 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
5532 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5533 else
5534 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
5535 rm -f "$tmpfile"
5538 else
5539 if $doit; then
5540 echo "Creating $pobase/Makevars"
5541 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5542 else
5543 echo "Create $pobase/Makevars"
5544 rm -f "$tmpfile"
5546 func_append added_files "$pobase/Makevars$nl"
5548 # Create po makefile parameterization, part 2.
5549 func_dest_tmpfilename $pobase/POTFILES.in
5550 func_emit_po_POTFILES_in > "$tmpfile"
5551 if test -f "$destdir"/$pobase/POTFILES.in; then
5552 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5553 rm -f "$tmpfile"
5554 else
5555 if $doit; then
5556 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5557 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5558 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5559 else
5560 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5561 rm -f "$tmpfile"
5564 else
5565 if $doit; then
5566 echo "Creating $pobase/POTFILES.in"
5567 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5568 else
5569 echo "Create $pobase/POTFILES.in"
5570 rm -f "$tmpfile"
5572 func_append added_files "$pobase/POTFILES.in$nl"
5574 # Fetch PO files.
5575 TP_URL="https://translationproject.org/latest/"
5576 if $doit; then
5577 echo "Fetching gnulib PO files from $TP_URL"
5578 (cd "$destdir"/$pobase \
5579 && wget --no-verbose --mirror --level=1 -nd -A.po -P . "${TP_URL}gnulib/"
5581 else
5582 echo "Fetch gnulib PO files from $TP_URL"
5584 # Create po/LINGUAS.
5585 if $doit; then
5586 func_dest_tmpfilename $pobase/LINGUAS
5587 (cd "$destdir"/$pobase \
5588 && { echo '# Set of available languages.'
5589 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5591 ) > "$tmpfile"
5592 if test -f "$destdir"/$pobase/LINGUAS; then
5593 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5594 rm -f "$tmpfile"
5595 else
5596 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5597 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5598 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5600 else
5601 echo "Creating $pobase/LINGUAS"
5602 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5603 func_append added_files "$pobase/LINGUAS$nl"
5605 else
5606 if test -f "$destdir"/$pobase/LINGUAS; then
5607 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5608 else
5609 echo "Create $pobase/LINGUAS"
5614 # func_count_relative_local_gnulib_path
5615 # gl_LOCAL_DIR requires local_gnulib_path to be set relatively to destdir
5616 # Input:
5617 # - local_gnulib_path from --local-dir
5618 # - destdir from --dir
5619 # Output:
5620 # - relative_local_dir path to be stored into gl_LOCAL_DIR
5621 func_count_relative_local_gnulib_path ()
5623 relative_local_gnulib_path=
5624 save_IFS="$IFS"
5625 IFS="$PATH_SEPARATOR"
5626 for local_dir in $local_gnulib_path
5628 IFS="$save_IFS"
5629 # Store the local_dir relative to destdir.
5630 case "$local_dir" in
5631 "" | /*)
5632 relative_local_dir="$local_dir" ;;
5634 case "$destdir" in
5635 /*) relative_local_dir="$local_dir" ;;
5637 # destdir, local_dir are both relative.
5638 func_relativize "$destdir" "$local_dir"
5639 relative_local_dir="$reldir" ;;
5640 esac ;;
5641 esac
5642 func_path_append relative_local_gnulib_path "$relative_local_dir"
5643 done
5644 IFS="$save_IFS"
5647 # Create m4/gnulib-cache.m4.
5648 func_dest_tmpfilename $m4base/gnulib-cache.m4
5650 func_emit_copyright_notice
5651 echo "#"
5652 echo "# This file represents the specification of how gnulib-tool is used."
5653 echo "# It acts as a cache: It is written and read by gnulib-tool."
5654 echo "# In projects that use version control, this file is meant to be put under"
5655 echo "# version control, like the configure.ac and various Makefile.am files."
5656 echo
5657 echo
5658 echo "# Specification in the form of a command-line invocation:"
5659 printf '%s\n' "$actioncmd"
5660 echo
5661 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5662 func_count_relative_local_gnulib_path
5663 echo "gl_LOCAL_DIR([$relative_local_gnulib_path])"
5664 echo "gl_MODULES(["
5665 echo "$specified_modules" | sed -e 's/^/ /g'
5666 echo "])"
5667 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5668 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5669 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5670 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5671 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5672 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5673 echo "gl_AVOID([$avoidlist])"
5674 echo "gl_SOURCE_BASE([$sourcebase])"
5675 echo "gl_M4_BASE([$m4base])"
5676 echo "gl_PO_BASE([$pobase])"
5677 echo "gl_DOC_BASE([$docbase])"
5678 echo "gl_TESTS_BASE([$testsbase])"
5679 if $inctests; then
5680 echo "gl_WITH_TESTS"
5682 echo "gl_LIB([$libname])"
5683 if test -n "$lgpl"; then
5684 if test "$lgpl" = yes; then
5685 echo "gl_LGPL"
5686 else
5687 echo "gl_LGPL([$lgpl])"
5690 echo "gl_MAKEFILE_NAME([$makefile_name])"
5691 if test "$cond_dependencies" = true; then
5692 echo "gl_CONDITIONAL_DEPENDENCIES"
5694 if test "$libtool" = true; then
5695 echo "gl_LIBTOOL"
5697 echo "gl_MACRO_PREFIX([$macro_prefix])"
5698 echo "gl_PO_DOMAIN([$po_domain])"
5699 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5700 if test -n "$vc_files"; then
5701 echo "gl_VC_FILES([$vc_files])"
5703 ) > "$tmpfile"
5704 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5705 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
5706 rm -f "$tmpfile"
5707 else
5708 if $doit; then
5709 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5710 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5711 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5712 else
5713 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5714 if false; then
5715 cat "$tmpfile"
5716 echo
5717 echo "# gnulib-cache.m4 ends here"
5719 rm -f "$tmpfile"
5722 else
5723 if $doit; then
5724 echo "Creating $m4base/gnulib-cache.m4"
5725 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5726 else
5727 echo "Create $m4base/gnulib-cache.m4"
5728 cat "$tmpfile"
5729 rm -f "$tmpfile"
5733 # Create m4/gnulib-comp.m4.
5734 func_dest_tmpfilename $m4base/gnulib-comp.m4
5736 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5737 func_emit_copyright_notice
5738 echo "#"
5739 echo "# This file represents the compiled summary of the specification in"
5740 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5741 echo "# to be invoked from configure.ac."
5742 echo "# In projects that use version control, this file can be treated like"
5743 echo "# other built files."
5744 echo
5745 echo
5746 echo "# This macro should be invoked from $configure_ac, in the section"
5747 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5748 echo "# any checks for libraries, header files, types and library functions."
5749 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5750 echo "["
5751 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5752 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5753 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5754 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5756 func_emit_pre_early_macros : ' ' "$final_modules"
5758 if ! $gnu_make && test -n "$uses_subdirs"; then
5759 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5761 for module in $final_modules; do
5762 func_verify_module
5763 if test -n "$module"; then
5764 echo "# Code from module $module:"
5765 func_get_autoconf_early_snippet "$module"
5767 done \
5768 | sed -e '/^$/d;' -e 's/^/ /'
5769 echo "])"
5770 echo
5771 echo "# This macro should be invoked from $configure_ac, in the section"
5772 echo "# \"Check for header files, types and library functions\"."
5773 echo "AC_DEFUN([${macro_prefix}_INIT],"
5774 echo "["
5775 if test "$libtool" = true; then
5776 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5777 echo " gl_cond_libtool=true"
5778 else
5779 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5780 echo " gl_cond_libtool=false"
5781 echo " gl_libdeps="
5782 echo " gl_ltlibdeps="
5784 if test "$auxdir" != "build-aux"; then
5785 sed_replace_build_aux='
5787 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5788 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5791 else
5792 sed_replace_build_aux="$sed_noop"
5794 echo " gl_m4_base='$m4base'"
5795 func_emit_initmacro_start $macro_prefix
5796 echo " gl_source_base='$sourcebase'"
5797 if test -n "$witness_c_macro"; then
5798 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5800 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false true
5801 if test -n "$witness_c_macro"; then
5802 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5804 echo " # End of code from modules"
5805 func_emit_initmacro_end $macro_prefix
5806 echo " gltests_libdeps="
5807 echo " gltests_ltlibdeps="
5808 func_emit_initmacro_start ${macro_prefix}tests
5809 echo " gl_source_base='$testsbase'"
5810 # Define a tests witness macro that depends on the package.
5811 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5812 # See <https://lists.gnu.org/r/automake/2009-05/msg00145.html>.
5813 echo "changequote(,)dnl"
5814 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"
5815 echo "changequote([, ])dnl"
5816 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5817 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5818 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5819 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true true true
5820 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5821 func_emit_initmacro_end ${macro_prefix}tests
5822 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5823 # created using libtool, because libtool already handles the dependencies.
5824 if test "$libtool" != true; then
5825 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5826 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5827 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5828 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5829 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5831 if $use_libtests; then
5832 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5833 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5835 echo "])"
5836 func_emit_initmacro_done $macro_prefix $sourcebase
5837 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5838 echo
5839 echo "# This macro records the list of files which have been installed by"
5840 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5841 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5842 echo "$files" | sed -e 's,^, ,'
5843 echo "])"
5844 ) > "$tmpfile"
5845 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5846 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
5847 rm -f "$tmpfile"
5848 else
5849 if $doit; then
5850 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5851 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5852 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5853 else
5854 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5855 if false; then
5856 cat "$tmpfile"
5857 echo
5858 echo "# gnulib-comp.m4 ends here"
5860 rm -f "$tmpfile"
5863 else
5864 if $doit; then
5865 echo "Creating $m4base/gnulib-comp.m4"
5866 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5867 else
5868 echo "Create $m4base/gnulib-comp.m4"
5869 cat "$tmpfile"
5870 rm -f "$tmpfile"
5874 if $gentests; then
5875 # Create tests makefile.
5876 func_dest_tmpfilename $testsbase/$makefile_am
5877 destfile="$testsbase/$makefile_am"
5878 modules="$testsrelated_modules"
5879 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5880 if test -f "$destdir"/$testsbase/$makefile_am; then
5881 if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
5882 rm -f "$tmpfile"
5883 else
5884 if $doit; then
5885 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5886 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5887 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5888 else
5889 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5890 rm -f "$tmpfile"
5893 else
5894 if $doit; then
5895 echo "Creating $testsbase/$makefile_am"
5896 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5897 else
5898 echo "Create $testsbase/$makefile_am"
5899 rm -f "$tmpfile"
5901 func_append added_files "$testsbase/$makefile_am$nl"
5905 if test "$vc_files" != false; then
5906 # Update the .cvsignore and .gitignore files.
5907 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5908 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5909 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5910 echo "$m4base/|A|gnulib-comp.m4"
5911 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5912 { # Rearrange file descriptors. Needed because "while ... done < ..."
5913 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5914 exec 5<&0 < "$tmp"/fileset-changes
5915 func_update_ignorelist ()
5917 ignore="$1"
5918 if test "$ignore" = .gitignore; then
5919 # In a .gitignore file, "foo" applies to the current directory and all
5920 # subdirectories, whereas "/foo" applies to the current directory only.
5921 anchor='/'
5922 escaped_anchor='\/'
5923 doubly_escaped_anchor='\\/'
5924 else
5925 anchor=''
5926 escaped_anchor=''
5927 doubly_escaped_anchor=''
5929 if test -f "$destdir/$dir$ignore"; then
5930 if test -n "$dir_added" || test -n "$dir_removed"; then
5931 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5932 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5933 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5934 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5935 > "$tmp"/ignore-removed
5937 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5938 if $doit; then
5939 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5940 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5941 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5942 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5943 } > "$tmp"/sed-ignore-removed
5944 { cat "$destdir/$dir$ignore"~
5945 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5946 } | sed -f "$tmp"/sed-ignore-removed \
5947 > "$destdir/$dir$ignore"
5948 else
5949 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5953 else
5954 if test -n "$dir_added"; then
5955 if $doit; then
5956 echo "Creating $destdir/$dir$ignore"
5958 if test "$ignore" = .cvsignore; then
5959 echo ".deps"
5960 # Automake generates Makefile rules that create .dirstamp files.
5961 echo ".dirstamp"
5963 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5964 } > "$destdir/$dir$ignore"
5965 else
5966 echo "Create $destdir/$dir$ignore"
5971 func_done_dir ()
5973 dir="$1"
5974 dir_added="$2"
5975 dir_removed="$3"
5976 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5977 func_update_ignorelist .cvsignore
5979 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5980 func_update_ignorelist .gitignore
5983 last_dir=
5984 last_dir_added=
5985 last_dir_removed=
5986 while read line; do
5987 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5988 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5989 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5990 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5991 if test "$next_dir" != "$last_dir"; then
5992 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5993 last_dir="$next_dir"
5994 last_dir_added=
5995 last_dir_removed=
5997 case $op in
5998 A) func_append last_dir_added "$file$nl";;
5999 R) func_append last_dir_removed "$file$nl";;
6000 esac
6001 done
6002 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
6003 exec 0<&5 5<&-
6007 echo "Finished."
6008 echo
6009 echo "You may need to add #include directives for the following .h files."
6010 # Intersect $specified_modules and $main_modules
6011 # (since $specified_modules is not necessarily of subset of $main_modules
6012 # - some may have been skipped through --avoid, and since the elements of
6013 # $main_modules but not in $specified_modules can go away without explicit
6014 # notice - through changes in the module dependencies).
6015 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
6016 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
6017 # First the #include <...> directives without #ifs, sorted for convenience,
6018 # then the #include "..." directives without #ifs, sorted for convenience,
6019 # then the #include directives that are surrounded by #ifs. Not sorted.
6020 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
6021 include_directive=`func_get_include_directive "$module"`
6022 case "$nl$include_directive" in
6023 *"$nl#if"*)
6024 echo "$include_directive" 1>&5
6027 echo "$include_directive" | grep -v 'include "' 1>&6
6028 echo "$include_directive" | grep 'include "' 1>&7
6030 esac
6031 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
6033 LC_ALL=C sort -u "$tmp"/include-angles
6034 LC_ALL=C sort -u "$tmp"/include-quotes
6035 cat "$tmp"/include-if
6036 ) | sed -e '/^$/d' -e 's/^/ /'
6037 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
6039 for module in $main_modules; do
6040 func_get_link_directive "$module"
6041 done \
6042 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
6043 if test `wc -l < "$tmp"/link` != 0; then
6044 echo
6045 echo "You may need to use the following Makefile variables when linking."
6046 echo "Use them in <program>_LDADD when linking a program, or"
6047 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
6048 cat "$tmp"/link
6050 rm -f "$tmp"/link
6052 echo
6053 echo "Don't forget to"
6054 if test "$makefile_am" = Makefile.am; then
6055 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
6056 else
6057 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
6059 if test -n "$pobase"; then
6060 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
6062 if $gentests; then
6063 if test "$makefile_am" = Makefile.am; then
6064 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
6065 else
6066 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
6069 edit=0
6070 while test $edit != $makefile_am_edits; do
6071 edit=`expr $edit + 1`
6072 eval dir=\"\$makefile_am_edit${edit}_dir\"
6073 eval var=\"\$makefile_am_edit${edit}_var\"
6074 eval val=\"\$makefile_am_edit${edit}_val\"
6075 if test -n "$var"; then
6076 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
6078 done
6079 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
6080 position_early_after=AC_PROG_CC_STDC
6081 else
6082 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
6083 position_early_after=AC_PROG_CC_C99
6084 else
6085 position_early_after=AC_PROG_CC
6088 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
6089 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
6092 # func_create_testdir testdir modules
6093 # Input:
6094 # - local_gnulib_path from --local-dir
6095 # - modcache true or false, from --cache-modules/--no-cache-modules
6096 # - auxdir directory relative to destdir where to place build aux files
6097 # - inctests true if tests should be included, false otherwise
6098 # - incobsolete true if obsolete modules among dependencies should be
6099 # included, blank otherwise
6100 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
6101 # blank otherwise
6102 # - excl_longrunning_tests true if long-runnings tests should be excluded,
6103 # blank otherwise
6104 # - excl_privileged_tests true if tests that require root privileges should be
6105 # excluded, blank otherwise
6106 # - excl_unportable_tests true if tests that fail on some platforms should be
6107 # excluded, blank otherwise
6108 # - single_configure true if a single configure file should be generated,
6109 # false for a separate configure file for the tests
6110 # - avoidlist list of modules to avoid
6111 # - cond_dependencies true if --conditional-dependencies was given, false if
6112 # --no-conditional-dependencies was given, blank otherwise
6113 # - libtool true if --libtool was given, false if --no-libtool was
6114 # given, blank otherwise
6115 # - copymode copy mode for files in general
6116 # - lcopymode copy mode for files from local_gnulib_path
6117 func_create_testdir ()
6119 testdir="$1"
6120 modules="$2"
6121 if test -z "$modules"; then
6122 # All modules together.
6123 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6124 # Except non-recursive-gnulib-prefix-hack, which represents a nonstandard
6125 # way of using Automake.
6126 # Except timevar, which lacks the required file timevar.def.
6127 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
6128 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
6129 modules=`func_all_modules`
6130 modules=`for m in $modules; do case $m in config-h | non-recursive-gnulib-prefix-hack | timevar | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
6132 specified_modules="$modules"
6134 # Canonicalize the list of specified modules.
6135 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
6137 # Test modules which invoke AC_CONFIG_FILES cannot be used with
6138 # --with-tests --single-configure. Avoid them.
6139 if $inctests && $single_configure; then
6140 avoidlist="$avoidlist havelib-tests"
6143 # Unlike in func_import, here we want to include all kinds of tests for the
6144 # directly specified modules, but not for dependencies.
6145 inc_all_direct_tests=true
6146 inc_all_indirect_tests="$inc_all_tests"
6148 # Check that the license of every module is consistent with the license of
6149 # its dependencies.
6150 saved_inctests="$inctests"
6151 # When computing transitive closures, don't consider $module to depend on
6152 # $module-tests. Need this because tests are implicitly GPL and may depend
6153 # on GPL modules - therefore we don't want a warning in this case.
6154 inctests=false
6155 for requested_module in $specified_modules; do
6156 requested_license=`func_get_license "$requested_module"`
6157 if test "$requested_license" != GPL; then
6158 # Here we use func_modules_transitive_closure, not just
6159 # func_get_dependencies, so that we also detect weird situations like
6160 # an LGPL module which depends on a GPLed build tool module which depends
6161 # on a GPL module.
6162 modules="$requested_module"
6163 func_modules_transitive_closure
6164 for module in $modules; do
6165 license=`func_get_license "$module"`
6166 case "$license" in
6167 'GPLed build tool') ;;
6168 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
6170 case "$requested_license" in
6171 GPLv3+ | GPL)
6172 case "$license" in
6173 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL | GPLv2+ | GPLv3+ | GPL) ;;
6174 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6175 esac
6177 GPLv2+)
6178 case "$license" in
6179 LGPLv2+ | 'LGPLv3+ or GPLv2' | GPLv2+) ;;
6180 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6181 esac
6183 LGPLv3+ | LGPL)
6184 case "$license" in
6185 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
6186 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6187 esac
6189 'LGPLv3+ or GPLv2')
6190 case "$license" in
6191 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
6192 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6193 esac
6195 LGPLv2+)
6196 case "$license" in
6197 LGPLv2+) ;;
6198 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6199 esac
6201 esac
6203 esac
6204 done
6206 done
6207 inctests="$saved_inctests"
6209 # Subdirectory names.
6210 sourcebase=gllib
6211 m4base=glm4
6212 pobase=
6213 docbase=gldoc
6214 testsbase=gltests
6215 macro_prefix=gl
6216 po_domain=
6217 witness_c_macro=
6218 vc_files=
6220 # Determine final module list.
6221 modules="$specified_modules"
6222 func_modules_transitive_closure
6223 if test $verbose -ge 0; then
6224 func_show_module_list
6226 final_modules="$modules"
6228 if $single_configure; then
6229 # Determine main module list and tests-related module list separately.
6230 func_modules_transitive_closure_separately
6233 if $single_configure; then
6234 # Determine whether a $testsbase/libtests.a is needed.
6235 func_determine_use_libtests
6238 # Add the dummy module if needed.
6239 if $single_configure; then
6240 func_modules_add_dummy_separately
6241 else
6242 func_modules_add_dummy
6245 # Note:
6246 # If $single_configure, we use the module lists $main_modules and
6247 # $testsrelated_modules; $modules is merely a temporary variable.
6248 # Whereas if ! $configure, the module list is $modules.
6250 # Show banner notice of every module.
6251 if $single_configure; then
6252 modules="$main_modules"
6253 func_modules_notice
6254 else
6255 func_modules_notice
6258 # Determine final file list.
6259 if $single_configure; then
6260 func_modules_to_filelist_separately
6261 else
6262 func_modules_to_filelist
6263 if test $verbose -ge 0; then
6264 echo "File list:"
6265 echo "$files" | sed -e 's/^/ /'
6268 # Add files for which the copy in gnulib is newer than the one that
6269 # "automake --add-missing --copy" would provide.
6270 files="$files build-aux/config.guess"
6271 files="$files build-aux/config.sub"
6272 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
6274 rewritten='%REWRITTEN%'
6275 sed_rewrite_files="\
6276 s,^build-aux/,$rewritten$auxdir/,
6277 s,^doc/,$rewritten$docbase/,
6278 s,^lib/,$rewritten$sourcebase/,
6279 s,^m4/,$rewritten$m4base/,
6280 s,^tests/,$rewritten$testsbase/,
6281 s,^tests=lib/,$rewritten$testsbase/,
6282 s,^top/,$rewritten,
6283 s,^$rewritten,,"
6285 # Create directories.
6286 for f in $files; do echo $f; done \
6287 | sed -e "$sed_rewrite_files" \
6288 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
6289 | LC_ALL=C sort -u \
6290 > "$tmp"/dirs
6291 { # Rearrange file descriptors. Needed because "while ... done < ..."
6292 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6293 exec 5<&0 < "$tmp"/dirs
6294 while read d; do
6295 mkdir -p "$testdir/$d"
6296 done
6297 exec 0<&5 5<&-
6300 # Copy files or make symbolic links or hard links.
6301 delimiter=' '
6302 for f in $files; do echo $f; done \
6303 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
6304 | LC_ALL=C sort \
6305 > "$tmp"/files
6306 { # Rearrange file descriptors. Needed because "while ... done < ..."
6307 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6308 exec 5<&0 < "$tmp"/files
6309 while read g f; do
6310 case "$f" in
6311 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
6312 esac
6313 func_lookup_file "$f"
6314 if test -n "$lookedup_tmp"; then
6315 cp -p "$lookedup_file" "$testdir/$g"
6316 else
6317 func_should_link
6318 if test "$copyaction" = symlink; then
6319 func_symlink "$lookedup_file" "$testdir/$g"
6320 else
6321 if test "$copyaction" = hardlink; then
6322 func_hardlink "$lookedup_file" "$testdir/$g"
6323 else
6324 cp -p "$lookedup_file" "$testdir/$g"
6328 done
6329 exec 0<&5 5<&-
6332 # Determine include_guard_prefix.
6333 func_compute_include_guard_prefix
6335 # Create Makefile.ams that are for testing.
6336 for_test=true
6338 # No special edits are needed.
6339 makefile_am_edits=0
6341 # Create $sourcebase/Makefile.am.
6342 mkdir -p "$testdir/$sourcebase"
6343 destfile="$sourcebase/Makefile.am"
6344 if $single_configure; then
6345 modules="$main_modules"
6347 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
6348 any_uses_subdirs="$uses_subdirs"
6350 # Create $m4base/Makefile.am.
6351 mkdir -p "$testdir/$m4base"
6352 (echo "## Process this file with automake to produce Makefile.in."
6353 echo
6354 echo "EXTRA_DIST ="
6355 for f in $files; do
6356 case "$f" in
6357 m4/* )
6358 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
6359 esac
6360 done
6361 ) > "$testdir/$m4base/Makefile.am"
6363 subdirs="$sourcebase $m4base"
6364 subdirs_with_configure_ac=""
6366 if false && test -f "$testdir"/$m4base/gettext.m4; then
6367 # Avoid stupid error message from automake:
6368 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
6369 mkdir -p "$testdir/po"
6370 (echo "## Process this file with automake to produce Makefile.in."
6371 ) > "$testdir/po/Makefile.am"
6372 func_append subdirs " po"
6375 if $inctests; then
6376 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
6377 if $single_configure; then
6378 # Create $testsbase/Makefile.am.
6379 destfile="$testsbase/Makefile.am"
6380 modules="$testsrelated_modules"
6381 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
6382 else
6383 # Viewed from the $testsbase subdirectory, $auxdir is different.
6384 saved_auxdir="$auxdir"
6385 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
6386 # Create $testsbase/Makefile.am.
6387 use_libtests=false
6388 destfile="$testsbase/Makefile.am"
6389 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
6390 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
6391 # Create $testsbase/configure.ac.
6392 (echo "# Process this file with autoconf to produce a configure script."
6393 echo "AC_INIT([dummy], [0])"
6394 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6395 echo "AM_INIT_AUTOMAKE"
6396 echo
6397 echo "AC_CONFIG_HEADERS([config.h])"
6398 echo
6399 echo "AC_PROG_CC"
6400 echo "AC_PROG_INSTALL"
6401 echo "AC_PROG_MAKE_SET"
6403 func_emit_pre_early_macros false '' "$modules"
6405 if test -n "$uses_subdirs"; then
6406 echo "AM_PROG_CC_C_O"
6407 echo
6409 for module in $modules; do
6410 func_verify_module
6411 if test -n "$module"; then
6412 case $module in
6413 gnumakefile | maintainer-makefile)
6414 # These modules are meant to be used only in the top-level directory.
6417 func_get_autoconf_early_snippet "$module"
6419 esac
6421 done \
6422 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6423 if test "$libtool" = true; then
6424 echo "LT_INIT([win32-dll])"
6425 echo "LT_LANG([C++])"
6426 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6427 echo "gl_cond_libtool=true"
6428 else
6429 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6430 echo "gl_cond_libtool=false"
6431 echo "gl_libdeps="
6432 echo "gl_ltlibdeps="
6434 # Wrap the set of autoconf snippets into an autoconf macro that is then
6435 # invoked. This is needed because autoconf does not support AC_REQUIRE
6436 # at the top level:
6437 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6438 # but we want the AC_REQUIRE to have its normal meaning (provide one
6439 # expansion of the required macro before the current point, and only one
6440 # expansion total).
6441 echo "AC_DEFUN([gl_INIT], ["
6442 sed_replace_build_aux='
6444 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6445 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6448 echo "gl_m4_base='../$m4base'"
6449 func_emit_initmacro_start $macro_prefix
6450 # We don't have explicit ordering constraints between the various
6451 # autoconf snippets. It's cleanest to put those of the library before
6452 # those of the tests.
6453 echo "gl_source_base='../$sourcebase'"
6454 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module false false false
6455 echo "gl_source_base='.'"
6456 func_emit_autoconf_snippets "$modules" "$modules" func_verify_tests_module false false false
6457 func_emit_initmacro_end $macro_prefix
6458 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6459 # created using libtool, because libtool already handles the dependencies.
6460 if test "$libtool" != true; then
6461 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6462 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6463 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6464 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6465 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6467 echo "])"
6468 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
6469 echo
6470 echo "gl_INIT"
6471 echo
6472 # Usually $testsbase/config.h will be a superset of config.h. Verify this
6473 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
6474 echo "AH_TOP([#include \"../config.h\"])"
6475 echo
6476 echo "AC_CONFIG_FILES([Makefile])"
6477 echo "AC_OUTPUT"
6478 ) > "$testdir/$testsbase/configure.ac"
6479 auxdir="$saved_auxdir"
6480 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
6482 func_append subdirs " $testsbase"
6485 # Create Makefile.am.
6486 (echo "## Process this file with automake to produce Makefile.in."
6487 echo
6488 echo "AUTOMAKE_OPTIONS = 1.11 foreign"
6489 echo
6490 echo "SUBDIRS = $subdirs"
6491 echo
6492 echo "ACLOCAL_AMFLAGS = -I $m4base"
6493 ) > "$testdir/Makefile.am"
6495 # Create configure.ac.
6496 (echo "# Process this file with autoconf to produce a configure script."
6497 echo "AC_INIT([dummy], [0])"
6498 if test "$auxdir" != "."; then
6499 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6501 echo "AM_INIT_AUTOMAKE"
6502 echo
6503 echo "AC_CONFIG_HEADERS([config.h])"
6504 echo
6505 echo "AC_PROG_CC"
6506 echo "AC_PROG_INSTALL"
6507 echo "AC_PROG_MAKE_SET"
6508 echo
6509 echo "# For autobuild."
6510 echo "AC_CANONICAL_BUILD"
6511 echo "AC_CANONICAL_HOST"
6512 echo
6513 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
6514 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
6515 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6516 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6518 func_emit_pre_early_macros false '' "$final_modules"
6520 if test -n "$any_uses_subdirs"; then
6521 echo "AM_PROG_CC_C_O"
6522 echo
6524 for module in $final_modules; do
6525 if $single_configure; then
6526 func_verify_module
6527 else
6528 func_verify_nontests_module
6530 if test -n "$module"; then
6531 func_get_autoconf_early_snippet "$module"
6533 done \
6534 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6535 if test "$libtool" = true; then
6536 echo "LT_INIT([win32-dll])"
6537 echo "LT_LANG([C++])"
6538 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6539 echo "gl_cond_libtool=true"
6540 else
6541 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6542 echo "gl_cond_libtool=false"
6543 echo "gl_libdeps="
6544 echo "gl_ltlibdeps="
6546 # Wrap the set of autoconf snippets into an autoconf macro that is then
6547 # invoked. This is needed because autoconf does not support AC_REQUIRE
6548 # at the top level:
6549 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6550 # but we want the AC_REQUIRE to have its normal meaning (provide one
6551 # expansion of the required macro before the current point, and only one
6552 # expansion total).
6553 echo "AC_DEFUN([gl_INIT], ["
6554 if test "$auxdir" != "build-aux"; then
6555 sed_replace_build_aux='
6557 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6558 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6561 else
6562 sed_replace_build_aux="$sed_noop"
6564 echo "gl_m4_base='$m4base'"
6565 func_emit_initmacro_start $macro_prefix
6566 echo "gl_source_base='$sourcebase'"
6567 if $single_configure; then
6568 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false false
6569 else
6570 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module true false false
6572 func_emit_initmacro_end $macro_prefix
6573 if $single_configure; then
6574 echo " gltests_libdeps="
6575 echo " gltests_ltlibdeps="
6576 func_emit_initmacro_start ${macro_prefix}tests
6577 echo " gl_source_base='$testsbase'"
6578 # Define a tests witness macro.
6579 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
6580 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6581 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6582 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6583 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true false false
6584 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6585 func_emit_initmacro_end ${macro_prefix}tests
6587 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6588 # created using libtool, because libtool already handles the dependencies.
6589 if test "$libtool" != true; then
6590 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6591 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6592 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6593 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6594 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6596 if $single_configure; then
6597 if $use_libtests; then
6598 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6599 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6602 echo "])"
6603 func_emit_initmacro_done $macro_prefix $sourcebase
6604 if $single_configure; then
6605 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6607 echo
6608 echo "gl_INIT"
6609 echo
6610 if test -n "$subdirs_with_configure_ac"; then
6611 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6613 makefiles="Makefile"
6614 for d in $subdirs; do
6615 # For subdirs that have a configure.ac by their own, it's the subdir's
6616 # configure.ac which creates the subdir's Makefile.am, not this one.
6617 case " $subdirs_with_configure_ac " in
6618 *" $d "*) ;;
6619 *) func_append makefiles " $d/Makefile" ;;
6620 esac
6621 done
6622 echo "AC_CONFIG_FILES([$makefiles])"
6623 echo "AC_OUTPUT"
6624 ) > "$testdir/configure.ac"
6626 # Create autogenerated files.
6627 (cd "$testdir"
6628 # Do not use "${AUTORECONF} --force --install", because it may invoke
6629 # autopoint, which brings in older versions of some of our .m4 files.
6630 if test -f $m4base/gettext.m4; then
6631 func_execute_command ${AUTOPOINT} --force || func_exit 1
6632 for f in $m4base/*.m4~; do
6633 if test -f $f; then
6634 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6636 done
6638 if test "$libtool" = true; then
6639 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6641 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6642 if ! test -d build-aux; then
6643 func_execute_command mkdir build-aux || func_exit 1
6645 func_execute_command ${AUTOCONF} || func_exit 1
6646 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6647 func_execute_command ${AUTOHEADER} &&
6648 func_execute_command touch config.h.in ||
6649 func_exit 1
6650 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6651 rm -rf autom4te.cache
6652 ) || func_exit 1
6653 if $inctests && ! $single_configure; then
6654 # Create autogenerated files.
6655 (cd "$testdir/$testsbase" || func_exit 1
6656 # Do not use "${AUTORECONF} --force --install", because it may invoke
6657 # autopoint, which brings in older versions of some of our .m4 files.
6658 if test -f ../$m4base/gettext.m4; then
6659 func_execute_command ${AUTOPOINT} --force || func_exit 1
6660 for f in ../$m4base/*.m4~; do
6661 if test -f $f; then
6662 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6664 done
6666 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6667 if ! test -d ../build-aux; then
6668 func_execute_command mkdir ../build-aux
6670 func_execute_command ${AUTOCONF} || func_exit 1
6671 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6672 func_execute_command ${AUTOHEADER} &&
6673 func_execute_command touch config.h.in ||
6674 func_exit 1
6675 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6676 rm -rf autom4te.cache
6677 ) || func_exit 1
6679 # Need to run configure and make once, to create built files that are to be
6680 # distributed (such as parse-datetime.c).
6681 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6682 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6683 cleaned_files=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6684 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6685 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6686 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6687 # such $(FOO_H) because they don't refer to distributed files.
6688 built_sources=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6689 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6690 | sed -e "$sed_remove_make_variables"`
6691 distributed_built_sources=`for file in $built_sources; do
6692 case "$cleaned_files" in
6693 *" "$file" "*) ;;
6694 *) echo $file ;;
6695 esac;
6696 done`
6697 tests_distributed_built_sources=
6698 if $inctests; then
6699 # Likewise for built files in the $testsbase directory.
6700 tests_cleaned_files=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6701 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6702 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6703 tests_built_sources=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6704 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6705 | sed -e "$sed_remove_make_variables"`
6706 tests_distributed_built_sources=`for file in $tests_built_sources; do
6707 case "$tests_cleaned_files" in
6708 *" "$file" "*) ;;
6709 *) echo $file ;;
6710 esac;
6711 done`
6713 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6714 (cd "$testdir"
6715 ./configure || func_exit 1
6716 if test -n "$distributed_built_sources"; then
6717 cd "$sourcebase"
6718 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6719 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6720 built_sources \
6721 || func_exit 1
6722 cd ..
6724 if test -n "$tests_distributed_built_sources"; then
6725 cd "$testsbase"
6726 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6727 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6728 built_sources \
6729 || func_exit 1
6730 cd ..
6732 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6733 distclean \
6734 || func_exit 1
6735 ) || func_exit 1
6737 (cd "$testdir"
6738 if test -f build-aux/test-driver; then
6739 patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver.diff || func_exit 1
6741 ) || func_exit 1
6744 # func_create_megatestdir megatestdir allmodules
6745 # Input:
6746 # - local_gnulib_path from --local-dir
6747 # - modcache true or false, from --cache-modules/--no-cache-modules
6748 # - auxdir directory relative to destdir where to place build aux files
6749 func_create_megatestdir ()
6751 megatestdir="$1"
6752 allmodules="$2"
6753 if test -z "$allmodules"; then
6754 allmodules=`func_all_modules`
6757 megasubdirs=
6758 # First, all modules one by one.
6759 for onemodule in $allmodules; do
6760 func_create_testdir "$megatestdir/$onemodule" $onemodule
6761 func_append megasubdirs "$onemodule "
6762 done
6763 # Then, all modules all together.
6764 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6765 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6766 func_create_testdir "$megatestdir/ALL" "$allmodules"
6767 func_append megasubdirs "ALL"
6769 # Create autobuild.
6770 cvsdate=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6771 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6772 | sed -e 's,January,01,' -e 's,Jan,01,' \
6773 -e 's,February,02,' -e 's,Feb,02,' \
6774 -e 's,March,03,' -e 's,Mar,03,' \
6775 -e 's,April,04,' -e 's,Apr,04,' \
6776 -e 's,May,05,' \
6777 -e 's,June,06,' -e 's,Jun,06,' \
6778 -e 's,July,07,' -e 's,Jul,07,' \
6779 -e 's,August,08,' -e 's,Aug,08,' \
6780 -e 's,September,09,' -e 's,Sep,09,' \
6781 -e 's,October,10,' -e 's,Oct,10,' \
6782 -e 's,November,11,' -e 's,Nov,11,' \
6783 -e 's,December,12,' -e 's,Dec,12,' \
6784 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6785 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6786 (echo '#!/bin/sh'
6787 echo "CVSDATE=$cvsdate"
6788 echo ": \${MAKE=make}"
6789 echo "test -d logs || mkdir logs"
6790 echo "for module in $megasubdirs; do"
6791 echo " echo \"Working on module \$module...\""
6792 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6793 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6794 echo " echo"
6795 echo " set -x"
6796 echo " : autobuild project... \$module"
6797 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6798 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6799 echo " : autobuild hostname... \`hostname\`"
6800 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6801 echo " echo rc=\$?"
6802 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6803 echo "done"
6804 ) > "$megatestdir/do-autobuild"
6805 chmod a+x "$megatestdir/do-autobuild"
6807 # Create Makefile.am.
6808 (echo "## Process this file with automake to produce Makefile.in."
6809 echo
6810 echo "AUTOMAKE_OPTIONS = 1.11 foreign"
6811 echo
6812 echo "SUBDIRS = $megasubdirs"
6813 echo
6814 echo "EXTRA_DIST = do-autobuild"
6815 ) > "$megatestdir/Makefile.am"
6817 # Create configure.ac.
6818 (echo "# Process this file with autoconf to produce a configure script."
6819 echo "AC_INIT([dummy], [0])"
6820 if test "$auxdir" != "."; then
6821 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6823 echo "AM_INIT_AUTOMAKE"
6824 echo
6825 echo "AC_PROG_MAKE_SET"
6826 echo
6827 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6828 echo "AC_CONFIG_FILES([Makefile])"
6829 echo "AC_OUTPUT"
6830 ) > "$megatestdir/configure.ac"
6832 # Create autogenerated files.
6833 (cd "$megatestdir"
6834 # Do not use "${AUTORECONF} --install", because autoreconf operates
6835 # recursively, but the subdirectories are already finished, therefore
6836 # calling autoreconf here would only waste lots of CPU time.
6837 func_execute_command ${ACLOCAL} || func_exit 1
6838 func_execute_command mkdir build-aux
6839 func_execute_command ${AUTOCONF} || func_exit 1
6840 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6841 rm -rf autom4te.cache
6842 if test -f build-aux/test-driver; then
6843 patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver.diff || func_exit 1
6845 ) || func_exit 1
6848 case $mode in
6849 "" )
6850 func_fatal_error "no mode specified" ;;
6852 list )
6853 func_all_modules
6856 find )
6857 # sed expression that converts a literal to a basic regular expression.
6858 # Needs to handle . [ \ * ^ $.
6859 sed_literal_to_basic_regex='s/\\/\\\\/g
6860 s/\[/\\[/g
6861 s/\^/\\^/g
6862 s/\([.*$]\)/[\1]/g'
6863 for filename
6865 if test -f "$gnulib_dir/$filename" \
6866 || func_lookup_local_file "$filename"; then
6867 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6868 filename_line_regex='^'"$filename_anywhere_regex"'$'
6869 module_candidates=`
6871 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6872 func_path_foreach "$local_gnulib_path" func_modules_in_dir %dir% | xargs -n 100 grep -l "$filename_anywhere_regex" /dev/null | sed -e 's,^modules/,,' -e 's,\.diff$,,'
6874 | func_sanitize_modulelist \
6875 | LC_ALL=C sort -u
6877 for module in $module_candidates; do
6878 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6879 echo $module
6881 done
6882 else
6883 func_warning "file $filename does not exist"
6885 done
6888 import | add-import | remove-import | update )
6890 # Where to import.
6891 if test -z "$destdir"; then
6892 destdir=.
6894 test -d "$destdir" \
6895 || func_fatal_error "destination directory does not exist: $destdir"
6897 # Prefer configure.ac to configure.in.
6898 if test -f "$destdir"/configure.ac; then
6899 configure_ac="$destdir/configure.ac"
6900 else
6901 if test -f "$destdir"/configure.in; then
6902 configure_ac="$destdir/configure.in"
6903 else
6904 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6908 # Analyze configure.ac.
6909 guessed_auxdir="."
6910 guessed_libtool=false
6911 my_sed_traces='
6912 s,#.*$,,
6913 s,^dnl .*$,,
6914 s, dnl .*$,,
6915 /AC_CONFIG_AUX_DIR/ {
6916 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6918 /A[CM]_PROG_LIBTOOL/ {
6919 s,^.*$,guessed_libtool=true,p
6921 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6923 if test -z "$auxdir"; then
6924 auxdir="$guessed_auxdir"
6927 # Determine where to apply func_import.
6928 if test "$mode" = import; then
6929 # Apply func_import to a particular gnulib directory.
6930 # The command line contains the complete specification; don't look at
6931 # the contents of gnulib-cache.m4.
6932 test -n "$supplied_libname" || supplied_libname=true
6933 test -n "$sourcebase" || sourcebase="lib"
6934 test -n "$m4base" || m4base="m4"
6935 test -n "$docbase" || docbase="doc"
6936 test -n "$testsbase" || testsbase="tests"
6937 test -n "$macro_prefix" || macro_prefix="gl"
6938 func_import "$*"
6939 else
6940 if test -n "$m4base"; then
6941 # Apply func_import to a particular gnulib directory.
6942 # Any number of additional modules can be given.
6943 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6944 # First use of gnulib in the given m4base.
6945 test -n "$supplied_libname" || supplied_libname=true
6946 test -n "$sourcebase" || sourcebase="lib"
6947 test -n "$docbase" || docbase="doc"
6948 test -n "$testsbase" || testsbase="tests"
6949 test -n "$macro_prefix" || macro_prefix="gl"
6951 func_import "$*"
6952 else
6953 # Apply func_import to all gnulib directories.
6954 # To get this list of directories, look at Makefile.am. (Not at
6955 # configure, because it may be omitted from version control. Also,
6956 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6957 # too expensive.)
6958 m4dirs=
6959 m4dirs_count=0
6960 if test -f "$destdir"/Makefile.am; then
6961 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6962 m4dir_is_next=
6963 for arg in $aclocal_amflags; do
6964 if test -n "$m4dir_is_next"; then
6965 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6966 case "$arg" in
6967 /*) ;;
6969 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6970 func_append m4dirs " $arg"
6971 m4dirs_count=`expr $m4dirs_count + 1`
6974 esac
6975 m4dir_is_next=
6976 else
6977 if test "X$arg" = "X-I"; then
6978 m4dir_is_next=yes
6979 else
6980 m4dir_is_next=
6983 done
6984 else
6985 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6986 if test -f "$destdir"/aclocal.m4; then
6987 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6988 sedexpr2='s,^[^/]*$,.,'
6989 sedexpr3='s,/[^/]*$,,'
6990 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6991 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6992 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6995 if test $m4dirs_count = 0; then
6996 # First use of gnulib in a package.
6997 # Any number of additional modules can be given.
6998 test -n "$supplied_libname" || supplied_libname=true
6999 test -n "$sourcebase" || sourcebase="lib"
7000 m4base="m4"
7001 test -n "$docbase" || docbase="doc"
7002 test -n "$testsbase" || testsbase="tests"
7003 test -n "$macro_prefix" || macro_prefix="gl"
7004 func_import "$*"
7005 else
7006 if test $m4dirs_count = 1; then
7007 # There's only one use of gnulib here. Assume the user means it.
7008 # Any number of additional modules can be given.
7009 for m4base in $m4dirs; do
7010 func_import "$*"
7011 done
7012 else
7013 # Ambiguous - guess what the user meant.
7014 if test $# = 0; then
7015 # No further arguments. Guess the user wants to update all of them.
7016 for m4base in $m4dirs; do
7017 # Perform func_import in a subshell, so that variable values
7018 # such as
7019 # local_gnulib_path, incobsolete, inc_cxx_tests,
7020 # inc_longrunning_tests, inc_privileged_tests,
7021 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
7022 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
7023 # makefile_name, libtool, macro_prefix, po_domain,
7024 # witness_c_macro, vc_files
7025 # don't propagate from one directory to another.
7026 (func_import) || func_exit 1
7027 done
7028 else
7029 # Really ambiguous.
7030 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
7038 create-testdir )
7039 if test -z "$destdir"; then
7040 func_fatal_error "please specify --dir option"
7042 mkdir "$destdir"
7043 test -d "$destdir" \
7044 || func_fatal_error "could not create destination directory"
7045 test -n "$auxdir" || auxdir="build-aux"
7046 func_create_testdir "$destdir" "$*"
7049 create-megatestdir )
7050 if test -z "$destdir"; then
7051 func_fatal_error "please specify --dir option"
7053 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7054 test -n "$auxdir" || auxdir="build-aux"
7055 func_create_megatestdir "$destdir" "$*"
7058 test )
7059 test -n "$destdir" || destdir=testdir$$
7060 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7061 test -n "$auxdir" || auxdir="build-aux"
7062 func_create_testdir "$destdir" "$*"
7063 cd "$destdir"
7064 mkdir build
7065 cd build
7066 ../configure || func_exit 1
7067 $MAKE || func_exit 1
7068 $MAKE check || func_exit 1
7069 $MAKE distclean || func_exit 1
7070 remaining=`find . -type f -print`
7071 if test -n "$remaining"; then
7072 echo "Remaining files:" $remaining 1>&2
7073 echo "gnulib-tool: *** Stop." 1>&2
7074 func_exit 1
7076 cd ..
7077 cd ..
7078 rm -rf "$destdir"
7081 megatest )
7082 test -n "$destdir" || destdir=testdir$$
7083 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7084 test -n "$auxdir" || auxdir="build-aux"
7085 func_create_megatestdir "$destdir" "$*"
7086 cd "$destdir"
7087 mkdir build
7088 cd build
7089 ../configure
7090 $MAKE
7091 $MAKE check
7092 $MAKE distclean
7093 remaining=`find . -type f -print`
7094 if test -n "$remaining"; then
7095 echo "Remaining files:" $remaining 1>&2
7096 echo "gnulib-tool: *** Stop." 1>&2
7097 func_exit 1
7099 cd ..
7100 cd ..
7101 rm -rf "$destdir"
7104 extract-description )
7105 for module
7107 func_verify_module
7108 if test -n "$module"; then
7109 func_get_description "$module"
7111 done
7114 extract-comment )
7115 for module
7117 func_verify_module
7118 if test -n "$module"; then
7119 func_get_comment "$module"
7121 done
7124 extract-status )
7125 for module
7127 func_verify_module
7128 if test -n "$module"; then
7129 func_get_status "$module"
7131 done
7134 extract-notice )
7135 for module
7137 func_verify_module
7138 if test -n "$module"; then
7139 func_get_notice "$module"
7141 done
7144 extract-applicability )
7145 for module
7147 func_verify_module
7148 if test -n "$module"; then
7149 func_get_applicability "$module"
7151 done
7154 extract-filelist )
7155 for module
7157 func_verify_module
7158 if test -n "$module"; then
7159 func_get_filelist "$module"
7161 done
7164 extract-dependencies )
7165 if test -n "$avoidlist"; then
7166 func_fatal_error "cannot combine --avoid and --extract-dependencies"
7168 for module
7170 func_verify_module
7171 if test -n "$module"; then
7172 func_get_dependencies "$module"
7174 done
7177 extract-recursive-dependencies )
7178 if test -n "$avoidlist"; then
7179 func_fatal_error "cannot combine --avoid and --extract-recursive-dependencies"
7181 for module
7183 func_verify_module
7184 if test -n "$module"; then
7185 func_get_dependencies_recursively "$module"
7187 done
7190 extract-autoconf-snippet )
7191 for module
7193 func_verify_module
7194 if test -n "$module"; then
7195 func_get_autoconf_snippet "$module"
7197 done
7200 extract-automake-snippet )
7201 for module
7203 func_verify_module
7204 if test -n "$module"; then
7205 func_get_automake_snippet "$module"
7207 done
7210 extract-include-directive )
7211 for module
7213 func_verify_module
7214 if test -n "$module"; then
7215 func_get_include_directive "$module"
7217 done
7220 extract-link-directive )
7221 for module
7223 func_verify_module
7224 if test -n "$module"; then
7225 func_get_link_directive "$module"
7227 done
7230 extract-recursive-link-directive )
7231 if test -n "$avoidlist"; then
7232 func_fatal_error "cannot combine --avoid and --extract-recursive-link-directive"
7234 for module
7236 func_verify_module
7237 if test -n "$module"; then
7238 func_get_link_directive_recursively "$module"
7240 done
7243 extract-license )
7244 for module
7246 func_verify_module
7247 if test -n "$module"; then
7248 func_get_license "$module"
7250 done
7253 extract-maintainer )
7254 for module
7256 func_verify_module
7257 if test -n "$module"; then
7258 func_get_maintainer "$module"
7260 done
7263 extract-tests-module )
7264 for module
7266 func_verify_module
7267 if test -n "$module"; then
7268 func_get_tests_module "$module"
7270 done
7273 copy-file )
7274 # Verify the number of arguments.
7275 if test $# -lt 1 || test $# -gt 2; then
7276 func_fatal_error "invalid number of arguments for --$mode"
7279 # The first argument is the file to be copied.
7280 f="$1"
7281 # Verify the file exists.
7282 func_lookup_file "$f"
7284 # The second argument is the destination; either a directory ot a file.
7285 # It defaults to the current directory.
7286 dest="$2"
7287 test -n "$dest" || dest='.'
7288 test -n "$sourcebase" || sourcebase="lib"
7289 test -n "$m4base" || m4base="m4"
7290 test -n "$docbase" || docbase="doc"
7291 test -n "$testsbase" || testsbase="tests"
7292 test -n "$auxdir" || auxdir="build-aux"
7293 rewritten='%REWRITTEN%'
7294 sed_rewrite_files="\
7295 s,^build-aux/,$rewritten$auxdir/,
7296 s,^doc/,$rewritten$docbase/,
7297 s,^lib/,$rewritten$sourcebase/,
7298 s,^m4/,$rewritten$m4base/,
7299 s,^tests/,$rewritten$testsbase/,
7300 s,^top/,$rewritten,
7301 s,^$rewritten,,"
7302 if test -d "$dest"; then
7303 destdir="$dest"
7304 g=`echo "$f" | sed -e "$sed_rewrite_files"`
7305 else
7306 destdir=`dirname "$dest"`
7307 g=`basename "$dest"`
7310 # Create the directory for destfile.
7311 d=`dirname "$destdir/$g"`
7312 if $doit; then
7313 if test -n "$d" && test ! -d "$d"; then
7314 mkdir -p "$d" || func_fatal_error "failed"
7317 # Copy the file.
7318 func_dest_tmpfilename "$g"
7319 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
7320 already_present=true
7321 if test -f "$destdir/$g"; then
7322 # The file already exists.
7323 func_update_file
7324 else
7325 # Install the file.
7326 # Don't protest if the file should be there but isn't: it happens
7327 # frequently that developers don't put autogenerated files under version
7328 # control.
7329 func_add_file
7331 rm -f "$tmpfile"
7335 func_fatal_error "unknown operation mode --$mode" ;;
7336 esac
7338 if test "$copymode" = hardlink -o "$lcopymode" = hardlink; then
7339 # Setting hard links modifies the ctime of files in the gnulib checkout.
7340 # This disturbs the result of the next "gitk" invocation.
7341 # Workaround: Let git scan the files. This can be done through
7342 # "git update-index --refresh" or "git status" or "git diff".
7343 if test -d "$gnulib_dir"/.git \
7344 && (git --version) >/dev/null 2>/dev/null; then
7345 (cd "$gnulib_dir" && git update-index --refresh >/dev/null)
7349 rm -rf "$tmp"
7350 # Undo the effect of the previous 'trap' command. Some shellology:
7351 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
7352 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
7353 # exit); for the others we need to call 'exit' explicitly. The value of $? is
7354 # 128 + signal number and is set before the trap-registered command is run.
7355 trap '' 0
7356 trap 'func_exit $?' 1 2 3 13 15
7358 exit 0
7360 # Local Variables:
7361 # indent-tabs-mode: nil
7362 # whitespace-check-buffer-indent: nil
7363 # End: