Fix last ChangeLog entry.
[gnulib.git] / gnulib-tool
blob2ba5dec65d2fd1b7ee218db9afca95fe9201390a
1 #! /bin/sh
3 # Copyright (C) 2002-2021 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
22 # CODING STYLE for this file:
23 # * Indentation: Indent by 2 spaces. Indent case clauses by 2 spaces as well.
24 # * Shell variable references: Use double-quote around shell variable
25 # references always (except when word splitting is explicitly desired),
26 # even when you know the double-quote are not needed. This style tends to
27 # avoid undesired word splitting caused by omitted double-quotes (the
28 # number one mistake in shell scripts).
29 # When the referenced variable can only have a finite number of possible
30 # values and these values are all simple words (e.g. true and false), it's
31 # OK to omit the double-quotes.
32 # * Backquotes:
33 # - Use backquotes like in `command`, not $(command).
34 # - Don't use `command` inside double-quotes. Instead assign the result of
35 # `command` to a variable, and use the value of the variable afterwards.
36 # * Functions:
37 # - All functions that don't emulate a program or shell built-in have a name
38 # that starts with 'func_'.
39 # - Document the implicit and explicit arguments of all functions, as well
40 # as their output variables and side effects.
41 # * Use test condition instead of [ condition ].
42 # * Minimize the use of eval; when you need it, make sure the string to be
43 # evaluated has a very simple syntactic structure.
45 progname=$0
46 package=gnulib
47 nl='
49 IFS=" "" $nl"
51 # You can set AUTOCONFPATH to empty if autoconf 2.64 is already in your PATH.
52 AUTOCONFPATH=
53 #case $USER in
54 # bruno )
55 # AUTOCONFBINDIR=/arch/x86-linux/gnu-inst-autoconf/2.64/bin
56 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
57 # ;;
58 #esac
60 # You can set AUTOMAKEPATH to empty if automake 1.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_ensure_writable DEST
798 # Ensures the file DEST is writable.
799 func_ensure_writable ()
801 test -w "$1" || chmod u+w "$1"
804 # func_ln_s SRC DEST
805 # Like ln -s, except use cp -p if ln -s fails.
806 func_ln_s ()
808 ln -s "$1" "$2" || {
809 echo "$progname: ln -s failed; falling back on cp -p" >&2
811 case "$1" in
812 /* | ?:*) # SRC is absolute.
813 cp_src="$1" ;;
814 *) # SRC is relative to the directory of DEST.
815 case "$2" in
816 */*) cp_src="${2%/*}/$1" ;;
817 *) cp_src="$1" ;;
818 esac
820 esac
822 cp -p "$cp_src" "$2"
823 func_ensure_writable "$2"
827 # func_symlink_target SRC DEST
828 # Determines LINK_TARGET such that "ln -s LINK_TARGET DEST" will create a
829 # symbolic link DEST that points to SRC.
830 # Output:
831 # - link_target link target, relative to the directory of DEST
832 func_symlink_target ()
834 case "$1" in
835 /* | ?:*)
836 link_target="$1" ;;
837 *) # SRC is relative.
838 case "$2" in
839 /* | ?:*)
840 link_target="`pwd`/$1" ;;
841 *) # DEST is relative too.
842 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
843 test -n "$ln_destdir" || ln_destdir="."
844 func_relativize "$ln_destdir" "$1"
845 link_target="$reldir"
847 esac
849 esac
852 # func_symlink SRC DEST
853 # Like func_ln_s, except that SRC is given relative to the current directory (or
854 # absolute), not given relative to the directory of DEST.
855 func_symlink ()
857 func_symlink_target "$1" "$2"
858 func_ln_s "$link_target" "$2"
861 # func_symlink_if_changed SRC DEST
862 # Like func_symlink, but avoids munging timestamps if the link is correct.
863 # SRC is given relative to the current directory (or absolute).
864 func_symlink_if_changed ()
866 if test $# -ne 2; then
867 echo "usage: func_symlink_if_changed SRC DEST" >&2
869 func_symlink_target "$1" "$2"
870 ln_target=`func_readlink "$2"`
871 if test -h "$2" && test "$link_target" = "$ln_target"; then
873 else
874 rm -f "$2"
875 func_ln_s "$link_target" "$2"
879 # func_hardlink SRC DEST
880 # Like ln, except use cp -p if ln fails.
881 # SRC is given relative to the current directory (or absolute).
882 func_hardlink ()
884 ln "$1" "$2" || {
885 echo "$progname: ln failed; falling back on cp -p" >&2
886 cp -p "$1" "$2"
887 func_ensure_writable "$2"
891 # Ensure an 'echo' command that
892 # 1. does not interpret backslashes and
893 # 2. does not print an error message "broken pipe" when writing into a pipe
894 # with no writers.
896 # Test cases for problem 1:
897 # echo '\n' | wc -l prints 1 when OK, 2 when KO
898 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
899 # Test cases for problem 2:
900 # echo hi | true frequently prints
901 # "bash: echo: write error: Broken pipe"
902 # to standard error in bash 3.2.
904 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
905 # BSD echo interprets '-n' as an option, which is also not desirable).
906 # Nowadays the problem occurs in 4 situations:
907 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
908 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
909 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
910 # - in zsh, when sh-emulation is not set,
911 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
912 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
913 # - in Solaris /bin/sh and OSF/1 /bin/sh.
914 # We try the following workarounds:
915 # - for all: respawn using $CONFIG_SHELL if that is set and works.
916 # - for bash >= 2.04: unset the shell option xpg_echo.
917 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
918 # - for bash < 2.0: define echo to a function that uses cat of a here document.
919 # - for zsh: turn sh-emulation on.
920 # - for ksh: alias echo to 'print -r'.
921 # - for ksh: alias echo to a function that uses cat of a here document.
922 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
923 # the ksh workaround.
924 # - otherwise: respawn using /bin/sh and rely on the workarounds.
925 # When respawning, we pass --no-reexec as first argument, so as to avoid
926 # turning this script into a fork bomb in unlucky situations.
928 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
929 # the 'printf' built-in. See
930 # <https://lists.gnu.org/r/bug-bash/2008-12/msg00050.html>
931 # <https://lists.gnu.org/r/bug-gnulib/2010-02/msg00154.html>
932 # The workaround is: define echo to a function that uses the printf built-in.
933 have_echo=
934 if echo '\t' | grep t > /dev/null; then
935 have_echo=yes # Lucky!
937 # Try the workarounds.
938 # Respawn using $CONFIG_SHELL if that is set and works.
939 if test -z "$have_echo" \
940 && test "X$1" != "X--no-reexec" \
941 && test -n "$CONFIG_SHELL" \
942 && test -f "$CONFIG_SHELL" \
943 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
944 exec $CONFIG_SHELL "$0" --no-reexec "$@"
945 exit 127
947 # For bash >= 2.04: unset the shell option xpg_echo.
948 if test -z "$have_echo" \
949 && test -n "$BASH_VERSION" \
950 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
951 shopt -o xpg_echo
952 have_echo=yes
954 # For bash >= 2.0: define echo to a function that uses the printf built-in.
955 # For bash < 2.0: define echo to a function that uses cat of a here document.
956 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
957 # Also handle problem 2, specific to bash 3.2, here.
958 if { test -z "$have_echo" \
959 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
961 && test -n "$BASH_VERSION"; then \
962 if type printf 2>/dev/null | grep / > /dev/null; then
963 # 'printf' is not a shell built-in.
964 echo ()
966 cat <<EOF
970 else
971 # 'printf' is a shell built-in.
972 echo ()
974 printf '%s\n' "$*"
977 if echo '\t' | grep t > /dev/null; then
978 have_echo=yes
981 # For zsh: turn sh-emulation on.
982 if test -z "$have_echo" \
983 && test -n "$ZSH_VERSION" \
984 && (emulate sh) >/dev/null 2>&1; then
985 emulate sh
987 # For ksh: alias echo to 'print -r'.
988 if test -z "$have_echo" \
989 && (type print) >/dev/null 2>&1; then
990 # A 'print' command exists.
991 if type print 2>/dev/null | grep / > /dev/null; then
993 else
994 # 'print' is a shell built-in.
995 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
996 # 'print' is the ksh shell built-in.
997 alias echo='print -r'
1001 if test -z "$have_echo" \
1002 && echo '\t' | grep t > /dev/null; then
1003 have_echo=yes
1005 # For ksh: alias echo to a function that uses cat of a here document.
1006 # The ksh manual page says:
1007 # "Aliasing is performed when scripts are read, not while they are executed.
1008 # Therefore, for an alias to take effect, the alias definition command has
1009 # to be executed before the command which references the alias is read."
1010 # Because of this, we have to play strange tricks with have_echo, to ensure
1011 # that the top-level statement containing the test starts after the 'alias'
1012 # command.
1013 if test -z "$have_echo"; then
1014 bsd_echo ()
1016 cat <<EOF
1020 if (alias echo=bsd_echo) 2>/dev/null; then
1021 alias echo=bsd_echo 2>/dev/null
1024 if test -z "$have_echo" \
1025 && echo '\t' | grep t > /dev/null; then
1026 have_echo=yes
1028 if test -z "$have_echo"; then
1029 if (alias echo=bsd_echo) 2>/dev/null; then
1030 unalias echo 2>/dev/null
1033 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
1034 if test -z "$have_echo" \
1035 && test "X$1" != "X--no-reexec" \
1036 && test -f /bin/ksh; then
1037 exec /bin/ksh "$0" --no-reexec "$@"
1038 exit 127
1040 # Otherwise: respawn using /bin/sh.
1041 if test -z "$have_echo" \
1042 && test "X$1" != "X--no-reexec" \
1043 && test -f /bin/sh; then
1044 exec /bin/sh "$0" --no-reexec "$@"
1045 exit 127
1047 if test -z "$have_echo"; then
1048 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
1050 if echo '\t' | grep t > /dev/null; then
1051 : # Works fine now.
1052 else
1053 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
1055 if test "X$1" = "X--no-reexec"; then
1056 shift
1059 # Unset CDPATH. Otherwise, output from 'cd dir' can surprise callers.
1060 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1062 # Determine the path separator early because the following option parsing code
1063 # requires that.
1064 func_determine_path_separator
1066 # Command-line option processing.
1067 # Removes the OPTIONS from the arguments. Sets the variables:
1068 # - mode one of: list, find, import, add-import, remove-import,
1069 # update, create-testdir, create-megatestdir, test, megatest,
1070 # copy-file
1071 # - destdir from --dir
1072 # - local_gnulib_path from --local-dir, highest priority dir comes first
1073 # - modcache true or false, from --cache-modules/--no-cache-modules
1074 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1075 # - libname, supplied_libname from --lib
1076 # - sourcebase from --source-base
1077 # - m4base from --m4-base
1078 # - pobase from --po-base
1079 # - docbase from --doc-base
1080 # - testsbase from --tests-base
1081 # - auxdir from --aux-dir
1082 # - inctests true if --with-tests was given, false if --without-tests
1083 # was given, blank otherwise
1084 # - incobsolete true if --with-obsolete was given, blank otherwise
1085 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
1086 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
1087 # otherwise
1088 # - inc_privileged_tests true if --with-privileged-tests was given, blank
1089 # otherwise
1090 # - inc_unportable_tests true if --with-unportable-tests was given, blank
1091 # otherwise
1092 # - inc_all_tests true if --with-all-tests was given, blank otherwise
1093 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
1094 # - excl_longrunning_tests true if --without-longrunning-tests was given,
1095 # blank otherwise
1096 # - excl_privileged_tests true if --without-privileged-tests was given, blank
1097 # otherwise
1098 # - excl_unportable_tests true if --without-unportable-tests was given, blank
1099 # otherwise
1100 # - single_configure true if --single-configure was given, false otherwise
1101 # - avoidlist list of modules to avoid, from --avoid
1102 # - cond_dependencies true if --conditional-dependencies was given, false if
1103 # --no-conditional-dependencies was given, blank otherwise
1104 # - lgpl yes or a number if --lgpl was given, blank otherwise
1105 # - gnu_make true if --gnu-make was given, false otherwise
1106 # - makefile_name from --makefile-name
1107 # - libtool true if --libtool was given, false if --no-libtool was
1108 # given, blank otherwise
1109 # - macro_prefix from --macro-prefix
1110 # - po_domain from --po-domain
1111 # - witness_c_macro from --witness-c-macro
1112 # - vc_files true if --vc-files was given, false if --no-vc-files was
1113 # given, blank otherwise
1114 # - autoconf_minversion minimum supported autoconf version
1115 # - doit : if actions shall be executed, false if only to be printed
1116 # - copymode symlink if --symlink or --more-symlinks was given,
1117 # hardlink if --hardlink or --more-hardlinks was given,
1118 # blank otherwise
1119 # - lcopymode symlink if --local-symlink was given,
1120 # hardlink if --local-hardlink was given,
1121 # blank otherwise
1122 # - do_copyrights blank if --more-symlinks or --more-hardlinks was given,
1123 # true otherwise
1125 mode=
1126 destdir=
1127 local_gnulib_path=
1128 modcache=true
1129 verbose=0
1130 libname=libgnu
1131 supplied_libname=
1132 sourcebase=
1133 m4base=
1134 pobase=
1135 docbase=
1136 testsbase=
1137 auxdir=
1138 inctests=
1139 incobsolete=
1140 inc_cxx_tests=
1141 inc_longrunning_tests=
1142 inc_privileged_tests=
1143 inc_unportable_tests=
1144 inc_all_tests=
1145 excl_cxx_tests=
1146 excl_longrunning_tests=
1147 excl_privileged_tests=
1148 excl_unportable_tests=
1149 single_configure=false
1150 avoidlist=
1151 cond_dependencies=
1152 lgpl=
1153 gnu_make=false
1154 makefile_name=
1155 libtool=
1156 macro_prefix=
1157 po_domain=
1158 witness_c_macro=
1159 vc_files=
1160 doit=:
1161 copymode=
1162 lcopymode=
1163 do_copyrights=true
1165 supplied_opts="$@"
1167 while test $# -gt 0; do
1168 case "$1" in
1169 --list | --lis )
1170 mode=list
1171 shift ;;
1172 --find | --fin | --fi | --f )
1173 mode=find
1174 shift ;;
1175 --import | --impor | --impo | --imp | --im | --i )
1176 mode=import
1177 shift ;;
1178 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1179 mode=add-import
1180 shift ;;
1181 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1182 mode=remove-import
1183 shift ;;
1184 --update | --updat | --upda | --upd | --up | --u )
1185 mode=update
1186 shift ;;
1187 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1188 mode=create-testdir
1189 shift ;;
1190 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1191 mode=create-megatestdir
1192 shift ;;
1193 --test | --tes | --te | --t )
1194 mode=test
1195 shift ;;
1196 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1197 mode=megatest
1198 shift ;;
1199 --extract-* )
1200 mode=`echo "X$1" | sed -e 's/^X--//'`
1201 shift ;;
1202 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1203 mode=copy-file
1204 shift ;;
1205 --dir )
1206 shift
1207 if test $# = 0; then
1208 func_fatal_error "missing argument for --dir"
1210 destdir=$1
1211 shift ;;
1212 --dir=* )
1213 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1214 shift ;;
1215 --local-dir )
1216 shift
1217 if test $# = 0; then
1218 func_fatal_error "missing argument for --local-dir"
1220 func_path_append local_gnulib_path "$1"
1221 shift ;;
1222 --local-dir=* )
1223 local_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1224 func_path_append local_gnulib_path "$local_dir"
1225 shift ;;
1226 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1227 modcache=true
1228 shift ;;
1229 --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 )
1230 modcache=false
1231 shift ;;
1232 --verbose | --verbos | --verbo | --verb )
1233 verbose=`expr $verbose + 1`
1234 shift ;;
1235 --quiet | --quie | --qui | --qu | --q )
1236 verbose=`expr $verbose - 1`
1237 shift ;;
1238 --lib )
1239 shift
1240 if test $# = 0; then
1241 func_fatal_error "missing argument for --lib"
1243 libname=$1
1244 supplied_libname=true
1245 shift ;;
1246 --lib=* )
1247 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1248 supplied_libname=true
1249 shift ;;
1250 --source-base )
1251 shift
1252 if test $# = 0; then
1253 func_fatal_error "missing argument for --source-base"
1255 sourcebase=$1
1256 shift ;;
1257 --source-base=* )
1258 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1259 shift ;;
1260 --m4-base )
1261 shift
1262 if test $# = 0; then
1263 func_fatal_error "missing argument for --m4-base"
1265 m4base=$1
1266 shift ;;
1267 --m4-base=* )
1268 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1269 shift ;;
1270 --po-base )
1271 shift
1272 if test $# = 0; then
1273 func_fatal_error "missing argument for --po-base"
1275 pobase=$1
1276 shift ;;
1277 --po-base=* )
1278 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1279 shift ;;
1280 --doc-base )
1281 shift
1282 if test $# = 0; then
1283 func_fatal_error "missing argument for --doc-base"
1285 docbase=$1
1286 shift ;;
1287 --doc-base=* )
1288 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1289 shift ;;
1290 --tests-base )
1291 shift
1292 if test $# = 0; then
1293 func_fatal_error "missing argument for --tests-base"
1295 testsbase=$1
1296 shift ;;
1297 --tests-base=* )
1298 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1299 shift ;;
1300 --aux-dir )
1301 shift
1302 if test $# = 0; then
1303 func_fatal_error "missing argument for --aux-dir"
1305 auxdir=$1
1306 shift ;;
1307 --aux-dir=* )
1308 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1309 shift ;;
1310 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1311 inctests=true
1312 shift ;;
1313 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1314 incobsolete=true
1315 shift ;;
1316 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1317 inc_cxx_tests=true
1318 shift ;;
1319 --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)
1320 inc_longrunning_tests=true
1321 shift ;;
1322 --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)
1323 inc_privileged_tests=true
1324 shift ;;
1325 --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)
1326 inc_unportable_tests=true
1327 shift ;;
1328 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1329 inc_all_tests=true
1330 shift ;;
1331 --without-tests | --without-test | --without-tes | --without-te | --without-t)
1332 inctests=false
1333 shift ;;
1334 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1335 excl_cxx_tests=true
1336 shift ;;
1337 --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)
1338 excl_longrunning_tests=true
1339 shift ;;
1340 --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)
1341 excl_privileged_tests=true
1342 shift ;;
1343 --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)
1344 excl_unportable_tests=true
1345 shift ;;
1346 --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)
1347 single_configure=true
1348 shift ;;
1349 --avoid )
1350 shift
1351 if test $# = 0; then
1352 func_fatal_error "missing argument for --avoid"
1354 func_append avoidlist " $1"
1355 shift ;;
1356 --avoid=* )
1357 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1358 func_append avoidlist " $arg"
1359 shift ;;
1360 --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)
1361 cond_dependencies=true
1362 shift ;;
1363 --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)
1364 cond_dependencies=false
1365 shift ;;
1366 --lgpl )
1367 lgpl=yes
1368 shift ;;
1369 --lgpl=* )
1370 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1371 case "$arg" in
1372 2 | 3orGPLv2 | 3) ;;
1373 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1374 esac
1375 lgpl=$arg
1376 shift ;;
1377 --gnu-make )
1378 gnu_make=true
1379 shift ;;
1380 --makefile-name )
1381 shift
1382 if test $# = 0; then
1383 func_fatal_error "missing argument for --makefile-name"
1385 makefile_name="$1"
1386 shift ;;
1387 --makefile-name=* )
1388 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1389 shift ;;
1390 --libtool )
1391 libtool=true
1392 shift ;;
1393 --no-libtool )
1394 libtool=false
1395 shift ;;
1396 --macro-prefix )
1397 shift
1398 if test $# = 0; then
1399 func_fatal_error "missing argument for --macro-prefix"
1401 macro_prefix="$1"
1402 shift ;;
1403 --macro-prefix=* )
1404 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1405 shift ;;
1406 --po-domain )
1407 shift
1408 if test $# = 0; then
1409 func_fatal_error "missing argument for --po-domain"
1411 po_domain="$1"
1412 shift ;;
1413 --po-domain=* )
1414 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1415 shift ;;
1416 --witness-c-macro )
1417 shift
1418 if test $# = 0; then
1419 func_fatal_error "missing argument for --witness-c-macro"
1421 witness_c_macro="$1"
1422 shift ;;
1423 --witness-c-macro=* )
1424 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1425 shift ;;
1426 --vc-files )
1427 vc_files=true
1428 shift ;;
1429 --no-vc-files )
1430 vc_files=false
1431 shift ;;
1432 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1433 # A no-op for backward compatibility.
1434 shift ;;
1435 --dry-run )
1436 doit=false
1437 shift ;;
1438 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1439 copymode=symlink
1440 shift ;;
1441 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1442 lcopymode=symlink
1443 shift ;;
1444 -h | --hardlink | --hardlin | --hardli | --hardl | --hard | --har | --ha )
1445 copymode=hardlink
1446 shift ;;
1447 --local-hardlink | --local-hardlin | --local-hardli | --local-hardl | --local-hard | --local-har | --local-ha | --local-h )
1448 lcopymode=hardlink
1449 shift ;;
1450 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s )
1451 copymode=symlink
1452 do_copyrights=
1453 shift ;;
1454 -H | --more-hardlinks | --more-hardlink | --more-hardlin | --more-hardli | --more-hardl | --more-hard | --more-har | --more-ha | --more-h )
1455 copymode=hardlink
1456 do_copyrights=
1457 shift ;;
1458 --help | --hel | --he )
1459 func_usage
1460 func_exit $? ;;
1461 --version | --versio | --versi | --vers )
1462 func_version
1463 func_exit $? ;;
1464 -- )
1465 # Stop option processing
1466 shift
1467 break ;;
1468 -* )
1469 echo "gnulib-tool: unknown option $1" 1>&2
1470 echo "Try 'gnulib-tool --help' for more information." 1>&2
1471 func_exit 1 ;;
1473 break ;;
1474 esac
1475 done
1477 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1478 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1479 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1480 || test "$single_configure" != false; then
1481 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1482 echo "Try 'gnulib-tool --help' for more information." 1>&2
1483 func_exit 1
1486 if test "$mode" = update; then
1487 if test $# != 0; then
1488 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1489 echo "Try 'gnulib-tool --help' for more information." 1>&2
1490 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1491 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1492 func_exit 1
1494 if test -n "$local_gnulib_path" || test -n "$supplied_libname" \
1495 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1496 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1497 || test -n "$inctests" || test -n "$incobsolete" \
1498 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1499 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1500 || test -n "$inc_all_tests" \
1501 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1502 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1503 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1504 || test -n "$macro_prefix" || test -n "$po_domain" \
1505 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1506 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1507 echo "Try 'gnulib-tool --help' for more information." 1>&2
1508 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1509 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1510 func_exit 1
1513 if test -n "$pobase" && test -z "$po_domain"; then
1514 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1515 echo "Try 'gnulib-tool --help' for more information." 1>&2
1516 func_exit 1
1518 if test -z "$pobase" && test -n "$po_domain"; then
1519 func_warning "--po-domain has no effect without a --po-base option"
1521 case $mode,$gnu_make in
1522 *test*,true)
1523 echo "gnulib-tool: --gnu-make not supported when including tests"
1524 func_exit 1;;
1525 esac
1526 # Canonicalize the inctests variable.
1527 case "$mode" in
1528 import | add-import | remove-import | update)
1529 if test -z "$inctests"; then
1530 inctests=false
1533 create-testdir | create-megatestdir | test | megatest)
1534 if test -z "$inctests"; then
1535 inctests=true
1538 esac
1539 # Now the only possible values of "$inctests" are true and false
1540 # (or blank but then it is irrelevant).
1542 # Determine the minimum supported autoconf version from the project's
1543 # configure.ac.
1544 DEFAULT_AUTOCONF_MINVERSION="2.64"
1545 autoconf_minversion=
1546 configure_ac=
1547 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1548 && test -n "$destdir"; then
1549 if test -f "$destdir"/configure.ac; then
1550 configure_ac="$destdir/configure.ac"
1551 else
1552 if test -f "$destdir"/configure.in; then
1553 configure_ac="$destdir/configure.in"
1556 else
1557 if test -f configure.ac; then
1558 configure_ac="configure.ac"
1559 else
1560 if test -f configure.in; then
1561 configure_ac="configure.in"
1565 if test -n "$configure_ac"; then
1566 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1567 # because when some m4 files are omitted from a version control repository,
1568 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1569 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1570 # autom4te: m4 failed with exit status: 1
1571 prereqs=
1572 my_sed_traces='
1573 s,#.*$,,
1574 s,^dnl .*$,,
1575 s, dnl .*$,,
1576 /AC_PREREQ/ {
1577 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1579 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1580 if test -n "$prereqs"; then
1581 autoconf_minversion=`
1582 for version in $prereqs; do echo $version; done |
1583 LC_ALL=C sort -nru | sed -e 1q
1587 if test -z "$autoconf_minversion"; then
1588 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1590 case "$autoconf_minversion" in
1591 1.* | 2.[0-5]* | 2.6[0-3]*)
1592 func_fatal_error "minimum supported autoconf version is 2.64. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1593 esac
1595 # Remove trailing slashes from the directory names. This is necessary for
1596 # m4base (to avoid an error in func_import) and optional for the others.
1597 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1598 old_local_gnulib_path="$local_gnulib_path"
1599 local_gnulib_path=
1600 save_IFS="$IFS"
1601 IFS=:
1602 for dir in $old_local_gnulib_path
1604 IFS="$save_IFS"
1605 case "$dir" in
1606 */ ) dir=`echo "$dir" | sed -e "$sed_trimtrailingslashes"` ;;
1607 esac
1608 func_path_append local_gnulib_path "$dir"
1609 done
1610 IFS="$save_IFS"
1611 case "$sourcebase" in
1612 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1613 esac
1614 case "$m4base" in
1615 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1616 esac
1617 case "$pobase" in
1618 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1619 esac
1620 case "$docbase" in
1621 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1622 esac
1623 case "$testsbase" in
1624 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1625 esac
1626 case "$auxdir" in
1627 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1628 esac
1631 func_gnulib_dir
1632 func_tmpdir
1633 trap 'exit_status=$?
1634 if test "$signal" != 0; then
1635 echo "caught signal $signal" >&2
1637 rm -rf "$tmp"
1638 exit $exit_status' 0
1639 for signal in 1 2 3 13 15; do
1640 trap '{ signal='$signal'; func_exit 1; }' $signal
1641 done
1642 signal=0
1644 # Note: The 'eval' silences stderr output in dash.
1645 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1646 # Zsh 4 and Bash 4 have associative arrays.
1647 have_associative=true
1648 else
1649 # For other shells, use 'eval' with computed shell variable names.
1650 have_associative=false
1653 # func_lookup_local_file_cb dir file
1654 # returns true and sets func_lookup_local_file_result if the file $dir/$file
1655 # exists.
1656 func_lookup_local_file_cb ()
1658 test -n "$func_lookup_local_file_result" && return 1 # already found?
1659 test -f "$1/$2" || return 1
1660 func_lookup_local_file_result=$1/$2
1664 # func_lookup_local_file file
1665 # looks up a file in $local_gnulib_path.
1666 # Input:
1667 # - local_gnulib_path from --local-dir
1668 # Output:
1669 # - func_lookup_local_file_result name of the file, valid only when the
1670 # function succeeded.
1671 func_lookup_local_file ()
1673 func_lookup_local_file_result=
1674 func_path_foreach "$local_gnulib_path" func_lookup_local_file_cb %dir% "$1"
1677 # func_lookup_file_cb dir
1678 # does one step in processing the $local_gnulib_path, looking for $dir/$lkfile
1679 # and $dir/$lkfile.diff.
1680 func_lookup_file_cb ()
1682 # If we found the file already in a --local-dir of higher priority, nothing
1683 # more to do.
1684 if test -z "$lookedup_file"; then
1685 # Otherwise, look for $dir/$lkfile and $dir/$lkfile.diff.
1686 if test -f "$1/$lkfile"; then
1687 lookedup_file="$1/$lkfile"
1688 else
1689 if test -f "$1/$lkfile.diff"; then
1690 lkpatches="$1/$lkfile.diff${lkpatches:+$PATH_SEPARATOR$lkpatches}"
1696 # func_lookup_file file
1697 # looks up a file in $local_gnulib_path or $gnulib_dir, or combines it through
1698 # 'patch'.
1699 # Input:
1700 # - local_gnulib_path from --local-dir
1701 # Output:
1702 # - lookedup_file name of the merged (combined) file
1703 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1704 func_lookup_file ()
1706 lkfile="$1"
1707 # Each element in $local_gnulib_path is a directory whose contents overrides
1708 # or amends the result of the lookup in the rest of $local_gnulib_path and
1709 # $gnulib_dir. So, the first element of $local_gnulib_path is the highest
1710 # priority one.
1711 lookedup_file=
1712 lkpatches=
1713 func_path_foreach "$local_gnulib_path" func_lookup_file_cb %dir%
1714 # Treat $gnulib_dir like a lowest-priority --local-dir, except that here we
1715 # don't look for .diff files.
1716 if test -z "$lookedup_file"; then
1717 if test -f "$gnulib_dir/$lkfile"; then
1718 lookedup_file="$gnulib_dir/$lkfile"
1719 else
1720 func_fatal_error "file $gnulib_dir/$lkfile not found"
1723 # Now apply the patches, from lowest-priority to highest-priority.
1724 lookedup_tmp=
1725 if test -n "$lkpatches"; then
1726 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1727 rm -f "$tmp/$lkbase"
1728 cp "$lookedup_file" "$tmp/$lkbase"
1729 func_ensure_writable "$tmp/$lkbase"
1730 save_IFS="$IFS"
1731 IFS="$PATH_SEPARATOR"
1732 for patchfile in $lkpatches; do
1733 IFS="$save_IFS"
1734 patch -s "$tmp/$lkbase" < "$patchfile" >&2 \
1735 || func_fatal_error "patch file $patchfile didn't apply cleanly"
1736 done
1737 IFS="$save_IFS"
1738 lookedup_file="$tmp/$lkbase"
1739 lookedup_tmp=true
1743 # func_sanitize_modulelist
1744 # receives a list of possible module names on standard input, one per line.
1745 # It removes those which are just file names unrelated to modules, and outputs
1746 # the resulting list to standard output, one per line.
1747 func_sanitize_modulelist ()
1749 sed -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1750 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1751 -e '/^README$/d' -e '/\/README$/d' \
1752 -e '/^TEMPLATE$/d' \
1753 -e '/^TEMPLATE-EXTENDED$/d' \
1754 -e '/^TEMPLATE-TESTS$/d' \
1755 -e '/^\..*/d' \
1756 -e '/~$/d'
1760 # func_modules_in_dir dir
1761 # outputs all module files in dir to standard output.
1762 func_modules_in_dir ()
1764 (test -d "$1" && cd "$1" && find modules -type f -print)
1767 # func_all_modules
1768 # Input:
1769 # - local_gnulib_path from --local-dir
1770 func_all_modules ()
1772 # Filter out metainformation files like README, which are not modules.
1773 # Filter out unit test modules; they can be retrieved through
1774 # --extract-tests-module if desired.
1776 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1777 func_path_foreach "$local_gnulib_path" func_modules_in_dir %dir% | sed -e 's,^modules/,,' -e 's,\.diff$,,'
1779 | func_sanitize_modulelist \
1780 | sed -e '/-tests$/d' \
1781 | LC_ALL=C sort -u
1784 # func_exists_local_module dir module
1785 # returns true if module exists in dir
1786 func_exists_local_module ()
1788 test -d "$1/modules" && test -f "$1/modules/$2";
1791 # func_exists_module module
1792 # tests whether a module, given by name, exists
1793 # Input:
1794 # - local_gnulib_path from --local-dir
1795 func_exists_module ()
1797 { test -f "$gnulib_dir/modules/$1" \
1798 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1" ; } \
1799 && test "ChangeLog" != "$1" \
1800 && test "COPYING" != "$1" \
1801 && test "README" != "$1" \
1802 && test "TEMPLATE" != "$1" \
1803 && test "TEMPLATE-EXTENDED" != "$1" \
1804 && test "TEMPLATE-TESTS" != "$1"
1807 # func_verify_module
1808 # verifies a module name
1809 # Input:
1810 # - local_gnulib_path from --local-dir
1811 # - module module name argument
1812 # Output:
1813 # - module unchanged if OK, empty if not OK
1814 # - lookedup_file if OK: name of the merged (combined) module description file
1815 # - lookedup_tmp if OK: true if it is located in the tmp directory, blank otherwise
1816 func_verify_module ()
1818 if func_exists_module "$module"; then
1819 # OK, $module is a correct module name.
1820 # Verify that building the module description with 'patch' succeeds.
1821 func_lookup_file "modules/$module"
1822 else
1823 func_warning "module $module doesn't exist"
1824 module=
1828 # func_verify_nontests_module
1829 # verifies a module name, excluding tests modules
1830 # Input:
1831 # - local_gnulib_path from --local-dir
1832 # - module module name argument
1833 func_verify_nontests_module ()
1835 case "$module" in
1836 *-tests ) module= ;;
1837 * ) func_verify_module ;;
1838 esac
1841 # func_verify_tests_module
1842 # verifies a module name, considering only tests modules
1843 # Input:
1844 # - local_gnulib_path from --local-dir
1845 # - module module name argument
1846 func_verify_tests_module ()
1848 case "$module" in
1849 *-tests ) func_verify_module ;;
1850 * ) module= ;;
1851 esac
1854 # Suffix of a sed expression that extracts a particular field from a
1855 # module description.
1856 # A field starts with a line that contains a keyword, such as 'Description',
1857 # followed by a colon and optional whitespace. All following lines, up to
1858 # the next field (or end of file if there is none) form the contents of the
1859 # field.
1860 # An absent field is equivalent to a field with empty contents.
1861 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1862 sed_extract_prog=':[ ]*$/ {
1865 s/^Description:[ ]*$//
1866 s/^Comment:[ ]*$//
1867 s/^Status:[ ]*$//
1868 s/^Notice:[ ]*$//
1869 s/^Applicability:[ ]*$//
1870 s/^Files:[ ]*$//
1871 s/^Depends-on:[ ]*$//
1872 s/^configure\.ac-early:[ ]*$//
1873 s/^configure\.ac:[ ]*$//
1874 s/^Makefile\.am:[ ]*$//
1875 s/^Include:[ ]*$//
1876 s/^Link:[ ]*$//
1877 s/^License:[ ]*$//
1878 s/^Maintainer:[ ]*$//
1885 # Piece of a sed expression that converts a field header line to a shell
1886 # variable name,
1887 # NOTE: Keep this in sync with sed_extract_prog above!
1888 sed_extract_field_header='
1889 s/^Description:[ ]*$/description/
1890 s/^Comment:[ ]*$/comment/
1891 s/^Status:[ ]*$/status/
1892 s/^Notice:[ ]*$/notice/
1893 s/^Applicability:[ ]*$/applicability/
1894 s/^Files:[ ]*$/files/
1895 s/^Depends-on:[ ]*$/dependson/
1896 s/^configure\.ac-early:[ ]*$/configureac_early/
1897 s/^configure\.ac:[ ]*$/configureac/
1898 s/^Makefile\.am:[ ]*$/makefile/
1899 s/^Include:[ ]*$/include/
1900 s/^Link:[ ]*$/link/
1901 s/^License:[ ]*$/license/
1902 s/^Maintainer:[ ]*$/maintainer/'
1904 if $modcache; then
1906 if $have_associative; then
1908 # Declare the associative arrays.
1909 declare -A modcache_cached
1910 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1911 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1912 eval "$declare_script"
1914 else
1916 # func_cache_var module
1917 # computes the cache variable name corresponding to $module.
1918 # Note: This computation can map different module names to the same
1919 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1920 # to protect against this case.
1921 # Output:
1922 # - cachevar a shell variable name
1923 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1924 # Bash 2.0 and newer, ksh, and zsh support the syntax
1925 # ${param//pattern/replacement}
1926 # as a shorthand for
1927 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1928 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1929 eval 'func_cache_var ()
1931 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1933 else
1934 func_cache_var ()
1936 case $1 in
1937 *[!a-zA-Z0-9_]*)
1938 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1940 cachevar=c_$1 ;;
1941 esac
1947 # func_init_sed_convert_to_cache_statements
1948 # Input:
1949 # - modcachevar_assignment
1950 # Output:
1951 # - sed_convert_to_cache_statements
1952 func_init_sed_convert_to_cache_statements ()
1954 # 'sed' script that turns a module description into shell script
1955 # assignments, suitable to be eval'ed. All active characters are escaped.
1956 # This script turns
1957 # Description:
1958 # Some module's description
1960 # Files:
1961 # lib/file.h
1962 # into:
1963 # modcache_description[$1]=\
1964 # 'Some module'"'"'s description
1966 # modcache_files[$1]=\
1967 # 'lib/file.h'
1968 # or:
1969 # c_MODULE_description_set=set; c_MODULE_description=\
1970 # 'Some module'"'"'s description
1972 # c_MODULE_files_set=set; c_MODULE_files=\
1973 # 'lib/file.h'
1974 # The script consists of two parts:
1975 # 1) Ignore the lines before the first field header.
1976 # 2) A loop, treating non-field-header lines by escaping single quotes
1977 # and adding a closing quote in the last line,
1978 sed_convert_to_cache_statements="
1979 :llla
1980 # Here we have not yet seen a field header.
1982 # See if the current line contains a field header.
1983 t llla1
1984 :llla1
1985 ${sed_extract_field_header}
1986 t lllb
1988 # No field header. Ignore the line.
1990 # Read the next line. Upon EOF, just exit.
1992 b llla
1994 :lllb
1995 # The current line contains a field header.
1997 # Turn it into the beginning of an assignment.
1998 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
2000 # Move it to the hold space. Don't print it yet,
2001 # because we want no assignment if the field is empty.
2004 # Read the next line.
2005 # Upon EOF, the field was empty. Print no assignment. Just exit.
2008 # See if the current line contains a field header.
2009 t lllb1
2010 :lllb1
2011 ${sed_extract_field_header}
2012 # If it is, the previous field was empty. Print no assignment.
2013 t lllb
2015 # Not a field header.
2017 # Print the previous line, held in the hold space.
2022 # Transform single quotes.
2023 s/'/'\"'\"'/g
2025 # Prepend a single quote.
2026 s/^/'/
2028 :lllc
2030 # Move it to the hold space.
2033 # Read the next line.
2034 # Upon EOF, branch.
2036 b llle
2040 # See if the current line contains a field header.
2041 t lllc1
2042 :lllc1
2043 ${sed_extract_field_header}
2044 t llld
2046 # Print the previous line, held in the hold space.
2051 # Transform single quotes.
2052 s/'/'\"'\"'/g
2054 b lllc
2056 :llld
2057 # A field header.
2058 # Print the previous line, held in the hold space, with a single quote
2059 # to end the assignment.
2061 s/\$/'/
2065 b lllb
2067 :llle
2068 # EOF seen.
2069 # Print the previous line, held in the hold space, with a single quote
2070 # to end the assignment.
2072 s/\$/'/
2074 # Exit.
2077 if ! $sed_comments; then
2078 # Remove comments.
2079 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
2080 | sed -e 's/^ *//' -e 's/^#.*//'`
2084 if $have_associative; then
2085 # sed_convert_to_cache_statements does not depend on the module.
2086 modcachevar_assignment='modcache_\1[$1]='
2087 func_init_sed_convert_to_cache_statements
2090 # func_cache_lookup_module module
2092 # looks up a module, like 'func_lookup_file modules/$module', and stores all
2093 # of its relevant data in a cache in the memory of the processing shell. If
2094 # already cached, it does not look it up again, thus saving file access time.
2095 # Parameters:
2096 # - module non-empty string
2097 # Output if $have_associative:
2098 # - modcache_cached[$module] set to yes
2099 # - modcache_description[$module] ==
2100 # - modcache_status[$module] \ set to the field's value, minus the
2101 # - ... / final newline,
2102 # - modcache_maintainer[$module] == or unset if the field's value is empty
2103 # Output if ! $have_associative:
2104 # - cachevar a shell variable name
2105 # - ${cachevar}_cached set to $module
2106 # - ${cachevar}_description ==
2107 # - ${cachevar}_status \ set to the field's value, minus the
2108 # - ... / final newline,
2109 # - ${cachevar}_maintainer == or unset if the field's value is empty
2110 # - ${cachevar}_description_set ==
2111 # - ${cachevar}_status_set \ set to non-empty if the field's value
2112 # - ... / is non-empty,
2113 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
2114 func_cache_lookup_module ()
2116 if $have_associative; then
2117 eval 'cached=${modcache_cached[$1]}'
2118 else
2119 func_cache_var "$1"
2120 eval "cached=\"\$${cachevar}_cached\""
2122 if test -z "$cached"; then
2123 # Not found in cache. Look it up on the file system.
2124 func_lookup_file "modules/$1"
2125 if $have_associative; then
2126 eval 'modcache_cached[$1]=yes'
2127 else
2128 eval "${cachevar}_cached=\"\$1\""
2130 if ! $have_associative; then
2131 # sed_convert_to_cache_statements depends on the module.
2132 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
2133 func_init_sed_convert_to_cache_statements
2135 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
2136 eval "$cache_statements"
2137 else
2138 if ! $have_associative; then
2139 if test "$1" != "$cached"; then
2140 func_fatal_error "cache variable collision between $1 and $cached"
2148 # func_get_description module
2149 # Input:
2150 # - local_gnulib_path from --local-dir
2151 # - modcache true or false, from --cache-modules/--no-cache-modules
2152 func_get_description ()
2154 if ! $modcache; then
2155 func_lookup_file "modules/$1"
2156 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
2157 else
2158 func_cache_lookup_module "$1"
2159 # Output the field's value, including the final newline (if any).
2160 if $have_associative; then
2161 if eval 'test -n "${modcache_description[$1]+set}"'; then
2162 eval 'echo "${modcache_description[$1]}"'
2164 else
2165 eval "field_set=\"\$${cachevar}_description_set\""
2166 if test -n "$field_set"; then
2167 eval "field_value=\"\$${cachevar}_description\""
2168 echo "${field_value}"
2174 # func_get_comment module
2175 # Input:
2176 # - local_gnulib_path from --local-dir
2177 # - modcache true or false, from --cache-modules/--no-cache-modules
2178 func_get_comment ()
2180 if ! $modcache; then
2181 func_lookup_file "modules/$1"
2182 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
2183 else
2184 func_cache_lookup_module "$1"
2185 # Output the field's value, including the final newline (if any).
2186 if $have_associative; then
2187 if eval 'test -n "${modcache_comment[$1]+set}"'; then
2188 eval 'echo "${modcache_comment[$1]}"'
2190 else
2191 eval "field_set=\"\$${cachevar}_comment_set\""
2192 if test -n "$field_set"; then
2193 eval "field_value=\"\$${cachevar}_comment\""
2194 echo "${field_value}"
2200 # func_get_status module
2201 # Input:
2202 # - local_gnulib_path from --local-dir
2203 # - modcache true or false, from --cache-modules/--no-cache-modules
2204 func_get_status ()
2206 if ! $modcache; then
2207 func_lookup_file "modules/$1"
2208 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
2209 else
2210 func_cache_lookup_module "$1"
2211 # Output the field's value, including the final newline (if any).
2212 if $have_associative; then
2213 if eval 'test -n "${modcache_status[$1]+set}"'; then
2214 eval 'echo "${modcache_status[$1]}"'
2216 else
2217 eval "field_set=\"\$${cachevar}_status_set\""
2218 if test -n "$field_set"; then
2219 eval "field_value=\"\$${cachevar}_status\""
2220 echo "${field_value}"
2226 # func_get_notice module
2227 # Input:
2228 # - local_gnulib_path from --local-dir
2229 # - modcache true or false, from --cache-modules/--no-cache-modules
2230 func_get_notice ()
2232 if ! $modcache; then
2233 func_lookup_file "modules/$1"
2234 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
2235 else
2236 func_cache_lookup_module "$1"
2237 # Output the field's value, including the final newline (if any).
2238 if $have_associative; then
2239 if eval 'test -n "${modcache_notice[$1]+set}"'; then
2240 eval 'echo "${modcache_notice[$1]}"'
2242 else
2243 eval "field_set=\"\$${cachevar}_notice_set\""
2244 if test -n "$field_set"; then
2245 eval "field_value=\"\$${cachevar}_notice\""
2246 echo "${field_value}"
2252 # func_get_applicability module
2253 # Input:
2254 # - local_gnulib_path from --local-dir
2255 # - modcache true or false, from --cache-modules/--no-cache-modules
2256 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
2257 func_get_applicability ()
2259 if ! $modcache; then
2260 func_lookup_file "modules/$1"
2261 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2262 else
2263 func_cache_lookup_module "$1"
2264 # Get the field's value, without the final newline.
2265 if $have_associative; then
2266 eval 'my_applicability="${modcache_applicability[$1]}"'
2267 else
2268 eval "my_applicability=\"\$${cachevar}_applicability\""
2271 if test -n "$my_applicability"; then
2272 echo $my_applicability
2273 else
2274 # The default is 'main' or 'tests', depending on the module's name.
2275 case $1 in
2276 *-tests) echo "tests";;
2277 *) echo "main";;
2278 esac
2282 # func_get_filelist module
2283 # Input:
2284 # - local_gnulib_path from --local-dir
2285 # - modcache true or false, from --cache-modules/--no-cache-modules
2286 func_get_filelist ()
2288 if ! $modcache; then
2289 func_lookup_file "modules/$1"
2290 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2291 else
2292 func_cache_lookup_module "$1"
2293 # Output the field's value, including the final newline (if any).
2294 if $have_associative; then
2295 if eval 'test -n "${modcache_files[$1]+set}"'; then
2296 eval 'echo "${modcache_files[$1]}"'
2298 else
2299 eval "field_set=\"\$${cachevar}_files_set\""
2300 if test -n "$field_set"; then
2301 eval "field_value=\"\$${cachevar}_files\""
2302 echo "${field_value}"
2306 echo m4/00gnulib.m4
2307 echo m4/zzgnulib.m4
2308 echo m4/gnulib-common.m4
2311 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2312 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2313 # elements starting with prefix and ending with suffix are considered.
2314 # Processing: removed_prefix and removed_suffix are removed from each element,
2315 # added_prefix and added_suffix are added to each element.
2316 # prefix, suffix should not contain shell-special characters.
2317 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2318 # added_prefix, added_suffix should not contain the characters \|&.
2319 func_filter_filelist ()
2321 if test "$2" != "$nl" \
2322 || { $fast_func_append \
2323 && { test -z "$6" || $fast_func_remove_prefix; } \
2324 && { test -z "$7" || $fast_func_remove_suffix; }; \
2325 }; then
2326 ffflist=
2327 for fff in $3; do
2328 # Do not quote possibly-empty parameters in case patterns,
2329 # AIX and HP-UX ksh won't match them if they are empty.
2330 case "$fff" in
2331 $4*$5)
2332 if test -n "$6"; then
2333 func_remove_prefix fff "$6"
2335 if test -n "$7"; then
2336 func_remove_suffix fff "$7"
2338 fff="$8${fff}$9"
2339 if test -z "$ffflist"; then
2340 ffflist="${fff}"
2341 else
2342 func_append ffflist "$2${fff}"
2345 esac
2346 done
2347 else
2348 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2349 ffflist=`for fff in $3; do
2350 case "$fff" in
2351 $4*$5) echo "$fff" ;;
2352 esac
2353 done | sed -e "$sed_fff_filter"`
2355 eval "$1=\"\$ffflist\""
2358 # func_get_dependencies module
2359 # Input:
2360 # - local_gnulib_path from --local-dir
2361 # - modcache true or false, from --cache-modules/--no-cache-modules
2362 func_get_dependencies ()
2364 # ${module}-tests implicitly depends on ${module}, if that module exists.
2365 case "$1" in
2366 *-tests)
2367 fgd1="$1"
2368 func_remove_suffix fgd1 '-tests'
2369 if func_exists_module "$fgd1"; then
2370 echo "$fgd1"
2373 esac
2374 # Then the explicit dependencies listed in the module description.
2375 { if ! $modcache; then
2376 func_lookup_file "modules/$1"
2377 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2378 else
2379 func_cache_lookup_module "$1"
2380 # Output the field's value, including the final newline (if any).
2381 if $have_associative; then
2382 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2383 eval 'echo "${modcache_dependson[$1]}"'
2385 else
2386 eval "field_set=\"\$${cachevar}_dependson_set\""
2387 if test -n "$field_set"; then
2388 eval "field_value=\"\$${cachevar}_dependson\""
2389 echo "${field_value}"
2394 | sed -e '/^#/d'
2397 sed_dependencies_without_conditions='s/ *\[.*//'
2399 # func_get_autoconf_early_snippet module
2400 # Input:
2401 # - local_gnulib_path from --local-dir
2402 # - modcache true or false, from --cache-modules/--no-cache-modules
2403 func_get_autoconf_early_snippet ()
2405 if ! $modcache; then
2406 func_lookup_file "modules/$1"
2407 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2408 else
2409 func_cache_lookup_module "$1"
2410 # Output the field's value, including the final newline (if any).
2411 if $have_associative; then
2412 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2413 eval 'echo "${modcache_configureac_early[$1]}"'
2415 else
2416 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2417 if test -n "$field_set"; then
2418 eval "field_value=\"\$${cachevar}_configureac_early\""
2419 echo "${field_value}"
2425 # func_get_autoconf_snippet module
2426 # Input:
2427 # - local_gnulib_path from --local-dir
2428 # - modcache true or false, from --cache-modules/--no-cache-modules
2429 func_get_autoconf_snippet ()
2431 if ! $modcache; then
2432 func_lookup_file "modules/$1"
2433 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2434 else
2435 func_cache_lookup_module "$1"
2436 # Output the field's value, including the final newline (if any).
2437 if $have_associative; then
2438 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2439 eval 'echo "${modcache_configureac[$1]}"'
2441 else
2442 eval "field_set=\"\$${cachevar}_configureac_set\""
2443 if test -n "$field_set"; then
2444 eval "field_value=\"\$${cachevar}_configureac\""
2445 echo "${field_value}"
2451 # Concatenate lines with trailing slash.
2452 # $1 is an optional filter to restrict the
2453 # concatenation to groups starting with that expression
2454 combine_lines() {
2455 sed -e "/$1.*"'\\$/{
2458 s/\\\n/ /
2459 s/\\$/\\/
2464 # func_get_automake_snippet_conditional module
2465 # returns the part of the Makefile.am snippet that can be put inside Automake
2466 # conditionals.
2467 # Input:
2468 # - local_gnulib_path from --local-dir
2469 # - modcache true or false, from --cache-modules/--no-cache-modules
2470 func_get_automake_snippet_conditional ()
2472 if ! $modcache; then
2473 func_lookup_file "modules/$1"
2474 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2475 else
2476 func_cache_lookup_module "$1"
2477 # Output the field's value, including the final newline (if any).
2478 if $have_associative; then
2479 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2480 eval 'echo "${modcache_makefile[$1]}"'
2482 else
2483 eval "field_set=\"\$${cachevar}_makefile_set\""
2484 if test -n "$field_set"; then
2485 eval "field_value=\"\$${cachevar}_makefile\""
2486 echo "${field_value}"
2492 # func_get_automake_snippet_unconditional module
2493 # returns the part of the Makefile.am snippet that must stay outside of
2494 # Automake conditionals.
2495 # Input:
2496 # - local_gnulib_path from --local-dir
2497 # - modcache true or false, from --cache-modules/--no-cache-modules
2498 func_get_automake_snippet_unconditional ()
2500 case "$1" in
2501 *-tests)
2502 # *-tests module live in tests/, not lib/.
2503 # Synthesize an EXTRA_DIST augmentation.
2504 all_files=`func_get_filelist $1`
2505 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2506 extra_files="$tests_files"
2507 if test -n "$extra_files"; then
2508 echo "EXTRA_DIST +=" $extra_files
2509 echo
2513 # Synthesize an EXTRA_DIST augmentation.
2514 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2515 already_mentioned_files=` \
2516 { if ! $modcache; then
2517 func_lookup_file "modules/$1"
2518 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2519 else
2520 func_cache_lookup_module "$1"
2521 if $have_associative; then
2522 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2523 eval 'echo "${modcache_makefile[$1]}"'
2525 else
2526 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2527 if test -n "$field_set"; then
2528 eval 'field_value="$'"${cachevar}"'_makefile"'
2529 echo "${field_value}"
2534 | combine_lines \
2535 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2536 all_files=`func_get_filelist $1`
2537 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2538 # Remove $already_mentioned_files from $lib_files.
2539 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2540 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2541 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2542 if test -n "$extra_files"; then
2543 echo "EXTRA_DIST +=" $extra_files
2544 echo
2546 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2547 # This is necessary so that automake can generate the right list of
2548 # dependency rules.
2549 # A possible approach would be to use autom4te --trace of the redefined
2550 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2551 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2552 # inside autoconf's built-in macros are not missed).
2553 # But it's simpler and more robust to do it here, based on the file list.
2554 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2555 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2556 # automake will generate a useless dependency; this is harmless.
2557 case "$1" in
2558 relocatable-prog-wrapper) ;;
2559 pt_chown) ;;
2561 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2562 if test -n "$extra_files"; then
2563 echo "EXTRA_lib_SOURCES +=" $extra_files
2564 echo
2567 esac
2568 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2569 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2570 if test -n "$buildaux_files"; then
2571 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2572 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2573 echo
2576 esac
2579 # func_get_automake_snippet module
2580 # Input:
2581 # - local_gnulib_path from --local-dir
2582 # - modcache true or false, from --cache-modules/--no-cache-modules
2583 func_get_automake_snippet ()
2585 func_get_automake_snippet_conditional "$1"
2586 func_get_automake_snippet_unconditional "$1"
2589 # func_get_include_directive module
2590 # Input:
2591 # - local_gnulib_path from --local-dir
2592 # - modcache true or false, from --cache-modules/--no-cache-modules
2593 func_get_include_directive ()
2596 if ! $modcache; then
2597 func_lookup_file "modules/$1"
2598 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2599 else
2600 func_cache_lookup_module "$1"
2601 # Output the field's value, including the final newline (if any).
2602 if $have_associative; then
2603 if eval 'test -n "${modcache_include[$1]+set}"'; then
2604 eval 'echo "${modcache_include[$1]}"'
2606 else
2607 eval "field_set=\"\$${cachevar}_include_set\""
2608 if test -n "$field_set"; then
2609 eval "field_value=\"\$${cachevar}_include\""
2610 echo "${field_value}"
2614 } | sed -e 's/^\(["<]\)/#include \1/'
2617 # func_get_link_directive module
2618 # Input:
2619 # - local_gnulib_path from --local-dir
2620 # - modcache true or false, from --cache-modules/--no-cache-modules
2621 func_get_link_directive ()
2623 if ! $modcache; then
2624 func_lookup_file "modules/$1"
2625 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2626 else
2627 func_cache_lookup_module "$1"
2628 # Output the field's value, including the final newline (if any).
2629 if $have_associative; then
2630 if eval 'test -n "${modcache_link[$1]+set}"'; then
2631 eval 'echo "${modcache_link[$1]}"'
2633 else
2634 eval "field_set=\"\$${cachevar}_link_set\""
2635 if test -n "$field_set"; then
2636 eval "field_value=\"\$${cachevar}_link\""
2637 echo "${field_value}"
2643 # func_get_license_raw module
2644 # Input:
2645 # - local_gnulib_path from --local-dir
2646 # - modcache true or false, from --cache-modules/--no-cache-modules
2647 func_get_license_raw ()
2649 if ! $modcache; then
2650 func_lookup_file "modules/$1"
2651 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2652 else
2653 func_cache_lookup_module "$1"
2654 # Output the field's value, including the final newline (if any).
2655 if $have_associative; then
2656 if eval 'test -n "${modcache_license[$1]+set}"'; then
2657 eval 'echo "${modcache_license[$1]}"'
2659 else
2660 eval "field_set=\"\$${cachevar}_license_set\""
2661 if test -n "$field_set"; then
2662 eval "field_value=\"\$${cachevar}_license\""
2663 echo "${field_value}"
2669 # func_get_license module
2670 # Input:
2671 # - local_gnulib_path from --local-dir
2672 # - modcache true or false, from --cache-modules/--no-cache-modules
2673 func_get_license ()
2675 # Warn if the License field is missing.
2676 case "$1" in
2677 *-tests ) ;;
2679 license=`func_get_license_raw "$1"`
2680 if test -z "$license"; then
2681 func_warning "module $1 lacks a License"
2684 esac
2685 case "$1" in
2686 parse-datetime )
2687 # These modules are under a weaker license only for the purpose of some
2688 # users who hand-edit it and don't use gnulib-tool. For the regular
2689 # gnulib users they are under a stricter license.
2690 echo "GPL"
2694 func_get_license_raw "$1"
2695 # The default is GPL.
2696 echo "GPL"
2697 } | sed -e 's,^ *$,,' | sed -e 1q
2699 esac
2702 # func_get_maintainer module
2703 # Input:
2704 # - local_gnulib_path from --local-dir
2705 # - modcache true or false, from --cache-modules/--no-cache-modules
2706 func_get_maintainer ()
2708 if ! $modcache; then
2709 func_lookup_file "modules/$1"
2710 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2711 else
2712 func_cache_lookup_module "$1"
2713 # Output the field's value, including the final newline (if any).
2714 if $have_associative; then
2715 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2716 eval 'echo "${modcache_maintainer[$1]}"'
2718 else
2719 eval "field_set=\"\$${cachevar}_maintainer_set\""
2720 if test -n "$field_set"; then
2721 eval "field_value=\"\$${cachevar}_maintainer\""
2722 echo "${field_value}"
2728 # func_get_tests_module module
2729 # Input:
2730 # - local_gnulib_path from --local-dir
2731 func_get_tests_module ()
2733 # The naming convention for tests modules is hardwired: ${module}-tests.
2734 if test -f "$gnulib_dir/modules/$1"-tests \
2735 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1-tests"; then
2736 echo "$1"-tests
2740 # func_get_dependencies_recursively module
2741 # Input:
2742 # - local_gnulib_path from --local-dir
2743 # - modcache true or false, from --cache-modules/--no-cache-modules
2744 func_get_dependencies_recursively ()
2746 # In order to process every module only once (for speed), process an "input
2747 # list" of modules, producing an "output list" of modules. During each round,
2748 # more modules can be queued in the input list. Once a module on the input
2749 # list has been processed, it is added to the "handled list", so we can avoid
2750 # to process it again.
2751 handledmodules=
2752 inmodules="$1"
2753 outmodules=
2754 while test -n "$inmodules"; do
2755 inmodules_this_round="$inmodules"
2756 inmodules= # Accumulator, queue for next round
2757 for module in $inmodules_this_round; do
2758 func_verify_module
2759 if test -n "$module"; then
2760 func_append outmodules " $module"
2761 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2762 for dep in $deps; do
2763 func_append inmodules " $dep"
2764 done
2766 done
2767 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2768 # Remove $handledmodules from $inmodules.
2769 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2770 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2771 done
2772 rm -f "$tmp"/queued-modules
2773 for m in $outmodules; do echo $m; done | LC_ALL=C sort -u
2776 # func_get_link_directive_recursively module
2777 # Input:
2778 # - local_gnulib_path from --local-dir
2779 # - modcache true or false, from --cache-modules/--no-cache-modules
2780 func_get_link_directive_recursively ()
2782 # In order to process every module only once (for speed), process an "input
2783 # list" of modules, producing an "output list" of modules. During each round,
2784 # more modules can be queued in the input list. Once a module on the input
2785 # list has been processed, it is added to the "handled list", so we can avoid
2786 # to process it again.
2787 handledmodules=
2788 inmodules="$1"
2789 outmodules=
2790 while test -n "$inmodules"; do
2791 inmodules_this_round="$inmodules"
2792 inmodules= # Accumulator, queue for next round
2793 for module in $inmodules_this_round; do
2794 func_verify_module
2795 if test -n "$module"; then
2796 if grep '^Link:[ ]*$' "$lookedup_file" >/dev/null; then
2797 # The module description has a 'Link:' field. Ignore the dependencies.
2798 func_append outmodules " $module"
2799 else
2800 # The module description has no 'Link:' field. Recurse through the dependencies.
2801 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2802 for dep in $deps; do
2803 func_append inmodules " $dep"
2804 done
2807 done
2808 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2809 # Remove $handledmodules from $inmodules.
2810 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2811 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2812 done
2813 rm -f "$tmp"/queued-modules
2814 for m in $outmodules; do func_get_link_directive "$m"; done | LC_ALL=C sort -u | sed -e '/^$/d'
2817 # func_acceptable module
2818 # tests whether a module is acceptable.
2819 # Input:
2820 # - avoidlist list of modules to avoid
2821 func_acceptable ()
2823 for avoid in $avoidlist; do
2824 if test "$avoid" = "$1"; then
2825 return 1
2827 done
2828 return 0
2831 # sed expression to keep the first 32 characters of each line.
2832 sed_first_32_chars='s/^\(................................\).*/\1/'
2834 # func_module_shellfunc_name module
2835 # computes the shell function name that will contain the m4 macros for the module.
2836 # Input:
2837 # - macro_prefix prefix to use
2838 # Output:
2839 # - shellfunc shell function name
2840 func_module_shellfunc_name ()
2842 case $1 in
2843 *[!a-zA-Z0-9_]*)
2844 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2846 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2847 esac
2850 # func_module_shellvar_name module
2851 # computes the shell variable name the will be set to true once the m4 macros
2852 # for the module have been executed.
2853 # Output:
2854 # - shellvar shell variable name
2855 func_module_shellvar_name ()
2857 case $1 in
2858 *[!a-zA-Z0-9_]*)
2859 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2861 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2862 esac
2865 # func_module_conditional_name module
2866 # computes the automake conditional name for the module.
2867 # Output:
2868 # - conditional name of automake conditional
2869 func_module_conditional_name ()
2871 case $1 in
2872 *[!a-zA-Z0-9_]*)
2873 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2875 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2876 esac
2879 # func_uncond_add_module B
2880 # notes the presence of B as an unconditional module.
2882 # func_conddep_add_module A B cond
2883 # notes the presence of a conditional dependency from module A to module B,
2884 # subject to the condition that A is enabled and cond is true.
2886 # func_cond_module_p B
2887 # tests whether module B is conditional.
2889 # func_cond_module_condition A B
2890 # returns the condition when B should be enabled as a dependency of A, once the
2891 # m4 code for A has been executed.
2892 # Output: - condition
2894 if $have_associative; then
2895 declare -A conddep_isuncond
2896 declare -A conddep_dependers
2897 declare -A conddep_condition
2898 func_uncond_add_module ()
2900 eval 'conddep_isuncond[$1]=true'
2901 eval 'unset conddep_dependers[$1]'
2903 func_conddep_add_module ()
2905 eval 'isuncond="${conddep_isuncond[$2]}"'
2906 if test -z "$isuncond"; then
2907 # No unconditional dependency to B known at this point.
2908 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2909 eval 'conddep_condition[$1---$2]="$3"'
2912 func_cond_module_p ()
2914 eval 'previous_dependers="${conddep_dependers[$1]}"'
2915 test -n "$previous_dependers"
2917 func_cond_module_condition ()
2919 eval 'condition="${conddep_condition[$1---$2]}"'
2921 else
2922 func_uncond_add_module ()
2924 case $1 in
2925 *[!a-zA-Z0-9_]*)
2926 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2928 suffix=$1 ;;
2929 esac
2930 eval 'conddep_isuncond_'"$suffix"'=true'
2931 eval 'unset conddep_dependers_'"$suffix"
2933 func_conddep_add_module ()
2935 case $2 in
2936 *[!a-zA-Z0-9_]*)
2937 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2939 suffix=$2 ;;
2940 esac
2941 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2942 if test -z "$isuncond"; then
2943 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2944 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2945 eval 'conddep_condition_'"$suffix"'="$3"'
2948 func_cond_module_p ()
2950 case $1 in
2951 *[!a-zA-Z0-9_]*)
2952 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2954 suffix=$1 ;;
2955 esac
2956 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2957 test -n "$previous_dependers"
2959 func_cond_module_condition ()
2961 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2962 eval 'condition="${conddep_condition_'"$suffix"'}"'
2966 # func_modules_transitive_closure
2967 # Input:
2968 # - local_gnulib_path from --local-dir
2969 # - gnu_make true if --gnu-make was given, false otherwise
2970 # - modcache true or false, from --cache-modules/--no-cache-modules
2971 # - modules list of specified modules
2972 # - inctests true if tests should be included, false otherwise
2973 # - incobsolete true if obsolete modules among dependencies should be
2974 # included, blank otherwise
2975 # - inc_cxx_tests true if C++ interoperability tests should be included,
2976 # blank otherwise
2977 # - inc_longrunning_tests true if long-runnings tests should be included,
2978 # blank otherwise
2979 # - inc_privileged_tests true if tests that require root privileges should be
2980 # included, blank otherwise
2981 # - inc_unportable_tests true if tests that fail on some platforms should be
2982 # included, blank otherwise
2983 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2984 # the unit tests of the specified modules should be
2985 # included, blank otherwise
2986 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2987 # the unit tests of the dependencies should be
2988 # included, blank otherwise
2989 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2990 # blank otherwise
2991 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2992 # blank otherwise
2993 # - excl_privileged_tests true if tests that require root privileges should be
2994 # excluded, blank otherwise
2995 # - excl_unportable_tests true if tests that fail on some platforms should be
2996 # excluded, blank otherwise
2997 # - avoidlist list of modules to avoid
2998 # - cond_dependencies true if conditional dependencies shall be supported,
2999 # blank otherwise
3000 # - tmp pathname of a temporary directory
3001 # Output:
3002 # - modules list of modules, including dependencies
3003 # - conddep_dependers, conddep_condition information about conditionally
3004 # enabled modules
3005 func_modules_transitive_closure ()
3007 sed_escape_dependency='s|\([/.]\)|\\\1|g'
3008 # In order to process every module only once (for speed), process an "input
3009 # list" of modules, producing an "output list" of modules. During each round,
3010 # more modules can be queued in the input list. Once a module on the input
3011 # list has been processed, it is added to the "handled list", so we can avoid
3012 # to process it again.
3013 handledmodules=
3014 inmodules="$modules"
3015 outmodules=
3016 fmtc_inc_all_tests="$inc_all_direct_tests"
3017 if test "$cond_dependencies" = true; then
3018 for module in $inmodules; do
3019 func_verify_module
3020 if test -n "$module"; then
3021 if func_acceptable $module; then
3022 func_uncond_add_module $module
3025 done
3027 while test -n "$inmodules"; do
3028 inmodules_this_round="$inmodules"
3029 inmodules= # Accumulator, queue for next round
3030 for module in $inmodules_this_round; do
3031 func_verify_module
3032 if test -n "$module"; then
3033 if func_acceptable $module; then
3034 func_append outmodules " $module"
3035 if test "$cond_dependencies" = true; then
3036 if ! $gnu_make \
3037 && func_get_automake_snippet_conditional $module \
3038 | grep '^if ' > /dev/null; then
3039 # A module whose Makefile.am snippet contains a reference to an
3040 # automake conditional. If we were to use it conditionally, we
3041 # would get an error
3042 # configure: error: conditional "..." was never defined.
3043 # because automake 1.11.1 does not handle nested conditionals
3044 # correctly. As a workaround, make the module unconditional.
3045 func_uncond_add_module $module
3047 if func_cond_module_p $module; then
3048 conditional=true
3049 else
3050 conditional=false
3053 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3054 # Duplicate dependencies are harmless, but Jim wants a warning.
3055 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
3056 if test -n "$duplicated_deps"; then
3057 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
3059 if $inctests; then
3060 testsmodule=`func_get_tests_module $module`
3061 if test -n "$testsmodule"; then
3062 deps="$deps $testsmodule"
3065 for dep in $deps; do
3066 # Determine whether to include the dependency or tests module.
3067 inc=true
3068 for word in `func_get_status $dep`; do
3069 case "$word" in
3070 obsolete)
3071 test -n "$incobsolete" \
3072 || inc=false
3074 c++-test)
3075 test -z "$excl_cxx_tests" \
3076 || inc=false
3077 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
3078 || inc=false
3080 longrunning-test)
3081 test -z "$excl_longrunning_tests" \
3082 || inc=false
3083 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
3084 || inc=false
3086 privileged-test)
3087 test -z "$excl_privileged_tests" \
3088 || inc=false
3089 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
3090 || inc=false
3092 unportable-test)
3093 test -z "$excl_unportable_tests" \
3094 || inc=false
3095 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
3096 || inc=false
3098 *-test)
3099 test -n "$fmtc_inc_all_tests" \
3100 || inc=false
3102 esac
3103 done
3104 if $inc && func_acceptable "$dep"; then
3105 func_append inmodules " $dep"
3106 if test "$cond_dependencies" = true; then
3107 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
3108 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
3109 s/^.*$/true/p
3111 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
3112 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
3114 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
3115 if test "$condition" = true; then
3116 condition=
3118 if test -n "$condition"; then
3119 func_conddep_add_module "$module" "$dep" "$condition"
3120 else
3121 if $conditional; then
3122 func_conddep_add_module "$module" "$dep" true
3123 else
3124 func_uncond_add_module "$dep"
3129 done
3132 done
3133 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
3134 # Remove $handledmodules from $inmodules.
3135 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
3136 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
3137 fmtc_inc_all_tests="$inc_all_indirect_tests"
3138 done
3139 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
3140 rm -f "$tmp"/queued-modules
3143 # func_show_module_list
3144 # Input:
3145 # - specified_modules list of specified modules (one per line, sorted)
3146 # - modules complete list of modules (one per line, sorted)
3147 # - tmp pathname of a temporary directory
3148 func_show_module_list ()
3150 if case "$TERM" in
3151 xterm*) test -t 1;;
3152 *) false;;
3153 esac; then
3154 # Assume xterm compatible escape sequences.
3155 bold_on=`printf '\033[1m'`
3156 bold_off=`printf '\033[0m'`
3157 else
3158 bold_on=
3159 bold_off=
3161 echo "Module list with included dependencies (indented):"
3162 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
3163 echo "$modules" | sed -e '/^$/d' \
3164 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
3165 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
3168 # func_modules_transitive_closure_separately
3169 # Determine main module list and tests-related module list separately.
3170 # The main module list is the transitive closure of the specified modules,
3171 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3172 # is specified, it will consist only of LGPLed source.
3173 # The tests-related module list is the transitive closure of the specified
3174 # modules, including tests modules, minus the main module list excluding
3175 # modules of applicability 'all'. Its lib/* sources (brought in through
3176 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3177 # source, even if --lgpl is specified.
3178 # Input:
3179 # - local_gnulib_path from --local-dir
3180 # - modcache true or false, from --cache-modules/--no-cache-modules
3181 # - specified_modules list of specified modules
3182 # - inctests true if tests should be included, false otherwise
3183 # - incobsolete true if obsolete modules among dependencies should be
3184 # included, blank otherwise
3185 # - inc_cxx_tests true if C++ interoperability tests should be included,
3186 # blank otherwise
3187 # - inc_longrunning_tests true if long-runnings tests should be included,
3188 # blank otherwise
3189 # - inc_privileged_tests true if tests that require root privileges should be
3190 # included, blank otherwise
3191 # - inc_unportable_tests true if tests that fail on some platforms should be
3192 # included, blank otherwise
3193 # - inc_all_direct_tests true if all kinds of problematic unit tests among
3194 # the unit tests of the specified modules should be
3195 # included, blank otherwise
3196 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
3197 # the unit tests of the dependencies should be
3198 # included, blank otherwise
3199 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
3200 # blank otherwise
3201 # - excl_longrunning_tests true if long-runnings tests should be excluded,
3202 # blank otherwise
3203 # - excl_privileged_tests true if tests that require root privileges should be
3204 # excluded, blank otherwise
3205 # - excl_unportable_tests true if tests that fail on some platforms should be
3206 # excluded, blank otherwise
3207 # - avoidlist list of modules to avoid
3208 # - cond_dependencies true if conditional dependencies shall be supported,
3209 # blank otherwise
3210 # - tmp pathname of a temporary directory
3211 # Output:
3212 # - main_modules list of modules, including dependencies
3213 # - testsrelated_modules list of tests-related modules, including dependencies
3214 # - conddep_dependers, conddep_condition information about conditionally
3215 # enabled modules
3216 func_modules_transitive_closure_separately ()
3218 # Determine main module list.
3219 saved_inctests="$inctests"
3220 inctests=false
3221 modules="$specified_modules"
3222 func_modules_transitive_closure
3223 main_modules="$modules"
3224 inctests="$saved_inctests"
3225 if test $verbose -ge 1; then
3226 echo "Main module list:"
3227 echo "$main_modules" | sed -e 's/^/ /'
3229 # Determine tests-related module list.
3230 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3231 testsrelated_modules=`for module in $main_modules; do
3232 if test \`func_get_applicability $module\` = main; then
3233 echo $module
3235 done \
3236 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3237 # If testsrelated_modules consists only of modules with applicability 'all',
3238 # set it to empty (because such modules are only helper modules for other modules).
3239 have_nontrivial_testsrelated_modules=
3240 for module in $testsrelated_modules; do
3241 if test `func_get_applicability $module` != all; then
3242 have_nontrivial_testsrelated_modules=yes
3243 break
3245 done
3246 if test -z "$have_nontrivial_testsrelated_modules"; then
3247 testsrelated_modules=
3249 if test $verbose -ge 1; then
3250 echo "Tests-related module list:"
3251 echo "$testsrelated_modules" | sed -e 's/^/ /'
3255 # func_determine_use_libtests
3256 # Determines whether a $testsbase/libtests.a is needed.
3257 # Input:
3258 # - local_gnulib_path from --local-dir
3259 # - modcache true or false, from --cache-modules/--no-cache-modules
3260 # - testsrelated_modules list of tests-related modules, including dependencies
3261 # Output:
3262 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3263 func_determine_use_libtests ()
3265 use_libtests=false
3266 for module in $testsrelated_modules; do
3267 func_verify_nontests_module
3268 if test -n "$module"; then
3269 all_files=`func_get_filelist $module`
3270 # Test whether some file in $all_files lies in lib/.
3271 for f in $all_files; do
3272 case $f in
3273 lib/*)
3274 use_libtests=true
3275 break 2
3277 esac
3278 done
3280 done
3283 # func_remove_if_blocks
3284 # removes if...endif blocks from an automake snippet.
3285 func_remove_if_blocks ()
3287 sed -n -e '/^if / {
3290 s/^endif//
3298 # func_modules_add_dummy
3299 # Input:
3300 # - local_gnulib_path from --local-dir
3301 # - modcache true or false, from --cache-modules/--no-cache-modules
3302 # - modules list of modules, including dependencies
3303 # Output:
3304 # - modules list of modules, including 'dummy' if needed
3305 func_modules_add_dummy ()
3307 # Determine whether any module provides a lib_SOURCES augmentation.
3308 have_lib_SOURCES=
3309 for module in $modules; do
3310 func_verify_nontests_module
3311 if test -n "$module"; then
3312 if test "$cond_dependencies" = true && func_cond_module_p $module; then
3313 # Ignore conditional modules, since they are not guaranteed to
3314 # contribute to lib_SOURCES.
3316 else
3317 # Extract the value of unconditional "lib_SOURCES += ..." augmentations.
3318 for file in `func_get_automake_snippet "$module" | combine_lines |
3319 func_remove_if_blocks |
3320 sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
3321 # Ignore .h files since they are not compiled.
3322 case "$file" in
3323 *.h) ;;
3325 have_lib_SOURCES=yes
3326 break 2
3328 esac
3329 done
3332 done
3333 # Add the dummy module, to make sure the library will be non-empty.
3334 if test -z "$have_lib_SOURCES"; then
3335 if func_acceptable "dummy"; then
3336 func_append modules " dummy"
3341 # func_modules_add_dummy_separately
3342 # Input:
3343 # - local_gnulib_path from --local-dir
3344 # - modcache true or false, from --cache-modules/--no-cache-modules
3345 # - main_modules list of modules, including dependencies
3346 # - testsrelated_modules list of tests-related modules, including dependencies
3347 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3348 # Output:
3349 # - main_modules list of modules, including 'dummy' if needed
3350 # - testsrelated_modules list of tests-related modules, including 'dummy' if
3351 # needed
3352 func_modules_add_dummy_separately ()
3354 # Add the dummy module to the main module list if needed.
3355 modules="$main_modules"
3356 func_modules_add_dummy
3357 main_modules="$modules"
3359 # Add the dummy module to the tests-related module list if needed.
3360 if $use_libtests; then
3361 modules="$testsrelated_modules"
3362 func_modules_add_dummy
3363 testsrelated_modules="$modules"
3367 # func_modules_notice
3368 # Input:
3369 # - local_gnulib_path from --local-dir
3370 # - modcache true or false, from --cache-modules/--no-cache-modules
3371 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3372 # - modules list of modules, including dependencies
3373 func_modules_notice ()
3375 if test $verbose -ge -1; then
3376 for module in $modules; do
3377 func_verify_module
3378 if test -n "$module"; then
3379 msg=`func_get_notice $module`
3380 if test -n "$msg"; then
3381 echo "Notice from module $module:"
3382 echo "$msg" | sed -e 's/^/ /'
3385 done
3389 # func_modules_to_filelist
3390 # Input:
3391 # - local_gnulib_path from --local-dir
3392 # - modcache true or false, from --cache-modules/--no-cache-modules
3393 # - modules list of modules, including dependencies
3394 # Output:
3395 # - files list of files
3396 func_modules_to_filelist ()
3398 files=
3399 for module in $modules; do
3400 func_verify_module
3401 if test -n "$module"; then
3402 fs=`func_get_filelist $module`
3403 func_append files " $fs"
3405 done
3406 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3409 # func_modules_to_filelist_separately
3410 # Determine the final file lists.
3411 # They must be computed separately, because files in lib/* go into
3412 # $sourcebase/ if they are in the main file list but into $testsbase/
3413 # if they are in the tests-related file list. Furthermore lib/dummy.c
3414 # can be in both.
3415 # Input:
3416 # - local_gnulib_path from --local-dir
3417 # - modcache true or false, from --cache-modules/--no-cache-modules
3418 # - main_modules list of modules, including dependencies
3419 # - testsrelated_modules list of tests-related modules, including dependencies
3420 func_modules_to_filelist_separately ()
3422 # Determine final main file list.
3423 modules="$main_modules"
3424 func_modules_to_filelist
3425 main_files="$files"
3426 # Determine final tests-related file list.
3427 modules="$testsrelated_modules"
3428 func_modules_to_filelist
3429 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3430 # Merge both file lists.
3431 sed_remove_empty_lines='/^$/d'
3432 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3433 if test $verbose -ge 0; then
3434 echo "File list:"
3435 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3436 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3440 # func_compute_include_guard_prefix
3441 # Determine include_guard_prefix.
3442 # Input:
3443 # - macro_prefix prefix of gl_LIBOBJS macros to use
3444 # Output:
3445 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3446 # - sed_replace_include_guard_prefix
3447 # sed expression for resolving ${gl_include_guard_prefix}
3448 func_compute_include_guard_prefix ()
3450 if test "$macro_prefix" = gl; then
3451 include_guard_prefix='GL'
3452 else
3453 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3455 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3458 # func_execute_command command [args...]
3459 # Executes a command.
3460 # Uses also the variables
3461 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3462 func_execute_command ()
3464 if test $verbose -ge 0; then
3465 echo "executing $*"
3466 "$@"
3467 else
3468 # Commands like automake produce output to stderr even when they succeed.
3469 # Turn this output off if the command succeeds.
3470 "$@" > "$tmp"/cmdout 2>&1
3471 cmdret=$?
3472 if test $cmdret = 0; then
3473 rm -f "$tmp"/cmdout
3474 else
3475 echo "executing $*"
3476 cat "$tmp"/cmdout 1>&2
3477 rm -f "$tmp"/cmdout
3478 (exit $cmdret)
3483 # func_dest_tmpfilename file
3484 # determines the name of a temporary file (file is relative to destdir).
3485 # Input:
3486 # - destdir target directory
3487 # - doit : if actions shall be executed, false if only to be printed
3488 # - tmp pathname of a temporary directory
3489 # Sets variable:
3490 # - tmpfile absolute filename of the temporary file
3491 func_dest_tmpfilename ()
3493 if $doit; then
3494 # Put the new contents of $file in a file in the same directory (needed
3495 # to guarantee that an 'mv' to "$destdir/$file" works).
3496 tmpfile="$destdir/$1.tmp"
3497 else
3498 # Put the new contents of $file in a file in a temporary directory
3499 # (because the directory of "$file" might not exist).
3500 tmpfile="$tmp"/`basename "$1"`.tmp
3504 # func_is_local_file lookedup_file file
3505 # check whether file should be instantiated from local gnulib directory
3506 func_is_local_file ()
3508 dname=$1
3509 func_remove_suffix dname "/$2"
3510 func_path_foreach "$local_gnulib_path" test %dir% = "$dname"
3513 # func_should_link
3514 # determines whether the file $f should be copied, symlinked, or hardlinked.
3515 # Input:
3516 # - copymode copy mode for files in general
3517 # - lcopymode copy mode for files from local_gnulib_path
3518 # - f the original file name
3519 # - lookedup_file name of the merged (combined) file
3520 # Sets variable:
3521 # - copyaction copy or symlink or hardlink
3522 func_should_link ()
3524 if test -n "$lcopymode" && func_is_local_file "$lookedup_file" "$f"; then
3525 copyaction="$lcopymode"
3526 else
3527 if test -n "$copymode"; then
3528 copyaction="$copymode"
3529 else
3530 copyaction=copy
3535 # func_add_file
3536 # copies a file from gnulib into the destination directory. The destination
3537 # is known to not exist.
3538 # Input:
3539 # - destdir target directory
3540 # - local_gnulib_path from --local-dir
3541 # - modcache true or false, from --cache-modules/--no-cache-modules
3542 # - f the original file name
3543 # - lookedup_file name of the merged (combined) file
3544 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3545 # - g the rewritten file name
3546 # - tmpfile absolute filename of the temporary file
3547 # - doit : if actions shall be executed, false if only to be printed
3548 # - copymode copy mode for files in general
3549 # - lcopymode copy mode for files from local_gnulib_path
3550 func_add_file ()
3552 if $doit; then
3553 echo "Copying file $g"
3554 func_should_link
3555 if test "$copyaction" = symlink \
3556 && test -z "$lookedup_tmp" \
3557 && cmp -s "$lookedup_file" "$tmpfile"; then
3558 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3559 else
3560 if test "$copyaction" = hardlink \
3561 && test -z "$lookedup_tmp" \
3562 && cmp -s "$lookedup_file" "$tmpfile"; then
3563 func_hardlink "$lookedup_file" "$destdir/$g"
3564 else
3565 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3568 else
3569 echo "Copy file $g"
3573 # func_update_file
3574 # copies a file from gnulib into the destination directory. The destination
3575 # is known to exist.
3576 # Input:
3577 # - destdir target directory
3578 # - local_gnulib_path from --local-dir
3579 # - modcache true or false, from --cache-modules/--no-cache-modules
3580 # - f the original file name
3581 # - lookedup_file name of the merged (combined) file
3582 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3583 # - g the rewritten file name
3584 # - tmpfile absolute filename of the temporary file
3585 # - doit : if actions shall be executed, false if only to be printed
3586 # - copymode copy mode for files in general
3587 # - lcopymode copy mode for files from local_gnulib_path
3588 # - already_present nonempty if the file should already exist, empty otherwise
3589 func_update_file ()
3591 if cmp -s "$destdir/$g" "$tmpfile"; then
3592 : # The file has not changed.
3593 else
3594 # Replace the file.
3595 if $doit; then
3596 if test -n "$already_present"; then
3597 echo "Updating file $g (backup in ${g}~)"
3598 else
3599 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3601 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3602 func_should_link
3603 if test "$copyaction" = symlink \
3604 && test -z "$lookedup_tmp" \
3605 && cmp -s "$lookedup_file" "$tmpfile"; then
3606 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3607 else
3608 if test "$copyaction" = hardlink \
3609 && test -z "$lookedup_tmp" \
3610 && cmp -s "$lookedup_file" "$tmpfile"; then
3611 func_hardlink "$lookedup_file" "$destdir/$g"
3612 else
3613 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3616 else
3617 if test -n "$already_present"; then
3618 echo "Update file $g (backup in ${g}~)"
3619 else
3620 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3626 # func_emit_lib_Makefile_am
3627 # emits the contents of library makefile to standard output.
3628 # Input:
3629 # - local_gnulib_path from --local-dir
3630 # - modcache true or false, from --cache-modules/--no-cache-modules
3631 # - modules list of modules, including dependencies
3632 # - libname library name
3633 # - pobase directory relative to destdir where to place *.po files
3634 # - auxdir directory relative to destdir where to place build aux files
3635 # - gnu_make true if --gnu-make was given, false otherwise
3636 # - makefile_name from --makefile-name
3637 # - libtool true if libtool will be used, false or blank otherwise
3638 # - macro_prefix prefix of gl_LIBOBJS macros to use
3639 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3640 # - witness_c_macro from --witness-c-macro
3641 # - actioncmd (optional) command that will reproduce this invocation
3642 # - for_test true if creating a package for testing, false otherwise
3643 # - sed_replace_include_guard_prefix
3644 # sed expression for resolving ${gl_include_guard_prefix}
3645 # - destfile filename relative to destdir of makefile being generated
3646 # Input/Output:
3647 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
3648 # list of edits to be done to Makefile.am variables
3649 # Output:
3650 # - uses_subdirs nonempty if object files in subdirs exist
3651 func_emit_lib_Makefile_am ()
3653 # When using GNU make, or when creating an includable Makefile.am snippet,
3654 # augment variables with += instead of assigning them.
3655 if $gnu_make || test -n "$makefile_name"; then
3656 assign='+='
3657 else
3658 assign='='
3660 if test "$libtool" = true; then
3661 libext=la
3662 perhapsLT=LT
3663 sed_eliminate_LDFLAGS="$sed_noop"
3664 else
3665 libext=a
3666 perhapsLT=
3667 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3669 if $for_test; then
3670 # When creating a package for testing: Attempt to provoke failures,
3671 # especially link errors, already during "make" rather than during
3672 # "make check", because "make check" is not possible in a cross-compiling
3673 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3674 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3675 else
3676 sed_transform_check_PROGRAMS="$sed_noop"
3678 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3679 $gnu_make ||
3680 echo "## Process this file with automake to produce Makefile.in."
3681 func_emit_copyright_notice
3682 if test -n "$actioncmd"; then
3683 printf '# Reproduce by:\n%s\n' "$actioncmd"
3685 echo
3686 uses_subdirs=
3688 for module in $modules; do
3689 func_verify_nontests_module
3690 if test -n "$module"; then
3692 func_get_automake_snippet_conditional "$module" |
3693 LC_ALL=C \
3694 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3695 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3696 -e "$sed_eliminate_LDFLAGS" \
3697 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3698 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3699 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3700 -e "$sed_transform_check_PROGRAMS" \
3701 -e "$sed_replace_include_guard_prefix"
3702 if test "$module" = 'alloca'; then
3703 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3704 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3706 } | combine_lines "${libname}_${libext}_SOURCES" > "$tmp"/amsnippet1
3708 func_get_automake_snippet_unconditional "$module" |
3709 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3710 } > "$tmp"/amsnippet2
3711 # Skip the contents if it's entirely empty.
3712 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3713 echo "## begin gnulib module $module"
3714 if $gnu_make; then
3715 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
3716 convert_to_gnu_make='s/^if \(.*\)/ifneq (,$(\1))/'
3717 else
3718 convert_to_gnu_make=
3720 echo
3721 if test "$cond_dependencies" = true; then
3722 if func_cond_module_p "$module"; then
3723 func_module_conditional_name "$module"
3724 if $gnu_make; then
3725 echo "ifneq (,\$($conditional))"
3726 else
3727 echo "if $conditional"
3731 sed "$convert_to_gnu_make" "$tmp"/amsnippet1
3732 if test "$cond_dependencies" = true; then
3733 if func_cond_module_p "$module"; then
3734 echo "endif"
3737 sed "$convert_to_gnu_make" "$tmp"/amsnippet2
3738 if $gnu_make; then
3739 echo "endif"
3741 echo "## end gnulib module $module"
3742 echo
3744 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3745 # Test whether there are some source files in subdirectories.
3746 for f in `func_get_filelist "$module"`; do
3747 case $f in
3748 lib/*/*.c)
3749 uses_subdirs=yes
3750 break
3752 esac
3753 done
3755 done
3756 } > "$tmp"/allsnippets
3757 if test -z "$makefile_name"; then
3758 # If there are source files in subdirectories, prevent collision of the
3759 # object files (example: hash.c and libxml/hash.c).
3760 subdir_options=
3761 if test -n "$uses_subdirs"; then
3762 subdir_options=' subdir-objects'
3764 echo "AUTOMAKE_OPTIONS = 1.11 gnits${subdir_options}"
3766 echo
3767 if test -z "$makefile_name"; then
3768 echo "SUBDIRS ="
3769 echo "noinst_HEADERS ="
3770 echo "noinst_LIBRARIES ="
3771 echo "noinst_LTLIBRARIES ="
3772 # Automake versions < 1.11.4 create an empty pkgdatadir at
3773 # installation time if you specify pkgdata_DATA to empty.
3774 # See automake bugs #10997 and #11030:
3775 # * https://debbugs.gnu.org/10997
3776 # * https://debbugs.gnu.org/11030
3777 # So we need this workaround.
3778 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3779 echo "pkgdata_DATA ="
3781 echo "EXTRA_DIST ="
3782 echo "BUILT_SOURCES ="
3783 echo "SUFFIXES ="
3785 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3786 if test -z "$makefile_name"; then
3787 echo "MOSTLYCLEANDIRS ="
3788 echo "CLEANFILES ="
3789 echo "DISTCLEANFILES ="
3790 echo "MAINTAINERCLEANFILES ="
3792 if $gnu_make; then
3793 echo "# Start of GNU Make output."
3795 # Put autoconf output into a temporary file, so that its exit status
3796 # can be checked from the shell. Signal any error by putting a
3797 # syntax error into the output makefile.
3798 ${AUTOCONF} -t 'AC_SUBST:$1 = @$1@' "$configure_ac" \
3799 >"$tmp"/makeout 2>"$tmp"/makeout2 &&
3800 LC_ALL=C sort -u "$tmp"/makeout || {
3801 echo "== gnulib-tool GNU Make output failed as follows =="
3802 sed 's/^/# stderr: /' "$tmp"/makeout2
3804 rm -f "$tmp"/makeout "$tmp"/makeout2
3806 echo "# End of GNU Make output."
3807 else
3808 echo "# No GNU Make output."
3810 # Execute edits that apply to the Makefile.am being generated.
3811 edit=0
3812 while test $edit != $makefile_am_edits; do
3813 edit=`expr $edit + 1`
3814 eval dir=\"\$makefile_am_edit${edit}_dir\"
3815 eval var=\"\$makefile_am_edit${edit}_var\"
3816 eval val=\"\$makefile_am_edit${edit}_val\"
3817 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
3818 if test -n "$var"; then
3819 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3820 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
3821 # The added subdirectory ${val} needs to be mentioned after '.'.
3822 # Since we don't have '.' among SUBDIRS so far, add it now.
3823 val=". ${val}"
3825 echo "${var} += ${val}"
3826 eval "makefile_am_edit${edit}_var="
3829 done
3830 if test -n "$witness_c_macro"; then
3831 cppflags_part1=" -D$witness_c_macro=1"
3832 else
3833 cppflags_part1=
3835 if $for_test; then
3836 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3837 else
3838 cppflags_part2=
3840 if test -z "$makefile_name"; then
3841 echo
3842 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3843 echo "AM_CFLAGS ="
3844 else
3845 if test -n "$cppflags_part1$cppflags_part2"; then
3846 echo
3847 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3850 echo
3851 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3852 || { test -n "$makefile_name" \
3853 && test -f "$sourcebase/Makefile.am" \
3854 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3855 }; then
3856 # One of the snippets or the user's Makefile.am already specifies an
3857 # installation location for the library. Don't confuse automake by saying
3858 # it should not be installed.
3860 else
3861 # By default, the generated library should not be installed.
3862 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3864 echo
3865 echo "${libname}_${libext}_SOURCES ="
3866 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3867 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3868 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3869 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3870 echo "EXTRA_${libname}_${libext}_SOURCES ="
3871 if test "$libtool" = true; then
3872 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3873 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3874 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3875 # the link dependencies of all modules.
3876 for module in $modules; do
3877 func_verify_nontests_module
3878 if test -n "$module"; then
3879 func_get_link_directive "$module"
3881 done \
3882 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3883 | LC_ALL=C sort -u \
3884 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3886 echo
3887 if test -n "$pobase"; then
3888 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3889 echo
3891 cat "$tmp"/allsnippets \
3892 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3893 echo
3894 echo "mostlyclean-local: mostlyclean-generic"
3895 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3896 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3897 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3898 echo " fi; \\"
3899 echo " done; \\"
3900 echo " :"
3901 rm -f "$tmp"/allsnippets
3904 # func_emit_po_Makevars
3905 # emits the contents of po/ makefile parameterization to standard output.
3906 # Input:
3907 # - local_gnulib_path from --local-dir
3908 # - modcache true or false, from --cache-modules/--no-cache-modules
3909 # - sourcebase directory relative to destdir where to place source code
3910 # - pobase directory relative to destdir where to place *.po files
3911 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3912 func_emit_po_Makevars ()
3914 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3915 func_emit_copyright_notice
3916 echo
3917 echo "# Usually the message domain is the same as the package name."
3918 echo "# But here it has a '-gnulib' suffix."
3919 echo "DOMAIN = ${po_domain}-gnulib"
3920 echo
3921 echo "# These two variables depend on the location of this directory."
3922 echo "subdir = ${pobase}"
3923 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3924 echo
3925 cat <<\EOF
3926 # These options get passed to xgettext.
3927 XGETTEXT_OPTIONS = \
3928 --keyword=_ --flag=_:1:pass-c-format \
3929 --keyword=N_ --flag=N_:1:pass-c-format \
3930 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3931 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3932 --flag=error:3:c-format --flag=error_at_line:5:c-format
3934 # This is the copyright holder that gets inserted into the header of the
3935 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3936 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3938 # This is the email address or URL to which the translators shall report
3939 # bugs in the untranslated strings:
3940 # - Strings which are not entire sentences, see the maintainer guidelines
3941 # in the GNU gettext documentation, section 'Preparing Strings'.
3942 # - Strings which use unclear terms or require additional context to be
3943 # understood.
3944 # - Strings which make invalid assumptions about notation of date, time or
3945 # money.
3946 # - Pluralisation problems.
3947 # - Incorrect English spelling.
3948 # - Incorrect formatting.
3949 # It can be your email address, or a mailing list address where translators
3950 # can write to without being subscribed, or the URL of a web page through
3951 # which the translators can contact you.
3952 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3954 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3955 # message catalogs shall be used. It is usually empty.
3956 EXTRA_LOCALE_CATEGORIES =
3958 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3959 # context. Possible values are "yes" and "no". Set this to yes if the
3960 # package uses functions taking also a message context, like pgettext(), or
3961 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3962 USE_MSGCTXT = no
3966 # func_emit_po_POTFILES_in
3967 # emits the file list to be passed to xgettext to standard output.
3968 # Input:
3969 # - local_gnulib_path from --local-dir
3970 # - modcache true or false, from --cache-modules/--no-cache-modules
3971 # - sourcebase directory relative to destdir where to place source code
3972 # - files list of new files
3973 func_emit_po_POTFILES_in ()
3975 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3976 func_emit_copyright_notice
3977 echo
3978 echo "# List of files which contain translatable strings."
3979 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3982 # func_emit_tests_Makefile_am witness_macro
3983 # emits the contents of tests makefile to standard output.
3984 # Input:
3985 # - local_gnulib_path from --local-dir
3986 # - modcache true or false, from --cache-modules/--no-cache-modules
3987 # - modules list of modules, including dependencies
3988 # - libname library name
3989 # - auxdir directory relative to destdir where to place build aux files
3990 # - gnu_make true if --gnu-make was given, false otherwise
3991 # - makefile_name from --makefile-name
3992 # - libtool true if libtool will be used, false or blank otherwise
3993 # - sourcebase relative directory containing lib source code
3994 # - m4base relative directory containing autoconf macros
3995 # - testsbase relative directory containing unit test code
3996 # - macro_prefix prefix of gl_LIBOBJS macros to use
3997 # - witness_c_macro from --witness-c-macro
3998 # - for_test true if creating a package for testing, false otherwise
3999 # - single_configure true if a single configure file should be generated,
4000 # false for a separate configure file for the tests
4001 # - use_libtests true if a libtests.a should be built, false otherwise
4002 # - sed_replace_include_guard_prefix
4003 # sed expression for resolving ${gl_include_guard_prefix}
4004 # - destfile filename relative to destdir of makefile being generated
4005 # Input/Output:
4006 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
4007 # list of edits to be done to Makefile.am variables
4008 # Output:
4009 # - uses_subdirs nonempty if object files in subdirs exist
4010 func_emit_tests_Makefile_am ()
4012 witness_macro="$1"
4013 if test "$libtool" = true; then
4014 libext=la
4015 perhapsLT=LT
4016 sed_eliminate_LDFLAGS="$sed_noop"
4017 else
4018 libext=a
4019 perhapsLT=
4020 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
4022 if $for_test; then
4023 # When creating a package for testing: Attempt to provoke failures,
4024 # especially link errors, already during "make" rather than during
4025 # "make check", because "make check" is not possible in a cross-compiling
4026 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
4027 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
4028 else
4029 sed_transform_check_PROGRAMS="$sed_noop"
4031 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
4032 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
4033 echo "## Process this file with automake to produce Makefile.in."
4034 func_emit_copyright_notice
4035 echo
4036 uses_subdirs=
4038 for module in $modules; do
4039 if $for_test && ! $single_configure; then
4040 func_verify_tests_module
4041 else
4042 func_verify_module
4044 if test -n "$module"; then
4046 func_get_automake_snippet_conditional "$module" |
4047 LC_ALL=C \
4048 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
4049 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
4050 -e "$sed_eliminate_LDFLAGS" \
4051 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
4052 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
4053 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
4054 -e "$sed_transform_check_PROGRAMS" \
4055 -e "$sed_replace_include_guard_prefix"
4056 if $use_libtests && test "$module" = 'alloca'; then
4057 echo "libtests_a_LIBADD += @ALLOCA@"
4058 echo "libtests_a_DEPENDENCIES += @ALLOCA@"
4060 } | combine_lines "libtests_a_SOURCES" > "$tmp"/amsnippet1
4062 func_get_automake_snippet_unconditional "$module" |
4063 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g'
4064 } > "$tmp"/amsnippet2
4065 # Skip the contents if it's entirely empty.
4066 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
4067 # Mention long-running tests at the end.
4068 ofd=3
4069 for word in `func_get_status "$module"`; do
4070 if test "$word" = 'longrunning-test'; then
4071 ofd=4
4072 break
4074 done
4075 { echo "## begin gnulib module $module"
4076 if $gnu_make; then
4077 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
4078 convert_to_gnu_make='s/^if \(.*\)/ifneq (,$(\1))/'
4079 else
4080 convert_to_gnu_make=
4082 echo
4083 if test "$cond_dependencies" = true; then
4084 if func_cond_module_p "$module"; then
4085 func_module_conditional_name "$module"
4086 if $gnu_make; then
4087 echo "ifneq (,\$($conditional))"
4088 else
4089 echo "if $conditional"
4093 sed "$convert_to_gnu_make" "$tmp"/amsnippet1
4094 if test "$cond_dependencies" = true; then
4095 if func_cond_module_p "$module"; then
4096 echo "endif"
4099 sed "$convert_to_gnu_make" "$tmp"/amsnippet2
4100 if $gnu_make; then
4101 echo "endif"
4103 echo "## end gnulib module $module"
4104 echo
4105 } >&$ofd
4107 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
4108 # Test whether there are some source files in subdirectories.
4109 for f in `func_get_filelist "$module"`; do
4110 case $f in
4111 lib/*/*.c | tests/*/*.c)
4112 uses_subdirs=yes
4113 break
4115 esac
4116 done
4118 done
4119 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
4120 # Generate dependencies here, since it eases the debugging of test failures.
4121 # If there are source files in subdirectories, prevent collision of the
4122 # object files (example: hash.c and libxml/hash.c).
4123 subdir_options=
4124 if test -n "$uses_subdirs"; then
4125 subdir_options=' subdir-objects'
4127 echo "AUTOMAKE_OPTIONS = 1.11 foreign${subdir_options}"
4128 echo
4129 if $for_test && ! $single_configure; then
4130 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
4131 echo
4133 # Nothing is being added to SUBDIRS; nevertheless the existence of this
4134 # variable is needed to avoid an error from automake:
4135 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
4136 echo "SUBDIRS = ."
4137 echo "TESTS ="
4138 echo "XFAIL_TESTS ="
4139 echo "TESTS_ENVIRONMENT ="
4140 echo "noinst_PROGRAMS ="
4141 if ! $for_test; then
4142 echo "check_PROGRAMS ="
4144 echo "EXTRA_PROGRAMS ="
4145 echo "noinst_HEADERS ="
4146 echo "noinst_LIBRARIES ="
4147 if $use_libtests; then
4148 if $for_test; then
4149 echo "noinst_LIBRARIES += libtests.a"
4150 else
4151 echo "check_LIBRARIES = libtests.a"
4154 # Automake versions < 1.11.4 create an empty pkgdatadir at
4155 # installation time if you specify pkgdata_DATA to empty.
4156 # See automake bugs #10997 and #11030:
4157 # * https://debbugs.gnu.org/10997
4158 # * https://debbugs.gnu.org/11030
4159 # So we need this workaround.
4160 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
4161 echo "pkgdata_DATA ="
4163 echo "EXTRA_DIST ="
4164 echo "BUILT_SOURCES ="
4165 echo "SUFFIXES ="
4166 echo "MOSTLYCLEANFILES = core *.stackdump"
4167 echo "MOSTLYCLEANDIRS ="
4168 echo "CLEANFILES ="
4169 echo "DISTCLEANFILES ="
4170 echo "MAINTAINERCLEANFILES ="
4171 # Execute edits that apply to the Makefile.am being generated.
4172 edit=0
4173 while test $edit != $makefile_am_edits; do
4174 edit=`expr $edit + 1`
4175 eval dir=\"\$makefile_am_edit${edit}_dir\"
4176 eval var=\"\$makefile_am_edit${edit}_var\"
4177 eval val=\"\$makefile_am_edit${edit}_val\"
4178 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
4179 if test -n "$var"; then
4180 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
4181 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
4182 # The added subdirectory ${val} needs to be mentioned after '.'.
4183 # But we have '.' among SUBDIRS already, so do nothing.
4186 echo "${var} += ${val}"
4187 eval "makefile_am_edit${edit}_var="
4190 done
4191 echo
4192 echo "AM_CPPFLAGS = \\"
4193 if $for_test; then
4194 echo " -DGNULIB_STRICT_CHECKING=1 \\"
4196 if test -n "$witness_c_macro"; then
4197 echo " -D$witness_c_macro=1 \\"
4199 if test -n "${witness_macro}"; then
4200 echo " -D@${witness_macro}@=1 \\"
4202 echo " -I. -I\$(srcdir) \\"
4203 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
4204 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
4205 echo
4206 if $use_libtests; then
4207 # All test programs need to be linked with libtests.a.
4208 # It needs to be passed to the linker before ${libname}.${libext}, since
4209 # the tests-related modules depend on the main modules.
4210 # It also needs to be passed to the linker after ${libname}.${libext}
4211 # because the latter might contain incomplete modules (such as the
4212 # 'version-etc' module whose dependency to 'version-etc-fsf' is voluntarily
4213 # omitted).
4214 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
4215 # not matter.
4216 echo "LDADD = libtests.a ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext} libtests.a ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext} libtests.a \$(LIBTESTS_LIBDEPS)"
4217 else
4218 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
4220 echo
4221 if $use_libtests; then
4222 echo "libtests_a_SOURCES ="
4223 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
4224 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
4225 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
4226 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
4227 echo "EXTRA_libtests_a_SOURCES ="
4228 # The circular dependency in LDADD requires this.
4229 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
4230 echo
4232 # Many test scripts use ${EXEEXT} or ${srcdir}.
4233 # EXEEXT is defined by AC_PROG_CC through autoconf.
4234 # srcdir is defined by autoconf and automake.
4235 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
4236 echo
4237 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
4238 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
4239 echo "# Clean up after Solaris cc."
4240 echo "clean-local:"
4241 echo " rm -rf SunWS_cache"
4242 echo
4243 echo "mostlyclean-local: mostlyclean-generic"
4244 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
4245 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
4246 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
4247 echo " fi; \\"
4248 echo " done; \\"
4249 echo " :"
4250 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
4253 # func_emit_initmacro_start macro_prefix
4254 # emits the first few statements of the gl_INIT macro to standard output.
4255 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4256 func_emit_initmacro_start ()
4258 macro_prefix_arg="$1"
4259 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
4260 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
4261 # LIBOBJS. The purpose is to allow several gnulib instantiations under
4262 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
4263 # flexibility.)
4264 # Furthermore it avoids an automake error like this when a Makefile.am
4265 # that uses pieces of gnulib also uses $(LIBOBJ):
4266 # automatically discovered file `error.c' should not be explicitly mentioned
4267 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
4268 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
4269 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
4270 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
4271 # automatically discovered file `error.c' should not be explicitly mentioned
4272 # We let automake know about the files to be distributed through the
4273 # EXTRA_lib_SOURCES variable.
4274 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
4275 # Create data variables for checking the presence of files that are mentioned
4276 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
4277 # because we want the check to happen when the configure file is created,
4278 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
4279 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
4280 # in which to expect them.
4281 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
4282 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
4283 echo " gl_COMMON"
4286 # func_emit_initmacro_end macro_prefix
4287 # emits the last few statements of the gl_INIT macro to standard output.
4288 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4289 func_emit_initmacro_end ()
4291 macro_prefix_arg="$1"
4292 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
4293 # The check is performed only when autoconf is run from the directory where
4294 # the configure.ac resides; if it is run from a different directory, the
4295 # check is skipped.
4296 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
4297 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
4298 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
4299 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
4300 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
4301 echo " exit 1"
4302 echo " fi"
4303 echo " done])dnl"
4304 echo " m4_if(m4_sysval, [0], [],"
4305 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
4306 echo " ])"
4307 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
4308 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
4309 echo " m4_popdef([AC_LIBSOURCES])"
4310 echo " m4_popdef([AC_REPLACE_FUNCS])"
4311 echo " m4_popdef([AC_LIBOBJ])"
4312 echo " AC_CONFIG_COMMANDS_PRE(["
4313 echo " ${macro_prefix_arg}_libobjs="
4314 echo " ${macro_prefix_arg}_ltlibobjs="
4315 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
4316 echo " # Remove the extension."
4317 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
4318 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
4319 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
4320 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
4321 echo " done"
4322 echo " fi"
4323 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
4324 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
4325 echo " ])"
4328 # func_emit_initmacro_done macro_prefix sourcebase
4329 # emits a few statements after the gl_INIT macro to standard output.
4330 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4331 # - sourcebase directory relative to destdir where to place source code
4332 func_emit_initmacro_done ()
4334 macro_prefix_arg="$1"
4335 sourcebase_arg="$2"
4336 echo
4337 echo "# Like AC_LIBOBJ, except that the module name goes"
4338 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4339 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
4340 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
4341 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
4342 echo "])"
4343 echo
4344 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
4345 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4346 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
4347 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
4348 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
4349 echo "])"
4350 echo
4351 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
4352 echo "# expected is derived from the gnulib-tool parameterization,"
4353 echo "# and alloca is special cased (for the alloca-opt module)."
4354 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
4355 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
4356 echo " m4_foreach([_gl_NAME], [\$1], ["
4357 echo " m4_if(_gl_NAME, [alloca.c], [], ["
4358 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
4359 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
4360 echo " ])"
4361 echo " ])"
4362 echo "])"
4365 # func_emit_autoconf_snippet indentation
4366 # emits the autoconf snippet of a module.
4367 # Input:
4368 # - indentation spaces to prepend on each line
4369 # - local_gnulib_path from --local-dir
4370 # - modcache true or false, from --cache-modules/--no-cache-modules
4371 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4372 # - sed_replace_include_guard_prefix
4373 # sed expression for resolving ${gl_include_guard_prefix}
4374 # - module the module name
4375 # - toplevel true or false. 'false' means a subordinate use of
4376 # gnulib-tool.
4377 # - disable_libtool true or false. It tells whether to disable libtool
4378 # handling even if it has been specified through the
4379 # command line options.
4380 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4381 # invocations.
4382 func_emit_autoconf_snippet ()
4384 indentation="$1"
4385 if { case $module in
4386 gnumakefile | maintainer-makefile)
4387 # These modules are meant to be used only in the top-level directory.
4388 $toplevel ;;
4390 true ;;
4391 esac
4392 }; then
4393 func_get_autoconf_snippet "$module" \
4394 | sed -e '/^$/d;' -e "s/^/$indentation/" \
4395 -e "$sed_replace_build_aux" \
4396 -e "$sed_replace_include_guard_prefix" \
4397 | { if $disable_libtool; then
4398 sed -e 's/\$gl_cond_libtool/false/g' \
4399 -e 's/gl_libdeps/gltests_libdeps/g' \
4400 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4401 else
4405 | { if $disable_gettext; then
4406 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
4407 else
4408 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
4409 # autopoint through at least GNU gettext version 0.18.2.
4410 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
4413 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
4414 echo 'changequote(,)dnl'
4415 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4416 echo 'changequote([, ])dnl'
4417 echo 'AC_SUBST([LTALLOCA])'
4422 # func_emit_autoconf_snippets modules referenceable_modules verifier toplevel disable_libtool disable_gettext
4423 # collects and emit the autoconf snippets of a set of modules.
4424 # Input:
4425 # - local_gnulib_path from --local-dir
4426 # - modcache true or false, from --cache-modules/--no-cache-modules
4427 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4428 # - sed_replace_include_guard_prefix
4429 # sed expression for resolving ${gl_include_guard_prefix}
4430 # - modules the list of modules.
4431 # - referenceable_modules the list of modules which may be referenced as dependencies.
4432 # - verifier one of func_verify_module, func_verify_nontests_module,
4433 # func_verify_tests_module. It selects the subset of
4434 # $modules to consider.
4435 # - toplevel true or false. 'false' means a subordinate use of
4436 # gnulib-tool.
4437 # - disable_libtool true or false. It tells whether to disable libtool
4438 # handling even if it has been specified through the
4439 # command line options.
4440 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4441 # invocations.
4442 func_emit_autoconf_snippets ()
4444 referenceable_modules="$2"
4445 verifier="$3"
4446 toplevel="$4"
4447 disable_libtool="$5"
4448 disable_gettext="$6"
4449 if test "$cond_dependencies" = true; then
4450 for m in $referenceable_modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
4451 # Emit the autoconf code for the unconditional modules.
4452 for module in $1; do
4453 eval $verifier
4454 if test -n "$module"; then
4455 if func_cond_module_p "$module"; then
4457 else
4458 func_emit_autoconf_snippet " "
4461 done
4462 # Initialize the shell variables indicating that the modules are enabled.
4463 for module in $1; do
4464 eval $verifier
4465 if test -n "$module"; then
4466 if func_cond_module_p "$module"; then
4467 func_module_shellvar_name "$module"
4468 echo " $shellvar=false"
4471 done
4472 # Emit the autoconf code for the conditional modules, each in a separate
4473 # function. This makes it possible to support cycles among conditional
4474 # modules.
4475 for module in $1; do
4476 eval $verifier
4477 if test -n "$module"; then
4478 if func_cond_module_p "$module"; then
4479 func_module_shellfunc_name "$module"
4480 func_module_shellvar_name "$module"
4481 echo " $shellfunc ()"
4482 echo ' {'
4483 echo " if ! \$$shellvar; then"
4484 func_emit_autoconf_snippet " "
4485 echo " $shellvar=true"
4486 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4487 # Intersect $deps with the modules list $1.
4488 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4489 for dep in $deps; do
4490 if func_cond_module_p "$dep"; then
4491 func_module_shellfunc_name "$dep"
4492 func_cond_module_condition "$module" "$dep"
4493 if test "$condition" != true; then
4494 echo " if $condition; then"
4495 echo " $shellfunc"
4496 echo ' fi'
4497 else
4498 echo " $shellfunc"
4500 else
4501 # The autoconf code for $dep has already been emitted above and
4502 # therefore is already executed when this function is run.
4505 done
4506 echo ' fi'
4507 echo ' }'
4510 done
4511 # Emit the dependencies from the unconditional to the conditional modules.
4512 for module in $1; do
4513 eval $verifier
4514 if test -n "$module"; then
4515 if func_cond_module_p "$module"; then
4517 else
4518 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4519 # Intersect $deps with the modules list $1.
4520 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4521 for dep in $deps; do
4522 if func_cond_module_p "$dep"; then
4523 func_module_shellfunc_name "$dep"
4524 func_cond_module_condition "$module" "$dep"
4525 if test "$condition" != true; then
4526 echo " if $condition; then"
4527 echo " $shellfunc"
4528 echo ' fi'
4529 else
4530 echo " $shellfunc"
4532 else
4533 # The autoconf code for $dep has already been emitted above and
4534 # therefore is already executed when this code is run.
4537 done
4540 done
4541 # Define the Automake conditionals.
4542 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4543 for module in $1; do
4544 eval $verifier
4545 if test -n "$module"; then
4546 if func_cond_module_p "$module"; then
4547 func_module_conditional_name "$module"
4548 func_module_shellvar_name "$module"
4549 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4552 done
4553 else
4554 # Ignore the conditions, and enable all modules unconditionally.
4555 for module in $1; do
4556 eval $verifier
4557 if test -n "$module"; then
4558 func_emit_autoconf_snippet " "
4560 done
4564 # func_emit_pre_early_macros require indentation modules
4565 # The require parameter can be ':' (AC_REQUIRE) or 'false' (direct call).
4566 func_emit_pre_early_macros ()
4568 echo
4569 echo "${2}# Pre-early section."
4570 if $1; then
4571 _pre_early_snippet="echo \"${2}AC_REQUIRE([\$_pre_early_macro])\""
4572 else
4573 _pre_early_snippet="echo \"${2}\$_pre_early_macro\""
4576 # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB. Doing
4577 # AC_REQUIRE in configure-ac.early is not early enough.
4578 _pre_early_macro="gl_USE_SYSTEM_EXTENSIONS"
4579 case "${nl}${3}${nl}" in
4580 *${nl}extensions${nl}*) eval "$_pre_early_snippet" ;;
4581 esac
4583 _pre_early_macro="gl_PROG_AR_RANLIB"
4584 eval "$_pre_early_snippet"
4585 echo
4588 # func_reconstruct_cached_dir
4589 # callback for func_reconstruct_cached_local_gnulib_path
4590 # Input:
4591 # - destdir from --dir
4592 # Output:
4593 # - local_gnulib_path restored '--local-dir' path from cache
4594 func_reconstruct_cached_dir ()
4596 cached_dir=$1
4597 if test -n "$cached_dir"; then
4598 case "$destdir" in
4600 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4602 case "$cached_dir" in
4604 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4606 func_relconcat "$destdir" "$cached_dir"
4607 func_path_append local_gnulib_path "$relconcat" ;;
4608 esac ;;
4609 esac
4613 # func_reconstruct_cached_local_gnulib_path
4614 # reconstruct local_gnulib_path from cached_local_gnulib_path to be set
4615 # relatively to $destdir again.
4616 # Input:
4617 # - cached_local_gnulib_path local_gnulib_path stored within gnulib-cache.m4
4618 # - destdir from --dir
4619 # Output:
4620 # - local_gnulib_path restored '--local-dir' path from cache
4621 func_reconstruct_cached_local_gnulib_path ()
4623 func_path_foreach "$cached_local_gnulib_path" func_reconstruct_cached_dir %dir%
4626 # func_import modules
4627 # Uses also the variables
4628 # - mode import or add-import or remove-import or update
4629 # - destdir target directory
4630 # - local_gnulib_path from --local-dir
4631 # - modcache true or false, from --cache-modules/--no-cache-modules
4632 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4633 # - libname library name
4634 # - supplied_libname true if --lib was given, blank otherwise
4635 # - sourcebase directory relative to destdir where to place source code
4636 # - m4base directory relative to destdir where to place *.m4 macros
4637 # - pobase directory relative to destdir where to place *.po files
4638 # - docbase directory relative to destdir where to place doc files
4639 # - testsbase directory relative to destdir where to place unit test code
4640 # - auxdir directory relative to destdir where to place build aux files
4641 # - inctests true if --with-tests was given, false otherwise
4642 # - incobsolete true if --with-obsolete was given, blank otherwise
4643 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4644 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4645 # otherwise
4646 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4647 # otherwise
4648 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4649 # otherwise
4650 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4651 # - avoidlist list of modules to avoid, from --avoid
4652 # - cond_dependencies true if --conditional-dependencies was given, false if
4653 # --no-conditional-dependencies was given, blank otherwise
4654 # - lgpl yes or a number if library's license shall be LGPL,
4655 # blank otherwise
4656 # - makefile_name from --makefile-name
4657 # - libtool true if --libtool was given, false if --no-libtool was
4658 # given, blank otherwise
4659 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4660 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4661 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4662 # - witness_c_macro from --witness-c-macro
4663 # - vc_files true if --vc-files was given, false if --no-vc-files was
4664 # given, blank otherwise
4665 # - autoconf_minversion minimum supported autoconf version
4666 # - doit : if actions shall be executed, false if only to be printed
4667 # - copymode copy mode for files in general
4668 # - lcopymode copy mode for files from local_gnulib_path
4669 # - do_copyrights true if copyright notices in files should be replaced,
4670 # blank otherwise
4671 func_import ()
4673 # Get the cached settings.
4674 # In 'import' mode, we read them only for the purpose of knowing the old
4675 # installed file list, and don't use them as defaults.
4676 cached_local_gnulib_path=
4677 cached_specified_modules=
4678 cached_incobsolete=
4679 cached_inc_cxx_tests=
4680 cached_inc_longrunning_tests=
4681 cached_inc_privileged_tests=
4682 cached_inc_unportable_tests=
4683 cached_inc_all_tests=
4684 cached_avoidlist=
4685 cached_sourcebase=
4686 cached_m4base=
4687 cached_pobase=
4688 cached_docbase=
4689 cached_testsbase=
4690 cached_inctests=
4691 cached_libname=
4692 cached_lgpl=
4693 cached_makefile_name=
4694 cached_cond_dependencies=
4695 cached_libtool=
4696 cached_macro_prefix=
4697 cached_po_domain=
4698 cached_witness_c_macro=
4699 cached_vc_files=
4700 cached_files=
4701 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4702 cached_libtool=false
4703 my_sed_traces='
4704 s,#.*$,,
4705 s,^dnl .*$,,
4706 s, dnl .*$,,
4707 /gl_LOCAL_DIR(/ {
4708 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_path="\1",p
4710 /gl_MODULES(/ {
4713 s/)/)/
4718 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4720 /gl_WITH_OBSOLETE/ {
4721 s,^.*$,cached_incobsolete=true,p
4723 /gl_WITH_CXX_TESTS/ {
4724 s,^.*$,cached_inc_cxx_tests=true,p
4726 /gl_WITH_LONGRUNNING_TESTS/ {
4727 s,^.*$,cached_inc_longrunning_tests=true,p
4729 /gl_WITH_PRIVILEGED_TESTS/ {
4730 s,^.*$,cached_inc_privileged_tests=true,p
4732 /gl_WITH_UNPORTABLE_TESTS/ {
4733 s,^.*$,cached_inc_unportable_tests=true,p
4735 /gl_WITH_ALL_TESTS/ {
4736 s,^.*$,cached_inc_all_tests=true,p
4738 /gl_AVOID(/ {
4739 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4741 /gl_SOURCE_BASE(/ {
4742 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4744 /gl_M4_BASE(/ {
4745 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4747 /gl_PO_BASE(/ {
4748 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4750 /gl_DOC_BASE(/ {
4751 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4753 /gl_TESTS_BASE(/ {
4754 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4756 /gl_WITH_TESTS/ {
4757 s,^.*$,cached_inctests=true,p
4759 /gl_LIB(/ {
4760 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4762 /gl_LGPL(/ {
4763 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4765 /gl_LGPL/ {
4766 s,^.*$,cached_lgpl=yes,p
4768 /gl_MAKEFILE_NAME(/ {
4769 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4771 /gl_CONDITIONAL_DEPENDENCIES/ {
4772 s,^.*$,cached_cond_dependencies=true,p
4774 /gl_LIBTOOL/ {
4775 s,^.*$,cached_libtool=true,p
4777 /gl_MACRO_PREFIX(/ {
4778 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4780 /gl_PO_DOMAIN(/ {
4781 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4783 /gl_WITNESS_C_MACRO(/ {
4784 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4786 /gl_VC_FILES(/ {
4787 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4789 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4790 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4791 my_sed_traces='
4792 s,#.*$,,
4793 s,^dnl .*$,,
4794 s, dnl .*$,,
4795 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4796 s,^.*$,cached_files=",p
4800 s,^\]).*$,",
4802 s,["$`\\],,g
4809 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4813 if test "$mode" = import; then
4814 # In 'import' mode, the new set of specified modules overrides the cached
4815 # set of modules. Ignore the cached settings.
4816 specified_modules="$1"
4817 else
4818 # Merge the cached settings with the specified ones.
4819 # The m4base must be the same as expected from the pathname.
4820 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4821 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4823 # The local_gnulib_path defaults to the cached one. Recall that the cached one
4824 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4825 if test -z "$local_gnulib_path"; then
4826 func_reconstruct_cached_local_gnulib_path
4828 case $mode in
4829 add-import)
4830 # Append the cached and the specified module names. So that
4831 # "gnulib-tool --add-import foo" means to add the module foo.
4832 specified_modules="$cached_specified_modules $1"
4834 remove-import)
4835 # Take the cached module names, minus the specified module names.
4836 specified_modules=
4837 if $have_associative; then
4838 # Use an associative array, for O(N) worst-case run time.
4839 declare -A to_remove
4840 for m in $1; do
4841 eval 'to_remove[$m]=yes'
4842 done
4843 for module in $cached_specified_modules; do
4844 if eval 'test -z "${to_remove[$module]}"'; then
4845 func_append specified_modules "$module "
4847 done
4848 else
4849 # This loop has O(N**2) worst-case run time.
4850 for module in $cached_specified_modules; do
4851 to_remove=
4852 for m in $1; do
4853 if test "$m" = "$module"; then
4854 to_remove=yes
4855 break
4857 done
4858 if test -z "$to_remove"; then
4859 func_append specified_modules "$module "
4861 done
4864 update)
4865 # Take the cached module names. There are no specified module names.
4866 specified_modules="$cached_specified_modules"
4868 esac
4869 # Included obsolete modules among the dependencies if specified either way.
4870 if test -z "$incobsolete"; then
4871 incobsolete="$cached_incobsolete"
4873 # Included special kinds of tests modules among the dependencies if specified
4874 # either way.
4875 if test -z "$inc_cxx_tests"; then
4876 inc_cxx_tests="$cached_inc_cxx_tests"
4878 if test -z "$inc_longrunning_tests"; then
4879 inc_longrunning_tests="$cached_inc_longrunning_tests"
4881 if test -z "$inc_privileged_tests"; then
4882 inc_privileged_tests="$cached_inc_privileged_tests"
4884 if test -z "$inc_unportable_tests"; then
4885 inc_unportable_tests="$cached_inc_unportable_tests"
4887 if test -z "$inc_all_tests"; then
4888 inc_all_tests="$cached_inc_all_tests"
4890 # Append the cached and the specified avoidlist. This is probably better
4891 # than dropping the cached one when --avoid is specified at least once.
4892 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4893 avoidlist=`echo $avoidlist`
4895 # The sourcebase defaults to the cached one.
4896 if test -z "$sourcebase"; then
4897 sourcebase="$cached_sourcebase"
4898 if test -z "$sourcebase"; then
4899 func_fatal_error "missing --source-base option"
4902 # The pobase defaults to the cached one.
4903 if test -z "$pobase"; then
4904 pobase="$cached_pobase"
4906 # The docbase defaults to the cached one.
4907 if test -z "$docbase"; then
4908 docbase="$cached_docbase"
4909 if test -z "$docbase"; then
4910 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."
4913 # The testsbase defaults to the cached one.
4914 if test -z "$testsbase"; then
4915 testsbase="$cached_testsbase"
4916 if test -z "$testsbase"; then
4917 func_fatal_error "missing --tests-base option"
4920 # Require the tests if specified either way.
4921 if ! $inctests; then
4922 inctests="$cached_inctests"
4923 if test -z "$inctests"; then
4924 inctests=false
4927 # The libname defaults to the cached one.
4928 if test -z "$supplied_libname"; then
4929 libname="$cached_libname"
4930 if test -z "$libname"; then
4931 func_fatal_error "missing --lib option"
4934 # Require LGPL if specified either way.
4935 if test -z "$lgpl"; then
4936 lgpl="$cached_lgpl"
4938 # The makefile_name defaults to the cached one.
4939 if test -z "$makefile_name"; then
4940 makefile_name="$cached_makefile_name"
4942 # Use conditional dependencies if specified either way.
4943 if test -z "$cond_dependencies"; then
4944 cond_dependencies="$cached_cond_dependencies"
4946 # Use libtool if specified either way, or if guessed.
4947 if test -z "$libtool"; then
4948 if test -n "$cached_m4base"; then
4949 libtool="$cached_libtool"
4950 else
4951 libtool="$guessed_libtool"
4954 # The macro_prefix defaults to the cached one.
4955 if test -z "$macro_prefix"; then
4956 macro_prefix="$cached_macro_prefix"
4957 if test -z "$macro_prefix"; then
4958 func_fatal_error "missing --macro-prefix option"
4961 # The po_domain defaults to the cached one.
4962 if test -z "$po_domain"; then
4963 po_domain="$cached_po_domain"
4965 # The witness_c_macro defaults to the cached one.
4966 if test -z "$witness_c_macro"; then
4967 witness_c_macro="$cached_witness_c_macro"
4969 # The vc_files defaults to the cached one.
4970 if test -z "$vc_files"; then
4971 vc_files="$cached_vc_files"
4973 # Ensure constraints.
4974 if test "$cond_dependencies" = true && $inctests; then
4975 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4976 func_exit 1
4979 # --without-*-tests options are not supported here.
4980 excl_cxx_tests=
4981 excl_longrunning_tests=
4982 excl_privileged_tests=
4983 excl_unportable_tests=
4985 # Canonicalize the list of specified modules.
4986 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4988 # Include all kinds of tests modules if --with-all-tests was specified.
4989 inc_all_direct_tests="$inc_all_tests"
4990 inc_all_indirect_tests="$inc_all_tests"
4992 # Determine final module list.
4993 modules="$specified_modules"
4994 func_modules_transitive_closure
4995 if test $verbose -ge 0; then
4996 func_show_module_list
4998 final_modules="$modules"
5000 # Determine main module list and tests-related module list separately.
5001 func_modules_transitive_closure_separately
5003 # Determine whether a $testsbase/libtests.a is needed.
5004 func_determine_use_libtests
5006 # Add the dummy module to the main module list or to the tests-related module
5007 # list if needed.
5008 func_modules_add_dummy_separately
5010 # If --lgpl, verify that the licenses of modules are compatible.
5011 if test -n "$lgpl"; then
5012 license_incompatibilities=
5013 for module in $main_modules; do
5014 license=`func_get_license $module`
5015 case $license in
5016 'GPLed build tool') ;;
5017 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5019 case "$lgpl" in
5020 yes | 3)
5021 case $license in
5022 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
5023 *) func_append license_incompatibilities "$module $license$nl" ;;
5024 esac
5026 3orGPLv2)
5027 case $license in
5028 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
5029 *) func_append license_incompatibilities "$module $license$nl" ;;
5030 esac
5033 case $license in
5034 LGPLv2+) ;;
5035 *) func_append license_incompatibilities "$module $license$nl" ;;
5036 esac
5038 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
5039 esac
5041 esac
5042 done
5043 if test -n "$license_incompatibilities"; then
5044 # Format the license incompatibilities as a table.
5045 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
5046 s,^\(.................................................[^ ]*\) *, \1 ,'
5047 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
5048 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
5052 # Show banner notice of every module.
5053 modules="$main_modules"
5054 func_modules_notice
5056 # Determine script to apply to imported library files.
5057 sed_transform_lib_file=
5058 for module in $main_modules; do
5059 if test $module = config-h; then
5060 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
5061 sed_transform_lib_file=$sed_transform_lib_file'
5062 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
5064 break
5066 done
5067 sed_transform_main_lib_file="$sed_transform_lib_file"
5068 if test -n "$do_copyrights"; then
5069 if test -n "$lgpl"; then
5070 # Update license.
5071 case "$lgpl" in
5072 yes | 3)
5073 sed_transform_main_lib_file=$sed_transform_main_lib_file'
5074 s/GNU General/GNU Lesser General/g
5075 s/General Public License/Lesser General Public License/g
5076 s/Lesser Lesser General Public License/Lesser General Public License/g
5079 3orGPLv2)
5080 sed_transform_main_lib_file=$sed_transform_main_lib_file'
5081 /^ *This program is free software/i\
5082 This program is free software: you can redistribute it and\/or\
5083 modify it under the terms of either:\
5085 * the GNU Lesser General Public License as published by the Free\
5086 Software Foundation; either version 3 of the License, or (at your\
5087 option) any later version.\
5091 * the GNU General Public License as published by the Free\
5092 Software Foundation; either version 2 of the License, or (at your\
5093 option) any later version.\
5095 or both in parallel, as here.
5096 /^ *This program is free software/,/^$/d
5100 sed_transform_main_lib_file=$sed_transform_main_lib_file'
5101 s/GNU General/GNU Lesser General/g
5102 s/General Public License/Lesser General Public License/g
5103 s/Lesser Lesser General Public License/Lesser General Public License/g
5105 s/version [23]\([ ,]\)/version 2.1\1/g
5108 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
5109 esac
5110 else
5111 # Update license.
5112 sed_transform_main_lib_file=$sed_transform_main_lib_file'
5113 s/GNU Lesser General/GNU General/g
5114 s/Lesser General Public License/General Public License/g
5116 s/GNU Library General/GNU General/g
5117 s/Library General Public License/General Public License/g
5119 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
5124 # Determine script to apply to auxiliary files that go into $auxdir/.
5125 sed_transform_build_aux_file=
5126 if test -n "$do_copyrights"; then
5127 # Update license.
5128 sed_transform_build_aux_file=$sed_transform_build_aux_file'
5129 s/GNU Lesser General/GNU General/g
5130 s/Lesser General Public License/General Public License/g
5132 s/GNU Library General/GNU General/g
5133 s/Library General Public License/General Public License/g
5135 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
5139 # Determine script to apply to library files that go into $testsbase/.
5140 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
5141 if test -n "$do_copyrights"; then
5142 # Update license.
5143 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
5144 s/GNU Lesser General/GNU General/g
5145 s/Lesser General Public License/General Public License/g
5147 s/GNU Library General/GNU General/g
5148 s/Library General Public License/General Public License/g
5150 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
5154 # Determine the final file lists.
5155 func_modules_to_filelist_separately
5157 test -n "$files" \
5158 || func_fatal_error "refusing to do nothing"
5160 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
5161 new_files="$files m4/gnulib-tool.m4"
5162 old_files="$cached_files"
5163 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
5164 func_append old_files " m4/gnulib-tool.m4"
5167 rewritten='%REWRITTEN%'
5168 sed_rewrite_old_files="\
5169 s,^build-aux/,$rewritten$auxdir/,
5170 s,^doc/,$rewritten$cached_docbase/,
5171 s,^lib/,$rewritten$cached_sourcebase/,
5172 s,^m4/,$rewritten$cached_m4base/,
5173 s,^tests/,$rewritten$cached_testsbase/,
5174 s,^tests=lib/,$rewritten$cached_testsbase/,
5175 s,^top/,$rewritten,
5176 s,^$rewritten,,"
5177 sed_rewrite_new_files="\
5178 s,^build-aux/,$rewritten$auxdir/,
5179 s,^doc/,$rewritten$docbase/,
5180 s,^lib/,$rewritten$sourcebase/,
5181 s,^m4/,$rewritten$m4base/,
5182 s,^tests/,$rewritten$testsbase/,
5183 s,^tests=lib/,$rewritten$testsbase/,
5184 s,^top/,$rewritten,
5185 s,^$rewritten,,"
5187 # Determine whether to put anything into $testsbase.
5188 testsfiles=`echo "$files" | sed -n -e 's,^tests/,,p' -e 's,^tests=lib/,,p'`
5189 if test -n "$testsfiles"; then
5190 gentests=true
5191 else
5192 gentests=false
5195 # Create directories.
5196 { echo "$sourcebase"
5197 echo "$m4base"
5198 if test -n "$pobase"; then
5199 echo "$pobase"
5201 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
5202 if test -n "$docfiles"; then
5203 echo "$docbase"
5205 if $gentests; then
5206 echo "$testsbase"
5208 echo "$auxdir"
5209 for f in $files; do echo $f; done \
5210 | sed -e "$sed_rewrite_new_files" \
5211 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5212 | LC_ALL=C sort -u
5213 } > "$tmp"/dirs
5214 { # Rearrange file descriptors. Needed because "while ... done < ..."
5215 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5216 exec 5<&0 < "$tmp"/dirs
5217 while read d; do
5218 if test ! -d "$destdir/$d"; then
5219 if $doit; then
5220 echo "Creating directory $destdir/$d"
5221 mkdir -p "$destdir/$d" || func_fatal_error "failed"
5222 else
5223 echo "Create directory $destdir/$d"
5226 done
5227 exec 0<&5 5<&-
5230 # Copy files or make symbolic links or hard links. Remove obsolete files.
5231 added_files=''
5232 removed_files=''
5233 delimiter=' '
5234 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5235 # representing the files according to the last gnulib-tool invocation.
5236 for f in $old_files; do echo $f; done \
5237 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
5238 | LC_ALL=C sort \
5239 > "$tmp"/old-files
5240 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5241 # representing the files after this gnulib-tool invocation.
5242 for f in $new_files; do echo $f; done \
5243 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
5244 | LC_ALL=C sort \
5245 > "$tmp"/new-files
5246 # First the files that are in old-files, but not in new-files:
5247 sed_take_first_column='s,'"$delimiter"'.*,,'
5248 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
5249 # Remove the file. Do nothing if the user already removed it.
5250 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
5251 if $doit; then
5252 echo "Removing file $g (backup in ${g}~)"
5253 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
5254 else
5255 echo "Remove file $g (backup in ${g}~)"
5257 func_append removed_files "$g$nl"
5259 done
5260 # func_add_or_update handles a file that ought to be present afterwards.
5261 # Uses parameters
5262 # - f the original file name
5263 # - g the rewritten file name
5264 # - already_present nonempty if the file should already exist, empty
5265 # otherwise
5266 func_add_or_update ()
5268 of="$f"
5269 case "$f" in
5270 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5271 esac
5272 func_dest_tmpfilename "$g"
5273 func_lookup_file "$f"
5274 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5275 func_ensure_writable "$tmpfile"
5276 case "$f" in
5277 *.class | *.mo )
5278 # Don't process binary files with sed.
5281 if test -n "$sed_transform_main_lib_file"; then
5282 case "$of" in
5283 lib/*)
5284 sed -e "$sed_transform_main_lib_file" \
5285 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5287 esac
5289 if test -n "$sed_transform_build_aux_file"; then
5290 case "$of" in
5291 build-aux/*)
5292 sed -e "$sed_transform_build_aux_file" \
5293 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5295 esac
5297 if test -n "$sed_transform_testsrelated_lib_file"; then
5298 case "$of" in
5299 tests=lib/*)
5300 sed -e "$sed_transform_testsrelated_lib_file" \
5301 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5303 esac
5306 esac
5307 if test -f "$destdir/$g"; then
5308 # The file already exists.
5309 func_update_file
5310 else
5311 # Install the file.
5312 # Don't protest if the file should be there but isn't: it happens
5313 # frequently that developers don't put autogenerated files under version control.
5314 func_add_file
5315 func_append added_files "$g$nl"
5317 rm -f "$tmpfile"
5319 # Then the files that are in new-files, but not in old-files:
5320 sed_take_last_column='s,^.*'"$delimiter"',,'
5321 already_present=
5322 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
5323 | sed -e "$sed_take_last_column" \
5324 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
5325 { # Rearrange file descriptors. Needed because "while ... done < ..."
5326 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5327 exec 5<&0 < "$tmp"/added-files
5328 while read g f; do
5329 func_add_or_update
5330 done
5331 exec 0<&5 5<&-
5333 # Then the files that are in new-files and in old-files:
5334 already_present=true
5335 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
5336 | sed -e "$sed_take_last_column" \
5337 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
5338 { # Rearrange file descriptors. Needed because "while ... done < ..."
5339 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5340 exec 5<&0 < "$tmp"/kept-files
5341 while read g f; do
5342 func_add_or_update
5343 done
5344 exec 0<&5 5<&-
5347 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
5348 actioncmd="# gnulib-tool --import"
5350 # Local helper.
5351 func_append_local_dir ()
5353 func_append "$1" " --local-dir=$2"
5355 func_path_foreach "$local_gnulib_path" func_append_local_dir actioncmd %dir%
5357 # Break the action command log into multiple lines.
5358 # Emacs puts some gnulib-tool log lines in its source repository, and
5359 # git send-email rejects patch lines longer than 998 characters.
5360 # Also, config.status uses awk, and the HP-UX 11.00 awk fails if a
5361 # line has length >= 3071; similarly, the IRIX 6.5 awk fails if a
5362 # line has length >= 3072.
5363 func_append_actionarg ()
5365 func_append actioncmd " \\$nl# $1"
5367 func_append_actionarg "--lib=$libname"
5368 func_append_actionarg "--source-base=$sourcebase"
5369 func_append_actionarg "--m4-base=$m4base"
5370 if test -n "$pobase"; then
5371 func_append_actionarg "--po-base=$pobase"
5373 func_append_actionarg "--doc-base=$docbase"
5374 func_append_actionarg "--tests-base=$testsbase"
5375 func_append_actionarg "--aux-dir=$auxdir"
5376 if $inctests; then
5377 func_append_actionarg "--with-tests"
5379 if test -n "$incobsolete"; then
5380 func_append_actionarg "--with-obsolete"
5382 if test -n "$inc_cxx_tests"; then
5383 func_append_actionarg "--with-c++-tests"
5385 if test -n "$inc_longrunning_tests"; then
5386 func_append_actionarg "--with-longrunning-tests"
5388 if test -n "$inc_privileged_tests"; then
5389 func_append_actionarg "--with-privileged-tests"
5391 if test -n "$inc_unportable_tests"; then
5392 func_append_actionarg "--with-unportable-tests"
5394 if test -n "$inc_all_tests"; then
5395 func_append_actionarg "--with-all-tests"
5397 if test -n "$lgpl"; then
5398 if test "$lgpl" = yes; then
5399 func_append_actionarg "--lgpl"
5400 else
5401 func_append_actionarg "--lgpl=$lgpl"
5404 if $gnu_make; then
5405 func_append_actionarg "--gnu-make"
5407 if test -n "$makefile_name"; then
5408 func_append_actionarg "--makefile-name=$makefile_name"
5410 if test "$cond_dependencies" = true; then
5411 func_append_actionarg "--conditional-dependencies"
5412 else
5413 func_append_actionarg "--no-conditional-dependencies"
5415 if test "$libtool" = true; then
5416 func_append_actionarg "--libtool"
5417 else
5418 func_append_actionarg "--no-libtool"
5420 func_append_actionarg "--macro-prefix=$macro_prefix"
5421 if test -n "$po_domain"; then
5422 func_append_actionarg "--po-domain=$po_domain"
5424 if test -n "$witness_c_macro"; then
5425 func_append_actionarg "--witness-c-macro=$witness_c_macro"
5427 if test -n "$vc_files"; then
5428 if test "$vc_files" = true; then
5429 func_append_actionarg "--vc-files"
5430 else
5431 func_append_actionarg "--no-vc-files"
5434 for module in $avoidlist; do
5435 func_append_actionarg "--avoid=$module"
5436 done
5437 for module in $specified_modules; do
5438 func_append_actionarg "$module"
5439 done
5441 # Determine include_guard_prefix.
5442 func_compute_include_guard_prefix
5444 # Default the makefile name to Makefile.am.
5445 if test -n "$makefile_name"; then
5446 makefile_am=$makefile_name
5447 else
5448 makefile_am=Makefile.am
5451 # Create normal Makefile.ams.
5452 for_test=false
5454 # Setup list of Makefile.am edits that are to be performed afterwards.
5455 # Some of these edits apply to files that we will generate; others are
5456 # under the responsibility of the developer.
5457 makefile_am_edits=0
5458 # func_note_Makefile_am_edit dir var value [dotfirst]
5459 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
5460 # ${value}.
5461 # If ${dotfirst} is non-empty, this mention needs to be present after '.'.
5462 # This is a special hack for the SUBDIRS variable, cf.
5463 # <https://www.gnu.org/software/automake/manual/html_node/Subdirectories.html>.
5464 func_note_Makefile_am_edit ()
5466 makefile_am_edits=`expr $makefile_am_edits + 1`
5467 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
5468 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
5469 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
5470 eval makefile_am_edit${makefile_am_edits}_dotfirst=\"\$4\"
5472 if test "$makefile_am" = Makefile.am; then
5473 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
5474 sourcebase_base=`basename "$sourcebase"`
5475 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
5477 if test -n "$pobase"; then
5478 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
5479 pobase_base=`basename "$pobase"`
5480 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
5482 if $inctests; then
5483 if test "$makefile_am" = Makefile.am; then
5484 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
5485 testsbase_base=`basename "$testsbase"`
5486 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base" true
5489 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
5491 # Find the first parent directory of $m4base that contains or will contain
5492 # a Makefile.am.
5493 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
5494 s,//*$,/,'
5495 sed_butlast='s,[^/][^/]*//*$,,'
5496 dir1="${m4base}/"; dir2=""
5497 while test -n "$dir1" \
5498 && ! { test -f "${destdir}/${dir1}Makefile.am" \
5499 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5500 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5501 || { $gentests \
5502 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
5503 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
5504 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
5505 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
5506 done
5507 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
5510 # Create library makefile.
5511 func_dest_tmpfilename $sourcebase/$makefile_am
5512 destfile="$sourcebase/$makefile_am"
5513 modules="$main_modules"
5514 func_emit_lib_Makefile_am > "$tmpfile"
5515 if test -f "$destdir"/$sourcebase/$makefile_am; then
5516 if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
5517 rm -f "$tmpfile"
5518 else
5519 if $doit; then
5520 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5521 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
5522 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5523 else
5524 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5525 rm -f "$tmpfile"
5528 else
5529 if $doit; then
5530 echo "Creating $sourcebase/$makefile_am"
5531 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5532 else
5533 echo "Create $sourcebase/$makefile_am"
5534 rm -f "$tmpfile"
5536 func_append added_files "$sourcebase/$makefile_am$nl"
5539 # Create po/ directory.
5540 if test -n "$pobase"; then
5541 # Create po makefile and auxiliary files.
5542 for file in Makefile.in.in remove-potcdate.sin; do
5543 func_dest_tmpfilename $pobase/$file
5544 func_lookup_file build-aux/po/$file
5545 cat "$lookedup_file" > "$tmpfile"
5546 if test -f "$destdir"/$pobase/$file; then
5547 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
5548 rm -f "$tmpfile"
5549 else
5550 if $doit; then
5551 echo "Updating $pobase/$file (backup in $pobase/$file~)"
5552 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
5553 mv -f "$tmpfile" "$destdir"/$pobase/$file
5554 else
5555 echo "Update $pobase/$file (backup in $pobase/$file~)"
5556 rm -f "$tmpfile"
5559 else
5560 if $doit; then
5561 echo "Creating $pobase/$file"
5562 mv -f "$tmpfile" "$destdir"/$pobase/$file
5563 else
5564 echo "Create $pobase/$file"
5565 rm -f "$tmpfile"
5567 func_append added_files "$pobase/$file$nl"
5569 done
5570 # Create po makefile parameterization, part 1.
5571 func_dest_tmpfilename $pobase/Makevars
5572 func_emit_po_Makevars > "$tmpfile"
5573 if test -f "$destdir"/$pobase/Makevars; then
5574 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
5575 rm -f "$tmpfile"
5576 else
5577 if $doit; then
5578 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
5579 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
5580 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5581 else
5582 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
5583 rm -f "$tmpfile"
5586 else
5587 if $doit; then
5588 echo "Creating $pobase/Makevars"
5589 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5590 else
5591 echo "Create $pobase/Makevars"
5592 rm -f "$tmpfile"
5594 func_append added_files "$pobase/Makevars$nl"
5596 # Create po makefile parameterization, part 2.
5597 func_dest_tmpfilename $pobase/POTFILES.in
5598 func_emit_po_POTFILES_in > "$tmpfile"
5599 if test -f "$destdir"/$pobase/POTFILES.in; then
5600 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5601 rm -f "$tmpfile"
5602 else
5603 if $doit; then
5604 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5605 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5606 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5607 else
5608 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5609 rm -f "$tmpfile"
5612 else
5613 if $doit; then
5614 echo "Creating $pobase/POTFILES.in"
5615 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5616 else
5617 echo "Create $pobase/POTFILES.in"
5618 rm -f "$tmpfile"
5620 func_append added_files "$pobase/POTFILES.in$nl"
5622 # Fetch PO files.
5623 TP_URL="https://translationproject.org/latest/"
5624 if $doit; then
5625 echo "Fetching gnulib PO files from $TP_URL"
5626 (cd "$destdir"/$pobase \
5627 && wget --no-verbose --mirror --level=1 -nd -A.po -P . "${TP_URL}gnulib/"
5629 else
5630 echo "Fetch gnulib PO files from $TP_URL"
5632 # Create po/LINGUAS.
5633 if $doit; then
5634 func_dest_tmpfilename $pobase/LINGUAS
5635 (cd "$destdir"/$pobase \
5636 && { echo '# Set of available languages.'
5637 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5639 ) > "$tmpfile"
5640 if test -f "$destdir"/$pobase/LINGUAS; then
5641 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5642 rm -f "$tmpfile"
5643 else
5644 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5645 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5646 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5648 else
5649 echo "Creating $pobase/LINGUAS"
5650 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5651 func_append added_files "$pobase/LINGUAS$nl"
5653 else
5654 if test -f "$destdir"/$pobase/LINGUAS; then
5655 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5656 else
5657 echo "Create $pobase/LINGUAS"
5662 # func_count_relative_local_gnulib_path
5663 # gl_LOCAL_DIR requires local_gnulib_path to be set relatively to destdir
5664 # Input:
5665 # - local_gnulib_path from --local-dir
5666 # - destdir from --dir
5667 # Output:
5668 # - relative_local_dir path to be stored into gl_LOCAL_DIR
5669 func_count_relative_local_gnulib_path ()
5671 relative_local_gnulib_path=
5672 save_IFS="$IFS"
5673 IFS="$PATH_SEPARATOR"
5674 for local_dir in $local_gnulib_path
5676 IFS="$save_IFS"
5677 # Store the local_dir relative to destdir.
5678 case "$local_dir" in
5679 "" | /*)
5680 relative_local_dir="$local_dir" ;;
5682 case "$destdir" in
5683 /*) relative_local_dir="$local_dir" ;;
5685 # destdir, local_dir are both relative.
5686 func_relativize "$destdir" "$local_dir"
5687 relative_local_dir="$reldir" ;;
5688 esac ;;
5689 esac
5690 func_path_append relative_local_gnulib_path "$relative_local_dir"
5691 done
5692 IFS="$save_IFS"
5695 # Create m4/gnulib-cache.m4.
5696 func_dest_tmpfilename $m4base/gnulib-cache.m4
5698 func_emit_copyright_notice
5699 echo "#"
5700 echo "# This file represents the specification of how gnulib-tool is used."
5701 echo "# It acts as a cache: It is written and read by gnulib-tool."
5702 echo "# In projects that use version control, this file is meant to be put under"
5703 echo "# version control, like the configure.ac and various Makefile.am files."
5704 echo
5705 echo
5706 echo "# Specification in the form of a command-line invocation:"
5707 printf '%s\n' "$actioncmd"
5708 echo
5709 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5710 func_count_relative_local_gnulib_path
5711 echo "gl_LOCAL_DIR([$relative_local_gnulib_path])"
5712 echo "gl_MODULES(["
5713 echo "$specified_modules" | sed -e 's/^/ /g'
5714 echo "])"
5715 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5716 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5717 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5718 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5719 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5720 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5721 echo "gl_AVOID([$avoidlist])"
5722 echo "gl_SOURCE_BASE([$sourcebase])"
5723 echo "gl_M4_BASE([$m4base])"
5724 echo "gl_PO_BASE([$pobase])"
5725 echo "gl_DOC_BASE([$docbase])"
5726 echo "gl_TESTS_BASE([$testsbase])"
5727 if $inctests; then
5728 echo "gl_WITH_TESTS"
5730 echo "gl_LIB([$libname])"
5731 if test -n "$lgpl"; then
5732 if test "$lgpl" = yes; then
5733 echo "gl_LGPL"
5734 else
5735 echo "gl_LGPL([$lgpl])"
5738 echo "gl_MAKEFILE_NAME([$makefile_name])"
5739 if test "$cond_dependencies" = true; then
5740 echo "gl_CONDITIONAL_DEPENDENCIES"
5742 if test "$libtool" = true; then
5743 echo "gl_LIBTOOL"
5745 echo "gl_MACRO_PREFIX([$macro_prefix])"
5746 echo "gl_PO_DOMAIN([$po_domain])"
5747 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5748 if test -n "$vc_files"; then
5749 echo "gl_VC_FILES([$vc_files])"
5751 ) > "$tmpfile"
5752 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5753 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
5754 rm -f "$tmpfile"
5755 else
5756 if $doit; then
5757 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5758 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5759 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5760 else
5761 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5762 if false; then
5763 cat "$tmpfile"
5764 echo
5765 echo "# gnulib-cache.m4 ends here"
5767 rm -f "$tmpfile"
5770 else
5771 if $doit; then
5772 echo "Creating $m4base/gnulib-cache.m4"
5773 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5774 else
5775 echo "Create $m4base/gnulib-cache.m4"
5776 cat "$tmpfile"
5777 rm -f "$tmpfile"
5781 # Create m4/gnulib-comp.m4.
5782 func_dest_tmpfilename $m4base/gnulib-comp.m4
5784 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5785 func_emit_copyright_notice
5786 echo "#"
5787 echo "# This file represents the compiled summary of the specification in"
5788 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5789 echo "# to be invoked from configure.ac."
5790 echo "# In projects that use version control, this file can be treated like"
5791 echo "# other built files."
5792 echo
5793 echo
5794 echo "# This macro should be invoked from $configure_ac, in the section"
5795 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5796 echo "# any checks for libraries, header files, types and library functions."
5797 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5798 echo "["
5799 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5800 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5801 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5802 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5804 func_emit_pre_early_macros : ' ' "$final_modules"
5806 if ! $gnu_make && test -n "$uses_subdirs"; then
5807 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5809 for module in $final_modules; do
5810 func_verify_module
5811 if test -n "$module"; then
5812 echo "# Code from module $module:"
5813 func_get_autoconf_early_snippet "$module"
5815 done \
5816 | sed -e '/^$/d;' -e 's/^/ /'
5817 echo "])"
5818 echo
5819 echo "# This macro should be invoked from $configure_ac, in the section"
5820 echo "# \"Check for header files, types and library functions\"."
5821 echo "AC_DEFUN([${macro_prefix}_INIT],"
5822 echo "["
5823 if test "$libtool" = true; then
5824 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5825 echo " gl_cond_libtool=true"
5826 else
5827 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5828 echo " gl_cond_libtool=false"
5829 echo " gl_libdeps="
5830 echo " gl_ltlibdeps="
5832 if test "$auxdir" != "build-aux"; then
5833 sed_replace_build_aux='
5835 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5836 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5839 else
5840 sed_replace_build_aux="$sed_noop"
5842 echo " gl_m4_base='$m4base'"
5843 func_emit_initmacro_start $macro_prefix
5844 echo " gl_source_base='$sourcebase'"
5845 if test -n "$witness_c_macro"; then
5846 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5848 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false true
5849 if test -n "$witness_c_macro"; then
5850 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5852 echo " # End of code from modules"
5853 func_emit_initmacro_end $macro_prefix
5854 echo " gltests_libdeps="
5855 echo " gltests_ltlibdeps="
5856 func_emit_initmacro_start ${macro_prefix}tests
5857 echo " gl_source_base='$testsbase'"
5858 # Define a tests witness macro that depends on the package.
5859 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5860 # See <https://lists.gnu.org/r/automake/2009-05/msg00145.html>.
5861 echo "changequote(,)dnl"
5862 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"
5863 echo "changequote([, ])dnl"
5864 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5865 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5866 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5867 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true true true
5868 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5869 func_emit_initmacro_end ${macro_prefix}tests
5870 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5871 # created using libtool, because libtool already handles the dependencies.
5872 if test "$libtool" != true; then
5873 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5874 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5875 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5876 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5877 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5879 if $use_libtests; then
5880 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5881 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5883 echo "])"
5884 func_emit_initmacro_done $macro_prefix $sourcebase
5885 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5886 echo
5887 echo "# This macro records the list of files which have been installed by"
5888 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5889 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5890 echo "$files" | sed -e 's,^, ,'
5891 echo "])"
5892 ) > "$tmpfile"
5893 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5894 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
5895 rm -f "$tmpfile"
5896 else
5897 if $doit; then
5898 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5899 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5900 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5901 else
5902 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5903 if false; then
5904 cat "$tmpfile"
5905 echo
5906 echo "# gnulib-comp.m4 ends here"
5908 rm -f "$tmpfile"
5911 else
5912 if $doit; then
5913 echo "Creating $m4base/gnulib-comp.m4"
5914 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5915 else
5916 echo "Create $m4base/gnulib-comp.m4"
5917 cat "$tmpfile"
5918 rm -f "$tmpfile"
5922 if $gentests; then
5923 # Create tests makefile.
5924 func_dest_tmpfilename $testsbase/$makefile_am
5925 destfile="$testsbase/$makefile_am"
5926 modules="$testsrelated_modules"
5927 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5928 if test -f "$destdir"/$testsbase/$makefile_am; then
5929 if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
5930 rm -f "$tmpfile"
5931 else
5932 if $doit; then
5933 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5934 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5935 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5936 else
5937 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5938 rm -f "$tmpfile"
5941 else
5942 if $doit; then
5943 echo "Creating $testsbase/$makefile_am"
5944 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5945 else
5946 echo "Create $testsbase/$makefile_am"
5947 rm -f "$tmpfile"
5949 func_append added_files "$testsbase/$makefile_am$nl"
5953 if test "$vc_files" != false; then
5954 # Update the .cvsignore and .gitignore files.
5955 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5956 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5957 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5958 echo "$m4base/|A|gnulib-comp.m4"
5959 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5960 { # Rearrange file descriptors. Needed because "while ... done < ..."
5961 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5962 exec 5<&0 < "$tmp"/fileset-changes
5963 func_update_ignorelist ()
5965 ignore="$1"
5966 if test "$ignore" = .gitignore; then
5967 # In a .gitignore file, "foo" applies to the current directory and all
5968 # subdirectories, whereas "/foo" applies to the current directory only.
5969 anchor='/'
5970 escaped_anchor='\/'
5971 doubly_escaped_anchor='\\/'
5972 else
5973 anchor=''
5974 escaped_anchor=''
5975 doubly_escaped_anchor=''
5977 if test -f "$destdir/$dir$ignore"; then
5978 if test -n "$dir_added" || test -n "$dir_removed"; then
5979 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5980 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5981 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5982 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5983 > "$tmp"/ignore-removed
5985 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5986 if $doit; then
5987 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5988 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5989 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5990 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5991 } > "$tmp"/sed-ignore-removed
5992 { cat "$destdir/$dir$ignore"~
5993 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5994 } | sed -f "$tmp"/sed-ignore-removed \
5995 > "$destdir/$dir$ignore"
5996 else
5997 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
6001 else
6002 if test -n "$dir_added"; then
6003 if $doit; then
6004 echo "Creating $destdir/$dir$ignore"
6006 if test "$ignore" = .cvsignore; then
6007 echo ".deps"
6008 # Automake generates Makefile rules that create .dirstamp files.
6009 echo ".dirstamp"
6011 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
6012 } > "$destdir/$dir$ignore"
6013 else
6014 echo "Create $destdir/$dir$ignore"
6019 func_done_dir ()
6021 dir="$1"
6022 dir_added="$2"
6023 dir_removed="$3"
6024 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
6025 func_update_ignorelist .cvsignore
6027 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
6028 func_update_ignorelist .gitignore
6031 last_dir=
6032 last_dir_added=
6033 last_dir_removed=
6034 while read line; do
6035 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
6036 next_dir=`echo "$line" | sed -e 's,|.*,,'`
6037 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
6038 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
6039 if test "$next_dir" != "$last_dir"; then
6040 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
6041 last_dir="$next_dir"
6042 last_dir_added=
6043 last_dir_removed=
6045 case $op in
6046 A) func_append last_dir_added "$file$nl";;
6047 R) func_append last_dir_removed "$file$nl";;
6048 esac
6049 done
6050 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
6051 exec 0<&5 5<&-
6055 echo "Finished."
6056 echo
6057 echo "You may need to add #include directives for the following .h files."
6058 # Intersect $specified_modules and $main_modules
6059 # (since $specified_modules is not necessarily of subset of $main_modules
6060 # - some may have been skipped through --avoid, and since the elements of
6061 # $main_modules but not in $specified_modules can go away without explicit
6062 # notice - through changes in the module dependencies).
6063 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
6064 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
6065 # First the #include <...> directives without #ifs, sorted for convenience,
6066 # then the #include "..." directives without #ifs, sorted for convenience,
6067 # then the #include directives that are surrounded by #ifs. Not sorted.
6068 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
6069 include_directive=`func_get_include_directive "$module"`
6070 case "$nl$include_directive" in
6071 *"$nl#if"*)
6072 echo "$include_directive" 1>&5
6075 echo "$include_directive" | grep -v 'include "' 1>&6
6076 echo "$include_directive" | grep 'include "' 1>&7
6078 esac
6079 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
6081 LC_ALL=C sort -u "$tmp"/include-angles
6082 LC_ALL=C sort -u "$tmp"/include-quotes
6083 cat "$tmp"/include-if
6084 ) | sed -e '/^$/d' -e 's/^/ /'
6085 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
6087 for module in $main_modules; do
6088 func_get_link_directive "$module"
6089 done \
6090 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
6091 if test `wc -l < "$tmp"/link` != 0; then
6092 echo
6093 echo "You may need to use the following Makefile variables when linking."
6094 echo "Use them in <program>_LDADD when linking a program, or"
6095 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
6096 cat "$tmp"/link
6098 rm -f "$tmp"/link
6100 echo
6101 echo "Don't forget to"
6102 if test "$makefile_am" = Makefile.am; then
6103 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
6104 else
6105 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
6107 if test -n "$pobase"; then
6108 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
6110 if $gentests; then
6111 if test "$makefile_am" = Makefile.am; then
6112 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
6113 else
6114 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
6117 edit=0
6118 while test $edit != $makefile_am_edits; do
6119 edit=`expr $edit + 1`
6120 eval dir=\"\$makefile_am_edit${edit}_dir\"
6121 eval var=\"\$makefile_am_edit${edit}_var\"
6122 eval val=\"\$makefile_am_edit${edit}_val\"
6123 if test -n "$var"; then
6124 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
6126 done
6127 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
6128 position_early_after=AC_PROG_CC_STDC
6129 else
6130 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
6131 position_early_after=AC_PROG_CC_C99
6132 else
6133 position_early_after=AC_PROG_CC
6136 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
6137 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
6140 # func_create_testdir testdir modules
6141 # Input:
6142 # - local_gnulib_path from --local-dir
6143 # - modcache true or false, from --cache-modules/--no-cache-modules
6144 # - auxdir directory relative to destdir where to place build aux files
6145 # - inctests true if tests should be included, false otherwise
6146 # - incobsolete true if obsolete modules among dependencies should be
6147 # included, blank otherwise
6148 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
6149 # blank otherwise
6150 # - excl_longrunning_tests true if long-runnings tests should be excluded,
6151 # blank otherwise
6152 # - excl_privileged_tests true if tests that require root privileges should be
6153 # excluded, blank otherwise
6154 # - excl_unportable_tests true if tests that fail on some platforms should be
6155 # excluded, blank otherwise
6156 # - single_configure true if a single configure file should be generated,
6157 # false for a separate configure file for the tests
6158 # - avoidlist list of modules to avoid
6159 # - cond_dependencies true if --conditional-dependencies was given, false if
6160 # --no-conditional-dependencies was given, blank otherwise
6161 # - libtool true if --libtool was given, false if --no-libtool was
6162 # given, blank otherwise
6163 # - copymode copy mode for files in general
6164 # - lcopymode copy mode for files from local_gnulib_path
6165 func_create_testdir ()
6167 testdir="$1"
6168 modules="$2"
6169 if test -z "$modules"; then
6170 # All modules together.
6171 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6172 # Except non-recursive-gnulib-prefix-hack, which represents a nonstandard
6173 # way of using Automake.
6174 # Except timevar, which lacks the required file timevar.def.
6175 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
6176 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
6177 modules=`func_all_modules`
6178 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`
6180 specified_modules="$modules"
6182 # Canonicalize the list of specified modules.
6183 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
6185 # Test modules which invoke AC_CONFIG_FILES cannot be used with
6186 # --with-tests --single-configure. Avoid them.
6187 if $inctests && $single_configure; then
6188 avoidlist="$avoidlist havelib-tests"
6191 # Unlike in func_import, here we want to include all kinds of tests for the
6192 # directly specified modules, but not for dependencies.
6193 inc_all_direct_tests=true
6194 inc_all_indirect_tests="$inc_all_tests"
6196 # Check that the license of every module is consistent with the license of
6197 # its dependencies.
6198 saved_inctests="$inctests"
6199 # When computing transitive closures, don't consider $module to depend on
6200 # $module-tests. Need this because tests are implicitly GPL and may depend
6201 # on GPL modules - therefore we don't want a warning in this case.
6202 inctests=false
6203 for requested_module in $specified_modules; do
6204 requested_license=`func_get_license "$requested_module"`
6205 if test "$requested_license" != GPL; then
6206 # Here we use func_modules_transitive_closure, not just
6207 # func_get_dependencies, so that we also detect weird situations like
6208 # an LGPL module which depends on a GPLed build tool module which depends
6209 # on a GPL module.
6210 modules="$requested_module"
6211 func_modules_transitive_closure
6212 for module in $modules; do
6213 license=`func_get_license "$module"`
6214 case "$license" in
6215 'GPLed build tool') ;;
6216 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
6218 case "$requested_license" in
6219 GPLv3+ | GPL)
6220 case "$license" in
6221 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL | GPLv2+ | GPLv3+ | GPL) ;;
6222 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6223 esac
6225 GPLv2+)
6226 case "$license" in
6227 LGPLv2+ | 'LGPLv3+ or GPLv2' | GPLv2+) ;;
6228 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6229 esac
6231 LGPLv3+ | LGPL)
6232 case "$license" in
6233 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
6234 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6235 esac
6237 'LGPLv3+ or GPLv2')
6238 case "$license" in
6239 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
6240 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6241 esac
6243 LGPLv2+)
6244 case "$license" in
6245 LGPLv2+) ;;
6246 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6247 esac
6249 esac
6251 esac
6252 done
6254 done
6255 inctests="$saved_inctests"
6257 # Subdirectory names.
6258 sourcebase=gllib
6259 m4base=glm4
6260 pobase=
6261 docbase=gldoc
6262 testsbase=gltests
6263 macro_prefix=gl
6264 po_domain=
6265 witness_c_macro=
6266 vc_files=
6268 # Determine final module list.
6269 modules="$specified_modules"
6270 func_modules_transitive_closure
6271 if test $verbose -ge 0; then
6272 func_show_module_list
6274 final_modules="$modules"
6276 if $single_configure; then
6277 # Determine main module list and tests-related module list separately.
6278 func_modules_transitive_closure_separately
6281 if $single_configure; then
6282 # Determine whether a $testsbase/libtests.a is needed.
6283 func_determine_use_libtests
6286 # Add the dummy module if needed.
6287 if $single_configure; then
6288 func_modules_add_dummy_separately
6289 else
6290 func_modules_add_dummy
6293 # Note:
6294 # If $single_configure, we use the module lists $main_modules and
6295 # $testsrelated_modules; $modules is merely a temporary variable.
6296 # Whereas if ! $single_configure, the module list is $modules.
6298 # Show banner notice of every module.
6299 if $single_configure; then
6300 modules="$main_modules"
6301 func_modules_notice
6302 else
6303 func_modules_notice
6306 # Determine final file list.
6307 if $single_configure; then
6308 func_modules_to_filelist_separately
6309 else
6310 func_modules_to_filelist
6311 if test $verbose -ge 0; then
6312 echo "File list:"
6313 echo "$files" | sed -e 's/^/ /'
6316 # Add files for which the copy in gnulib is newer than the one that
6317 # "automake --add-missing --copy" would provide.
6318 files="$files build-aux/config.guess"
6319 files="$files build-aux/config.sub"
6320 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
6322 rewritten='%REWRITTEN%'
6323 sed_rewrite_files="\
6324 s,^build-aux/,$rewritten$auxdir/,
6325 s,^doc/,$rewritten$docbase/,
6326 s,^lib/,$rewritten$sourcebase/,
6327 s,^m4/,$rewritten$m4base/,
6328 s,^tests/,$rewritten$testsbase/,
6329 s,^tests=lib/,$rewritten$testsbase/,
6330 s,^top/,$rewritten,
6331 s,^$rewritten,,"
6333 # Create directories.
6334 for f in $files; do echo $f; done \
6335 | sed -e "$sed_rewrite_files" \
6336 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
6337 | LC_ALL=C sort -u \
6338 > "$tmp"/dirs
6339 { # Rearrange file descriptors. Needed because "while ... done < ..."
6340 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6341 exec 5<&0 < "$tmp"/dirs
6342 while read d; do
6343 mkdir -p "$testdir/$d"
6344 done
6345 exec 0<&5 5<&-
6348 # Copy files or make symbolic links or hard links.
6349 delimiter=' '
6350 for f in $files; do echo $f; done \
6351 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
6352 | LC_ALL=C sort \
6353 > "$tmp"/files
6354 { # Rearrange file descriptors. Needed because "while ... done < ..."
6355 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6356 exec 5<&0 < "$tmp"/files
6357 while read g f; do
6358 case "$f" in
6359 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
6360 esac
6361 func_lookup_file "$f"
6362 if test -n "$lookedup_tmp"; then
6363 cp -p "$lookedup_file" "$testdir/$g"
6364 func_ensure_writable "$testdir/$g"
6365 else
6366 func_should_link
6367 if test "$copyaction" = symlink; then
6368 func_symlink "$lookedup_file" "$testdir/$g"
6369 else
6370 if test "$copyaction" = hardlink; then
6371 func_hardlink "$lookedup_file" "$testdir/$g"
6372 else
6373 cp -p "$lookedup_file" "$testdir/$g"
6374 func_ensure_writable "$testdir/$g"
6378 done
6379 exec 0<&5 5<&-
6382 # Determine include_guard_prefix.
6383 func_compute_include_guard_prefix
6385 # Create Makefile.ams that are for testing.
6386 for_test=true
6388 # No special edits are needed.
6389 makefile_am_edits=0
6391 # Create $sourcebase/Makefile.am.
6392 mkdir -p "$testdir/$sourcebase"
6393 destfile="$sourcebase/Makefile.am"
6394 if $single_configure; then
6395 modules="$main_modules"
6397 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
6398 any_uses_subdirs="$uses_subdirs"
6400 # Create $m4base/Makefile.am.
6401 mkdir -p "$testdir/$m4base"
6402 (echo "## Process this file with automake to produce Makefile.in."
6403 echo
6404 echo "EXTRA_DIST ="
6405 for f in $files; do
6406 case "$f" in
6407 m4/* )
6408 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
6409 esac
6410 done
6411 ) > "$testdir/$m4base/Makefile.am"
6413 subdirs="$sourcebase $m4base"
6414 subdirs_with_configure_ac=""
6416 if false && test -f "$testdir"/$m4base/gettext.m4; then
6417 # Avoid stupid error message from automake:
6418 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
6419 mkdir -p "$testdir/po"
6420 (echo "## Process this file with automake to produce Makefile.in."
6421 ) > "$testdir/po/Makefile.am"
6422 func_append subdirs " po"
6425 if $inctests; then
6426 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
6427 if $single_configure; then
6428 # Create $testsbase/Makefile.am.
6429 destfile="$testsbase/Makefile.am"
6430 modules="$testsrelated_modules"
6431 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
6432 else
6433 # Viewed from the $testsbase subdirectory, $auxdir is different.
6434 saved_auxdir="$auxdir"
6435 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
6436 # Create $testsbase/Makefile.am.
6437 use_libtests=false
6438 destfile="$testsbase/Makefile.am"
6439 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
6440 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
6441 # Create $testsbase/configure.ac.
6442 (echo "# Process this file with autoconf to produce a configure script."
6443 echo "AC_INIT([dummy], [0])"
6444 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6445 echo "AM_INIT_AUTOMAKE"
6446 echo
6447 echo "AC_CONFIG_HEADERS([config.h])"
6448 echo
6449 echo "AC_PROG_CC"
6450 echo "AC_PROG_INSTALL"
6451 echo "AC_PROG_MAKE_SET"
6453 func_emit_pre_early_macros false '' "$modules"
6455 if test -n "$uses_subdirs"; then
6456 echo "AM_PROG_CC_C_O"
6457 echo
6459 for module in $modules; do
6460 func_verify_module
6461 if test -n "$module"; then
6462 case $module in
6463 gnumakefile | maintainer-makefile)
6464 # These modules are meant to be used only in the top-level directory.
6467 func_get_autoconf_early_snippet "$module"
6469 esac
6471 done \
6472 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6473 if test "$libtool" = true; then
6474 echo "LT_INIT([win32-dll])"
6475 echo "LT_LANG([C++])"
6476 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6477 echo "gl_cond_libtool=true"
6478 else
6479 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6480 echo "gl_cond_libtool=false"
6481 echo "gl_libdeps="
6482 echo "gl_ltlibdeps="
6484 # Wrap the set of autoconf snippets into an autoconf macro that is then
6485 # invoked. This is needed because autoconf does not support AC_REQUIRE
6486 # at the top level:
6487 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6488 # but we want the AC_REQUIRE to have its normal meaning (provide one
6489 # expansion of the required macro before the current point, and only one
6490 # expansion total).
6491 echo "AC_DEFUN([gl_INIT], ["
6492 sed_replace_build_aux='
6494 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6495 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6498 echo "gl_m4_base='../$m4base'"
6499 func_emit_initmacro_start $macro_prefix
6500 # We don't have explicit ordering constraints between the various
6501 # autoconf snippets. It's cleanest to put those of the library before
6502 # those of the tests.
6503 echo "gl_source_base='../$sourcebase'"
6504 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module false false false
6505 echo "gl_source_base='.'"
6506 func_emit_autoconf_snippets "$modules" "$modules" func_verify_tests_module false false false
6507 func_emit_initmacro_end $macro_prefix
6508 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6509 # created using libtool, because libtool already handles the dependencies.
6510 if test "$libtool" != true; then
6511 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6512 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6513 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6514 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6515 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6517 echo "])"
6518 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
6519 echo
6520 echo "gl_INIT"
6521 echo
6522 # Usually $testsbase/config.h will be a superset of config.h. Verify this
6523 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
6524 echo "AH_TOP([#include \"../config.h\"])"
6525 echo
6526 echo "AC_CONFIG_FILES([Makefile])"
6527 echo "AC_OUTPUT"
6528 ) > "$testdir/$testsbase/configure.ac"
6529 auxdir="$saved_auxdir"
6530 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
6532 func_append subdirs " $testsbase"
6535 # Create Makefile.am.
6536 (echo "## Process this file with automake to produce Makefile.in."
6537 echo
6538 echo "AUTOMAKE_OPTIONS = 1.11 foreign"
6539 echo
6540 echo "SUBDIRS = $subdirs"
6541 echo
6542 echo "ACLOCAL_AMFLAGS = -I $m4base"
6543 ) > "$testdir/Makefile.am"
6545 # Create configure.ac.
6546 (echo "# Process this file with autoconf to produce a configure script."
6547 echo "AC_INIT([dummy], [0])"
6548 if test "$auxdir" != "."; then
6549 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6551 echo "AM_INIT_AUTOMAKE"
6552 echo
6553 echo "AC_CONFIG_HEADERS([config.h])"
6554 echo
6555 echo "AC_PROG_CC"
6556 echo "AC_PROG_INSTALL"
6557 echo "AC_PROG_MAKE_SET"
6558 echo
6559 echo "# For autobuild."
6560 echo "AC_CANONICAL_BUILD"
6561 echo "AC_CANONICAL_HOST"
6562 echo
6563 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
6564 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
6565 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6566 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6568 func_emit_pre_early_macros false '' "$final_modules"
6570 if test -n "$any_uses_subdirs"; then
6571 echo "AM_PROG_CC_C_O"
6572 echo
6574 for module in $final_modules; do
6575 if $single_configure; then
6576 func_verify_module
6577 else
6578 func_verify_nontests_module
6580 if test -n "$module"; then
6581 func_get_autoconf_early_snippet "$module"
6583 done \
6584 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6585 if test "$libtool" = true; then
6586 echo "LT_INIT([win32-dll])"
6587 echo "LT_LANG([C++])"
6588 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6589 echo "gl_cond_libtool=true"
6590 else
6591 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6592 echo "gl_cond_libtool=false"
6593 echo "gl_libdeps="
6594 echo "gl_ltlibdeps="
6596 # Wrap the set of autoconf snippets into an autoconf macro that is then
6597 # invoked. This is needed because autoconf does not support AC_REQUIRE
6598 # at the top level:
6599 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6600 # but we want the AC_REQUIRE to have its normal meaning (provide one
6601 # expansion of the required macro before the current point, and only one
6602 # expansion total).
6603 echo "AC_DEFUN([gl_INIT], ["
6604 if test "$auxdir" != "build-aux"; then
6605 sed_replace_build_aux='
6607 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6608 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6611 else
6612 sed_replace_build_aux="$sed_noop"
6614 echo "gl_m4_base='$m4base'"
6615 func_emit_initmacro_start $macro_prefix
6616 echo "gl_source_base='$sourcebase'"
6617 if $single_configure; then
6618 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false false
6619 else
6620 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module true false false
6622 func_emit_initmacro_end $macro_prefix
6623 if $single_configure; then
6624 echo " gltests_libdeps="
6625 echo " gltests_ltlibdeps="
6626 func_emit_initmacro_start ${macro_prefix}tests
6627 echo " gl_source_base='$testsbase'"
6628 # Define a tests witness macro.
6629 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
6630 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6631 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6632 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6633 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true false false
6634 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6635 func_emit_initmacro_end ${macro_prefix}tests
6637 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6638 # created using libtool, because libtool already handles the dependencies.
6639 if test "$libtool" != true; then
6640 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6641 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6642 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6643 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6644 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6646 if $single_configure; then
6647 if $use_libtests; then
6648 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6649 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6652 echo "])"
6653 func_emit_initmacro_done $macro_prefix $sourcebase
6654 if $single_configure; then
6655 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6657 echo
6658 echo "gl_INIT"
6659 echo
6660 if test -n "$subdirs_with_configure_ac"; then
6661 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6663 makefiles="Makefile"
6664 for d in $subdirs; do
6665 # For subdirs that have a configure.ac by their own, it's the subdir's
6666 # configure.ac which creates the subdir's Makefile.am, not this one.
6667 case " $subdirs_with_configure_ac " in
6668 *" $d "*) ;;
6669 *) func_append makefiles " $d/Makefile" ;;
6670 esac
6671 done
6672 echo "AC_CONFIG_FILES([$makefiles])"
6673 echo "AC_OUTPUT"
6674 ) > "$testdir/configure.ac"
6676 # Create autogenerated files.
6677 (cd "$testdir"
6678 # Do not use "${AUTORECONF} --force --install", because it may invoke
6679 # autopoint, which brings in older versions of some of our .m4 files.
6680 if test -f $m4base/gettext.m4; then
6681 func_execute_command ${AUTOPOINT} --force || func_exit 1
6682 for f in $m4base/*.m4~; do
6683 if test -f $f; then
6684 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6686 done
6688 if test "$libtool" = true; then
6689 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6691 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6692 if ! test -d build-aux; then
6693 func_execute_command mkdir build-aux || func_exit 1
6695 func_execute_command ${AUTOCONF} || func_exit 1
6696 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6697 func_execute_command ${AUTOHEADER} &&
6698 func_execute_command touch config.h.in ||
6699 func_exit 1
6700 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6701 rm -rf autom4te.cache
6702 ) || func_exit 1
6703 if $inctests && ! $single_configure; then
6704 # Create autogenerated files.
6705 (cd "$testdir/$testsbase" || func_exit 1
6706 # Do not use "${AUTORECONF} --force --install", because it may invoke
6707 # autopoint, which brings in older versions of some of our .m4 files.
6708 if test -f ../$m4base/gettext.m4; then
6709 func_execute_command ${AUTOPOINT} --force || func_exit 1
6710 for f in ../$m4base/*.m4~; do
6711 if test -f $f; then
6712 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6714 done
6716 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6717 if ! test -d ../build-aux; then
6718 func_execute_command mkdir ../build-aux
6720 func_execute_command ${AUTOCONF} || func_exit 1
6721 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6722 func_execute_command ${AUTOHEADER} &&
6723 func_execute_command touch config.h.in ||
6724 func_exit 1
6725 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6726 rm -rf autom4te.cache
6727 ) || func_exit 1
6729 # Need to run configure and make once, to create built files that are to be
6730 # distributed (such as parse-datetime.c).
6731 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6732 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6733 cleaned_files=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6734 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6735 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6736 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6737 # such $(FOO_H) because they don't refer to distributed files.
6738 built_sources=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6739 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6740 | sed -e "$sed_remove_make_variables"`
6741 distributed_built_sources=`for file in $built_sources; do
6742 case "$cleaned_files" in
6743 *" "$file" "*) ;;
6744 *) echo $file ;;
6745 esac;
6746 done`
6747 tests_distributed_built_sources=
6748 if $inctests; then
6749 # Likewise for built files in the $testsbase directory.
6750 tests_cleaned_files=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6751 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6752 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6753 tests_built_sources=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6754 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6755 | sed -e "$sed_remove_make_variables"`
6756 tests_distributed_built_sources=`for file in $tests_built_sources; do
6757 case "$tests_cleaned_files" in
6758 *" "$file" "*) ;;
6759 *) echo $file ;;
6760 esac;
6761 done`
6763 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6764 (cd "$testdir"
6765 ./configure || func_exit 1
6766 if test -n "$distributed_built_sources"; then
6767 cd "$sourcebase"
6768 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6769 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6770 built_sources \
6771 || func_exit 1
6772 cd ..
6774 if test -n "$tests_distributed_built_sources"; then
6775 cd "$testsbase"
6776 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6777 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6778 built_sources \
6779 || func_exit 1
6780 cd ..
6782 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6783 distclean \
6784 || func_exit 1
6785 ) || func_exit 1
6787 (cd "$testdir"
6788 if test -f build-aux/test-driver; then
6789 patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver.diff || func_exit 1
6791 ) || func_exit 1
6794 # func_create_megatestdir megatestdir allmodules
6795 # Input:
6796 # - local_gnulib_path from --local-dir
6797 # - modcache true or false, from --cache-modules/--no-cache-modules
6798 # - auxdir directory relative to destdir where to place build aux files
6799 func_create_megatestdir ()
6801 megatestdir="$1"
6802 allmodules="$2"
6803 if test -z "$allmodules"; then
6804 allmodules=`func_all_modules`
6807 megasubdirs=
6808 # First, all modules one by one.
6809 for onemodule in $allmodules; do
6810 func_create_testdir "$megatestdir/$onemodule" $onemodule
6811 func_append megasubdirs "$onemodule "
6812 done
6813 # Then, all modules all together.
6814 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6815 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6816 func_create_testdir "$megatestdir/ALL" "$allmodules"
6817 func_append megasubdirs "ALL"
6819 # Create autobuild.
6820 cvsdate=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6821 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6822 | sed -e 's,January,01,' -e 's,Jan,01,' \
6823 -e 's,February,02,' -e 's,Feb,02,' \
6824 -e 's,March,03,' -e 's,Mar,03,' \
6825 -e 's,April,04,' -e 's,Apr,04,' \
6826 -e 's,May,05,' \
6827 -e 's,June,06,' -e 's,Jun,06,' \
6828 -e 's,July,07,' -e 's,Jul,07,' \
6829 -e 's,August,08,' -e 's,Aug,08,' \
6830 -e 's,September,09,' -e 's,Sep,09,' \
6831 -e 's,October,10,' -e 's,Oct,10,' \
6832 -e 's,November,11,' -e 's,Nov,11,' \
6833 -e 's,December,12,' -e 's,Dec,12,' \
6834 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6835 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6836 (echo '#!/bin/sh'
6837 echo "CVSDATE=$cvsdate"
6838 echo ": \${MAKE=make}"
6839 echo "test -d logs || mkdir logs"
6840 echo "for module in $megasubdirs; do"
6841 echo " echo \"Working on module \$module...\""
6842 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6843 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6844 echo " echo"
6845 echo " set -x"
6846 echo " : autobuild project... \$module"
6847 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6848 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6849 echo " : autobuild hostname... \`hostname\`"
6850 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6851 echo " echo rc=\$?"
6852 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6853 echo "done"
6854 ) > "$megatestdir/do-autobuild"
6855 chmod a+x "$megatestdir/do-autobuild"
6857 # Create Makefile.am.
6858 (echo "## Process this file with automake to produce Makefile.in."
6859 echo
6860 echo "AUTOMAKE_OPTIONS = 1.11 foreign"
6861 echo
6862 echo "SUBDIRS = $megasubdirs"
6863 echo
6864 echo "EXTRA_DIST = do-autobuild"
6865 ) > "$megatestdir/Makefile.am"
6867 # Create configure.ac.
6868 (echo "# Process this file with autoconf to produce a configure script."
6869 echo "AC_INIT([dummy], [0])"
6870 if test "$auxdir" != "."; then
6871 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6873 echo "AM_INIT_AUTOMAKE"
6874 echo
6875 echo "AC_PROG_MAKE_SET"
6876 echo
6877 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6878 echo "AC_CONFIG_FILES([Makefile])"
6879 echo "AC_OUTPUT"
6880 ) > "$megatestdir/configure.ac"
6882 # Create autogenerated files.
6883 (cd "$megatestdir"
6884 # Do not use "${AUTORECONF} --install", because autoreconf operates
6885 # recursively, but the subdirectories are already finished, therefore
6886 # calling autoreconf here would only waste lots of CPU time.
6887 func_execute_command ${ACLOCAL} || func_exit 1
6888 func_execute_command mkdir build-aux
6889 func_execute_command ${AUTOCONF} || func_exit 1
6890 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6891 rm -rf autom4te.cache
6892 if test -f build-aux/test-driver; then
6893 patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver.diff || func_exit 1
6895 ) || func_exit 1
6898 case $mode in
6899 "" )
6900 func_fatal_error "no mode specified" ;;
6902 list )
6903 func_all_modules
6906 find )
6907 # sed expression that converts a literal to a basic regular expression.
6908 # Needs to handle . [ \ * ^ $.
6909 sed_literal_to_basic_regex='s/\\/\\\\/g
6910 s/\[/\\[/g
6911 s/\^/\\^/g
6912 s/\([.*$]\)/[\1]/g'
6913 for filename
6915 if test -f "$gnulib_dir/$filename" \
6916 || func_lookup_local_file "$filename"; then
6917 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6918 filename_line_regex='^'"$filename_anywhere_regex"'$'
6919 module_candidates=`
6921 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6922 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$,,'
6924 | func_sanitize_modulelist \
6925 | LC_ALL=C sort -u
6927 for module in $module_candidates; do
6928 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6929 echo $module
6931 done
6932 else
6933 func_warning "file $filename does not exist"
6935 done
6938 import | add-import | remove-import | update )
6940 # Where to import.
6941 if test -z "$destdir"; then
6942 destdir=.
6944 test -d "$destdir" \
6945 || func_fatal_error "destination directory does not exist: $destdir"
6947 # Prefer configure.ac to configure.in.
6948 if test -f "$destdir"/configure.ac; then
6949 configure_ac="$destdir/configure.ac"
6950 else
6951 if test -f "$destdir"/configure.in; then
6952 configure_ac="$destdir/configure.in"
6953 else
6954 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6958 # Analyze configure.ac.
6959 guessed_auxdir="."
6960 guessed_libtool=false
6961 my_sed_traces='
6962 s,#.*$,,
6963 s,^dnl .*$,,
6964 s, dnl .*$,,
6965 /AC_CONFIG_AUX_DIR/ {
6966 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6968 /A[CM]_PROG_LIBTOOL/ {
6969 s,^.*$,guessed_libtool=true,p
6971 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6973 if test -z "$auxdir"; then
6974 auxdir="$guessed_auxdir"
6977 # Determine where to apply func_import.
6978 if test "$mode" = import; then
6979 # Apply func_import to a particular gnulib directory.
6980 # The command line contains the complete specification; don't look at
6981 # the contents of gnulib-cache.m4.
6982 test -n "$supplied_libname" || supplied_libname=true
6983 test -n "$sourcebase" || sourcebase="lib"
6984 test -n "$m4base" || m4base="m4"
6985 test -n "$docbase" || docbase="doc"
6986 test -n "$testsbase" || testsbase="tests"
6987 test -n "$macro_prefix" || macro_prefix="gl"
6988 func_import "$*"
6989 else
6990 if test -n "$m4base"; then
6991 # Apply func_import to a particular gnulib directory.
6992 # Any number of additional modules can be given.
6993 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6994 # First use of gnulib in the given m4base.
6995 test -n "$supplied_libname" || supplied_libname=true
6996 test -n "$sourcebase" || sourcebase="lib"
6997 test -n "$docbase" || docbase="doc"
6998 test -n "$testsbase" || testsbase="tests"
6999 test -n "$macro_prefix" || macro_prefix="gl"
7001 func_import "$*"
7002 else
7003 # Apply func_import to all gnulib directories.
7004 # To get this list of directories, look at Makefile.am. (Not at
7005 # configure, because it may be omitted from version control. Also,
7006 # don't run "find $destdir -name gnulib-cache.m4", as it might be
7007 # too expensive.)
7008 m4dirs=
7009 m4dirs_count=0
7010 if test -f "$destdir"/Makefile.am; then
7011 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
7012 m4dir_is_next=
7013 for arg in $aclocal_amflags; do
7014 if test -n "$m4dir_is_next"; then
7015 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
7016 case "$arg" in
7017 /*) ;;
7019 if test -f "$destdir/$arg"/gnulib-cache.m4; then
7020 func_append m4dirs " $arg"
7021 m4dirs_count=`expr $m4dirs_count + 1`
7024 esac
7025 m4dir_is_next=
7026 else
7027 if test "X$arg" = "X-I"; then
7028 m4dir_is_next=yes
7029 else
7030 m4dir_is_next=
7033 done
7034 else
7035 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
7036 if test -f "$destdir"/aclocal.m4; then
7037 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
7038 sedexpr2='s,^[^/]*$,.,'
7039 sedexpr3='s,/[^/]*$,,'
7040 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
7041 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
7042 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
7045 if test $m4dirs_count = 0; then
7046 # First use of gnulib in a package.
7047 # Any number of additional modules can be given.
7048 test -n "$supplied_libname" || supplied_libname=true
7049 test -n "$sourcebase" || sourcebase="lib"
7050 m4base="m4"
7051 test -n "$docbase" || docbase="doc"
7052 test -n "$testsbase" || testsbase="tests"
7053 test -n "$macro_prefix" || macro_prefix="gl"
7054 func_import "$*"
7055 else
7056 if test $m4dirs_count = 1; then
7057 # There's only one use of gnulib here. Assume the user means it.
7058 # Any number of additional modules can be given.
7059 for m4base in $m4dirs; do
7060 func_import "$*"
7061 done
7062 else
7063 # Ambiguous - guess what the user meant.
7064 if test $# = 0; then
7065 # No further arguments. Guess the user wants to update all of them.
7066 for m4base in $m4dirs; do
7067 # Perform func_import in a subshell, so that variable values
7068 # such as
7069 # local_gnulib_path, incobsolete, inc_cxx_tests,
7070 # inc_longrunning_tests, inc_privileged_tests,
7071 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
7072 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
7073 # makefile_name, libtool, macro_prefix, po_domain,
7074 # witness_c_macro, vc_files
7075 # don't propagate from one directory to another.
7076 (func_import) || func_exit 1
7077 done
7078 else
7079 # Really ambiguous.
7080 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
7088 create-testdir )
7089 if test -z "$destdir"; then
7090 func_fatal_error "please specify --dir option"
7092 mkdir "$destdir"
7093 test -d "$destdir" \
7094 || func_fatal_error "could not create destination directory"
7095 test -n "$auxdir" || auxdir="build-aux"
7096 func_create_testdir "$destdir" "$*"
7099 create-megatestdir )
7100 if test -z "$destdir"; then
7101 func_fatal_error "please specify --dir option"
7103 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7104 test -n "$auxdir" || auxdir="build-aux"
7105 func_create_megatestdir "$destdir" "$*"
7108 test )
7109 test -n "$destdir" || destdir=testdir$$
7110 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7111 test -n "$auxdir" || auxdir="build-aux"
7112 func_create_testdir "$destdir" "$*"
7113 cd "$destdir"
7114 mkdir build
7115 cd build
7116 ../configure || func_exit 1
7117 $MAKE || func_exit 1
7118 $MAKE check || func_exit 1
7119 $MAKE distclean || func_exit 1
7120 remaining=`find . -type f -print`
7121 if test -n "$remaining"; then
7122 echo "Remaining files:" $remaining 1>&2
7123 echo "gnulib-tool: *** Stop." 1>&2
7124 func_exit 1
7126 cd ..
7127 cd ..
7128 rm -rf "$destdir"
7131 megatest )
7132 test -n "$destdir" || destdir=testdir$$
7133 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7134 test -n "$auxdir" || auxdir="build-aux"
7135 func_create_megatestdir "$destdir" "$*"
7136 cd "$destdir"
7137 mkdir build
7138 cd build
7139 ../configure
7140 $MAKE
7141 $MAKE check
7142 $MAKE distclean
7143 remaining=`find . -type f -print`
7144 if test -n "$remaining"; then
7145 echo "Remaining files:" $remaining 1>&2
7146 echo "gnulib-tool: *** Stop." 1>&2
7147 func_exit 1
7149 cd ..
7150 cd ..
7151 rm -rf "$destdir"
7154 extract-description )
7155 for module
7157 func_verify_module
7158 if test -n "$module"; then
7159 func_get_description "$module"
7161 done
7164 extract-comment )
7165 for module
7167 func_verify_module
7168 if test -n "$module"; then
7169 func_get_comment "$module"
7171 done
7174 extract-status )
7175 for module
7177 func_verify_module
7178 if test -n "$module"; then
7179 func_get_status "$module"
7181 done
7184 extract-notice )
7185 for module
7187 func_verify_module
7188 if test -n "$module"; then
7189 func_get_notice "$module"
7191 done
7194 extract-applicability )
7195 for module
7197 func_verify_module
7198 if test -n "$module"; then
7199 func_get_applicability "$module"
7201 done
7204 extract-filelist )
7205 for module
7207 func_verify_module
7208 if test -n "$module"; then
7209 func_get_filelist "$module"
7211 done
7214 extract-dependencies )
7215 if test -n "$avoidlist"; then
7216 func_fatal_error "cannot combine --avoid and --extract-dependencies"
7218 for module
7220 func_verify_module
7221 if test -n "$module"; then
7222 func_get_dependencies "$module"
7224 done
7227 extract-recursive-dependencies )
7228 if test -n "$avoidlist"; then
7229 func_fatal_error "cannot combine --avoid and --extract-recursive-dependencies"
7231 for module
7233 func_verify_module
7234 if test -n "$module"; then
7235 func_get_dependencies_recursively "$module"
7237 done
7240 extract-autoconf-snippet )
7241 for module
7243 func_verify_module
7244 if test -n "$module"; then
7245 func_get_autoconf_snippet "$module"
7247 done
7250 extract-automake-snippet )
7251 for module
7253 func_verify_module
7254 if test -n "$module"; then
7255 func_get_automake_snippet "$module"
7257 done
7260 extract-include-directive )
7261 for module
7263 func_verify_module
7264 if test -n "$module"; then
7265 func_get_include_directive "$module"
7267 done
7270 extract-link-directive )
7271 for module
7273 func_verify_module
7274 if test -n "$module"; then
7275 func_get_link_directive "$module"
7277 done
7280 extract-recursive-link-directive )
7281 if test -n "$avoidlist"; then
7282 func_fatal_error "cannot combine --avoid and --extract-recursive-link-directive"
7284 for module
7286 func_verify_module
7287 if test -n "$module"; then
7288 func_get_link_directive_recursively "$module"
7290 done
7293 extract-license )
7294 for module
7296 func_verify_module
7297 if test -n "$module"; then
7298 func_get_license "$module"
7300 done
7303 extract-maintainer )
7304 for module
7306 func_verify_module
7307 if test -n "$module"; then
7308 func_get_maintainer "$module"
7310 done
7313 extract-tests-module )
7314 for module
7316 func_verify_module
7317 if test -n "$module"; then
7318 func_get_tests_module "$module"
7320 done
7323 copy-file )
7324 # Verify the number of arguments.
7325 if test $# -lt 1 || test $# -gt 2; then
7326 func_fatal_error "invalid number of arguments for --$mode"
7329 # The first argument is the file to be copied.
7330 f="$1"
7331 # Verify the file exists.
7332 func_lookup_file "$f"
7334 # The second argument is the destination; either a directory ot a file.
7335 # It defaults to the current directory.
7336 dest="$2"
7337 test -n "$dest" || dest='.'
7338 test -n "$sourcebase" || sourcebase="lib"
7339 test -n "$m4base" || m4base="m4"
7340 test -n "$docbase" || docbase="doc"
7341 test -n "$testsbase" || testsbase="tests"
7342 test -n "$auxdir" || auxdir="build-aux"
7343 rewritten='%REWRITTEN%'
7344 sed_rewrite_files="\
7345 s,^build-aux/,$rewritten$auxdir/,
7346 s,^doc/,$rewritten$docbase/,
7347 s,^lib/,$rewritten$sourcebase/,
7348 s,^m4/,$rewritten$m4base/,
7349 s,^tests/,$rewritten$testsbase/,
7350 s,^top/,$rewritten,
7351 s,^$rewritten,,"
7352 if test -d "$dest"; then
7353 destdir="$dest"
7354 g=`echo "$f" | sed -e "$sed_rewrite_files"`
7355 else
7356 destdir=`dirname "$dest"`
7357 g=`basename "$dest"`
7360 # Create the directory for destfile.
7361 d=`dirname "$destdir/$g"`
7362 if $doit; then
7363 if test -n "$d" && test ! -d "$d"; then
7364 mkdir -p "$d" || func_fatal_error "failed"
7367 # Copy the file.
7368 func_dest_tmpfilename "$g"
7369 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
7370 func_ensure_writable "$tmpfile"
7371 already_present=true
7372 if test -f "$destdir/$g"; then
7373 # The file already exists.
7374 func_update_file
7375 else
7376 # Install the file.
7377 # Don't protest if the file should be there but isn't: it happens
7378 # frequently that developers don't put autogenerated files under version
7379 # control.
7380 func_add_file
7382 rm -f "$tmpfile"
7386 func_fatal_error "unknown operation mode --$mode" ;;
7387 esac
7389 if test "$copymode" = hardlink -o "$lcopymode" = hardlink; then
7390 # Setting hard links modifies the ctime of files in the gnulib checkout.
7391 # This disturbs the result of the next "gitk" invocation.
7392 # Workaround: Let git scan the files. This can be done through
7393 # "git update-index --refresh" or "git status" or "git diff".
7394 if test -d "$gnulib_dir"/.git \
7395 && (git --version) >/dev/null 2>/dev/null; then
7396 (cd "$gnulib_dir" && git update-index --refresh >/dev/null)
7400 rm -rf "$tmp"
7401 # Undo the effect of the previous 'trap' command. Some shellology:
7402 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
7403 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
7404 # exit); for the others we need to call 'exit' explicitly. The value of $? is
7405 # 128 + signal number and is set before the trap-registered command is run.
7406 trap '' 0
7407 trap 'func_exit $?' 1 2 3 13 15
7409 exit 0
7411 # Local Variables:
7412 # indent-tabs-mode: nil
7413 # whitespace-check-buffer-indent: nil
7414 # End: