stat-time: fix macOS bug with negative file times
[gnulib.git] / gnulib-tool
blobae1b17f4dd3f7643c26f6df86391d61031b07629
1 #! /bin/sh
3 # Copyright (C) 2002-2023 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 --tests-makefile-name=NAME
309 Name of makefile in the tests-base directory
310 (default as specified through --makefile-name).
311 --automake-subdir Specify that the makefile in the source-base
312 directory be generated in such a way that it can
313 be 'include'd from the toplevel Makefile.am.
314 --automake-subdir-tests
315 Likewise, but for the tests directory.
316 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
317 'gl_INIT'. Default is 'gl'.
318 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
319 the package name. A suffix '-gnulib' is appended.
320 --witness-c-macro=NAME Specify the C macro that is defined when the
321 sources in this directory are compiled or used.
322 --vc-files Update version control related files.
323 --no-vc-files Don't update version control related files
324 (.gitignore and/or .cvsignore).
326 Options for --create-[mega]testdir, --[mega]test:
328 --single-configure Generate a single configure file, not a separate
329 configure file for the tests directory.
331 Options for --import, --add/remove-import, --update,
332 --create-[mega]testdir, --[mega]test:
334 -s, --symbolic, --symlink Make symbolic links instead of copying files.
335 --local-symlink Make symbolic links instead of copying files, only
336 for files from the local override directory.
337 -h, --hardlink Make hard links instead of copying files.
338 --local-hardlink Make hard links instead of copying files, only
339 for files from the local override directory.
341 Options for --import, --add/remove-import, --update:
343 -S, --more-symlinks Deprecated; equivalent to --symlink.
344 -H, --more-hardlinks Deprecated; equivalent to --hardlink.
346 Report bugs to <bug-gnulib@gnu.org>."
349 # func_version
350 # outputs to stdout the --version message.
351 func_version ()
353 func_gnulib_dir
354 if test -d "$gnulib_dir"/.git \
355 && (git --version) >/dev/null 2>/dev/null \
356 && (date --version) >/dev/null 2>/dev/null; then
357 # gnulib checked out from git.
358 sed_extract_first_date='/^Date/{
359 s/^Date:[ ]*//p
362 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
363 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
364 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
365 date=`echo "$date" | sed -e "$sed_year_before_time"`
366 # Use GNU date to compute the time in GMT.
367 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
368 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
369 else
370 # gnulib copy without versioning information.
371 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
372 version=
374 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
375 echo "\
376 gnulib-tool (GNU $package $date)$version
377 Copyright (C) $year Free Software Foundation, Inc.
378 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
379 This is free software: you are free to change and redistribute it.
380 There is NO WARRANTY, to the extent permitted by law.
382 printf "Written by %s, %s, and %s.\n" "Bruno Haible" "Paul Eggert" "Simon Josefsson"
385 # func_emit_copyright_notice
386 # outputs to stdout a header for a generated file.
387 func_emit_copyright_notice ()
389 sed -n -e '/Copyright/ {
392 }' < "$self_abspathname"
393 echo "#"
394 echo "# This file is free software; you can redistribute it and/or modify"
395 echo "# it under the terms of the GNU General Public License as published by"
396 echo "# the Free Software Foundation, either version 3 of the License, or"
397 echo "# (at your option) any later version."
398 echo "#"
399 echo "# This file is distributed in the hope that it will be useful,"
400 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
401 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
402 echo "# GNU General Public License for more details."
403 echo "#"
404 echo "# You should have received a copy of the GNU General Public License"
405 echo "# along with this file. If not, see <https://www.gnu.org/licenses/>."
406 echo "#"
407 echo "# As a special exception to the GNU General Public License,"
408 echo "# this file may be distributed as part of a program that"
409 echo "# contains a configuration script generated by Autoconf, under"
410 echo "# the same distribution terms as the rest of that program."
411 echo "#"
412 echo "# Generated by gnulib-tool."
415 # func_exit STATUS
416 # exits with a given status.
417 # This function needs to be used, rather than 'exit', when a 'trap' handler is
418 # in effect that refers to $?.
419 func_exit ()
421 (exit $1); exit $1
424 # func_gnulib_dir
425 # locates the directory where the gnulib repository lives
426 # Input:
427 # - progname name of this program
428 # Sets variables
429 # - self_abspathname absolute pathname of gnulib-tool
430 # - gnulib_dir absolute pathname of gnulib repository
431 func_gnulib_dir ()
433 case "$progname" in
434 /* | ?:*) self_abspathname="$progname" ;;
435 */*) self_abspathname=`pwd`/"$progname" ;;
437 # Look in $PATH.
438 # Iterate through the elements of $PATH.
439 # We use IFS=: instead of
440 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
441 # because the latter does not work when some PATH element contains spaces.
442 # We use a canonicalized $pathx instead of $PATH, because empty PATH
443 # elements are by definition equivalent to '.', however field splitting
444 # according to IFS=: loses empty fields in many shells:
445 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
446 # beginning, at the end, and in the middle),
447 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
448 # at the beginning and at the end,
449 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
450 # Solaris lose empty fields at the end.
451 # The 'case' statement is an optimization, to avoid evaluating the
452 # explicit canonicalization command when $PATH contains no empty fields.
453 self_abspathname=
454 if test "$PATH_SEPARATOR" = ";"; then
455 # On Windows, programs are searched in "." before $PATH.
456 pathx=".;$PATH"
457 else
458 # On Unix, we have to convert empty PATH elements to ".".
459 pathx="$PATH"
460 case :$PATH: in
461 *::*)
462 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
464 esac
466 save_IFS="$IFS"
467 IFS="$PATH_SEPARATOR"
468 for d in $pathx; do
469 IFS="$save_IFS"
470 test -z "$d" && d=.
471 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
472 self_abspathname="$d/$progname"
473 break
475 done
476 IFS="$save_IFS"
477 if test -z "$self_abspathname"; then
478 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
481 esac
482 while test -h "$self_abspathname"; do
483 # Resolve symbolic link.
484 linkval=`func_readlink "$self_abspathname"`
485 test -n "$linkval" || break
486 case "$linkval" in
487 /* | ?:* ) self_abspathname="$linkval" ;;
488 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
489 esac
490 done
491 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
494 # func_tmpdir
495 # creates a temporary directory.
496 # Input:
497 # - progname name of this program
498 # Sets variable
499 # - tmp pathname of freshly created temporary directory
500 func_tmpdir ()
502 # Use the environment variable TMPDIR, falling back to /tmp. This allows
503 # users to specify a different temporary directory, for example, if their
504 # /tmp is filled up or too small.
505 : "${TMPDIR=/tmp}"
507 # Use the mktemp program if available. If not available, hide the error
508 # message.
509 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
510 test -n "$tmp" && test -d "$tmp"
511 } ||
513 # Use a simple mkdir command. It is guaranteed to fail if the directory
514 # already exists. $RANDOM is bash specific and expands to empty in shells
515 # other than bash, ksh and zsh. Its use does not increase security;
516 # rather, it minimizes the probability of failure in a very cluttered /tmp
517 # directory.
518 tmp=$TMPDIR/gl$$-$RANDOM
519 (umask 077 && mkdir "$tmp")
520 } ||
522 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
523 func_exit 1
527 # func_append var value
528 # appends the given value to the shell variable var.
529 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
530 # Use bash's += operator. It reduces complexity of appending repeatedly to
531 # a single variable from O(n^2) to O(n).
532 func_append ()
534 eval "$1+=\"\$2\""
536 fast_func_append=true
537 else
538 func_append ()
540 eval "$1=\"\$$1\$2\""
542 fast_func_append=false
545 # func_remove_prefix var prefix
546 # removes the given prefix from the value of the shell variable var.
547 # var should be the name of a shell variable.
548 # Its value should not contain a newline and not start or end with whitespace.
549 # prefix should not contain the characters "$`\{}[]^|.
550 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
551 func_remove_prefix ()
553 eval "$1=\${$1#\$2}"
555 fast_func_remove_prefix=true
556 else
557 func_remove_prefix ()
559 eval "value=\"\$$1\""
560 prefix="$2"
561 case "$prefix" in
562 *.*)
563 sed_escape_dots='s/\([.]\)/\\\1/g'
564 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
566 esac
567 value=`echo "$value" | sed -e "s|^${prefix}||"`
568 eval "$1=\"\$value\""
570 fast_func_remove_prefix=false
573 # Determine whether we should use ':' or ';' as PATH_SEPARATOR.
574 func_determine_path_separator ()
576 if test "${PATH_SEPARATOR+set}" != set; then
577 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
578 # contains only /bin. Note that ksh looks also at the FPATH variable,
579 # so we have to set that as well for the test.
580 PATH_SEPARATOR=:
581 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
582 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
583 || PATH_SEPARATOR=';'
588 # func_path_append pathvar directory
589 # appends directory to pathvar, delimiting directories by PATH_SEPARATOR.
590 func_path_append ()
592 if eval "test -n \"\$$1\""; then
593 func_append "$1" "$PATH_SEPARATOR$2"
594 else
595 eval "$1=\$2"
599 # func_path_foreach_inner
600 # helper for func_path_foreach because we need new 'args' array
601 # Input:
602 # - fpf_dir directory from local_gnulib_path
603 # - fpf_cb callback to be run for fpf_dir
604 func_path_foreach_inner ()
606 set %start% "$@"
607 for _fpf_arg
609 case "$_fpf_arg" in
610 %start%)
611 set dummy
613 %dir%)
614 set "$@" "$fpf_dir"
617 set "$@" "$_fpf_arg"
619 esac
620 done
621 shift
623 "$fpf_cb" "$@"
626 # func_path_foreach path method args
627 # Execute method for each directory in path. The method will be called
628 # like `method args` while any argument '%dir%' within args will be replaced
629 # with processed directory from path.
630 func_path_foreach ()
632 fpf_dirs="$1"; shift
633 fpf_cb="$1"; shift
634 fpf_rc=false
636 fpf_save_IFS="$IFS"
637 IFS="$PATH_SEPARATOR"
638 for fpf_dir in $fpf_dirs
640 IFS="$fpf_save_IFS"
641 func_path_foreach_inner "$@" && fpf_rc=:
642 done
643 IFS="$fpf_save_IFS"
644 $fpf_rc
647 # func_remove_suffix var suffix
648 # removes the given suffix from the value of the shell variable var.
649 # var should be the name of a shell variable.
650 # Its value should not contain a newline and not start or end with whitespace.
651 # suffix should not contain the characters "$`\{}[]^|.
652 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
653 func_remove_suffix ()
655 eval "$1=\${$1%\$2}"
657 fast_func_remove_suffix=true
658 else
659 func_remove_suffix ()
661 eval "value=\"\$$1\""
662 suffix="$2"
663 case "$suffix" in
664 *.*)
665 sed_escape_dots='s/\([.]\)/\\\1/g'
666 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
668 esac
669 value=`echo "$value" | sed -e "s|${suffix}\$||"`
670 eval "$1=\"\$value\""
672 fast_func_remove_suffix=false
675 # func_fatal_error message
676 # outputs to stderr a fatal error message, and terminates the program.
677 # Input:
678 # - progname name of this program
679 func_fatal_error ()
681 echo "$progname: *** $1" 1>&2
682 echo "$progname: *** Stop." 1>&2
683 func_exit 1
686 # func_warning message
687 # Outputs to stderr a warning message,
688 func_warning ()
690 echo "gnulib-tool: warning: $1" 1>&2
693 # func_readlink SYMLINK
694 # outputs the target of the given symlink.
695 if (type readlink) > /dev/null 2>&1; then
696 func_readlink ()
698 # Use the readlink program from GNU coreutils.
699 readlink "$1"
701 else
702 func_readlink ()
704 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
705 # would do the wrong thing if the link target contains " -> ".
706 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
710 # func_relativize DIR1 DIR2
711 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
712 # Input:
713 # - DIR1 relative pathname, relative to the current directory
714 # - DIR2 relative pathname, relative to the current directory
715 # Output:
716 # - reldir relative pathname of DIR2, relative to DIR1
717 func_relativize ()
719 dir0=`pwd`
720 dir1="$1"
721 dir2="$2"
722 sed_first='s,^\([^/]*\)/.*$,\1,'
723 sed_rest='s,^[^/]*/*,,'
724 sed_last='s,^.*/\([^/]*\)$,\1,'
725 sed_butlast='s,/*[^/]*$,,'
726 while test -n "$dir1"; do
727 first=`echo "$dir1" | sed -e "$sed_first"`
728 if test "$first" != "."; then
729 if test "$first" = ".."; then
730 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
731 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
732 else
733 first2=`echo "$dir2" | sed -e "$sed_first"`
734 if test "$first2" = "$first"; then
735 dir2=`echo "$dir2" | sed -e "$sed_rest"`
736 else
737 dir2="../$dir2"
739 dir0="$dir0"/"$first"
742 dir1=`echo "$dir1" | sed -e "$sed_rest"`
743 done
744 reldir="$dir2"
747 # func_relconcat DIR1 DIR2
748 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
749 # Input:
750 # - DIR1 relative pathname, relative to the current directory
751 # - DIR2 relative pathname, relative to DIR1
752 # Output:
753 # - relconcat DIR1/DIR2, relative to the current directory
754 func_relconcat ()
756 dir1="$1"
757 dir2="$2"
758 sed_first='s,^\([^/]*\)/.*$,\1,'
759 sed_rest='s,^[^/]*/*,,'
760 sed_last='s,^.*/\([^/]*\)$,\1,'
761 sed_butlast='s,/*[^/]*$,,'
762 while true; do
763 first=`echo "$dir2" | sed -e "$sed_first"`
764 if test "$first" = "."; then
765 dir2=`echo "$dir2" | sed -e "$sed_rest"`
766 if test -z "$dir2"; then
767 relconcat="$dir1"
768 break
770 else
771 last=`echo "$dir1" | sed -e "$sed_last"`
772 while test "$last" = "."; do
773 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
774 last=`echo "$dir1" | sed -e "$sed_last"`
775 done
776 if test -z "$dir1"; then
777 relconcat="$dir2"
778 break
780 if test "$first" = ".."; then
781 if test "$last" = ".."; then
782 relconcat="$dir1/$dir2"
783 break
785 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
786 dir2=`echo "$dir2" | sed -e "$sed_rest"`
787 if test -z "$dir1"; then
788 relconcat="$dir2"
789 break
791 if test -z "$dir2"; then
792 relconcat="$dir1"
793 break
795 else
796 relconcat="$dir1/$dir2"
797 break
800 done
803 # func_ensure_writable DEST
804 # Ensures the file DEST is writable.
805 func_ensure_writable ()
807 test -w "$1" || chmod u+w "$1"
810 # func_ln_s SRC DEST
811 # Like ln -s, except use cp -p if ln -s fails.
812 func_ln_s ()
814 ln -s "$1" "$2" || {
815 echo "$progname: ln -s failed; falling back on cp -p" >&2
817 case "$1" in
818 /* | ?:*) # SRC is absolute.
819 cp_src="$1" ;;
820 *) # SRC is relative to the directory of DEST.
821 case "$2" in
822 */*) cp_src="${2%/*}/$1" ;;
823 *) cp_src="$1" ;;
824 esac
826 esac
828 cp -p "$cp_src" "$2"
829 func_ensure_writable "$2"
833 # func_symlink_target SRC DEST
834 # Determines LINK_TARGET such that "ln -s LINK_TARGET DEST" will create a
835 # symbolic link DEST that points to SRC.
836 # Output:
837 # - link_target link target, relative to the directory of DEST
838 func_symlink_target ()
840 case "$1" in
841 /* | ?:*)
842 link_target="$1" ;;
843 *) # SRC is relative.
844 case "$2" in
845 /* | ?:*)
846 link_target="`pwd`/$1" ;;
847 *) # DEST is relative too.
848 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
849 test -n "$ln_destdir" || ln_destdir="."
850 func_relativize "$ln_destdir" "$1"
851 link_target="$reldir"
853 esac
855 esac
858 # func_symlink SRC DEST
859 # Like func_ln_s, except that SRC is given relative to the current directory (or
860 # absolute), not given relative to the directory of DEST.
861 func_symlink ()
863 func_symlink_target "$1" "$2"
864 func_ln_s "$link_target" "$2"
867 # func_symlink_if_changed SRC DEST
868 # Like func_symlink, but avoids munging timestamps if the link is correct.
869 # SRC is given relative to the current directory (or absolute).
870 func_symlink_if_changed ()
872 if test $# -ne 2; then
873 echo "usage: func_symlink_if_changed SRC DEST" >&2
875 func_symlink_target "$1" "$2"
876 ln_target=`func_readlink "$2"`
877 if test -h "$2" && test "$link_target" = "$ln_target"; then
879 else
880 rm -f "$2"
881 func_ln_s "$link_target" "$2"
885 # func_hardlink SRC DEST
886 # Like ln, except use cp -p if ln fails.
887 # SRC is given relative to the current directory (or absolute).
888 func_hardlink ()
890 ln "$1" "$2" || {
891 echo "$progname: ln failed; falling back on cp -p" >&2
892 cp -p "$1" "$2"
893 func_ensure_writable "$2"
897 # The 'join' program does not exist on all platforms. Where it exists,
898 # we can use it. Where not, bail out.
899 if (type join) >/dev/null 2>&1; then
901 else
902 echo "$progname: 'join' program not found. Consider installing GNU coreutils." >&2
903 func_exit 1
906 # Ensure an 'echo' command that
907 # 1. does not interpret backslashes and
908 # 2. does not print an error message "broken pipe" when writing into a pipe
909 # with no writers.
911 # Test cases for problem 1:
912 # echo '\n' | wc -l prints 1 when OK, 2 when KO
913 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
914 # Test cases for problem 2:
915 # echo hi | true frequently prints
916 # "bash: echo: write error: Broken pipe"
917 # to standard error in bash 3.2.
919 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
920 # BSD echo interprets '-n' as an option, which is also not desirable).
921 # Nowadays the problem occurs in 4 situations:
922 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
923 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
924 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
925 # - in zsh, when sh-emulation is not set,
926 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
927 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
928 # - in Solaris /bin/sh and OSF/1 /bin/sh.
929 # We try the following workarounds:
930 # - for all: respawn using $CONFIG_SHELL if that is set and works.
931 # - for bash >= 2.04: unset the shell option xpg_echo.
932 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
933 # - for bash < 2.0: define echo to a function that uses cat of a here document.
934 # - for zsh: turn sh-emulation on.
935 # - for ksh: alias echo to 'print -r'.
936 # - for ksh: alias echo to a function that uses cat of a here document.
937 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
938 # the ksh workaround.
939 # - otherwise: respawn using /bin/sh and rely on the workarounds.
940 # When respawning, we pass --no-reexec as first argument, so as to avoid
941 # turning this script into a fork bomb in unlucky situations.
943 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
944 # the 'printf' built-in. See
945 # <https://lists.gnu.org/r/bug-bash/2008-12/msg00050.html>
946 # <https://lists.gnu.org/r/bug-gnulib/2010-02/msg00154.html>
947 # The workaround is: define echo to a function that uses the printf built-in.
948 have_echo=
949 if echo '\t' | grep t > /dev/null; then
950 have_echo=yes # Lucky!
952 # Try the workarounds.
953 # Respawn using $CONFIG_SHELL if that is set and works.
954 if test -z "$have_echo" \
955 && test "X$1" != "X--no-reexec" \
956 && test -n "$CONFIG_SHELL" \
957 && test -f "$CONFIG_SHELL" \
958 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
959 exec $CONFIG_SHELL "$0" --no-reexec "$@"
960 exit 127
962 # For bash >= 2.04: unset the shell option xpg_echo.
963 if test -z "$have_echo" \
964 && test -n "$BASH_VERSION" \
965 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
966 shopt -o xpg_echo
967 have_echo=yes
969 # For bash >= 2.0: define echo to a function that uses the printf built-in.
970 # For bash < 2.0: define echo to a function that uses cat of a here document.
971 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
972 # Also handle problem 2, specific to bash 3.2, here.
973 if { test -z "$have_echo" \
974 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
976 && test -n "$BASH_VERSION"; then \
977 if type printf 2>/dev/null | grep / > /dev/null; then
978 # 'printf' is not a shell built-in.
979 echo ()
981 cat <<EOF
985 else
986 # 'printf' is a shell built-in.
987 echo ()
989 printf '%s\n' "$*"
992 if echo '\t' | grep t > /dev/null; then
993 have_echo=yes
996 # For zsh: turn sh-emulation on.
997 if test -z "$have_echo" \
998 && test -n "$ZSH_VERSION" \
999 && (emulate sh) >/dev/null 2>&1; then
1000 emulate sh
1002 # For ksh: alias echo to 'print -r'.
1003 if test -z "$have_echo" \
1004 && (type print) >/dev/null 2>&1; then
1005 # A 'print' command exists.
1006 if type print 2>/dev/null | grep / > /dev/null; then
1008 else
1009 # 'print' is a shell built-in.
1010 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
1011 # 'print' is the ksh shell built-in.
1012 alias echo='print -r'
1016 if test -z "$have_echo" \
1017 && echo '\t' | grep t > /dev/null; then
1018 have_echo=yes
1020 # For ksh: alias echo to a function that uses cat of a here document.
1021 # The ksh manual page says:
1022 # "Aliasing is performed when scripts are read, not while they are executed.
1023 # Therefore, for an alias to take effect, the alias definition command has
1024 # to be executed before the command which references the alias is read."
1025 # Because of this, we have to play strange tricks with have_echo, to ensure
1026 # that the top-level statement containing the test starts after the 'alias'
1027 # command.
1028 if test -z "$have_echo"; then
1029 bsd_echo ()
1031 cat <<EOF
1035 if (alias echo=bsd_echo) 2>/dev/null; then
1036 alias echo=bsd_echo 2>/dev/null
1039 if test -z "$have_echo" \
1040 && echo '\t' | grep t > /dev/null; then
1041 have_echo=yes
1043 if test -z "$have_echo"; then
1044 if (alias echo=bsd_echo) 2>/dev/null; then
1045 unalias echo 2>/dev/null
1048 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
1049 if test -z "$have_echo" \
1050 && test "X$1" != "X--no-reexec" \
1051 && test -f /bin/ksh; then
1052 exec /bin/ksh "$0" --no-reexec "$@"
1053 exit 127
1055 # Otherwise: respawn using /bin/sh.
1056 if test -z "$have_echo" \
1057 && test "X$1" != "X--no-reexec" \
1058 && test -f /bin/sh; then
1059 exec /bin/sh "$0" --no-reexec "$@"
1060 exit 127
1062 if test -z "$have_echo"; then
1063 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
1065 if echo '\t' | grep t > /dev/null; then
1066 : # Works fine now.
1067 else
1068 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
1070 if test "X$1" = "X--no-reexec"; then
1071 shift
1074 # Unset CDPATH. Otherwise, output from 'cd dir' can surprise callers.
1075 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1077 # Determine the path separator early because the following option parsing code
1078 # requires that.
1079 func_determine_path_separator
1081 # Command-line option processing.
1082 # Removes the OPTIONS from the arguments. Sets the variables:
1083 # - mode one of: list, find, import, add-import, remove-import,
1084 # update, create-testdir, create-megatestdir, test, megatest,
1085 # copy-file
1086 # - destdir from --dir
1087 # - local_gnulib_path from --local-dir, highest priority dir comes first
1088 # - modcache true or false, from --cache-modules/--no-cache-modules
1089 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1090 # - libname, supplied_libname from --lib
1091 # - sourcebase from --source-base
1092 # - m4base from --m4-base
1093 # - pobase from --po-base
1094 # - docbase from --doc-base
1095 # - testsbase from --tests-base
1096 # - auxdir from --aux-dir
1097 # - inctests true if --with-tests was given, false if --without-tests
1098 # was given, blank otherwise
1099 # - incobsolete true if --with-obsolete was given, blank otherwise
1100 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
1101 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
1102 # otherwise
1103 # - inc_privileged_tests true if --with-privileged-tests was given, blank
1104 # otherwise
1105 # - inc_unportable_tests true if --with-unportable-tests was given, blank
1106 # otherwise
1107 # - inc_all_tests true if --with-all-tests was given, blank otherwise
1108 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
1109 # - excl_longrunning_tests true if --without-longrunning-tests was given,
1110 # blank otherwise
1111 # - excl_privileged_tests true if --without-privileged-tests was given, blank
1112 # otherwise
1113 # - excl_unportable_tests true if --without-unportable-tests was given, blank
1114 # otherwise
1115 # - single_configure true if --single-configure was given, false otherwise
1116 # - avoidlist list of modules to avoid, from --avoid
1117 # - cond_dependencies true if --conditional-dependencies was given, false if
1118 # --no-conditional-dependencies was given, blank otherwise
1119 # - lgpl yes or a number if --lgpl was given, blank otherwise
1120 # - gnu_make true if --gnu-make was given, false otherwise
1121 # - makefile_name from --makefile-name
1122 # - tests_makefile_name from --tests-makefile-name
1123 # - automake_subdir true if --automake-subdir was given, false otherwise
1124 # - automake_subdir_tests true if --automake-subdir-tests was given, false otherwise
1125 # - libtool true if --libtool was given, false if --no-libtool was
1126 # given, blank otherwise
1127 # - macro_prefix from --macro-prefix
1128 # - po_domain from --po-domain
1129 # - witness_c_macro from --witness-c-macro
1130 # - vc_files true if --vc-files was given, false if --no-vc-files was
1131 # given, blank otherwise
1132 # - autoconf_minversion minimum supported autoconf version
1133 # - doit : if actions shall be executed, false if only to be printed
1134 # - copymode symlink if --symlink or --more-symlinks was given,
1135 # hardlink if --hardlink or --more-hardlinks was given,
1136 # blank otherwise
1137 # - lcopymode symlink if --local-symlink was given,
1138 # hardlink if --local-hardlink was given,
1139 # blank otherwise
1141 mode=
1142 destdir=
1143 local_gnulib_path=
1144 modcache=true
1145 verbose=0
1146 libname=libgnu
1147 supplied_libname=
1148 sourcebase=
1149 m4base=
1150 pobase=
1151 docbase=
1152 testsbase=
1153 auxdir=
1154 inctests=
1155 incobsolete=
1156 inc_cxx_tests=
1157 inc_longrunning_tests=
1158 inc_privileged_tests=
1159 inc_unportable_tests=
1160 inc_all_tests=
1161 excl_cxx_tests=
1162 excl_longrunning_tests=
1163 excl_privileged_tests=
1164 excl_unportable_tests=
1165 single_configure=false
1166 avoidlist=
1167 cond_dependencies=
1168 lgpl=
1169 gnu_make=false
1170 makefile_name=
1171 tests_makefile_name=
1172 automake_subdir=false
1173 automake_subdir_tests=false
1174 libtool=
1175 macro_prefix=
1176 po_domain=
1177 witness_c_macro=
1178 vc_files=
1179 doit=:
1180 copymode=
1181 lcopymode=
1183 while test $# -gt 0; do
1184 case "$1" in
1185 --list | --lis )
1186 mode=list
1187 shift ;;
1188 --find | --fin | --fi | --f )
1189 mode=find
1190 shift ;;
1191 --import | --impor | --impo | --imp | --im | --i )
1192 mode=import
1193 shift ;;
1194 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1195 mode=add-import
1196 shift ;;
1197 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1198 mode=remove-import
1199 shift ;;
1200 --update | --updat | --upda | --upd | --up | --u )
1201 mode=update
1202 shift ;;
1203 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1204 mode=create-testdir
1205 shift ;;
1206 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1207 mode=create-megatestdir
1208 shift ;;
1209 --test | --tes | --te | --t )
1210 mode=test
1211 shift ;;
1212 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1213 mode=megatest
1214 shift ;;
1215 --extract-* )
1216 mode=`echo "X$1" | sed -e 's/^X--//'`
1217 shift ;;
1218 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1219 mode=copy-file
1220 shift ;;
1221 --dir )
1222 shift
1223 if test $# = 0; then
1224 func_fatal_error "missing argument for --dir"
1226 destdir=$1
1227 shift ;;
1228 --dir=* )
1229 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1230 shift ;;
1231 --local-dir )
1232 shift
1233 if test $# = 0; then
1234 func_fatal_error "missing argument for --local-dir"
1236 func_path_append local_gnulib_path "$1"
1237 shift ;;
1238 --local-dir=* )
1239 local_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1240 func_path_append local_gnulib_path "$local_dir"
1241 shift ;;
1242 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1243 modcache=true
1244 shift ;;
1245 --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 )
1246 modcache=false
1247 shift ;;
1248 --verbose | --verbos | --verbo | --verb )
1249 verbose=`expr $verbose + 1`
1250 shift ;;
1251 --quiet | --quie | --qui | --qu | --q )
1252 verbose=`expr $verbose - 1`
1253 shift ;;
1254 --lib )
1255 shift
1256 if test $# = 0; then
1257 func_fatal_error "missing argument for --lib"
1259 libname=$1
1260 supplied_libname=true
1261 shift ;;
1262 --lib=* )
1263 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1264 supplied_libname=true
1265 shift ;;
1266 --source-base )
1267 shift
1268 if test $# = 0; then
1269 func_fatal_error "missing argument for --source-base"
1271 sourcebase=$1
1272 shift ;;
1273 --source-base=* )
1274 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1275 shift ;;
1276 --m4-base )
1277 shift
1278 if test $# = 0; then
1279 func_fatal_error "missing argument for --m4-base"
1281 m4base=$1
1282 shift ;;
1283 --m4-base=* )
1284 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1285 shift ;;
1286 --po-base )
1287 shift
1288 if test $# = 0; then
1289 func_fatal_error "missing argument for --po-base"
1291 pobase=$1
1292 shift ;;
1293 --po-base=* )
1294 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1295 shift ;;
1296 --doc-base )
1297 shift
1298 if test $# = 0; then
1299 func_fatal_error "missing argument for --doc-base"
1301 docbase=$1
1302 shift ;;
1303 --doc-base=* )
1304 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1305 shift ;;
1306 --tests-base )
1307 shift
1308 if test $# = 0; then
1309 func_fatal_error "missing argument for --tests-base"
1311 testsbase=$1
1312 shift ;;
1313 --tests-base=* )
1314 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1315 shift ;;
1316 --aux-dir )
1317 shift
1318 if test $# = 0; then
1319 func_fatal_error "missing argument for --aux-dir"
1321 auxdir=$1
1322 shift ;;
1323 --aux-dir=* )
1324 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1325 shift ;;
1326 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1327 inctests=true
1328 shift ;;
1329 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1330 incobsolete=true
1331 shift ;;
1332 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1333 inc_cxx_tests=true
1334 shift ;;
1335 --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)
1336 inc_longrunning_tests=true
1337 shift ;;
1338 --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)
1339 inc_privileged_tests=true
1340 shift ;;
1341 --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)
1342 inc_unportable_tests=true
1343 shift ;;
1344 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1345 inc_all_tests=true
1346 shift ;;
1347 --without-tests | --without-test | --without-tes | --without-te | --without-t)
1348 inctests=false
1349 shift ;;
1350 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1351 excl_cxx_tests=true
1352 shift ;;
1353 --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)
1354 excl_longrunning_tests=true
1355 shift ;;
1356 --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)
1357 excl_privileged_tests=true
1358 shift ;;
1359 --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)
1360 excl_unportable_tests=true
1361 shift ;;
1362 --single-configure | --single-configur | --single-configu | --single-config | --single-confi | --single-conf | --single-con | --single-co | --single-c | --single- | --single | --singl | --sing | --sin | --si)
1363 single_configure=true
1364 shift ;;
1365 --avoid )
1366 shift
1367 if test $# = 0; then
1368 func_fatal_error "missing argument for --avoid"
1370 func_append avoidlist " $1"
1371 shift ;;
1372 --avoid=* )
1373 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1374 func_append avoidlist " $arg"
1375 shift ;;
1376 --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)
1377 cond_dependencies=true
1378 shift ;;
1379 --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)
1380 cond_dependencies=false
1381 shift ;;
1382 --lgpl )
1383 lgpl=yes
1384 shift ;;
1385 --lgpl=* )
1386 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1387 case "$arg" in
1388 2 | 3orGPLv2 | 3) ;;
1389 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1390 esac
1391 lgpl=$arg
1392 shift ;;
1393 --gnu-make )
1394 gnu_make=true
1395 shift ;;
1396 --makefile-name )
1397 shift
1398 if test $# = 0; then
1399 func_fatal_error "missing argument for --makefile-name"
1401 makefile_name="$1"
1402 shift ;;
1403 --makefile-name=* )
1404 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1405 shift ;;
1406 --tests-makefile-name )
1407 shift
1408 if test $# = 0; then
1409 func_fatal_error "missing argument for --tests-makefile-name"
1411 tests_makefile_name="$1"
1412 shift ;;
1413 --tests-makefile-name=* )
1414 tests_makefile_name=`echo "X$1" | sed -e 's/^X--tests-makefile-name=//'`
1415 shift ;;
1416 --automake-subdir )
1417 automake_subdir=true
1418 shift ;;
1419 --automake-subdir-tests )
1420 automake_subdir_tests=true
1421 shift ;;
1422 --libtool )
1423 libtool=true
1424 shift ;;
1425 --no-libtool )
1426 libtool=false
1427 shift ;;
1428 --macro-prefix )
1429 shift
1430 if test $# = 0; then
1431 func_fatal_error "missing argument for --macro-prefix"
1433 macro_prefix="$1"
1434 shift ;;
1435 --macro-prefix=* )
1436 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1437 shift ;;
1438 --po-domain )
1439 shift
1440 if test $# = 0; then
1441 func_fatal_error "missing argument for --po-domain"
1443 po_domain="$1"
1444 shift ;;
1445 --po-domain=* )
1446 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1447 shift ;;
1448 --witness-c-macro )
1449 shift
1450 if test $# = 0; then
1451 func_fatal_error "missing argument for --witness-c-macro"
1453 witness_c_macro="$1"
1454 shift ;;
1455 --witness-c-macro=* )
1456 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1457 shift ;;
1458 --vc-files )
1459 vc_files=true
1460 shift ;;
1461 --no-vc-files )
1462 vc_files=false
1463 shift ;;
1464 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1465 # A no-op for backward compatibility.
1466 shift ;;
1467 --dry-run )
1468 doit=false
1469 shift ;;
1470 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1471 copymode=symlink
1472 shift ;;
1473 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1474 lcopymode=symlink
1475 shift ;;
1476 -h | --hardlink | --hardlin | --hardli | --hardl | --hard | --har | --ha )
1477 copymode=hardlink
1478 shift ;;
1479 --local-hardlink | --local-hardlin | --local-hardli | --local-hardl | --local-hard | --local-har | --local-ha | --local-h )
1480 lcopymode=hardlink
1481 shift ;;
1482 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s )
1483 copymode=symlink
1484 shift ;;
1485 -H | --more-hardlinks | --more-hardlink | --more-hardlin | --more-hardli | --more-hardl | --more-hard | --more-har | --more-ha | --more-h )
1486 copymode=hardlink
1487 shift ;;
1488 --help | --hel | --he )
1489 func_usage
1490 func_exit $? ;;
1491 --version | --versio | --versi | --vers )
1492 func_version
1493 func_exit $? ;;
1494 -- )
1495 # Stop option processing
1496 shift
1497 break ;;
1498 -* )
1499 echo "gnulib-tool: unknown option $1" 1>&2
1500 echo "Try 'gnulib-tool --help' for more information." 1>&2
1501 func_exit 1 ;;
1503 break ;;
1504 esac
1505 done
1507 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1508 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1509 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1510 || test "$single_configure" != false; then
1511 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1512 echo "Try 'gnulib-tool --help' for more information." 1>&2
1513 func_exit 1
1516 if test "$mode" = update; then
1517 if test $# != 0; then
1518 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1519 echo "Try 'gnulib-tool --help' for more information." 1>&2
1520 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1521 echo "you need to use 'gnulib-tool --import' - at your own risk!" 1>&2
1522 func_exit 1
1524 if test -n "$local_gnulib_path" || test -n "$supplied_libname" \
1525 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1526 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1527 || test -n "$inctests" || test -n "$incobsolete" \
1528 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1529 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1530 || test -n "$inc_all_tests" \
1531 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1532 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1533 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1534 || test -n "$tests_makefile_name" || test "$automake_subdir" != false \
1535 || test "$automake_subdir_tests" != false \
1536 || test -n "$macro_prefix" || test -n "$po_domain" \
1537 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1538 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1539 echo "Try 'gnulib-tool --help' for more information." 1>&2
1540 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1541 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1542 func_exit 1
1545 if test -n "$pobase" && test -z "$po_domain"; then
1546 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1547 echo "Try 'gnulib-tool --help' for more information." 1>&2
1548 func_exit 1
1550 if test -z "$pobase" && test -n "$po_domain"; then
1551 func_warning "--po-domain has no effect without a --po-base option"
1553 case $mode,$gnu_make in
1554 *test*,true)
1555 echo "gnulib-tool: --gnu-make not supported when including tests"
1556 func_exit 1;;
1557 esac
1558 # Canonicalize the inctests variable.
1559 case "$mode" in
1560 import | add-import | remove-import | update)
1561 if test -z "$inctests"; then
1562 inctests=false
1565 create-testdir | create-megatestdir | test | megatest)
1566 if test -z "$inctests"; then
1567 inctests=true
1570 esac
1571 # Now the only possible values of "$inctests" are true and false
1572 # (or blank but then it is irrelevant).
1574 # Determine the minimum supported autoconf version from the project's
1575 # configure.ac.
1576 DEFAULT_AUTOCONF_MINVERSION="2.64"
1577 autoconf_minversion=
1578 configure_ac=
1579 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1580 && test -n "$destdir"; then
1581 if test -f "$destdir"/configure.ac; then
1582 configure_ac="$destdir/configure.ac"
1583 else
1584 if test -f "$destdir"/configure.in; then
1585 configure_ac="$destdir/configure.in"
1588 else
1589 if test -f configure.ac; then
1590 configure_ac="configure.ac"
1591 else
1592 if test -f configure.in; then
1593 configure_ac="configure.in"
1597 if test -n "$configure_ac"; then
1598 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1599 # because when some m4 files are omitted from a version control repository,
1600 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1601 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1602 # autom4te: m4 failed with exit status: 1
1603 my_sed_traces='
1604 s,#.*$,,
1605 s,^dnl .*$,,
1606 s, dnl .*$,,
1607 /AC_PREREQ/ {
1608 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1610 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1611 if test -n "$prereqs"; then
1612 autoconf_minversion=`
1613 for version in $prereqs; do echo $version; done |
1614 LC_ALL=C sort -nru | sed -e 1q
1618 if test -z "$autoconf_minversion"; then
1619 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1621 case "$autoconf_minversion" in
1622 1.* | 2.[0-5]* | 2.6[0-3]*)
1623 func_fatal_error "minimum supported autoconf version is 2.64. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1624 esac
1626 # Determine whether --automake-subdir/--automake-subdir-tests are supported.
1627 if $automake_subdir || $automake_subdir_tests; then
1628 found_subdir_objects=false
1629 if test -n "$configure_ac"; then
1630 my_sed_traces='
1631 s,#.*$,,
1632 s,^dnl .*$,,
1633 s, dnl .*$,,
1634 /AM_INIT_AUTOMAKE/ {
1635 s,^.*AM_INIT_AUTOMAKE([[ ]*\([^])]*\).*$,\1,p
1637 automake_options=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1638 for option in $automake_options; do
1639 case "$option" in
1640 subdir-objects ) found_subdir_objects=true ;;
1641 esac
1642 done
1644 if test -f "${destdir:-.}"/Makefile.am; then
1645 automake_options=`sed -n -e 's/^AUTOMAKE_OPTIONS[ ]*=\(.*\)$/\1/p' "${destdir:-.}"/Makefile.am`
1646 for option in $automake_options; do
1647 case "$option" in
1648 subdir-objects ) found_subdir_objects=true ;;
1649 esac
1650 done
1652 if ! $found_subdir_objects; then
1653 func_fatal_error "Option --automake-subdir/--automake-subdir-tests are only supported if the definition of AUTOMAKE_OPTIONS in Makefile.am contains 'subdir-objects'."
1657 # Remove trailing slashes from the directory names. This is necessary for
1658 # m4base (to avoid an error in func_import) and optional for the others.
1659 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1660 old_local_gnulib_path="$local_gnulib_path"
1661 local_gnulib_path=
1662 save_IFS="$IFS"
1663 IFS=:
1664 for dir in $old_local_gnulib_path
1666 IFS="$save_IFS"
1667 case "$dir" in
1668 */ ) dir=`echo "$dir" | sed -e "$sed_trimtrailingslashes"` ;;
1669 esac
1670 func_path_append local_gnulib_path "$dir"
1671 done
1672 IFS="$save_IFS"
1673 case "$sourcebase" in
1674 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1675 esac
1676 case "$m4base" in
1677 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1678 esac
1679 case "$pobase" in
1680 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1681 esac
1682 case "$docbase" in
1683 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1684 esac
1685 case "$testsbase" in
1686 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1687 esac
1688 case "$auxdir" in
1689 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1690 esac
1693 func_gnulib_dir
1694 func_tmpdir
1695 trap 'exit_status=$?
1696 if test "$signal" != EXIT; then
1697 echo "caught signal SIG$signal" >&2
1699 rm -rf "$tmp"
1700 exit $exit_status' EXIT
1701 for signal in HUP INT QUIT PIPE TERM; do
1702 trap '{ signal='$signal'; func_exit 1; }' $signal
1703 done
1704 signal=EXIT
1706 # Note: The 'eval' silences stderr output in dash.
1707 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1708 # Zsh 4 and Bash 4 have associative arrays.
1709 have_associative=true
1710 else
1711 # For other shells, use 'eval' with computed shell variable names.
1712 have_associative=false
1715 # func_lookup_local_file_cb dir file
1716 # returns true and sets func_lookup_local_file_result if the file $dir/$file
1717 # exists.
1718 func_lookup_local_file_cb ()
1720 test -n "$func_lookup_local_file_result" && return 1 # already found?
1721 test -f "$1/$2" || return 1
1722 func_lookup_local_file_result=$1/$2
1726 # func_lookup_local_file file
1727 # looks up a file in $local_gnulib_path.
1728 # Input:
1729 # - local_gnulib_path from --local-dir
1730 # Output:
1731 # - func_lookup_local_file_result name of the file, valid only when the
1732 # function succeeded.
1733 func_lookup_local_file ()
1735 func_lookup_local_file_result=
1736 func_path_foreach "$local_gnulib_path" func_lookup_local_file_cb %dir% "$1"
1739 # func_lookup_file_cb dir
1740 # does one step in processing the $local_gnulib_path, looking for $dir/$lkfile
1741 # and $dir/$lkfile.diff.
1742 func_lookup_file_cb ()
1744 # If we found the file already in a --local-dir of higher priority, nothing
1745 # more to do.
1746 if test -z "$lookedup_file"; then
1747 # Otherwise, look for $dir/$lkfile and $dir/$lkfile.diff.
1748 if test -f "$1/$lkfile"; then
1749 lookedup_file="$1/$lkfile"
1750 else
1751 if test -f "$1/$lkfile.diff"; then
1752 lkpatches="$1/$lkfile.diff${lkpatches:+$PATH_SEPARATOR$lkpatches}"
1758 # func_lookup_file file
1759 # looks up a file in $local_gnulib_path or $gnulib_dir, or combines it through
1760 # 'patch'.
1761 # Input:
1762 # - local_gnulib_path from --local-dir
1763 # Output:
1764 # - lookedup_file name of the merged (combined) file
1765 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1766 func_lookup_file ()
1768 lkfile="$1"
1769 # Each element in $local_gnulib_path is a directory whose contents overrides
1770 # or amends the result of the lookup in the rest of $local_gnulib_path and
1771 # $gnulib_dir. So, the first element of $local_gnulib_path is the highest
1772 # priority one.
1773 lookedup_file=
1774 lkpatches=
1775 func_path_foreach "$local_gnulib_path" func_lookup_file_cb %dir%
1776 # Treat $gnulib_dir like a lowest-priority --local-dir, except that here we
1777 # don't look for .diff files.
1778 if test -z "$lookedup_file"; then
1779 if test -f "$gnulib_dir/$lkfile"; then
1780 lookedup_file="$gnulib_dir/$lkfile"
1781 else
1782 func_fatal_error "file $gnulib_dir/$lkfile not found"
1785 # Now apply the patches, from lowest-priority to highest-priority.
1786 lookedup_tmp=
1787 if test -n "$lkpatches"; then
1788 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1789 rm -f "$tmp/$lkbase"
1790 cp "$lookedup_file" "$tmp/$lkbase"
1791 func_ensure_writable "$tmp/$lkbase"
1792 save_IFS="$IFS"
1793 IFS="$PATH_SEPARATOR"
1794 for patchfile in $lkpatches; do
1795 IFS="$save_IFS"
1796 patch -s "$tmp/$lkbase" < "$patchfile" >&2 \
1797 || func_fatal_error "patch file $patchfile didn't apply cleanly"
1798 done
1799 IFS="$save_IFS"
1800 lookedup_file="$tmp/$lkbase"
1801 lookedup_tmp=true
1805 # func_sanitize_modulelist
1806 # receives a list of possible module names on standard input, one per line.
1807 # It removes those which are just file names unrelated to modules, and outputs
1808 # the resulting list to standard output, one per line.
1809 func_sanitize_modulelist ()
1811 sed -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1812 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1813 -e '/^README$/d' -e '/\/README$/d' \
1814 -e '/^TEMPLATE$/d' \
1815 -e '/^TEMPLATE-EXTENDED$/d' \
1816 -e '/^TEMPLATE-TESTS$/d' \
1817 -e '/^\..*/d' \
1818 -e '/\.orig$/d' \
1819 -e '/\.rej$/d' \
1820 -e '/~$/d'
1824 # func_modules_in_dir dir
1825 # outputs all module files in dir to standard output.
1826 func_modules_in_dir ()
1828 (test -d "$1" && cd "$1" && find modules -type f -print)
1831 # func_all_modules
1832 # Input:
1833 # - local_gnulib_path from --local-dir
1834 func_all_modules ()
1836 # Filter out metainformation files like README, which are not modules.
1837 # Filter out unit test modules; they can be retrieved through
1838 # --extract-tests-module if desired.
1840 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1841 func_path_foreach "$local_gnulib_path" func_modules_in_dir %dir% | sed -e 's,^modules/,,' -e 's,\.diff$,,'
1843 | func_sanitize_modulelist \
1844 | sed -e '/-tests$/d' \
1845 | LC_ALL=C sort -u
1848 # func_exists_local_module dir module
1849 # returns true if module exists in dir
1850 func_exists_local_module ()
1852 test -d "$1/modules" && test -f "$1/modules/$2";
1855 # func_exists_module module
1856 # tests whether a module, given by name, exists
1857 # Input:
1858 # - local_gnulib_path from --local-dir
1859 func_exists_module ()
1861 { test -f "$gnulib_dir/modules/$1" \
1862 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1" ; } \
1863 && test "ChangeLog" != "$1" \
1864 && test "COPYING" != "$1" \
1865 && test "README" != "$1" \
1866 && test "TEMPLATE" != "$1" \
1867 && test "TEMPLATE-EXTENDED" != "$1" \
1868 && test "TEMPLATE-TESTS" != "$1"
1871 # func_verify_module
1872 # verifies a module name
1873 # Input:
1874 # - local_gnulib_path from --local-dir
1875 # - module module name argument
1876 # Output:
1877 # - module unchanged if OK, empty if not OK
1878 # - lookedup_file if OK: name of the merged (combined) module description file
1879 # - lookedup_tmp if OK: true if it is located in the tmp directory, blank otherwise
1880 func_verify_module ()
1882 if func_exists_module "$module"; then
1883 # OK, $module is a correct module name.
1884 # Verify that building the module description with 'patch' succeeds.
1885 func_lookup_file "modules/$module"
1886 else
1887 func_warning "module $module doesn't exist"
1888 module=
1892 # func_verify_nontests_module
1893 # verifies a module name, excluding tests modules
1894 # Input:
1895 # - local_gnulib_path from --local-dir
1896 # - module module name argument
1897 func_verify_nontests_module ()
1899 case "$module" in
1900 *-tests ) module= ;;
1901 * ) func_verify_module ;;
1902 esac
1905 # Suffix of a sed expression that extracts a particular field from a
1906 # module description.
1907 # A field starts with a line that contains a keyword, such as 'Description',
1908 # followed by a colon and optional whitespace. All following lines, up to
1909 # the next field (or end of file if there is none) form the contents of the
1910 # field.
1911 # An absent field is equivalent to a field with empty contents.
1912 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1913 sed_extract_prog=':[ ]*$/ {
1916 s/^Description:[ ]*$//
1917 s/^Comment:[ ]*$//
1918 s/^Status:[ ]*$//
1919 s/^Notice:[ ]*$//
1920 s/^Applicability:[ ]*$//
1921 s/^Files:[ ]*$//
1922 s/^Depends-on:[ ]*$//
1923 s/^configure\.ac-early:[ ]*$//
1924 s/^configure\.ac:[ ]*$//
1925 s/^Makefile\.am:[ ]*$//
1926 s/^Include:[ ]*$//
1927 s/^Link:[ ]*$//
1928 s/^License:[ ]*$//
1929 s/^Maintainer:[ ]*$//
1936 # Piece of a sed expression that converts a field header line to a shell
1937 # variable name,
1938 # NOTE: Keep this in sync with sed_extract_prog above!
1939 sed_extract_field_header='
1940 s/^Description:[ ]*$/description/
1941 s/^Comment:[ ]*$/comment/
1942 s/^Status:[ ]*$/status/
1943 s/^Notice:[ ]*$/notice/
1944 s/^Applicability:[ ]*$/applicability/
1945 s/^Files:[ ]*$/files/
1946 s/^Depends-on:[ ]*$/dependson/
1947 s/^configure\.ac-early:[ ]*$/configureac_early/
1948 s/^configure\.ac:[ ]*$/configureac/
1949 s/^Makefile\.am:[ ]*$/makefile/
1950 s/^Include:[ ]*$/include/
1951 s/^Link:[ ]*$/link/
1952 s/^License:[ ]*$/license/
1953 s/^Maintainer:[ ]*$/maintainer/'
1955 if $modcache; then
1957 if $have_associative; then
1959 # Declare the associative arrays.
1960 declare -A modcache_cached
1961 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1962 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1963 eval "$declare_script"
1965 else
1967 # func_cache_var module
1968 # computes the cache variable name corresponding to $module.
1969 # Note: This computation can map different module names to the same
1970 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1971 # to protect against this case.
1972 # Output:
1973 # - cachevar a shell variable name
1974 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1975 # Bash 2.0 and newer, ksh, and zsh support the syntax
1976 # ${param//pattern/replacement}
1977 # as a shorthand for
1978 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1979 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1980 eval 'func_cache_var ()
1982 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1984 else
1985 func_cache_var ()
1987 case $1 in
1988 *[!a-zA-Z0-9_]*)
1989 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1991 cachevar=c_$1 ;;
1992 esac
1998 # func_init_sed_convert_to_cache_statements
1999 # Input:
2000 # - modcachevar_assignment
2001 # Output:
2002 # - sed_convert_to_cache_statements
2003 func_init_sed_convert_to_cache_statements ()
2005 # 'sed' script that turns a module description into shell script
2006 # assignments, suitable to be eval'ed. All active characters are escaped.
2007 # This script turns
2008 # Description:
2009 # Some module's description
2011 # Files:
2012 # lib/file.h
2013 # into:
2014 # modcache_description[$1]=\
2015 # 'Some module'"'"'s description
2017 # modcache_files[$1]=\
2018 # 'lib/file.h'
2019 # or:
2020 # c_MODULE_description_set=set; c_MODULE_description=\
2021 # 'Some module'"'"'s description
2023 # c_MODULE_files_set=set; c_MODULE_files=\
2024 # 'lib/file.h'
2025 # The script consists of two parts:
2026 # 1) Ignore the lines before the first field header.
2027 # 2) A loop, treating non-field-header lines by escaping single quotes
2028 # and adding a closing quote in the last line,
2029 sed_convert_to_cache_statements="
2030 :llla
2031 # Here we have not yet seen a field header.
2033 # See if the current line contains a field header.
2034 t llla1
2035 :llla1
2036 ${sed_extract_field_header}
2037 t lllb
2039 # No field header. Ignore the line.
2041 # Read the next line. Upon EOF, just exit.
2043 b llla
2045 :lllb
2046 # The current line contains a field header.
2048 # Turn it into the beginning of an assignment.
2049 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
2051 # Move it to the hold space. Don't print it yet,
2052 # because we want no assignment if the field is empty.
2055 # Read the next line.
2056 # Upon EOF, the field was empty. Print no assignment. Just exit.
2059 # See if the current line contains a field header.
2060 t lllb1
2061 :lllb1
2062 ${sed_extract_field_header}
2063 # If it is, the previous field was empty. Print no assignment.
2064 t lllb
2066 # Not a field header.
2068 # Print the previous line, held in the hold space.
2073 # Transform single quotes.
2074 s/'/'\"'\"'/g
2076 # Prepend a single quote.
2077 s/^/'/
2079 :lllc
2081 # Move it to the hold space.
2084 # Read the next line.
2085 # Upon EOF, branch.
2087 b llle
2091 # See if the current line contains a field header.
2092 t lllc1
2093 :lllc1
2094 ${sed_extract_field_header}
2095 t llld
2097 # Print the previous line, held in the hold space.
2102 # Transform single quotes.
2103 s/'/'\"'\"'/g
2105 b lllc
2107 :llld
2108 # A field header.
2109 # Print the previous line, held in the hold space, with a single quote
2110 # to end the assignment.
2112 s/\$/'/
2116 b lllb
2118 :llle
2119 # EOF seen.
2120 # Print the previous line, held in the hold space, with a single quote
2121 # to end the assignment.
2123 s/\$/'/
2125 # Exit.
2128 if ! $sed_comments; then
2129 # Remove comments.
2130 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
2131 | sed -e 's/^ *//' -e 's/^#.*//'`
2135 if $have_associative; then
2136 # sed_convert_to_cache_statements does not depend on the module.
2137 modcachevar_assignment='modcache_\1[$1]='
2138 func_init_sed_convert_to_cache_statements
2141 # func_cache_lookup_module module
2143 # looks up a module, like 'func_lookup_file modules/$module', and stores all
2144 # of its relevant data in a cache in the memory of the processing shell. If
2145 # already cached, it does not look it up again, thus saving file access time.
2146 # Parameters:
2147 # - module non-empty string
2148 # Output if $have_associative:
2149 # - modcache_cached[$module] set to yes
2150 # - modcache_description[$module] ==
2151 # - modcache_status[$module] \ set to the field's value, minus the
2152 # - ... / final newline,
2153 # - modcache_maintainer[$module] == or unset if the field's value is empty
2154 # Output if ! $have_associative:
2155 # - cachevar a shell variable name
2156 # - ${cachevar}_cached set to $module
2157 # - ${cachevar}_description ==
2158 # - ${cachevar}_status \ set to the field's value, minus the
2159 # - ... / final newline,
2160 # - ${cachevar}_maintainer == or unset if the field's value is empty
2161 # - ${cachevar}_description_set ==
2162 # - ${cachevar}_status_set \ set to non-empty if the field's value
2163 # - ... / is non-empty,
2164 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
2165 func_cache_lookup_module ()
2167 if $have_associative; then
2168 eval 'cached=${modcache_cached[$1]}'
2169 else
2170 func_cache_var "$1"
2171 eval "cached=\"\$${cachevar}_cached\""
2173 if test -z "$cached"; then
2174 # Not found in cache. Look it up on the file system.
2175 func_lookup_file "modules/$1"
2176 if $have_associative; then
2177 eval 'modcache_cached[$1]=yes'
2178 else
2179 eval "${cachevar}_cached=\"\$1\""
2181 if ! $have_associative; then
2182 # sed_convert_to_cache_statements depends on the module.
2183 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
2184 func_init_sed_convert_to_cache_statements
2186 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
2187 eval "$cache_statements"
2188 else
2189 if ! $have_associative; then
2190 if test "$1" != "$cached"; then
2191 func_fatal_error "cache variable collision between $1 and $cached"
2199 # func_get_description module
2200 # Input:
2201 # - local_gnulib_path from --local-dir
2202 # - modcache true or false, from --cache-modules/--no-cache-modules
2203 func_get_description ()
2205 if ! $modcache; then
2206 func_lookup_file "modules/$1"
2207 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
2208 else
2209 func_cache_lookup_module "$1"
2210 # Output the field's value, including the final newline (if any).
2211 if $have_associative; then
2212 if eval 'test -n "${modcache_description[$1]+set}"'; then
2213 eval 'echo "${modcache_description[$1]}"'
2215 else
2216 eval "field_set=\"\$${cachevar}_description_set\""
2217 if test -n "$field_set"; then
2218 eval "field_value=\"\$${cachevar}_description\""
2219 echo "${field_value}"
2225 # func_get_comment module
2226 # Input:
2227 # - local_gnulib_path from --local-dir
2228 # - modcache true or false, from --cache-modules/--no-cache-modules
2229 func_get_comment ()
2231 if ! $modcache; then
2232 func_lookup_file "modules/$1"
2233 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
2234 else
2235 func_cache_lookup_module "$1"
2236 # Output the field's value, including the final newline (if any).
2237 if $have_associative; then
2238 if eval 'test -n "${modcache_comment[$1]+set}"'; then
2239 eval 'echo "${modcache_comment[$1]}"'
2241 else
2242 eval "field_set=\"\$${cachevar}_comment_set\""
2243 if test -n "$field_set"; then
2244 eval "field_value=\"\$${cachevar}_comment\""
2245 echo "${field_value}"
2251 # func_get_status module
2252 # Input:
2253 # - local_gnulib_path from --local-dir
2254 # - modcache true or false, from --cache-modules/--no-cache-modules
2255 func_get_status ()
2257 if ! $modcache; then
2258 func_lookup_file "modules/$1"
2259 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
2260 else
2261 func_cache_lookup_module "$1"
2262 # Output the field's value, including the final newline (if any).
2263 if $have_associative; then
2264 if eval 'test -n "${modcache_status[$1]+set}"'; then
2265 eval 'echo "${modcache_status[$1]}"'
2267 else
2268 eval "field_set=\"\$${cachevar}_status_set\""
2269 if test -n "$field_set"; then
2270 eval "field_value=\"\$${cachevar}_status\""
2271 echo "${field_value}"
2277 # func_get_notice module
2278 # Input:
2279 # - local_gnulib_path from --local-dir
2280 # - modcache true or false, from --cache-modules/--no-cache-modules
2281 func_get_notice ()
2283 if ! $modcache; then
2284 func_lookup_file "modules/$1"
2285 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
2286 else
2287 func_cache_lookup_module "$1"
2288 # Output the field's value, including the final newline (if any).
2289 if $have_associative; then
2290 if eval 'test -n "${modcache_notice[$1]+set}"'; then
2291 eval 'echo "${modcache_notice[$1]}"'
2293 else
2294 eval "field_set=\"\$${cachevar}_notice_set\""
2295 if test -n "$field_set"; then
2296 eval "field_value=\"\$${cachevar}_notice\""
2297 echo "${field_value}"
2303 # func_get_applicability module
2304 # Input:
2305 # - local_gnulib_path from --local-dir
2306 # - modcache true or false, from --cache-modules/--no-cache-modules
2307 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
2308 func_get_applicability ()
2310 if ! $modcache; then
2311 func_lookup_file "modules/$1"
2312 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2313 else
2314 func_cache_lookup_module "$1"
2315 # Get the field's value, without the final newline.
2316 if $have_associative; then
2317 eval 'my_applicability="${modcache_applicability[$1]}"'
2318 else
2319 eval "my_applicability=\"\$${cachevar}_applicability\""
2322 if test -n "$my_applicability"; then
2323 echo $my_applicability
2324 else
2325 # The default is 'main' or 'tests', depending on the module's name.
2326 case $1 in
2327 *-tests) echo "tests";;
2328 *) echo "main";;
2329 esac
2333 # func_get_filelist module
2334 # Input:
2335 # - local_gnulib_path from --local-dir
2336 # - modcache true or false, from --cache-modules/--no-cache-modules
2337 func_get_filelist ()
2339 if ! $modcache; then
2340 func_lookup_file "modules/$1"
2341 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2342 else
2343 func_cache_lookup_module "$1"
2344 # Output the field's value, including the final newline (if any).
2345 if $have_associative; then
2346 if eval 'test -n "${modcache_files[$1]+set}"'; then
2347 eval 'echo "${modcache_files[$1]}"'
2349 else
2350 eval "field_set=\"\$${cachevar}_files_set\""
2351 if test -n "$field_set"; then
2352 eval "field_value=\"\$${cachevar}_files\""
2353 echo "${field_value}"
2357 echo m4/00gnulib.m4
2358 echo m4/zzgnulib.m4
2359 echo m4/gnulib-common.m4
2362 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2363 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2364 # elements starting with prefix and ending with suffix are considered.
2365 # Processing: removed_prefix and removed_suffix are removed from each element,
2366 # added_prefix and added_suffix are added to each element.
2367 # prefix, suffix should not contain shell-special characters.
2368 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2369 # added_prefix, added_suffix should not contain the characters \|&.
2370 func_filter_filelist ()
2372 if test "$2" != "$nl" \
2373 || { $fast_func_append \
2374 && { test -z "$6" || $fast_func_remove_prefix; } \
2375 && { test -z "$7" || $fast_func_remove_suffix; }; \
2376 }; then
2377 ffflist=
2378 for fff in $3; do
2379 # Do not quote possibly-empty parameters in case patterns,
2380 # AIX and HP-UX ksh won't match them if they are empty.
2381 case "$fff" in
2382 $4*$5)
2383 if test -n "$6"; then
2384 func_remove_prefix fff "$6"
2386 if test -n "$7"; then
2387 func_remove_suffix fff "$7"
2389 fff="$8${fff}$9"
2390 if test -z "$ffflist"; then
2391 ffflist="${fff}"
2392 else
2393 func_append ffflist "$2${fff}"
2396 esac
2397 done
2398 else
2399 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2400 ffflist=`for fff in $3; do
2401 case "$fff" in
2402 $4*$5) echo "$fff" ;;
2403 esac
2404 done | sed -e "$sed_fff_filter"`
2406 eval "$1=\"\$ffflist\""
2409 # func_get_dependencies module
2410 # Input:
2411 # - local_gnulib_path from --local-dir
2412 # - modcache true or false, from --cache-modules/--no-cache-modules
2413 func_get_dependencies ()
2415 # ${module}-tests implicitly depends on ${module}, if that module exists.
2416 case "$1" in
2417 *-tests)
2418 fgd1="$1"
2419 func_remove_suffix fgd1 '-tests'
2420 if func_exists_module "$fgd1"; then
2421 echo "$fgd1"
2424 esac
2425 # Then the explicit dependencies listed in the module description.
2426 { if ! $modcache; then
2427 func_lookup_file "modules/$1"
2428 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2429 else
2430 func_cache_lookup_module "$1"
2431 # Output the field's value, including the final newline (if any).
2432 if $have_associative; then
2433 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2434 eval 'echo "${modcache_dependson[$1]}"'
2436 else
2437 eval "field_set=\"\$${cachevar}_dependson_set\""
2438 if test -n "$field_set"; then
2439 eval "field_value=\"\$${cachevar}_dependson\""
2440 echo "${field_value}"
2445 | sed -e '/^#/d'
2448 sed_dependencies_without_conditions='s/ *\[.*//'
2450 # func_get_autoconf_early_snippet module
2451 # Input:
2452 # - local_gnulib_path from --local-dir
2453 # - modcache true or false, from --cache-modules/--no-cache-modules
2454 func_get_autoconf_early_snippet ()
2456 if ! $modcache; then
2457 func_lookup_file "modules/$1"
2458 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2459 else
2460 func_cache_lookup_module "$1"
2461 # Output the field's value, including the final newline (if any).
2462 if $have_associative; then
2463 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2464 eval 'echo "${modcache_configureac_early[$1]}"'
2466 else
2467 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2468 if test -n "$field_set"; then
2469 eval "field_value=\"\$${cachevar}_configureac_early\""
2470 echo "${field_value}"
2476 # func_get_autoconf_snippet module
2477 # Input:
2478 # - local_gnulib_path from --local-dir
2479 # - modcache true or false, from --cache-modules/--no-cache-modules
2480 func_get_autoconf_snippet ()
2482 if ! $modcache; then
2483 func_lookup_file "modules/$1"
2484 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2485 else
2486 func_cache_lookup_module "$1"
2487 # Output the field's value, including the final newline (if any).
2488 if $have_associative; then
2489 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2490 eval 'echo "${modcache_configureac[$1]}"'
2492 else
2493 eval "field_set=\"\$${cachevar}_configureac_set\""
2494 if test -n "$field_set"; then
2495 eval "field_value=\"\$${cachevar}_configureac\""
2496 echo "${field_value}"
2502 # Concatenate lines with trailing slash.
2503 # $1 is an optional filter to restrict the
2504 # concatenation to groups starting with that expression
2505 combine_lines() {
2506 sed -e "/$1.*"'\\$/{
2509 s/\\\n/ /
2510 s/\\$/\\/
2515 # func_get_automake_snippet_conditional module
2516 # returns the part of the Makefile.am snippet that can be put inside Automake
2517 # conditionals.
2518 # Input:
2519 # - local_gnulib_path from --local-dir
2520 # - modcache true or false, from --cache-modules/--no-cache-modules
2521 func_get_automake_snippet_conditional ()
2523 if ! $modcache; then
2524 func_lookup_file "modules/$1"
2525 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2526 else
2527 func_cache_lookup_module "$1"
2528 # Output the field's value, including the final newline (if any).
2529 if $have_associative; then
2530 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2531 eval 'echo "${modcache_makefile[$1]}"'
2533 else
2534 eval "field_set=\"\$${cachevar}_makefile_set\""
2535 if test -n "$field_set"; then
2536 eval "field_value=\"\$${cachevar}_makefile\""
2537 echo "${field_value}"
2543 # func_get_automake_snippet_unconditional module
2544 # returns the part of the Makefile.am snippet that must stay outside of
2545 # Automake conditionals.
2546 # Input:
2547 # - local_gnulib_path from --local-dir
2548 # - modcache true or false, from --cache-modules/--no-cache-modules
2549 func_get_automake_snippet_unconditional ()
2551 case "$1" in
2552 *-tests)
2553 # *-tests module live in tests/, not lib/.
2554 # Synthesize an EXTRA_DIST augmentation.
2555 all_files=`func_get_filelist $1`
2556 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2557 extra_files="$tests_files"
2558 if test -n "$extra_files"; then
2559 echo "EXTRA_DIST +=" $extra_files
2560 echo
2564 # Synthesize an EXTRA_DIST augmentation.
2565 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2566 already_mentioned_files=` \
2567 { if ! $modcache; then
2568 func_lookup_file "modules/$1"
2569 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2570 else
2571 func_cache_lookup_module "$1"
2572 if $have_associative; then
2573 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2574 eval 'echo "${modcache_makefile[$1]}"'
2576 else
2577 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2578 if test -n "$field_set"; then
2579 eval 'field_value="$'"${cachevar}"'_makefile"'
2580 echo "${field_value}"
2585 | combine_lines \
2586 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2587 all_files=`func_get_filelist $1`
2588 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2589 # Remove $already_mentioned_files from $lib_files.
2590 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2591 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2592 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2593 if test -n "$extra_files"; then
2594 echo "EXTRA_DIST +=" $extra_files
2595 echo
2597 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2598 # This is necessary so that automake can generate the right list of
2599 # dependency rules.
2600 # A possible approach would be to use autom4te --trace of the redefined
2601 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2602 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2603 # inside autoconf's built-in macros are not missed).
2604 # But it's simpler and more robust to do it here, based on the file list.
2605 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2606 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2607 # automake will generate a useless dependency; this is harmless.
2608 case "$1" in
2609 relocatable-prog-wrapper) ;;
2610 pt_chown) ;;
2612 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2613 if test -n "$extra_files"; then
2614 echo "EXTRA_lib_SOURCES +=" $extra_files
2615 echo
2618 esac
2619 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2620 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2621 if test -n "$buildaux_files"; then
2622 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2623 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2624 echo
2627 esac
2630 # func_get_automake_snippet module
2631 # Input:
2632 # - local_gnulib_path from --local-dir
2633 # - modcache true or false, from --cache-modules/--no-cache-modules
2634 func_get_automake_snippet ()
2636 func_get_automake_snippet_conditional "$1"
2637 func_get_automake_snippet_unconditional "$1"
2640 # func_get_include_directive module
2641 # Input:
2642 # - local_gnulib_path from --local-dir
2643 # - modcache true or false, from --cache-modules/--no-cache-modules
2644 func_get_include_directive ()
2647 if ! $modcache; then
2648 func_lookup_file "modules/$1"
2649 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2650 else
2651 func_cache_lookup_module "$1"
2652 # Output the field's value, including the final newline (if any).
2653 if $have_associative; then
2654 if eval 'test -n "${modcache_include[$1]+set}"'; then
2655 eval 'echo "${modcache_include[$1]}"'
2657 else
2658 eval "field_set=\"\$${cachevar}_include_set\""
2659 if test -n "$field_set"; then
2660 eval "field_value=\"\$${cachevar}_include\""
2661 echo "${field_value}"
2665 } | sed -e 's/^\(["<]\)/#include \1/'
2668 # func_get_link_directive module
2669 # Input:
2670 # - local_gnulib_path from --local-dir
2671 # - modcache true or false, from --cache-modules/--no-cache-modules
2672 func_get_link_directive ()
2674 if ! $modcache; then
2675 func_lookup_file "modules/$1"
2676 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2677 else
2678 func_cache_lookup_module "$1"
2679 # Output the field's value, including the final newline (if any).
2680 if $have_associative; then
2681 if eval 'test -n "${modcache_link[$1]+set}"'; then
2682 eval 'echo "${modcache_link[$1]}"'
2684 else
2685 eval "field_set=\"\$${cachevar}_link_set\""
2686 if test -n "$field_set"; then
2687 eval "field_value=\"\$${cachevar}_link\""
2688 echo "${field_value}"
2694 # func_get_license_raw module
2695 # Input:
2696 # - local_gnulib_path from --local-dir
2697 # - modcache true or false, from --cache-modules/--no-cache-modules
2698 func_get_license_raw ()
2700 if ! $modcache; then
2701 func_lookup_file "modules/$1"
2702 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2703 else
2704 func_cache_lookup_module "$1"
2705 # Output the field's value, including the final newline (if any).
2706 if $have_associative; then
2707 if eval 'test -n "${modcache_license[$1]+set}"'; then
2708 eval 'echo "${modcache_license[$1]}"'
2710 else
2711 eval "field_set=\"\$${cachevar}_license_set\""
2712 if test -n "$field_set"; then
2713 eval "field_value=\"\$${cachevar}_license\""
2714 echo "${field_value}"
2720 # func_get_license module
2721 # Input:
2722 # - local_gnulib_path from --local-dir
2723 # - modcache true or false, from --cache-modules/--no-cache-modules
2724 func_get_license ()
2726 # Warn if the License field is missing.
2727 case "$1" in
2728 *-tests ) ;;
2730 license=`func_get_license_raw "$1"`
2731 if test -z "$license"; then
2732 func_warning "module $1 lacks a License"
2735 esac
2736 case "$1" in
2737 parse-datetime* )
2738 # These modules are under a weaker license only for the purpose of some
2739 # users who hand-edit it and don't use gnulib-tool. For the regular
2740 # gnulib users they are under a stricter license.
2741 echo "GPL"
2745 func_get_license_raw "$1"
2746 # The default is GPL.
2747 echo "GPL"
2748 } | sed -e 's,^ *$,,' | sed -e 1q
2750 esac
2753 # func_get_maintainer module
2754 # Input:
2755 # - local_gnulib_path from --local-dir
2756 # - modcache true or false, from --cache-modules/--no-cache-modules
2757 func_get_maintainer ()
2759 if ! $modcache; then
2760 func_lookup_file "modules/$1"
2761 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2762 else
2763 func_cache_lookup_module "$1"
2764 # Output the field's value, including the final newline (if any).
2765 if $have_associative; then
2766 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2767 eval 'echo "${modcache_maintainer[$1]}"'
2769 else
2770 eval "field_set=\"\$${cachevar}_maintainer_set\""
2771 if test -n "$field_set"; then
2772 eval "field_value=\"\$${cachevar}_maintainer\""
2773 echo "${field_value}"
2779 # func_get_tests_module module
2780 # Input:
2781 # - local_gnulib_path from --local-dir
2782 func_get_tests_module ()
2784 # The naming convention for tests modules is hardwired: ${module}-tests.
2785 if test -f "$gnulib_dir/modules/$1"-tests \
2786 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1-tests"; then
2787 echo "$1"-tests
2791 # func_verify_tests_module
2792 # verifies a module name, considering only tests modules and modules with
2793 # applicability 'all'.
2794 # Input:
2795 # - local_gnulib_path from --local-dir
2796 # - modcache true or false, from --cache-modules/--no-cache-modules
2797 # - module module name argument
2798 func_verify_tests_module ()
2800 func_verify_module
2801 if test -n "$module"; then
2802 if test `func_get_applicability $module` = main; then
2803 module=
2808 # func_repeat_module_in_tests
2809 # tests whether, when the tests have their own configure.ac script, a given
2810 # module should be repeated in the tests, although it was already among the main
2811 # modules.
2812 # Input:
2813 # - module module name argument
2814 func_repeat_module_in_tests ()
2816 case "$module" in
2817 libtextstyle-optional)
2818 # This module is special because it relies on a gl_LIBTEXTSTYLE_OPTIONAL
2819 # invocation that it does not itself do or require. Therefore if the
2820 # tests contain such an invocation, the module - as part of tests -
2821 # will produce different AC_SUBSTed variable values than the same module
2822 # - as part of the main configure.ac -.
2823 echo true ;;
2825 echo false ;;
2826 esac
2829 # func_get_dependencies_recursively module
2830 # Input:
2831 # - local_gnulib_path from --local-dir
2832 # - modcache true or false, from --cache-modules/--no-cache-modules
2833 func_get_dependencies_recursively ()
2835 # In order to process every module only once (for speed), process an "input
2836 # list" of modules, producing an "output list" of modules. During each round,
2837 # more modules can be queued in the input list. Once a module on the input
2838 # list has been processed, it is added to the "handled list", so we can avoid
2839 # to process it again.
2840 handledmodules=
2841 inmodules="$1"
2842 outmodules=
2843 while test -n "$inmodules"; do
2844 inmodules_this_round="$inmodules"
2845 inmodules= # Accumulator, queue for next round
2846 for module in $inmodules_this_round; do
2847 func_verify_module
2848 if test -n "$module"; then
2849 func_append outmodules " $module"
2850 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2851 for dep in $deps; do
2852 func_append inmodules " $dep"
2853 done
2855 done
2856 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2857 # Remove $handledmodules from $inmodules.
2858 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2859 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2860 done
2861 rm -f "$tmp"/queued-modules
2862 for m in $outmodules; do echo $m; done | LC_ALL=C sort -u
2865 # func_get_link_directive_recursively module
2866 # Input:
2867 # - local_gnulib_path from --local-dir
2868 # - modcache true or false, from --cache-modules/--no-cache-modules
2869 func_get_link_directive_recursively ()
2871 # In order to process every module only once (for speed), process an "input
2872 # list" of modules, producing an "output list" of modules. During each round,
2873 # more modules can be queued in the input list. Once a module on the input
2874 # list has been processed, it is added to the "handled list", so we can avoid
2875 # to process it again.
2876 handledmodules=
2877 inmodules="$1"
2878 outmodules=
2879 while test -n "$inmodules"; do
2880 inmodules_this_round="$inmodules"
2881 inmodules= # Accumulator, queue for next round
2882 for module in $inmodules_this_round; do
2883 func_verify_module
2884 if test -n "$module"; then
2885 if grep '^Link:[ ]*$' "$lookedup_file" >/dev/null; then
2886 # The module description has a 'Link:' field. Ignore the dependencies.
2887 func_append outmodules " $module"
2888 else
2889 # The module description has no 'Link:' field. Recurse through the dependencies.
2890 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2891 for dep in $deps; do
2892 func_append inmodules " $dep"
2893 done
2896 done
2897 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2898 # Remove $handledmodules from $inmodules.
2899 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2900 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2901 done
2902 rm -f "$tmp"/queued-modules
2903 for m in $outmodules; do func_get_link_directive "$m"; done | LC_ALL=C sort -u | sed -e '/^$/d'
2906 # func_acceptable module
2907 # tests whether a module is acceptable.
2908 # Input:
2909 # - avoidlist list of modules to avoid
2910 func_acceptable ()
2912 for avoid in $avoidlist; do
2913 if test "$avoid" = "$1"; then
2914 return 1
2916 done
2917 return 0
2920 # sed expression to keep the first 32 characters of each line.
2921 sed_first_32_chars='s/^\(................................\).*/\1/'
2923 # func_module_shellfunc_name module
2924 # computes the shell function name that will contain the m4 macros for the module.
2925 # Input:
2926 # - macro_prefix prefix to use
2927 # Output:
2928 # - shellfunc shell function name
2929 func_module_shellfunc_name ()
2931 case $1 in
2932 *[!a-zA-Z0-9_]*)
2933 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2935 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2936 esac
2939 # func_module_shellvar_name module
2940 # computes the shell variable name the will be set to true once the m4 macros
2941 # for the module have been executed.
2942 # Output:
2943 # - shellvar shell variable name
2944 func_module_shellvar_name ()
2946 case $1 in
2947 *[!a-zA-Z0-9_]*)
2948 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2950 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2951 esac
2954 # func_module_conditional_name module
2955 # computes the automake conditional name for the module.
2956 # Output:
2957 # - conditional name of automake conditional
2958 func_module_conditional_name ()
2960 case $1 in
2961 *[!a-zA-Z0-9_]*)
2962 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2964 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2965 esac
2968 # func_uncond_add_module B
2969 # notes the presence of B as an unconditional module.
2971 # func_conddep_add_module A B cond
2972 # notes the presence of a conditional dependency from module A to module B,
2973 # subject to the condition that A is enabled and cond is true.
2975 # func_cond_module_p B
2976 # tests whether module B is conditional.
2978 # func_cond_module_condition A B
2979 # returns the condition when B should be enabled as a dependency of A, once the
2980 # m4 code for A has been executed.
2981 # Output: - condition
2983 if $have_associative; then
2984 declare -A conddep_isuncond
2985 declare -A conddep_dependers
2986 declare -A conddep_condition
2987 func_uncond_add_module ()
2989 eval 'conddep_isuncond[$1]=true'
2990 eval 'unset conddep_dependers[$1]'
2992 func_conddep_add_module ()
2994 eval 'isuncond="${conddep_isuncond[$2]}"'
2995 if test -z "$isuncond"; then
2996 # No unconditional dependency to B known at this point.
2997 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2998 eval 'conddep_condition[$1---$2]="$3"'
3001 func_cond_module_p ()
3003 eval 'previous_dependers="${conddep_dependers[$1]}"'
3004 test -n "$previous_dependers"
3006 func_cond_module_condition ()
3008 eval 'condition="${conddep_condition[$1---$2]}"'
3010 else
3011 func_uncond_add_module ()
3013 case $1 in
3014 *[!a-zA-Z0-9_]*)
3015 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
3017 suffix=$1 ;;
3018 esac
3019 eval 'conddep_isuncond_'"$suffix"'=true'
3020 eval 'unset conddep_dependers_'"$suffix"
3022 func_conddep_add_module ()
3024 case $2 in
3025 *[!a-zA-Z0-9_]*)
3026 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
3028 suffix=$2 ;;
3029 esac
3030 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
3031 if test -z "$isuncond"; then
3032 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
3033 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
3034 eval 'conddep_condition_'"$suffix"'="$3"'
3037 func_cond_module_p ()
3039 case $1 in
3040 *[!a-zA-Z0-9_]*)
3041 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
3043 suffix=$1 ;;
3044 esac
3045 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
3046 test -n "$previous_dependers"
3048 func_cond_module_condition ()
3050 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
3051 eval 'condition="${conddep_condition_'"$suffix"'}"'
3055 # func_modules_transitive_closure
3056 # Input:
3057 # - local_gnulib_path from --local-dir
3058 # - gnu_make true if --gnu-make was given, false otherwise
3059 # - modcache true or false, from --cache-modules/--no-cache-modules
3060 # - modules list of specified modules
3061 # - inctests true if tests should be included, false otherwise
3062 # - incobsolete true if obsolete modules among dependencies should be
3063 # included, blank otherwise
3064 # - inc_cxx_tests true if C++ interoperability tests should be included,
3065 # blank otherwise
3066 # - inc_longrunning_tests true if long-runnings tests should be included,
3067 # blank otherwise
3068 # - inc_privileged_tests true if tests that require root privileges should be
3069 # included, blank otherwise
3070 # - inc_unportable_tests true if tests that fail on some platforms should be
3071 # included, blank otherwise
3072 # - inc_all_direct_tests true if all kinds of problematic unit tests among
3073 # the unit tests of the specified modules should be
3074 # included, blank otherwise
3075 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
3076 # the unit tests of the dependencies should be
3077 # included, blank otherwise
3078 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
3079 # blank otherwise
3080 # - excl_longrunning_tests true if long-runnings tests should be excluded,
3081 # blank otherwise
3082 # - excl_privileged_tests true if tests that require root privileges should be
3083 # excluded, blank otherwise
3084 # - excl_unportable_tests true if tests that fail on some platforms should be
3085 # excluded, blank otherwise
3086 # - avoidlist list of modules to avoid
3087 # - cond_dependencies true if conditional dependencies shall be supported,
3088 # blank otherwise
3089 # - tmp pathname of a temporary directory
3090 # Output:
3091 # - modules list of modules, including dependencies
3092 # - conddep_dependers, conddep_condition information about conditionally
3093 # enabled modules
3094 func_modules_transitive_closure ()
3096 sed_escape_dependency='s|\([/.]\)|\\\1|g'
3097 # In order to process every module only once (for speed), process an "input
3098 # list" of modules, producing an "output list" of modules. During each round,
3099 # more modules can be queued in the input list. Once a module on the input
3100 # list has been processed, it is added to the "handled list", so we can avoid
3101 # to process it again.
3102 handledmodules=
3103 inmodules="$modules"
3104 outmodules=
3105 fmtc_inc_all_tests="$inc_all_direct_tests"
3106 if test "$cond_dependencies" = true; then
3107 for module in $inmodules; do
3108 func_verify_module
3109 if test -n "$module"; then
3110 if func_acceptable $module; then
3111 func_uncond_add_module $module
3114 done
3116 while test -n "$inmodules"; do
3117 inmodules_this_round="$inmodules"
3118 inmodules= # Accumulator, queue for next round
3119 for module in $inmodules_this_round; do
3120 func_verify_module
3121 if test -n "$module"; then
3122 if func_acceptable $module; then
3123 func_append outmodules " $module"
3124 if test "$cond_dependencies" = true; then
3125 if func_cond_module_p $module; then
3126 conditional=true
3127 else
3128 conditional=false
3131 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3132 # Duplicate dependencies are harmless, but Jim wants a warning.
3133 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
3134 if test -n "$duplicated_deps"; then
3135 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
3137 if $inctests; then
3138 testsmodule=`func_get_tests_module $module`
3139 if test -n "$testsmodule"; then
3140 deps="$deps $testsmodule"
3143 for dep in $deps; do
3144 # Determine whether to include the dependency or tests module.
3145 inc=true
3146 for word in `func_get_status $dep`; do
3147 case "$word" in
3148 obsolete)
3149 test -n "$incobsolete" \
3150 || inc=false
3152 c++-test)
3153 test -z "$excl_cxx_tests" \
3154 || inc=false
3155 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
3156 || inc=false
3158 longrunning-test)
3159 test -z "$excl_longrunning_tests" \
3160 || inc=false
3161 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
3162 || inc=false
3164 privileged-test)
3165 test -z "$excl_privileged_tests" \
3166 || inc=false
3167 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
3168 || inc=false
3170 unportable-test)
3171 test -z "$excl_unportable_tests" \
3172 || inc=false
3173 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
3174 || inc=false
3176 *-test)
3177 test -n "$fmtc_inc_all_tests" \
3178 || inc=false
3180 esac
3181 done
3182 if $inc && func_acceptable "$dep"; then
3183 func_append inmodules " $dep"
3184 if test "$cond_dependencies" = true; then
3185 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
3186 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
3187 s/^.*$/true/p
3189 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*] *$/{
3190 s/^ *'"$escaped_dep"' *\[\(.*\)] *$/\1/p
3192 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
3193 if test "$condition" = true; then
3194 condition=
3196 if test -n "$condition"; then
3197 func_conddep_add_module "$module" "$dep" "$condition"
3198 else
3199 if $conditional; then
3200 func_conddep_add_module "$module" "$dep" true
3201 else
3202 func_uncond_add_module "$dep"
3207 done
3210 done
3211 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
3212 # Remove $handledmodules from $inmodules.
3213 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
3214 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
3215 fmtc_inc_all_tests="$inc_all_indirect_tests"
3216 done
3217 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
3218 rm -f "$tmp"/queued-modules
3221 # func_show_module_list
3222 # Input:
3223 # - specified_modules list of specified modules (one per line, sorted)
3224 # - modules complete list of modules (one per line, sorted)
3225 # - tmp pathname of a temporary directory
3226 func_show_module_list ()
3228 if case "$TERM" in
3229 xterm*) test -t 1;;
3230 *) false;;
3231 esac; then
3232 # Assume xterm compatible escape sequences.
3233 bold_on=`printf '\033[1m'`
3234 bold_off=`printf '\033[0m'`
3235 else
3236 bold_on=
3237 bold_off=
3239 echo "Module list with included dependencies (indented):"
3240 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
3241 echo "$modules" | sed -e '/^$/d' \
3242 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
3243 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
3246 # func_modules_transitive_closure_separately
3247 # Determine main module list and tests-related module list separately.
3248 # The main module list is the transitive closure of the specified modules,
3249 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3250 # is specified, it will consist only of LGPLed source.
3251 # The tests-related module list is the transitive closure of the specified
3252 # modules, including tests modules, minus the main module list excluding
3253 # modules of applicability 'all'. Its lib/* sources (brought in through
3254 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3255 # source, even if --lgpl is specified.
3256 # Input:
3257 # - local_gnulib_path from --local-dir
3258 # - modcache true or false, from --cache-modules/--no-cache-modules
3259 # - specified_modules list of specified modules
3260 # - inctests true if tests should be included, false otherwise
3261 # - incobsolete true if obsolete modules among dependencies should be
3262 # included, blank otherwise
3263 # - inc_cxx_tests true if C++ interoperability tests should be included,
3264 # blank otherwise
3265 # - inc_longrunning_tests true if long-runnings tests should be included,
3266 # blank otherwise
3267 # - inc_privileged_tests true if tests that require root privileges should be
3268 # included, blank otherwise
3269 # - inc_unportable_tests true if tests that fail on some platforms should be
3270 # included, blank otherwise
3271 # - inc_all_direct_tests true if all kinds of problematic unit tests among
3272 # the unit tests of the specified modules should be
3273 # included, blank otherwise
3274 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
3275 # the unit tests of the dependencies should be
3276 # included, blank otherwise
3277 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
3278 # blank otherwise
3279 # - excl_longrunning_tests true if long-runnings tests should be excluded,
3280 # blank otherwise
3281 # - excl_privileged_tests true if tests that require root privileges should be
3282 # excluded, blank otherwise
3283 # - excl_unportable_tests true if tests that fail on some platforms should be
3284 # excluded, blank otherwise
3285 # - avoidlist list of modules to avoid
3286 # - cond_dependencies true if conditional dependencies shall be supported,
3287 # blank otherwise
3288 # - tmp pathname of a temporary directory
3289 # Output:
3290 # - main_modules list of modules, including dependencies
3291 # - testsrelated_modules list of tests-related modules, including dependencies
3292 # - conddep_dependers, conddep_condition information about conditionally
3293 # enabled modules
3294 func_modules_transitive_closure_separately ()
3296 # Determine main module list.
3297 saved_inctests="$inctests"
3298 inctests=false
3299 modules="$specified_modules"
3300 func_modules_transitive_closure
3301 main_modules="$modules"
3302 inctests="$saved_inctests"
3303 if test $verbose -ge 1; then
3304 echo "Main module list:"
3305 echo "$main_modules" | sed -e 's/^/ /'
3307 # Determine tests-related module list.
3308 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3309 testsrelated_modules=`for module in $main_modules; do
3310 if test \`func_get_applicability $module\` = main; then
3311 echo $module
3313 done \
3314 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3315 # If testsrelated_modules consists only of modules with applicability 'all',
3316 # set it to empty (because such modules are only helper modules for other modules).
3317 have_nontrivial_testsrelated_modules=
3318 for module in $testsrelated_modules; do
3319 if test `func_get_applicability $module` != all; then
3320 have_nontrivial_testsrelated_modules=yes
3321 break
3323 done
3324 if test -z "$have_nontrivial_testsrelated_modules"; then
3325 testsrelated_modules=
3327 if test $verbose -ge 1; then
3328 echo "Tests-related module list:"
3329 echo "$testsrelated_modules" | sed -e 's/^/ /'
3333 # func_determine_use_libtests
3334 # Determines whether a $testsbase/libtests.a is needed.
3335 # Input:
3336 # - local_gnulib_path from --local-dir
3337 # - modcache true or false, from --cache-modules/--no-cache-modules
3338 # - testsrelated_modules list of tests-related modules, including dependencies
3339 # Output:
3340 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3341 func_determine_use_libtests ()
3343 use_libtests=false
3344 for module in $testsrelated_modules; do
3345 func_verify_nontests_module
3346 if test -n "$module"; then
3347 all_files=`func_get_filelist $module`
3348 # Test whether some file in $all_files lies in lib/.
3349 for f in $all_files; do
3350 case $f in
3351 lib/*)
3352 use_libtests=true
3353 break 2
3355 esac
3356 done
3358 done
3361 # func_remove_if_blocks
3362 # removes if...endif blocks from an automake snippet.
3363 func_remove_if_blocks ()
3365 sed -n -e '/^if / {
3368 s/^endif//
3376 # func_modules_add_dummy
3377 # Input:
3378 # - local_gnulib_path from --local-dir
3379 # - modcache true or false, from --cache-modules/--no-cache-modules
3380 # - modules list of modules, including dependencies
3381 # Output:
3382 # - modules list of modules, including 'dummy' if needed
3383 func_modules_add_dummy ()
3385 # Determine whether any module provides a lib_SOURCES augmentation.
3386 have_lib_SOURCES=
3387 for module in $modules; do
3388 func_verify_nontests_module
3389 if test -n "$module"; then
3390 if test "$cond_dependencies" = true && func_cond_module_p $module; then
3391 # Ignore conditional modules, since they are not guaranteed to
3392 # contribute to lib_SOURCES.
3394 else
3395 # Extract the value of unconditional "lib_SOURCES += ..." augmentations.
3396 for file in `func_get_automake_snippet "$module" | combine_lines |
3397 func_remove_if_blocks |
3398 sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
3399 # Ignore .h files since they are not compiled.
3400 case "$file" in
3401 *.h) ;;
3403 have_lib_SOURCES=yes
3404 break 2
3406 esac
3407 done
3410 done
3411 # Add the dummy module, to make sure the library will be non-empty.
3412 if test -z "$have_lib_SOURCES"; then
3413 if func_acceptable "dummy"; then
3414 func_append modules " dummy"
3419 # func_modules_add_dummy_separately
3420 # Input:
3421 # - local_gnulib_path from --local-dir
3422 # - modcache true or false, from --cache-modules/--no-cache-modules
3423 # - main_modules list of modules, including dependencies
3424 # - testsrelated_modules list of tests-related modules, including dependencies
3425 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3426 # Output:
3427 # - main_modules list of modules, including 'dummy' if needed
3428 # - testsrelated_modules list of tests-related modules, including 'dummy' if
3429 # needed
3430 func_modules_add_dummy_separately ()
3432 # Add the dummy module to the main module list if needed.
3433 modules="$main_modules"
3434 func_modules_add_dummy
3435 main_modules="$modules"
3437 # Add the dummy module to the tests-related module list if needed.
3438 if $use_libtests; then
3439 modules="$testsrelated_modules"
3440 func_modules_add_dummy
3441 testsrelated_modules="$modules"
3445 # func_modules_notice
3446 # Input:
3447 # - local_gnulib_path from --local-dir
3448 # - modcache true or false, from --cache-modules/--no-cache-modules
3449 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3450 # - modules list of modules, including dependencies
3451 func_modules_notice ()
3453 if test $verbose -ge -1; then
3454 for module in $modules; do
3455 func_verify_module
3456 if test -n "$module"; then
3457 msg=`func_get_notice $module`
3458 if test -n "$msg"; then
3459 echo "Notice from module $module:"
3460 echo "$msg" | sed -e 's/^/ /'
3463 done
3467 # func_modules_to_filelist
3468 # Input:
3469 # - local_gnulib_path from --local-dir
3470 # - modcache true or false, from --cache-modules/--no-cache-modules
3471 # - modules list of modules, including dependencies
3472 # Output:
3473 # - files list of files
3474 func_modules_to_filelist ()
3476 files=
3477 for module in $modules; do
3478 func_verify_module
3479 if test -n "$module"; then
3480 fs=`func_get_filelist $module`
3481 func_append files " $fs"
3483 done
3484 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3487 # func_modules_to_filelist_separately
3488 # Determine the final file lists.
3489 # They must be computed separately, because files in lib/* go into
3490 # $sourcebase/ if they are in the main file list but into $testsbase/
3491 # if they are in the tests-related file list. Furthermore lib/dummy.c
3492 # can be in both.
3493 # Input:
3494 # - local_gnulib_path from --local-dir
3495 # - modcache true or false, from --cache-modules/--no-cache-modules
3496 # - main_modules list of modules, including dependencies
3497 # - testsrelated_modules list of tests-related modules, including dependencies
3498 func_modules_to_filelist_separately ()
3500 # Determine final main file list.
3501 modules="$main_modules"
3502 func_modules_to_filelist
3503 main_files="$files"
3504 # Determine final tests-related file list.
3505 modules="$testsrelated_modules"
3506 func_modules_to_filelist
3507 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3508 # Merge both file lists.
3509 sed_remove_empty_lines='/^$/d'
3510 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3511 if test $verbose -ge 0; then
3512 echo "File list:"
3513 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3514 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3518 # func_compute_include_guard_prefix
3519 # Determine include_guard_prefix and module_indicator_prefix.
3520 # Input:
3521 # - macro_prefix prefix of gl_LIBOBJS macros to use
3522 # Output:
3523 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3524 # - sed_replace_include_guard_prefix
3525 # sed expression for resolving ${gl_include_guard_prefix}
3526 # - module_indicator_prefix prefix of GNULIB_<modulename> variables to use
3527 func_compute_include_guard_prefix ()
3529 if test "$macro_prefix" = gl; then
3530 include_guard_prefix='GL'
3531 else
3532 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3534 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3535 module_indicator_prefix="${include_guard_prefix}"
3538 # func_execute_command command [args...]
3539 # Executes a command.
3540 # Uses also the variables
3541 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3542 func_execute_command ()
3544 if test $verbose -ge 0; then
3545 echo "executing $*"
3546 "$@"
3547 else
3548 # Commands like automake produce output to stderr even when they succeed.
3549 # Turn this output off if the command succeeds.
3550 "$@" > "$tmp"/cmdout 2>&1
3551 cmdret=$?
3552 if test $cmdret = 0; then
3553 rm -f "$tmp"/cmdout
3554 else
3555 echo "executing $*"
3556 cat "$tmp"/cmdout 1>&2
3557 rm -f "$tmp"/cmdout
3558 (exit $cmdret)
3563 # func_dest_tmpfilename file
3564 # determines the name of a temporary file (file is relative to destdir).
3565 # Input:
3566 # - destdir target directory
3567 # - doit : if actions shall be executed, false if only to be printed
3568 # - tmp pathname of a temporary directory
3569 # Sets variable:
3570 # - tmpfile absolute filename of the temporary file
3571 func_dest_tmpfilename ()
3573 if $doit; then
3574 # Put the new contents of $file in a file in the same directory (needed
3575 # to guarantee that an 'mv' to "$destdir/$file" works).
3576 tmpfile="$destdir/$1.tmp"
3577 else
3578 # Put the new contents of $file in a file in a temporary directory
3579 # (because the directory of "$file" might not exist).
3580 tmpfile="$tmp"/`basename "$1"`.tmp
3584 # func_is_local_file lookedup_file file
3585 # check whether file should be instantiated from local gnulib directory
3586 func_is_local_file ()
3588 dname=$1
3589 func_remove_suffix dname "/$2"
3590 func_path_foreach "$local_gnulib_path" test %dir% = "$dname"
3593 # func_should_link
3594 # determines whether the file $f should be copied, symlinked, or hardlinked.
3595 # Input:
3596 # - copymode copy mode for files in general
3597 # - lcopymode copy mode for files from local_gnulib_path
3598 # - f the original file name
3599 # - lookedup_file name of the merged (combined) file
3600 # Sets variable:
3601 # - copyaction copy or symlink or hardlink
3602 func_should_link ()
3604 if test -n "$lcopymode" && func_is_local_file "$lookedup_file" "$f"; then
3605 copyaction="$lcopymode"
3606 else
3607 if test -n "$copymode"; then
3608 copyaction="$copymode"
3609 else
3610 copyaction=copy
3615 # func_add_file
3616 # copies a file from gnulib into the destination directory. The destination
3617 # is known to not exist.
3618 # Input:
3619 # - destdir target directory
3620 # - local_gnulib_path from --local-dir
3621 # - modcache true or false, from --cache-modules/--no-cache-modules
3622 # - f the original file name
3623 # - lookedup_file name of the merged (combined) file
3624 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3625 # - g the rewritten file name
3626 # - tmpfile absolute filename of the temporary file
3627 # - doit : if actions shall be executed, false if only to be printed
3628 # - copymode copy mode for files in general
3629 # - lcopymode copy mode for files from local_gnulib_path
3630 func_add_file ()
3632 if $doit; then
3633 echo "Copying file $g"
3634 func_should_link
3635 if test "$copyaction" = symlink \
3636 && test -z "$lookedup_tmp" \
3637 && cmp -s "$lookedup_file" "$tmpfile"; then
3638 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3639 else
3640 if test "$copyaction" = hardlink \
3641 && test -z "$lookedup_tmp" \
3642 && cmp -s "$lookedup_file" "$tmpfile"; then
3643 func_hardlink "$lookedup_file" "$destdir/$g"
3644 else
3645 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3648 else
3649 echo "Copy file $g"
3653 # func_update_file
3654 # copies a file from gnulib into the destination directory. The destination
3655 # is known to exist.
3656 # Input:
3657 # - destdir target directory
3658 # - local_gnulib_path from --local-dir
3659 # - modcache true or false, from --cache-modules/--no-cache-modules
3660 # - f the original file name
3661 # - lookedup_file name of the merged (combined) file
3662 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3663 # - g the rewritten file name
3664 # - tmpfile absolute filename of the temporary file
3665 # - doit : if actions shall be executed, false if only to be printed
3666 # - copymode copy mode for files in general
3667 # - lcopymode copy mode for files from local_gnulib_path
3668 # - already_present nonempty if the file should already exist, empty otherwise
3669 func_update_file ()
3671 if cmp -s "$destdir/$g" "$tmpfile"; then
3672 : # The file has not changed.
3673 else
3674 # Replace the file.
3675 if $doit; then
3676 if test -n "$already_present"; then
3677 echo "Updating file $g (backup in ${g}~)"
3678 else
3679 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3681 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3682 func_should_link
3683 if test "$copyaction" = symlink \
3684 && test -z "$lookedup_tmp" \
3685 && cmp -s "$lookedup_file" "$tmpfile"; then
3686 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3687 else
3688 if test "$copyaction" = hardlink \
3689 && test -z "$lookedup_tmp" \
3690 && cmp -s "$lookedup_file" "$tmpfile"; then
3691 func_hardlink "$lookedup_file" "$destdir/$g"
3692 else
3693 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3696 else
3697 if test -n "$already_present"; then
3698 echo "Update file $g (backup in ${g}~)"
3699 else
3700 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3706 # func_emit_lib_Makefile_am
3707 # emits the contents of library makefile to standard output.
3708 # Input:
3709 # - local_gnulib_path from --local-dir
3710 # - modcache true or false, from --cache-modules/--no-cache-modules
3711 # - modules list of modules, including dependencies
3712 # - libname library name
3713 # - pobase directory relative to destdir where to place *.po files
3714 # - auxdir directory relative to destdir where to place build aux files
3715 # - gnu_make true if --gnu-make was given, false otherwise
3716 # - makefile_name from --makefile-name
3717 # - automake_subdir true if --automake-subdir was given, false otherwise
3718 # - libtool true if libtool will be used, false or blank otherwise
3719 # - macro_prefix prefix of gl_LIBOBJS macros to use
3720 # - module_indicator_prefix prefix of GNULIB_<modulename> variables to use
3721 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3722 # - witness_c_macro from --witness-c-macro
3723 # - actioncmd (optional) command that will reproduce this invocation
3724 # - for_test true if creating a package for testing, false otherwise
3725 # - sed_replace_include_guard_prefix
3726 # sed expression for resolving ${gl_include_guard_prefix}
3727 # - destfile filename relative to destdir of makefile being generated
3728 # Input/Output:
3729 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
3730 # list of edits to be done to Makefile.am variables
3731 # Output:
3732 # - uses_subdirs nonempty if object files in subdirs exist
3733 func_emit_lib_Makefile_am ()
3735 # When using GNU make, or when creating an includable Makefile.am snippet,
3736 # augment variables with += instead of assigning them.
3737 if $gnu_make || test -n "$makefile_name"; then
3738 assign='+='
3739 else
3740 assign='='
3742 if test "$libtool" = true; then
3743 libext=la
3744 perhapsLT=LT
3745 sed_eliminate_LDFLAGS="$sed_noop"
3746 else
3747 libext=a
3748 perhapsLT=
3749 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3751 # Replace NMD, so as to remove redundant "$(MKDIR_P) '.'" invocations.
3752 # The logic is similar to how we define gl_source_base_prefix.
3753 if $automake_subdir; then
3754 sed_eliminate_NMD='s/@NMD@//;/@!NMD@/d'
3755 else
3756 sed_eliminate_NMD='/@NMD@/d;s/@!NMD@//'
3758 if $for_test; then
3759 # When creating a package for testing: Attempt to provoke failures,
3760 # especially link errors, already during "make" rather than during
3761 # "make check", because "make check" is not possible in a cross-compiling
3762 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3763 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3764 else
3765 sed_transform_check_PROGRAMS="$sed_noop"
3767 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3768 if ! $gnu_make; then
3769 echo "## Process this file with automake to produce Makefile.in."
3771 func_emit_copyright_notice
3772 if test -n "$actioncmd"; then
3773 printf '# Reproduce by:\n%s\n' "$actioncmd"
3775 echo
3776 uses_subdirs=
3778 for module in $modules; do
3779 func_verify_nontests_module
3780 if test -n "$module"; then
3782 func_get_automake_snippet_conditional "$module" |
3783 LC_ALL=C \
3784 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3785 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3786 -e "$sed_eliminate_LDFLAGS" \
3787 -e "$sed_eliminate_NMD" \
3788 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3789 -e 's,\$(GNULIB_,$('"${module_indicator_prefix}"'_GNULIB_,' \
3790 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3791 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3792 -e "$sed_transform_check_PROGRAMS" \
3793 -e "$sed_replace_include_guard_prefix"
3794 if test "$module" = 'alloca'; then
3795 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3796 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3798 } | combine_lines "${libname}_${libext}_SOURCES" > "$tmp"/amsnippet1
3800 func_get_automake_snippet_unconditional "$module" |
3801 LC_ALL=C \
3802 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3803 -e 's,\$(GNULIB_,$('"${module_indicator_prefix}"'_GNULIB_,'
3804 } > "$tmp"/amsnippet2
3805 # Skip the contents if it's entirely empty.
3806 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3807 echo "## begin gnulib module $module"
3808 if $gnu_make; then
3809 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
3810 convert_to_gnu_make_1='s/^if \(.*\)/ifneq (,$(\1_CONDITION))/'
3811 convert_to_gnu_make_2='s|%reldir%/||g'
3812 convert_to_gnu_make_3='s|%reldir%|.|g'
3814 echo
3815 if test "$cond_dependencies" = true; then
3816 if func_cond_module_p "$module"; then
3817 func_module_conditional_name "$module"
3818 if $gnu_make; then
3819 echo "ifneq (,\$(${conditional}_CONDITION))"
3820 else
3821 echo "if $conditional"
3825 if $gnu_make; then
3826 sed -e "$convert_to_gnu_make_1" \
3827 -e "$convert_to_gnu_make_2" \
3828 -e "$convert_to_gnu_make_3" \
3829 "$tmp"/amsnippet1
3830 else
3831 cat "$tmp"/amsnippet1
3833 if test "$cond_dependencies" = true; then
3834 if func_cond_module_p "$module"; then
3835 echo "endif"
3838 if $gnu_make; then
3839 sed -e "$convert_to_gnu_make_1" \
3840 -e "$convert_to_gnu_make_2" \
3841 -e "$convert_to_gnu_make_3" \
3842 "$tmp"/amsnippet2
3843 else
3844 cat "$tmp"/amsnippet2
3846 if $gnu_make; then
3847 echo "endif"
3849 echo "## end gnulib module $module"
3850 echo
3852 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3853 # Test whether there are some source files in subdirectories.
3854 for f in `func_get_filelist "$module"`; do
3855 case $f in
3856 lib/*/*.c)
3857 uses_subdirs=yes
3858 break
3860 esac
3861 done
3863 done
3864 } > "$tmp"/allsnippets
3865 if test -z "$makefile_name"; then
3866 # If there are source files in subdirectories, prevent collision of the
3867 # object files (example: hash.c and libxml/hash.c).
3868 subdir_options=
3869 if test -n "$uses_subdirs"; then
3870 subdir_options=' subdir-objects'
3872 echo "AUTOMAKE_OPTIONS = 1.14 gnits${subdir_options}"
3874 echo
3875 if test -z "$makefile_name"; then
3876 echo "SUBDIRS ="
3877 echo "noinst_HEADERS ="
3878 echo "noinst_LIBRARIES ="
3879 echo "noinst_LTLIBRARIES ="
3880 # Automake versions < 1.11.4 create an empty pkgdatadir at
3881 # installation time if you specify pkgdata_DATA to empty.
3882 # See automake bugs #10997 and #11030:
3883 # * https://debbugs.gnu.org/10997
3884 # * https://debbugs.gnu.org/11030
3885 # So we need this workaround.
3886 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3887 echo "pkgdata_DATA ="
3889 echo "EXTRA_DIST ="
3890 echo "BUILT_SOURCES ="
3891 echo "SUFFIXES ="
3893 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3894 if test -z "$makefile_name"; then
3895 echo "MOSTLYCLEANDIRS ="
3896 echo "CLEANFILES ="
3897 echo "DISTCLEANFILES ="
3898 echo "MAINTAINERCLEANFILES ="
3900 if $gnu_make; then
3901 echo "# Start of GNU Make output."
3903 # Put autoconf output into a temporary file, so that its exit status
3904 # can be checked from the shell. Signal any error by putting a
3905 # syntax error into the output makefile.
3906 ${AUTOCONF} -t 'AC_SUBST:$1 = @$1@' "$configure_ac" \
3907 >"$tmp"/makeout 2>"$tmp"/makeout2 &&
3908 LC_ALL=C sort -u "$tmp"/makeout || {
3909 echo "== gnulib-tool GNU Make output failed as follows =="
3910 sed 's/^/# stderr: /' "$tmp"/makeout2
3912 rm -f "$tmp"/makeout "$tmp"/makeout2
3914 echo "# End of GNU Make output."
3915 else
3916 echo "# No GNU Make output."
3918 # Execute edits that apply to the Makefile.am being generated.
3919 edit=0
3920 while test $edit != $makefile_am_edits; do
3921 edit=`expr $edit + 1`
3922 eval dir=\"\$makefile_am_edit${edit}_dir\"
3923 eval var=\"\$makefile_am_edit${edit}_var\"
3924 eval val=\"\$makefile_am_edit${edit}_val\"
3925 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
3926 if test -n "$var"; then
3927 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3928 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
3929 # The added subdirectory ${val} needs to be mentioned after '.'.
3930 # Since we don't have '.' among SUBDIRS so far, add it now.
3931 val=". ${val}"
3933 echo "${var} += ${val}"
3934 eval "makefile_am_edit${edit}_var="
3937 done
3938 if test -n "$witness_c_macro"; then
3939 cppflags_part1=" -D$witness_c_macro=1"
3940 else
3941 cppflags_part1=
3943 if $for_test; then
3944 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3945 else
3946 cppflags_part2=
3948 if test -z "$makefile_name"; then
3949 echo
3950 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3951 echo "AM_CFLAGS ="
3952 else
3953 if test -n "$cppflags_part1$cppflags_part2"; then
3954 echo
3955 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3958 echo
3959 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3960 || { test -n "$makefile_name" \
3961 && test -f "$sourcebase/Makefile.am" \
3962 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3963 }; then
3964 # One of the snippets or the user's Makefile.am already specifies an
3965 # installation location for the library. Don't confuse automake by saying
3966 # it should not be installed.
3968 else
3969 # By default, the generated library should not be installed.
3970 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3972 echo
3973 echo "${libname}_${libext}_SOURCES ="
3974 if ! $for_test; then
3975 echo "${libname}_${libext}_CFLAGS = \$(AM_CFLAGS) \$(GL_CFLAG_GNULIB_WARNINGS)"
3977 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3978 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3979 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3980 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3981 echo "EXTRA_${libname}_${libext}_SOURCES ="
3982 if test "$libtool" = true; then
3983 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3984 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3985 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3986 # the link dependencies of all modules.
3987 for module in $modules; do
3988 func_verify_nontests_module
3989 if test -n "$module"; then
3990 func_get_link_directive "$module"
3992 done \
3993 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3994 | LC_ALL=C sort -u \
3995 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3997 echo
3998 if test -n "$pobase"; then
3999 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
4000 echo
4002 cat "$tmp"/allsnippets \
4003 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
4004 echo
4005 echo "mostlyclean-local: mostlyclean-generic"
4006 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
4007 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
4008 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
4009 echo " fi; \\"
4010 echo " done; \\"
4011 echo " :"
4012 # Emit rules to erase .Po and .Plo files for AC_LIBOBJ invocations.
4013 # Extend the 'distclean' rule.
4014 echo "distclean-local: distclean-gnulib-libobjs"
4015 echo "distclean-gnulib-libobjs:"
4016 echo " -rm -f @${macro_prefix}_LIBOBJDEPS@"
4017 # Extend the 'maintainer-clean' rule.
4018 echo "maintainer-clean-local: distclean-gnulib-libobjs"
4019 rm -f "$tmp"/allsnippets
4022 # func_emit_po_Makevars
4023 # emits the contents of po/ makefile parameterization to standard output.
4024 # Input:
4025 # - local_gnulib_path from --local-dir
4026 # - modcache true or false, from --cache-modules/--no-cache-modules
4027 # - sourcebase directory relative to destdir where to place source code
4028 # - pobase directory relative to destdir where to place *.po files
4029 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4030 func_emit_po_Makevars ()
4032 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
4033 func_emit_copyright_notice
4034 echo
4035 echo "# Usually the message domain is the same as the package name."
4036 echo "# But here it has a '-gnulib' suffix."
4037 echo "DOMAIN = ${po_domain}-gnulib"
4038 echo
4039 echo "# These two variables depend on the location of this directory."
4040 echo "subdir = ${pobase}"
4041 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
4042 echo
4043 cat <<\EOF
4044 # These options get passed to xgettext.
4045 XGETTEXT_OPTIONS = \
4046 --keyword=_ --flag=_:1:pass-c-format \
4047 --keyword=N_ --flag=N_:1:pass-c-format \
4048 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
4049 --keyword='proper_name_lite:1,"This is a proper name. See the gettext manual, section Names."' \
4050 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
4051 --flag=error:3:c-format --flag=error_at_line:5:c-format
4053 # This is the copyright holder that gets inserted into the header of the
4054 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
4055 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
4057 # This is the email address or URL to which the translators shall report
4058 # bugs in the untranslated strings:
4059 # - Strings which are not entire sentences, see the maintainer guidelines
4060 # in the GNU gettext documentation, section 'Preparing Strings'.
4061 # - Strings which use unclear terms or require additional context to be
4062 # understood.
4063 # - Strings which make invalid assumptions about notation of date, time or
4064 # money.
4065 # - Pluralisation problems.
4066 # - Incorrect English spelling.
4067 # - Incorrect formatting.
4068 # It can be your email address, or a mailing list address where translators
4069 # can write to without being subscribed, or the URL of a web page through
4070 # which the translators can contact you.
4071 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
4073 # This is the list of locale categories, beyond LC_MESSAGES, for which the
4074 # message catalogs shall be used. It is usually empty.
4075 EXTRA_LOCALE_CATEGORIES =
4077 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
4078 # context. Possible values are "yes" and "no". Set this to yes if the
4079 # package uses functions taking also a message context, like pgettext(), or
4080 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
4081 USE_MSGCTXT = no
4085 # func_emit_po_POTFILES_in
4086 # emits the file list to be passed to xgettext to standard output.
4087 # Input:
4088 # - local_gnulib_path from --local-dir
4089 # - modcache true or false, from --cache-modules/--no-cache-modules
4090 # - sourcebase directory relative to destdir where to place source code
4091 # - files list of new files
4092 func_emit_po_POTFILES_in ()
4094 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
4095 func_emit_copyright_notice
4096 echo
4097 echo "# List of files which contain translatable strings."
4098 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
4101 # func_emit_tests_Makefile_am witness_macro
4102 # emits the contents of tests makefile to standard output.
4103 # Input:
4104 # - local_gnulib_path from --local-dir
4105 # - modcache true or false, from --cache-modules/--no-cache-modules
4106 # - modules list of modules, including dependencies
4107 # - libname library name
4108 # - auxdir directory relative to destdir where to place build aux files
4109 # - gnu_make true if --gnu-make was given, false otherwise
4110 # - makefile_name from --makefile-name
4111 # - tests_makefile_name from --tests-makefile-name
4112 # - libtool true if libtool will be used, false or blank otherwise
4113 # - sourcebase relative directory containing lib source code
4114 # - m4base relative directory containing autoconf macros
4115 # - testsbase relative directory containing unit test code
4116 # - macro_prefix prefix of gl_LIBOBJS macros to use
4117 # - module_indicator_prefix prefix of GNULIB_<modulename> variables to use
4118 # - witness_c_macro from --witness-c-macro
4119 # - for_test true if creating a package for testing, false otherwise
4120 # - single_configure true if a single configure file should be generated,
4121 # false for a separate configure file for the tests
4122 # - use_libtests true if a libtests.a should be built, false otherwise
4123 # - sed_replace_include_guard_prefix
4124 # sed expression for resolving ${gl_include_guard_prefix}
4125 # - destfile filename relative to destdir of makefile being generated
4126 # Input/Output:
4127 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
4128 # list of edits to be done to Makefile.am variables
4129 # Output:
4130 # - uses_subdirs nonempty if object files in subdirs exist
4131 func_emit_tests_Makefile_am ()
4133 witness_macro="$1"
4134 if test "$libtool" = true; then
4135 libext=la
4136 perhapsLT=LT
4137 sed_eliminate_LDFLAGS="$sed_noop"
4138 else
4139 libext=a
4140 perhapsLT=
4141 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
4143 # Replace NMD, so as to remove redundant "$(MKDIR_P) '.'" invocations.
4144 # The logic is similar to how we define gl_source_base_prefix.
4145 sed_eliminate_NMD='/@NMD@/d;s/@!NMD@//'
4146 if $for_test; then
4147 # When creating a package for testing: Attempt to provoke failures,
4148 # especially link errors, already during "make" rather than during
4149 # "make check", because "make check" is not possible in a cross-compiling
4150 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
4151 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
4152 else
4153 sed_transform_check_PROGRAMS="$sed_noop"
4155 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
4156 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
4157 echo "## Process this file with automake to produce Makefile.in."
4158 func_emit_copyright_notice
4159 echo
4160 uses_subdirs=
4162 for module in $modules; do
4163 if $for_test && ! $single_configure; then
4164 if `func_repeat_module_in_tests`; then
4165 func_verify_module
4166 else
4167 func_verify_tests_module
4169 else
4170 func_verify_module
4172 if test -n "$module"; then
4174 func_get_automake_snippet_conditional "$module" |
4175 LC_ALL=C \
4176 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
4177 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
4178 -e "$sed_eliminate_LDFLAGS" \
4179 -e "$sed_eliminate_NMD" \
4180 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
4181 -e 's,\$(GNULIB_,$('"${module_indicator_prefix}"'_GNULIB_,' \
4182 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
4183 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
4184 -e "$sed_transform_check_PROGRAMS" \
4185 -e "$sed_replace_include_guard_prefix"
4186 if $use_libtests && test "$module" = 'alloca'; then
4187 echo "libtests_a_LIBADD += @ALLOCA@"
4188 echo "libtests_a_DEPENDENCIES += @ALLOCA@"
4190 } | combine_lines "libtests_a_SOURCES" > "$tmp"/amsnippet1
4192 func_get_automake_snippet_unconditional "$module" |
4193 LC_ALL=C \
4194 sed -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
4195 -e 's,\$(GNULIB_,$('"${module_indicator_prefix}"'_GNULIB_,'
4196 } > "$tmp"/amsnippet2
4197 # Skip the contents if it's entirely empty.
4198 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
4199 # Mention long-running tests at the end.
4200 ofd=3
4201 for word in `func_get_status "$module"`; do
4202 if test "$word" = 'longrunning-test'; then
4203 ofd=4
4204 break
4206 done
4207 { echo "## begin gnulib module $module"
4208 if $gnu_make; then
4209 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
4210 convert_to_gnu_make_1='s/^if \(.*\)/ifneq (,$(\1_CONDITION))/'
4211 convert_to_gnu_make_2='s|%reldir%/||g'
4212 convert_to_gnu_make_3='s|%reldir%|.|g'
4214 echo
4215 if test "$cond_dependencies" = true; then
4216 if func_cond_module_p "$module"; then
4217 func_module_conditional_name "$module"
4218 if $gnu_make; then
4219 echo "ifneq (,\$(${conditional}_CONDITION))"
4220 else
4221 echo "if $conditional"
4225 if $gnu_make; then
4226 sed -e "$convert_to_gnu_make_1" \
4227 -e "$convert_to_gnu_make_2" \
4228 -e "$convert_to_gnu_make_3" \
4229 "$tmp"/amsnippet1
4230 else
4231 cat "$tmp"/amsnippet1
4233 if test "$cond_dependencies" = true; then
4234 if func_cond_module_p "$module"; then
4235 echo "endif"
4238 if $gnu_make; then
4239 sed -e "$convert_to_gnu_make_1" \
4240 -e "$convert_to_gnu_make_2" \
4241 -e "$convert_to_gnu_make_3" \
4242 "$tmp"/amsnippet2
4243 else
4244 cat "$tmp"/amsnippet2
4246 if $gnu_make; then
4247 echo "endif"
4249 echo "## end gnulib module $module"
4250 echo
4251 } >&$ofd
4253 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
4254 # Test whether there are some source files in subdirectories.
4255 for f in `func_get_filelist "$module"`; do
4256 case $f in
4257 lib/*/*.c | tests/*/*.c)
4258 uses_subdirs=yes
4259 break
4261 esac
4262 done
4264 done
4265 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
4266 # Generate dependencies here, since it eases the debugging of test failures.
4267 # If there are source files in subdirectories, prevent collision of the
4268 # object files (example: hash.c and libxml/hash.c).
4269 subdir_options=
4270 if test -n "$uses_subdirs"; then
4271 subdir_options=' subdir-objects'
4273 echo "AUTOMAKE_OPTIONS = 1.14 foreign${subdir_options}"
4274 echo
4275 if $for_test && ! $single_configure; then
4276 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
4277 echo
4279 # Nothing is being added to SUBDIRS; nevertheless the existence of this
4280 # variable is needed to avoid an error from automake:
4281 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
4282 echo "SUBDIRS = ."
4283 echo "TESTS ="
4284 echo "XFAIL_TESTS ="
4285 echo "TESTS_ENVIRONMENT ="
4286 echo "noinst_PROGRAMS ="
4287 if ! $for_test; then
4288 echo "check_PROGRAMS ="
4290 echo "EXTRA_PROGRAMS ="
4291 echo "noinst_HEADERS ="
4292 echo "noinst_LIBRARIES ="
4293 if $use_libtests; then
4294 if $for_test; then
4295 echo "noinst_LIBRARIES += libtests.a"
4296 else
4297 echo "check_LIBRARIES = libtests.a"
4300 # Automake versions < 1.11.4 create an empty pkgdatadir at
4301 # installation time if you specify pkgdata_DATA to empty.
4302 # See automake bugs #10997 and #11030:
4303 # * https://debbugs.gnu.org/10997
4304 # * https://debbugs.gnu.org/11030
4305 # So we need this workaround.
4306 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
4307 echo "pkgdata_DATA ="
4309 echo "EXTRA_DIST ="
4310 echo "BUILT_SOURCES ="
4311 echo "SUFFIXES ="
4312 echo "MOSTLYCLEANFILES = core *.stackdump"
4313 echo "MOSTLYCLEANDIRS ="
4314 echo "CLEANFILES ="
4315 echo "DISTCLEANFILES ="
4316 echo "MAINTAINERCLEANFILES ="
4317 # Execute edits that apply to the Makefile.am being generated.
4318 edit=0
4319 while test $edit != $makefile_am_edits; do
4320 edit=`expr $edit + 1`
4321 eval dir=\"\$makefile_am_edit${edit}_dir\"
4322 eval var=\"\$makefile_am_edit${edit}_var\"
4323 eval val=\"\$makefile_am_edit${edit}_val\"
4324 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
4325 if test -n "$var"; then
4326 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
4327 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
4328 # The added subdirectory ${val} needs to be mentioned after '.'.
4329 # But we have '.' among SUBDIRS already, so do nothing.
4332 echo "${var} += ${val}"
4333 eval "makefile_am_edit${edit}_var="
4336 done
4337 echo
4338 # Insert a '-Wno-error' option in the compilation commands emitted by
4339 # Automake, between $(AM_CPPFLAGS) and before the reference to @CFLAGS@.
4340 # Why?
4341 # 1) Because parts of the Gnulib tests exercise corner cases (invalid
4342 # arguments, endless recursions, etc.) that a compiler may warn about,
4343 # even with just the normal '-Wall' option.
4344 # 2) Because every package maintainer has their preferred set of warnings
4345 # that they may want to enforce in the main source code of their package.
4346 # But Gnulib tests are maintained in Gnulib and don't end up in binaries
4347 # that that package installs; therefore it does not make sense for
4348 # package maintainers to enforce the absence of warnings on these tests.
4349 # Why before @CFLAGS@?
4350 # - Because "the user is always right": If a user adds '-Werror' to their
4351 # CFLAGS, they have asked for errors, they will get errors. But they have
4352 # no right to complain about these errors, because Gnulib does not support
4353 # '-Werror'.
4354 cflags_for_gnulib_code=
4355 if ! $for_test; then
4356 # Enable or disable warnings as suitable for the Gnulib coding style.
4357 cflags_for_gnulib_code=" \$(GL_CFLAG_GNULIB_WARNINGS)"
4359 echo "CFLAGS = @GL_CFLAG_ALLOW_WARNINGS@${cflags_for_gnulib_code} @CFLAGS@"
4360 echo "CXXFLAGS = @GL_CXXFLAG_ALLOW_WARNINGS@ @CXXFLAGS@"
4361 echo
4362 echo "AM_CPPFLAGS = \\"
4363 if $for_test; then
4364 echo " -DGNULIB_STRICT_CHECKING=1 \\"
4366 if test -n "$witness_c_macro"; then
4367 echo " -D$witness_c_macro=1 \\"
4369 if test -n "${witness_macro}"; then
4370 echo " -D@${witness_macro}@=1 \\"
4372 echo " -I. -I\$(srcdir) \\"
4373 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
4374 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
4375 echo
4376 if $use_libtests; then
4377 # All test programs need to be linked with libtests.a.
4378 # It needs to be passed to the linker before ${libname}.${libext}, since
4379 # the tests-related modules depend on the main modules.
4380 # It also needs to be passed to the linker after ${libname}.${libext}
4381 # because the latter might contain incomplete modules (such as the
4382 # 'version-etc' module whose dependency to 'version-etc-fsf' is voluntarily
4383 # omitted).
4384 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
4385 # not matter.
4386 echo "LDADD = libtests.a ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext} libtests.a ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext} libtests.a \$(LIBTESTS_LIBDEPS)"
4387 else
4388 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
4390 echo
4391 if $use_libtests; then
4392 echo "libtests_a_SOURCES ="
4393 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
4394 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
4395 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
4396 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
4397 echo "EXTRA_libtests_a_SOURCES ="
4398 # The circular dependency in LDADD requires this.
4399 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
4400 echo
4402 # Many test scripts use ${EXEEXT} or ${srcdir}.
4403 # EXEEXT is defined by AC_PROG_CC through autoconf.
4404 # srcdir is defined by autoconf and automake.
4405 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
4406 echo
4407 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
4408 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
4409 # Arrange to print a message before compiling the files in this directory.
4410 echo "all: all-notice"
4411 echo "all-notice:"
4412 echo " @echo '## ---------------------------------------------------- ##'"
4413 echo " @echo '## ------------------- Gnulib tests ------------------- ##'"
4414 echo " @echo '## You can ignore compiler warnings in this directory. ##'"
4415 echo " @echo '## ---------------------------------------------------- ##'"
4416 echo
4417 # Arrange to print a message before executing the tests in this directory.
4418 echo "check-am: check-notice"
4419 echo "check-notice:"
4420 echo " @echo '## ---------------------------------------------------------------------- ##'"
4421 echo " @echo '## ---------------------------- Gnulib tests ---------------------------- ##'"
4422 echo " @echo '## Please report test failures in this directory to <bug-gnulib@gnu.org>. ##'"
4423 echo " @echo '## ---------------------------------------------------------------------- ##'"
4424 echo
4425 echo "# Clean up after Solaris cc."
4426 echo "clean-local:"
4427 echo " rm -rf SunWS_cache"
4428 echo
4429 echo "mostlyclean-local: mostlyclean-generic"
4430 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
4431 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
4432 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
4433 echo " fi; \\"
4434 echo " done; \\"
4435 echo " :"
4436 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
4439 # func_emit_initmacro_start macro_prefix gentests
4440 # emits the first few statements of the gl_INIT macro to standard output.
4441 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4442 # - gentests true if a tests Makefile.am is being generated,
4443 # false otherwise
4444 # - module_indicator_prefix prefix of GNULIB_<modulename> variables to use
4445 func_emit_initmacro_start ()
4447 macro_prefix_arg="$1"
4448 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
4449 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
4450 # LIBOBJS. The purpose is to allow several gnulib instantiations under
4451 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
4452 # flexibility.)
4453 # Furthermore it avoids an automake error like this when a Makefile.am
4454 # that uses pieces of gnulib also uses $(LIBOBJ):
4455 # automatically discovered file `error.c' should not be explicitly mentioned
4456 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
4457 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
4458 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
4459 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
4460 # automatically discovered file `error.c' should not be explicitly mentioned
4461 # We let automake know about the files to be distributed through the
4462 # EXTRA_lib_SOURCES variable.
4463 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
4464 # Create data variables for checking the presence of files that are mentioned
4465 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
4466 # because we want the check to happen when the configure file is created,
4467 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
4468 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
4469 # in which to expect them.
4470 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
4471 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
4472 # Scope for m4 macros.
4473 echo " m4_pushdef([GL_MACRO_PREFIX], [${macro_prefix_arg}])"
4474 # Scope the GNULIB_<modulename> variables.
4475 echo " m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [${module_indicator_prefix}])"
4476 echo " gl_COMMON"
4477 if "$2"; then
4478 echo " AC_REQUIRE([gl_CC_ALLOW_WARNINGS])"
4479 echo " AC_REQUIRE([gl_CXX_ALLOW_WARNINGS])"
4483 # func_emit_initmacro_end macro_prefix gentests
4484 # emits the last few statements of the gl_INIT macro to standard output.
4485 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4486 # - gentests true if a tests Makefile.am is being generated,
4487 # false otherwise
4488 # - automake_subdir true if --automake-subdir was given, false otherwise
4489 # - libtool true if --libtool was given, false if --no-libtool was
4490 # given, blank otherwise
4491 func_emit_initmacro_end ()
4493 macro_prefix_arg="$1"
4494 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
4495 # The check is performed only when autoconf is run from the directory where
4496 # the configure.ac resides; if it is run from a different directory, the
4497 # check is skipped.
4498 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
4499 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
4500 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
4501 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
4502 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
4503 echo " exit 1"
4504 echo " fi"
4505 echo " done])dnl"
4506 echo " m4_if(m4_sysval, [0], [],"
4507 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
4508 echo " ])"
4509 echo " m4_popdef([GL_MODULE_INDICATOR_PREFIX])"
4510 echo " m4_popdef([GL_MACRO_PREFIX])"
4511 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
4512 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
4513 echo " m4_popdef([AC_LIBSOURCES])"
4514 echo " m4_popdef([AC_REPLACE_FUNCS])"
4515 echo " m4_popdef([AC_LIBOBJ])"
4516 echo " AC_CONFIG_COMMANDS_PRE(["
4517 echo " ${macro_prefix_arg}_libobjs="
4518 echo " ${macro_prefix_arg}_ltlibobjs="
4519 echo " ${macro_prefix_arg}_libobjdeps="
4520 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
4521 echo " # Remove the extension."
4522 echo "changequote(,)dnl"
4523 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
4524 echo " sed_dirname1='s,//*,/,g'"
4525 echo " sed_dirname2='s,\\(.\\)/\$,\\1,'"
4526 echo " sed_dirname3='s,^[^/]*\$,.,'"
4527 echo " sed_dirname4='s,\\(.\\)/[^/]*\$,\\1,'"
4528 echo " sed_basename1='s,.*/,,'"
4529 echo "changequote([, ])dnl"
4530 if $automake_subdir && ! "$2" && test -n "$sourcebase" && test "$sourcebase" != '.'; then
4531 subdir="$sourcebase/"
4532 elif $automake_subdir_tests && "$2" && test -n "$testsbase" && test "$testsbase" != '.'; then
4533 subdir="$testsbase/"
4534 else
4535 subdir=
4537 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
4538 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs ${subdir}\$i.\$ac_objext\""
4539 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs ${subdir}\$i.lo\""
4540 echo " i_dir=\`echo \"\$i\" | sed -e \"\$sed_dirname1\" -e \"\$sed_dirname2\" -e \"\$sed_dirname3\" -e \"\$sed_dirname4\"\`"
4541 echo " i_base=\`echo \"\$i\" | sed -e \"\$sed_basename1\"\`"
4542 if test "$libtool" = true; then
4543 echo " ${macro_prefix_arg}_libobjdeps=\"\$${macro_prefix_arg}_libobjdeps ${subdir}\$i_dir/\\\$(DEPDIR)/\$i_base.Plo\""
4544 else
4545 echo " ${macro_prefix_arg}_libobjdeps=\"\$${macro_prefix_arg}_libobjdeps ${subdir}\$i_dir/\\\$(DEPDIR)/\$i_base.Po\""
4547 echo " done"
4548 echo " fi"
4549 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
4550 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
4551 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJDEPS], [\$${macro_prefix_arg}_libobjdeps])"
4552 echo " ])"
4555 # func_emit_initmacro_done macro_prefix sourcebase
4556 # emits a few statements after the gl_INIT macro to standard output.
4557 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4558 # - sourcebase directory relative to destdir where to place source code
4559 func_emit_initmacro_done ()
4561 macro_prefix_arg="$1"
4562 sourcebase_arg="$2"
4563 echo
4564 echo "# Like AC_LIBOBJ, except that the module name goes"
4565 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4566 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
4567 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
4568 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
4569 echo "])"
4570 echo
4571 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
4572 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4573 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
4574 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
4575 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
4576 echo "])"
4577 echo
4578 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
4579 echo "# expected is derived from the gnulib-tool parameterization,"
4580 echo "# and alloca is special cased (for the alloca-opt module)."
4581 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
4582 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
4583 echo " m4_foreach([_gl_NAME], [\$1], ["
4584 echo " m4_if(_gl_NAME, [alloca.c], [], ["
4585 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
4586 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
4587 echo " ])"
4588 echo " ])"
4589 echo "])"
4592 # func_emit_shellvars_init gentests base
4593 # emits some shell variable assignments to standard output.
4594 # - gentests true if a tests Makefile.am is being generated,
4595 # false otherwise
4596 # - base base directory, relative to the top-level directory
4597 # - automake_subdir true if --automake-subdir was given, false otherwise
4598 # - automake_subdir_tests true if --automake-subdir-tests was given, false otherwise
4599 func_emit_shellvars_init ()
4601 # Define the base directory, relative to the top-level directory.
4602 echo " gl_source_base='$2'"
4603 # Define the prefix for the file name of generated files.
4604 if $1 && $automake_subdir_tests; then
4605 # When tests share the same Makefile as the whole project, they
4606 # share the same base prefix.
4607 if test "$2" = "$testsbase"; then
4608 echo " gl_source_base_prefix='\$(top_build_prefix)$sourcebase/'"
4609 else
4610 echo " gl_source_base_prefix='\$(top_build_prefix)$2/'"
4612 elif ! $1 && $automake_subdir; then
4613 echo " gl_source_base_prefix='\$(top_build_prefix)$2/'"
4614 else
4615 echo " gl_source_base_prefix="
4619 # func_emit_autoconf_snippet indentation
4620 # emits the autoconf snippet of a module.
4621 # Input:
4622 # - indentation spaces to prepend on each line
4623 # - local_gnulib_path from --local-dir
4624 # - modcache true or false, from --cache-modules/--no-cache-modules
4625 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4626 # - sed_replace_include_guard_prefix
4627 # sed expression for resolving ${gl_include_guard_prefix}
4628 # - module the module name
4629 # - toplevel true or false. 'false' means a subordinate use of
4630 # gnulib-tool.
4631 # - disable_libtool true or false. It tells whether to disable libtool
4632 # handling even if it has been specified through the
4633 # command line options.
4634 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4635 # invocations.
4636 func_emit_autoconf_snippet ()
4638 indentation="$1"
4639 if { case $module in
4640 gnumakefile | maintainer-makefile)
4641 # These modules are meant to be used only in the top-level directory.
4642 $toplevel ;;
4644 true ;;
4645 esac
4646 }; then
4647 func_get_autoconf_snippet "$module" \
4648 | sed -e '/^$/d;' -e "s/^/$indentation/" \
4649 -e "$sed_replace_build_aux" \
4650 -e "$sed_replace_include_guard_prefix" \
4651 | { if $disable_libtool; then
4652 sed -e 's/\$gl_cond_libtool/false/g' \
4653 -e 's/gl_libdeps/gltests_libdeps/g' \
4654 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4655 else
4659 | { if $disable_gettext; then
4660 sed -e 's/AM_GNU_GETTEXT(\[external])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
4661 else
4662 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
4663 # autopoint through at least GNU gettext version 0.18.2.
4664 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
4667 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
4668 echo 'changequote(,)dnl'
4669 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4670 echo 'changequote([, ])dnl'
4671 echo 'AC_SUBST([LTALLOCA])'
4676 # func_emit_autoconf_snippets modules referenceable_modules verifier toplevel disable_libtool disable_gettext
4677 # collects and emit the autoconf snippets of a set of modules.
4678 # Input:
4679 # - local_gnulib_path from --local-dir
4680 # - modcache true or false, from --cache-modules/--no-cache-modules
4681 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4682 # - sed_replace_include_guard_prefix
4683 # sed expression for resolving ${gl_include_guard_prefix}
4684 # - modules the list of modules.
4685 # - referenceable_modules the list of modules which may be referenced as dependencies.
4686 # - verifier one of func_verify_module, func_verify_nontests_module,
4687 # func_verify_tests_module. It selects the subset of
4688 # $modules to consider.
4689 # - toplevel true or false. 'false' means a subordinate use of
4690 # gnulib-tool.
4691 # - disable_libtool true or false. It tells whether to disable libtool
4692 # handling even if it has been specified through the
4693 # command line options.
4694 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4695 # invocations.
4696 func_emit_autoconf_snippets ()
4698 referenceable_modules="$2"
4699 verifier="$3"
4700 toplevel="$4"
4701 disable_libtool="$5"
4702 disable_gettext="$6"
4703 if test "$cond_dependencies" = true; then
4704 for m in $referenceable_modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
4705 # Emit the autoconf code for the unconditional modules.
4706 for module in $1; do
4707 eval $verifier
4708 if test -n "$module"; then
4709 if func_cond_module_p "$module"; then
4711 else
4712 func_emit_autoconf_snippet " "
4715 done
4716 # Initialize the shell variables indicating that the modules are enabled.
4717 for module in $1; do
4718 eval $verifier
4719 if test -n "$module"; then
4720 if func_cond_module_p "$module"; then
4721 func_module_shellvar_name "$module"
4722 echo " $shellvar=false"
4725 done
4726 # Emit the autoconf code for the conditional modules, each in a separate
4727 # function. This makes it possible to support cycles among conditional
4728 # modules.
4729 for module in $1; do
4730 eval $verifier
4731 if test -n "$module"; then
4732 if func_cond_module_p "$module"; then
4733 func_module_shellfunc_name "$module"
4734 func_module_shellvar_name "$module"
4735 echo " $shellfunc ()"
4736 echo ' {'
4737 echo " if \$$shellvar; then :; else"
4738 func_emit_autoconf_snippet " "
4739 echo " $shellvar=true"
4740 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4741 # Intersect $deps with the modules list $1.
4742 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4743 for dep in $deps; do
4744 if func_cond_module_p "$dep"; then
4745 func_module_shellfunc_name "$dep"
4746 func_cond_module_condition "$module" "$dep"
4747 if test "$condition" != true; then
4748 echo " if $condition; then"
4749 echo " $shellfunc"
4750 echo ' fi'
4751 else
4752 echo " $shellfunc"
4754 else
4755 # The autoconf code for $dep has already been emitted above and
4756 # therefore is already executed when this function is run.
4759 done
4760 echo ' fi'
4761 echo ' }'
4764 done
4765 # Emit the dependencies from the unconditional to the conditional modules.
4766 for module in $1; do
4767 eval $verifier
4768 if test -n "$module"; then
4769 if func_cond_module_p "$module"; then
4771 else
4772 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4773 # Intersect $deps with the modules list $1.
4774 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4775 for dep in $deps; do
4776 if func_cond_module_p "$dep"; then
4777 func_module_shellfunc_name "$dep"
4778 func_cond_module_condition "$module" "$dep"
4779 if test "$condition" != true; then
4780 echo " if $condition; then"
4781 echo " $shellfunc"
4782 echo ' fi'
4783 else
4784 echo " $shellfunc"
4786 else
4787 # The autoconf code for $dep has already been emitted above and
4788 # therefore is already executed when this code is run.
4791 done
4794 done
4795 # Define the Automake conditionals.
4796 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4797 for module in $1; do
4798 eval $verifier
4799 if test -n "$module"; then
4800 if func_cond_module_p "$module"; then
4801 func_module_conditional_name "$module"
4802 func_module_shellvar_name "$module"
4803 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4806 done
4807 else
4808 # Ignore the conditions, and enable all modules unconditionally.
4809 for module in $1; do
4810 eval $verifier
4811 if test -n "$module"; then
4812 func_emit_autoconf_snippet " "
4814 done
4818 # func_emit_pre_early_macros require indentation modules
4819 # The require parameter can be ':' (AC_REQUIRE) or 'false' (direct call).
4820 func_emit_pre_early_macros ()
4822 echo
4823 echo "${2}# Pre-early section."
4824 if $1; then
4825 _pre_early_snippet="echo \"${2}AC_REQUIRE([\$_pre_early_macro])\""
4826 else
4827 _pre_early_snippet="echo \"${2}\$_pre_early_macro\""
4830 # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB. Doing
4831 # AC_REQUIRE in configure-ac.early is not early enough.
4832 _pre_early_macro="gl_USE_SYSTEM_EXTENSIONS"
4833 case "${nl}${3}${nl}" in
4834 *${nl}extensions${nl}*) eval "$_pre_early_snippet" ;;
4835 esac
4837 _pre_early_macro="gl_PROG_AR_RANLIB"
4838 eval "$_pre_early_snippet"
4839 echo
4842 # func_reconstruct_cached_dir
4843 # callback for func_reconstruct_cached_local_gnulib_path
4844 # Input:
4845 # - destdir from --dir
4846 # Output:
4847 # - local_gnulib_path restored '--local-dir' path from cache
4848 func_reconstruct_cached_dir ()
4850 cached_dir=$1
4851 if test -n "$cached_dir"; then
4852 case "$cached_dir" in
4854 func_path_append local_gnulib_path "$cached_dir" ;;
4856 case "$destdir" in
4858 # XXX This doesn't look right.
4859 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4861 func_relconcat "$destdir" "$cached_dir"
4862 func_path_append local_gnulib_path "$relconcat" ;;
4863 esac ;;
4864 esac
4868 # func_reconstruct_cached_local_gnulib_path
4869 # reconstruct local_gnulib_path from cached_local_gnulib_path to be set
4870 # relatively to $destdir again.
4871 # Input:
4872 # - cached_local_gnulib_path local_gnulib_path stored within gnulib-cache.m4
4873 # - destdir from --dir
4874 # Output:
4875 # - local_gnulib_path restored '--local-dir' path from cache
4876 func_reconstruct_cached_local_gnulib_path ()
4878 func_path_foreach "$cached_local_gnulib_path" func_reconstruct_cached_dir %dir%
4881 # func_import modules
4882 # Uses also the variables
4883 # - mode import or add-import or remove-import or update
4884 # - destdir target directory
4885 # - local_gnulib_path from --local-dir
4886 # - modcache true or false, from --cache-modules/--no-cache-modules
4887 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4888 # - libname library name
4889 # - supplied_libname true if --lib was given, blank otherwise
4890 # - sourcebase directory relative to destdir where to place source code
4891 # - m4base directory relative to destdir where to place *.m4 macros
4892 # - pobase directory relative to destdir where to place *.po files
4893 # - docbase directory relative to destdir where to place doc files
4894 # - testsbase directory relative to destdir where to place unit test code
4895 # - auxdir directory relative to destdir where to place build aux files
4896 # - inctests true if --with-tests was given, false otherwise
4897 # - incobsolete true if --with-obsolete was given, blank otherwise
4898 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4899 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4900 # otherwise
4901 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4902 # otherwise
4903 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4904 # otherwise
4905 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4906 # - avoidlist list of modules to avoid, from --avoid
4907 # - cond_dependencies true if --conditional-dependencies was given, false if
4908 # --no-conditional-dependencies was given, blank otherwise
4909 # - lgpl yes or a number if library's license shall be LGPL,
4910 # blank otherwise
4911 # - makefile_name from --makefile-name
4912 # - tests_makefile_name from --tests-makefile-name
4913 # - libtool true if --libtool was given, false if --no-libtool was
4914 # given, blank otherwise
4915 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4916 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4917 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4918 # - witness_c_macro from --witness-c-macro
4919 # - vc_files true if --vc-files was given, false if --no-vc-files was
4920 # given, blank otherwise
4921 # - autoconf_minversion minimum supported autoconf version
4922 # - doit : if actions shall be executed, false if only to be printed
4923 # - copymode copy mode for files in general
4924 # - lcopymode copy mode for files from local_gnulib_path
4925 func_import ()
4927 # Get the cached settings.
4928 # In 'import' mode, we read them only for the purpose of knowing the old
4929 # installed file list, and don't use them as defaults.
4930 cached_local_gnulib_path=
4931 cached_specified_modules=
4932 cached_incobsolete=
4933 cached_inc_cxx_tests=
4934 cached_inc_longrunning_tests=
4935 cached_inc_privileged_tests=
4936 cached_inc_unportable_tests=
4937 cached_inc_all_tests=
4938 cached_avoidlist=
4939 cached_sourcebase=
4940 cached_m4base=
4941 cached_pobase=
4942 cached_docbase=
4943 cached_testsbase=
4944 cached_inctests=
4945 cached_libname=
4946 cached_lgpl=
4947 cached_makefile_name=
4948 cached_tests_makefile_name=
4949 cached_automake_subdir=
4950 cached_cond_dependencies=
4951 cached_libtool=
4952 cached_macro_prefix=
4953 cached_po_domain=
4954 cached_witness_c_macro=
4955 cached_vc_files=
4956 cached_files=
4957 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4958 cached_libtool=false
4959 my_sed_traces='
4960 s,#.*$,,
4961 s,^dnl .*$,,
4962 s, dnl .*$,,
4963 /gl_LOCAL_DIR(/ {
4964 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_path="\1",p
4966 /gl_MODULES(/ {
4969 s/)/)/
4974 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4976 /gl_WITH_OBSOLETE/ {
4977 s,^.*$,cached_incobsolete=true,p
4979 /gl_WITH_CXX_TESTS/ {
4980 s,^.*$,cached_inc_cxx_tests=true,p
4982 /gl_WITH_LONGRUNNING_TESTS/ {
4983 s,^.*$,cached_inc_longrunning_tests=true,p
4985 /gl_WITH_PRIVILEGED_TESTS/ {
4986 s,^.*$,cached_inc_privileged_tests=true,p
4988 /gl_WITH_UNPORTABLE_TESTS/ {
4989 s,^.*$,cached_inc_unportable_tests=true,p
4991 /gl_WITH_ALL_TESTS/ {
4992 s,^.*$,cached_inc_all_tests=true,p
4994 /gl_AVOID(/ {
4995 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4997 /gl_SOURCE_BASE(/ {
4998 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
5000 /gl_M4_BASE(/ {
5001 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
5003 /gl_PO_BASE(/ {
5004 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
5006 /gl_DOC_BASE(/ {
5007 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
5009 /gl_TESTS_BASE(/ {
5010 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
5012 /gl_WITH_TESTS/ {
5013 s,^.*$,cached_inctests=true,p
5015 /gl_LIB(/ {
5016 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
5018 /gl_LGPL(/ {
5019 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
5021 /gl_LGPL/ {
5022 s,^.*$,cached_lgpl=yes,p
5024 /gl_MAKEFILE_NAME(/ {
5025 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
5027 /gl_TESTS_MAKEFILE_NAME(/ {
5028 s,^.*gl_TESTS_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_tests_makefile_name="\1",p
5030 /gl_AUTOMAKE_SUBDIR/ {
5031 s,^.*$,cached_automake_subdir=true,p
5033 /gl_CONDITIONAL_DEPENDENCIES/ {
5034 s,^.*$,cached_cond_dependencies=true,p
5036 /gl_LIBTOOL/ {
5037 s,^.*$,cached_libtool=true,p
5039 /gl_MACRO_PREFIX(/ {
5040 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
5042 /gl_PO_DOMAIN(/ {
5043 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
5045 /gl_WITNESS_C_MACRO(/ {
5046 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
5048 /gl_VC_FILES(/ {
5049 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
5051 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
5052 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5053 my_sed_traces='
5054 s,#.*$,,
5055 s,^dnl .*$,,
5056 s, dnl .*$,,
5057 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST], \[/ {
5058 s,^.*$,cached_files=",p
5062 s,^]).*$,",
5064 s,["$`\\],,g
5071 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
5075 if test "$mode" = import; then
5076 # In 'import' mode, the new set of specified modules overrides the cached
5077 # set of modules. Ignore the cached settings.
5078 specified_modules="$1"
5079 else
5080 # Merge the cached settings with the specified ones.
5081 # The m4base must be the same as expected from the pathname.
5082 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
5083 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
5085 # The local_gnulib_path defaults to the cached one. Recall that the cached one
5086 # is relative to $destdir, whereas the one we use is relative to . or absolute.
5087 if test -z "$local_gnulib_path"; then
5088 func_reconstruct_cached_local_gnulib_path
5090 case $mode in
5091 add-import)
5092 # Append the cached and the specified module names. So that
5093 # "gnulib-tool --add-import foo" means to add the module foo.
5094 specified_modules="$cached_specified_modules $1"
5096 remove-import)
5097 # Take the cached module names, minus the specified module names.
5098 specified_modules=
5099 if $have_associative; then
5100 # Use an associative array, for O(N) worst-case run time.
5101 declare -A to_remove
5102 for m in $1; do
5103 eval 'to_remove[$m]=yes'
5104 done
5105 for module in $cached_specified_modules; do
5106 if eval 'test -z "${to_remove[$module]}"'; then
5107 func_append specified_modules "$module "
5109 done
5110 else
5111 # This loop has O(N**2) worst-case run time.
5112 for module in $cached_specified_modules; do
5113 to_remove=
5114 for m in $1; do
5115 if test "$m" = "$module"; then
5116 to_remove=yes
5117 break
5119 done
5120 if test -z "$to_remove"; then
5121 func_append specified_modules "$module "
5123 done
5126 update)
5127 # Take the cached module names. There are no specified module names.
5128 specified_modules="$cached_specified_modules"
5130 esac
5131 # Included obsolete modules among the dependencies if specified either way.
5132 if test -z "$incobsolete"; then
5133 incobsolete="$cached_incobsolete"
5135 # Included special kinds of tests modules among the dependencies if specified
5136 # either way.
5137 if test -z "$inc_cxx_tests"; then
5138 inc_cxx_tests="$cached_inc_cxx_tests"
5140 if test -z "$inc_longrunning_tests"; then
5141 inc_longrunning_tests="$cached_inc_longrunning_tests"
5143 if test -z "$inc_privileged_tests"; then
5144 inc_privileged_tests="$cached_inc_privileged_tests"
5146 if test -z "$inc_unportable_tests"; then
5147 inc_unportable_tests="$cached_inc_unportable_tests"
5149 if test -z "$inc_all_tests"; then
5150 inc_all_tests="$cached_inc_all_tests"
5152 # Append the cached and the specified avoidlist. This is probably better
5153 # than dropping the cached one when --avoid is specified at least once.
5154 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
5155 avoidlist=`echo $avoidlist`
5157 # The sourcebase defaults to the cached one.
5158 if test -z "$sourcebase"; then
5159 sourcebase="$cached_sourcebase"
5160 if test -z "$sourcebase"; then
5161 func_fatal_error "missing --source-base option"
5164 # The pobase defaults to the cached one.
5165 if test -z "$pobase"; then
5166 pobase="$cached_pobase"
5168 # The docbase defaults to the cached one.
5169 if test -z "$docbase"; then
5170 docbase="$cached_docbase"
5171 if test -z "$docbase"; then
5172 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."
5175 # The testsbase defaults to the cached one.
5176 if test -z "$testsbase"; then
5177 testsbase="$cached_testsbase"
5178 if test -z "$testsbase"; then
5179 func_fatal_error "missing --tests-base option"
5182 # Require the tests if specified either way.
5183 if ! $inctests; then
5184 inctests="$cached_inctests"
5185 if test -z "$inctests"; then
5186 inctests=false
5189 # The libname defaults to the cached one.
5190 if test -z "$supplied_libname"; then
5191 libname="$cached_libname"
5192 if test -z "$libname"; then
5193 func_fatal_error "missing --lib option"
5196 # Require LGPL if specified either way.
5197 if test -z "$lgpl"; then
5198 lgpl="$cached_lgpl"
5200 # The makefile_name defaults to the cached one.
5201 if test -z "$makefile_name"; then
5202 makefile_name="$cached_makefile_name"
5204 # The tests_makefile_name defaults to the cached one.
5205 if test -z "$tests_makefile_name"; then
5206 tests_makefile_name="$cached_tests_makefile_name"
5208 # Use automake-subdir mode if specified either way.
5209 if ! $automake_subdir; then
5210 automake_subdir="$cached_automake_subdir"
5211 if test -z "$automake_subdir"; then
5212 automake_subdir=false
5215 # Use conditional dependencies if specified either way.
5216 if test -z "$cond_dependencies"; then
5217 cond_dependencies="$cached_cond_dependencies"
5219 # Use libtool if specified either way, or if guessed.
5220 if test -z "$libtool"; then
5221 if test -n "$cached_m4base"; then
5222 libtool="$cached_libtool"
5223 else
5224 libtool="$guessed_libtool"
5227 # The macro_prefix defaults to the cached one.
5228 if test -z "$macro_prefix"; then
5229 macro_prefix="$cached_macro_prefix"
5230 if test -z "$macro_prefix"; then
5231 func_fatal_error "missing --macro-prefix option"
5234 # The po_domain defaults to the cached one.
5235 if test -z "$po_domain"; then
5236 po_domain="$cached_po_domain"
5238 # The witness_c_macro defaults to the cached one.
5239 if test -z "$witness_c_macro"; then
5240 witness_c_macro="$cached_witness_c_macro"
5242 # The vc_files defaults to the cached one.
5243 if test -z "$vc_files"; then
5244 vc_files="$cached_vc_files"
5246 # Ensure constraints.
5247 if test "$cond_dependencies" = true && $inctests; then
5248 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
5249 func_exit 1
5252 # --without-*-tests options are not supported here.
5253 excl_cxx_tests=
5254 excl_longrunning_tests=
5255 excl_privileged_tests=
5256 excl_unportable_tests=
5258 # Canonicalize the list of specified modules.
5259 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5261 # Include all kinds of tests modules if --with-all-tests was specified.
5262 inc_all_direct_tests="$inc_all_tests"
5263 inc_all_indirect_tests="$inc_all_tests"
5265 # Determine final module list.
5266 modules="$specified_modules"
5267 func_modules_transitive_closure
5268 if test $verbose -ge 0; then
5269 func_show_module_list
5271 final_modules="$modules"
5273 # Determine main module list and tests-related module list separately.
5274 func_modules_transitive_closure_separately
5276 # Determine whether a $testsbase/libtests.a is needed.
5277 func_determine_use_libtests
5279 # Add the dummy module to the main module list or to the tests-related module
5280 # list if needed.
5281 func_modules_add_dummy_separately
5283 # If --lgpl, verify that the licenses of modules are compatible.
5284 if test -n "$lgpl"; then
5285 license_incompatibilities=
5286 for module in $main_modules; do
5287 license=`func_get_license $module`
5288 case $license in
5289 'GPLv2+ build tool' | 'GPLed build tool') ;;
5290 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5292 case "$lgpl" in
5293 yes | 3)
5294 case $license in
5295 LGPLv2+ | 'LGPLv3+ or GPLv2+' | LGPLv3+ | LGPL) ;;
5296 *) func_append license_incompatibilities "$module $license$nl" ;;
5297 esac
5299 3orGPLv2)
5300 case $license in
5301 LGPLv2+ | 'LGPLv3+ or GPLv2+') ;;
5302 *) func_append license_incompatibilities "$module $license$nl" ;;
5303 esac
5306 case $license in
5307 LGPLv2+) ;;
5308 *) func_append license_incompatibilities "$module $license$nl" ;;
5309 esac
5311 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
5312 esac
5314 esac
5315 done
5316 if test -n "$license_incompatibilities"; then
5317 # Format the license incompatibilities as a table.
5318 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
5319 s,^\(.................................................[^ ]*\) *, \1 ,'
5320 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
5321 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
5325 # Show banner notice of every module.
5326 modules="$main_modules"
5327 func_modules_notice
5329 # Determine script to apply to imported library files.
5330 sed_transform_lib_file=
5331 for module in $main_modules; do
5332 if test $module = config-h; then
5333 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
5334 sed_transform_lib_file=$sed_transform_lib_file'
5335 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
5337 break
5339 done
5340 sed_transform_main_lib_file="$sed_transform_lib_file"
5342 # Determine script to apply to auxiliary files that go into $auxdir/.
5343 sed_transform_build_aux_file=
5345 # Determine script to apply to library files that go into $testsbase/.
5346 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
5348 # Determine the final file lists.
5349 func_modules_to_filelist_separately
5351 test -n "$files" \
5352 || func_fatal_error "refusing to do nothing"
5354 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
5355 new_files="$files m4/gnulib-tool.m4"
5356 old_files="$cached_files"
5357 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
5358 func_append old_files " m4/gnulib-tool.m4"
5361 rewritten='%REWRITTEN%'
5362 sed_rewrite_old_files="\
5363 s,^build-aux/,$rewritten$auxdir/,
5364 s,^doc/,$rewritten$cached_docbase/,
5365 s,^lib/,$rewritten$cached_sourcebase/,
5366 s,^m4/,$rewritten$cached_m4base/,
5367 s,^tests/,$rewritten$cached_testsbase/,
5368 s,^tests=lib/,$rewritten$cached_testsbase/,
5369 s,^top/,$rewritten,
5370 s,^$rewritten,,"
5371 sed_rewrite_new_files="\
5372 s,^build-aux/,$rewritten$auxdir/,
5373 s,^doc/,$rewritten$docbase/,
5374 s,^lib/,$rewritten$sourcebase/,
5375 s,^m4/,$rewritten$m4base/,
5376 s,^tests/,$rewritten$testsbase/,
5377 s,^tests=lib/,$rewritten$testsbase/,
5378 s,^top/,$rewritten,
5379 s,^$rewritten,,"
5381 # Determine whether to put anything into $testsbase.
5382 testsfiles=`echo "$files" | sed -n -e 's,^tests/,,p' -e 's,^tests=lib/,,p'`
5383 if test -n "$testsfiles"; then
5384 gentests=true
5385 else
5386 gentests=false
5389 # Create directories.
5390 { echo "$sourcebase"
5391 echo "$m4base"
5392 if test -n "$pobase"; then
5393 echo "$pobase"
5395 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
5396 if test -n "$docfiles"; then
5397 echo "$docbase"
5399 if $gentests; then
5400 echo "$testsbase"
5402 echo "$auxdir"
5403 for f in $files; do echo $f; done \
5404 | sed -e "$sed_rewrite_new_files" \
5405 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5406 | LC_ALL=C sort -u
5407 } > "$tmp"/dirs
5408 { # Rearrange file descriptors. Needed because "while ... done < ..."
5409 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5410 exec 5<&0 < "$tmp"/dirs
5411 while read d; do
5412 if test ! -d "$destdir/$d"; then
5413 if $doit; then
5414 echo "Creating directory $destdir/$d"
5415 mkdir -p "$destdir/$d" || func_fatal_error "failed"
5416 else
5417 echo "Create directory $destdir/$d"
5420 done
5421 exec 0<&5 5<&-
5424 # Copy files or make symbolic links or hard links. Remove obsolete files.
5425 added_files=''
5426 removed_files=''
5427 delimiter=' '
5428 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5429 # representing the files according to the last gnulib-tool invocation.
5430 for f in $old_files; do echo $f; done \
5431 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
5432 | LC_ALL=C sort \
5433 > "$tmp"/old-files
5434 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5435 # representing the files after this gnulib-tool invocation.
5436 for f in $new_files; do echo $f; done \
5437 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
5438 | LC_ALL=C sort \
5439 > "$tmp"/new-files
5440 # First the files that are in old-files, but not in new-files:
5441 sed_take_first_column='s,'"$delimiter"'.*,,'
5442 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
5443 # Remove the file. Do nothing if the user already removed it.
5444 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
5445 if $doit; then
5446 echo "Removing file $g (backup in ${g}~)"
5447 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
5448 else
5449 echo "Remove file $g (backup in ${g}~)"
5451 func_append removed_files "$g$nl"
5453 done
5454 # func_add_or_update handles a file that ought to be present afterwards.
5455 # Uses parameters
5456 # - f the original file name
5457 # - g the rewritten file name
5458 # - already_present nonempty if the file should already exist, empty
5459 # otherwise
5460 func_add_or_update ()
5462 of="$f"
5463 case "$f" in
5464 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5465 esac
5466 func_dest_tmpfilename "$g"
5467 func_lookup_file "$f"
5468 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5469 func_ensure_writable "$tmpfile"
5470 case "$f" in
5471 *.class | *.mo )
5472 # Don't process binary files with sed.
5475 if test -n "$sed_transform_main_lib_file"; then
5476 case "$of" in
5477 lib/*)
5478 sed -e "$sed_transform_main_lib_file" \
5479 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5481 esac
5483 if test -n "$sed_transform_build_aux_file"; then
5484 case "$of" in
5485 build-aux/*)
5486 sed -e "$sed_transform_build_aux_file" \
5487 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5489 esac
5491 if test -n "$sed_transform_testsrelated_lib_file"; then
5492 case "$of" in
5493 tests=lib/*)
5494 sed -e "$sed_transform_testsrelated_lib_file" \
5495 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5497 esac
5500 esac
5501 if test -f "$destdir/$g"; then
5502 # The file already exists.
5503 func_update_file
5504 else
5505 # Install the file.
5506 # Don't protest if the file should be there but isn't: it happens
5507 # frequently that developers don't put autogenerated files under version control.
5508 func_add_file
5509 func_append added_files "$g$nl"
5511 rm -f "$tmpfile"
5513 # Then the files that are in new-files, but not in old-files:
5514 sed_take_last_column='s,^.*'"$delimiter"',,'
5515 already_present=
5516 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
5517 | sed -e "$sed_take_last_column" \
5518 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
5519 { # Rearrange file descriptors. Needed because "while ... done < ..."
5520 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5521 exec 5<&0 < "$tmp"/added-files
5522 while read g f; do
5523 func_add_or_update
5524 done
5525 exec 0<&5 5<&-
5527 # Then the files that are in new-files and in old-files:
5528 already_present=true
5529 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
5530 | sed -e "$sed_take_last_column" \
5531 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
5532 { # Rearrange file descriptors. Needed because "while ... done < ..."
5533 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5534 exec 5<&0 < "$tmp"/kept-files
5535 while read g f; do
5536 func_add_or_update
5537 done
5538 exec 0<&5 5<&-
5541 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
5542 actioncmd="# gnulib-tool --import"
5544 # Local helper.
5545 func_append_local_dir ()
5547 func_append "$1" " --local-dir=$2"
5549 func_path_foreach "$local_gnulib_path" func_append_local_dir actioncmd %dir%
5551 # Break the action command log into multiple lines.
5552 # Emacs puts some gnulib-tool log lines in its source repository, and
5553 # git send-email rejects patch lines longer than 998 characters.
5554 # Also, config.status uses awk, and the HP-UX 11.00 awk fails if a
5555 # line has length >= 3071; similarly, the IRIX 6.5 awk fails if a
5556 # line has length >= 3072.
5557 func_append_actionarg ()
5559 func_append actioncmd " \\$nl# $1"
5561 func_append_actionarg "--lib=$libname"
5562 func_append_actionarg "--source-base=$sourcebase"
5563 func_append_actionarg "--m4-base=$m4base"
5564 if test -n "$pobase"; then
5565 func_append_actionarg "--po-base=$pobase"
5567 func_append_actionarg "--doc-base=$docbase"
5568 func_append_actionarg "--tests-base=$testsbase"
5569 func_append_actionarg "--aux-dir=$auxdir"
5570 if $inctests; then
5571 func_append_actionarg "--with-tests"
5573 if test -n "$incobsolete"; then
5574 func_append_actionarg "--with-obsolete"
5576 if test -n "$inc_cxx_tests"; then
5577 func_append_actionarg "--with-c++-tests"
5579 if test -n "$inc_longrunning_tests"; then
5580 func_append_actionarg "--with-longrunning-tests"
5582 if test -n "$inc_privileged_tests"; then
5583 func_append_actionarg "--with-privileged-tests"
5585 if test -n "$inc_unportable_tests"; then
5586 func_append_actionarg "--with-unportable-tests"
5588 if test -n "$inc_all_tests"; then
5589 func_append_actionarg "--with-all-tests"
5591 if test -n "$lgpl"; then
5592 if test "$lgpl" = yes; then
5593 func_append_actionarg "--lgpl"
5594 else
5595 func_append_actionarg "--lgpl=$lgpl"
5598 if $gnu_make; then
5599 func_append_actionarg "--gnu-make"
5601 if test -n "$makefile_name"; then
5602 func_append_actionarg "--makefile-name=$makefile_name"
5604 if test -n "$tests_makefile_name"; then
5605 func_append_actionarg "--tests-makefile-name=$tests_makefile_name"
5607 if $automake_subdir; then
5608 func_append_actionarg "--automake-subdir"
5610 if $automake_subdir_tests; then
5611 func_append_actionarg "--automake-subdir-tests"
5613 if test "$cond_dependencies" = true; then
5614 func_append_actionarg "--conditional-dependencies"
5615 else
5616 func_append_actionarg "--no-conditional-dependencies"
5618 if test "$libtool" = true; then
5619 func_append_actionarg "--libtool"
5620 else
5621 func_append_actionarg "--no-libtool"
5623 func_append_actionarg "--macro-prefix=$macro_prefix"
5624 if test -n "$po_domain"; then
5625 func_append_actionarg "--po-domain=$po_domain"
5627 if test -n "$witness_c_macro"; then
5628 func_append_actionarg "--witness-c-macro=$witness_c_macro"
5630 if test -n "$vc_files"; then
5631 if test "$vc_files" = true; then
5632 func_append_actionarg "--vc-files"
5633 else
5634 func_append_actionarg "--no-vc-files"
5637 for module in $avoidlist; do
5638 func_append_actionarg "--avoid=$module"
5639 done
5640 for module in $specified_modules; do
5641 func_append_actionarg "$module"
5642 done
5644 # Determine include_guard_prefix and module_indicator_prefix.
5645 func_compute_include_guard_prefix
5647 # Default the source makefile name to Makefile.am.
5648 if test -n "$makefile_name"; then
5649 source_makefile_am="$makefile_name"
5650 else
5651 source_makefile_am='Makefile.am'
5653 # Default the tests makefile name to the source makefile name.
5654 if test -n "$tests_makefile_name"; then
5655 tests_makefile_am="$tests_makefile_name"
5656 else
5657 tests_makefile_am="$source_makefile_am"
5660 # Create normal Makefile.ams.
5661 for_test=false
5663 # Setup list of Makefile.am edits that are to be performed afterwards.
5664 # Some of these edits apply to files that we will generate; others are
5665 # under the responsibility of the developer.
5666 makefile_am_edits=0
5667 # func_note_Makefile_am_edit dir var value [dotfirst]
5668 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
5669 # ${value}.
5670 # If ${dotfirst} is non-empty, this mention needs to be present after '.'.
5671 # This is a special hack for the SUBDIRS variable, cf.
5672 # <https://www.gnu.org/software/automake/manual/html_node/Subdirectories.html>.
5673 func_note_Makefile_am_edit ()
5675 makefile_am_edits=`expr $makefile_am_edits + 1`
5676 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
5677 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
5678 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
5679 eval makefile_am_edit${makefile_am_edits}_dotfirst=\"\$4\"
5681 if test "$source_makefile_am" = Makefile.am; then
5682 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
5683 sourcebase_base=`basename "$sourcebase"`
5684 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
5686 if test -n "$pobase"; then
5687 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
5688 pobase_base=`basename "$pobase"`
5689 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
5691 if $inctests; then
5692 if test "$tests_makefile_am" = Makefile.am; then
5693 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
5694 testsbase_base=`basename "$testsbase"`
5695 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base" true
5698 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "${m4base}"
5700 # Find the first parent directory of $m4base that contains or will contain
5701 # a Makefile.am.
5702 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
5703 s,//*$,/,'
5704 sed_butlast='s,[^/][^/]*//*$,,'
5705 dir1="${m4base}/"; dir2=""
5706 while test -n "$dir1" \
5707 && ! { test -f "${destdir}/${dir1}Makefile.am" \
5708 || test "${dir1}Makefile.am" = "$sourcebase/$source_makefile_am" \
5709 || test "./${dir1}Makefile.am" = "$sourcebase/$source_makefile_am" \
5710 || { $gentests \
5711 && { test "${dir1}Makefile.am" = "$testsbase/$tests_makefile_am" \
5712 || test "./${dir1}Makefile.am" = "$testsbase/$tests_makefile_am"; }; }; }; do
5713 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
5714 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
5715 done
5716 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
5719 # Create po/ directory.
5720 if test -n "$pobase"; then
5721 # Create po makefile and auxiliary files.
5722 for file in Makefile.in.in remove-potcdate.sin; do
5723 func_dest_tmpfilename $pobase/$file
5724 func_lookup_file build-aux/po/$file
5725 cat "$lookedup_file" > "$tmpfile"
5726 if test -f "$destdir"/$pobase/$file; then
5727 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
5728 rm -f "$tmpfile"
5729 else
5730 if $doit; then
5731 echo "Updating $pobase/$file (backup in $pobase/$file~)"
5732 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
5733 mv -f "$tmpfile" "$destdir"/$pobase/$file
5734 else
5735 echo "Update $pobase/$file (backup in $pobase/$file~)"
5736 rm -f "$tmpfile"
5739 else
5740 if $doit; then
5741 echo "Creating $pobase/$file"
5742 mv -f "$tmpfile" "$destdir"/$pobase/$file
5743 else
5744 echo "Create $pobase/$file"
5745 rm -f "$tmpfile"
5747 func_append added_files "$pobase/$file$nl"
5749 done
5750 # Create po makefile parameterization, part 1.
5751 func_dest_tmpfilename $pobase/Makevars
5752 func_emit_po_Makevars > "$tmpfile"
5753 if test -f "$destdir"/$pobase/Makevars; then
5754 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
5755 rm -f "$tmpfile"
5756 else
5757 if $doit; then
5758 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
5759 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
5760 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5761 else
5762 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
5763 rm -f "$tmpfile"
5766 else
5767 if $doit; then
5768 echo "Creating $pobase/Makevars"
5769 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5770 else
5771 echo "Create $pobase/Makevars"
5772 rm -f "$tmpfile"
5774 func_append added_files "$pobase/Makevars$nl"
5776 # Create po makefile parameterization, part 2.
5777 func_dest_tmpfilename $pobase/POTFILES.in
5778 func_emit_po_POTFILES_in > "$tmpfile"
5779 if test -f "$destdir"/$pobase/POTFILES.in; then
5780 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5781 rm -f "$tmpfile"
5782 else
5783 if $doit; then
5784 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5785 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5786 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5787 else
5788 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5789 rm -f "$tmpfile"
5792 else
5793 if $doit; then
5794 echo "Creating $pobase/POTFILES.in"
5795 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5796 else
5797 echo "Create $pobase/POTFILES.in"
5798 rm -f "$tmpfile"
5800 func_append added_files "$pobase/POTFILES.in$nl"
5802 # Fetch PO files.
5803 TP_URL="https://translationproject.org/latest/"
5804 if $doit; then
5805 echo "Fetching gnulib PO files from $TP_URL"
5806 (cd "$destdir"/$pobase \
5807 && wget --no-verbose --mirror --level=1 -nd -A.po -P . "${TP_URL}gnulib/"
5809 else
5810 echo "Fetch gnulib PO files from $TP_URL"
5812 # Create po/LINGUAS.
5813 if $doit; then
5814 func_dest_tmpfilename $pobase/LINGUAS
5815 (cd "$destdir"/$pobase \
5816 && { echo '# Set of available languages.'
5817 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5819 ) > "$tmpfile"
5820 if test -f "$destdir"/$pobase/LINGUAS; then
5821 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5822 rm -f "$tmpfile"
5823 else
5824 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5825 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5826 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5828 else
5829 echo "Creating $pobase/LINGUAS"
5830 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5831 func_append added_files "$pobase/LINGUAS$nl"
5833 else
5834 if test -f "$destdir"/$pobase/LINGUAS; then
5835 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5836 else
5837 echo "Create $pobase/LINGUAS"
5842 # func_compute_relative_local_gnulib_path
5843 # gl_LOCAL_DIR requires local_gnulib_path to be set relatively to destdir
5844 # Input:
5845 # - local_gnulib_path from --local-dir
5846 # - destdir from --dir
5847 # Output:
5848 # - relative_local_dir path to be stored into gl_LOCAL_DIR
5849 func_compute_relative_local_gnulib_path ()
5851 relative_local_gnulib_path=
5852 save_IFS="$IFS"
5853 IFS="$PATH_SEPARATOR"
5854 for local_dir in $local_gnulib_path
5856 IFS="$save_IFS"
5857 # Store the local_dir relative to destdir.
5858 case "$local_dir" in
5859 "" | /*)
5860 relative_local_dir="$local_dir" ;;
5862 case "$destdir" in
5864 # XXX This doesn't look right.
5865 relative_local_dir="$local_dir" ;;
5867 # destdir, local_dir are both relative.
5868 func_relativize "$destdir" "$local_dir"
5869 relative_local_dir="$reldir" ;;
5870 esac ;;
5871 esac
5872 func_path_append relative_local_gnulib_path "$relative_local_dir"
5873 done
5874 IFS="$save_IFS"
5877 # Create m4/gnulib-cache.m4.
5878 func_dest_tmpfilename $m4base/gnulib-cache.m4
5880 func_emit_copyright_notice
5881 echo "#"
5882 echo "# This file represents the specification of how gnulib-tool is used."
5883 echo "# It acts as a cache: It is written and read by gnulib-tool."
5884 echo "# In projects that use version control, this file is meant to be put under"
5885 echo "# version control, like the configure.ac and various Makefile.am files."
5886 echo
5887 echo
5888 echo "# Specification in the form of a command-line invocation:"
5889 printf '%s\n' "$actioncmd"
5890 echo
5891 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5892 func_compute_relative_local_gnulib_path
5893 echo "gl_LOCAL_DIR([$relative_local_gnulib_path])"
5894 echo "gl_MODULES(["
5895 echo "$specified_modules" | sed -e 's/^/ /g'
5896 echo "])"
5897 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5898 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5899 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5900 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5901 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5902 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5903 echo "gl_AVOID([$avoidlist])"
5904 echo "gl_SOURCE_BASE([$sourcebase])"
5905 echo "gl_M4_BASE([$m4base])"
5906 echo "gl_PO_BASE([$pobase])"
5907 echo "gl_DOC_BASE([$docbase])"
5908 echo "gl_TESTS_BASE([$testsbase])"
5909 if $inctests; then
5910 echo "gl_WITH_TESTS"
5912 echo "gl_LIB([$libname])"
5913 if test -n "$lgpl"; then
5914 if test "$lgpl" = yes; then
5915 echo "gl_LGPL"
5916 else
5917 echo "gl_LGPL([$lgpl])"
5920 echo "gl_MAKEFILE_NAME([$makefile_name])"
5921 if test -n "$tests_makefile_name"; then
5922 echo "gl_TESTS_MAKEFILE_NAME([$tests_makefile_name])"
5924 if test "$automake_subdir" = true; then
5925 echo "gl_AUTOMAKE_SUBDIR"
5927 if test "$cond_dependencies" = true; then
5928 echo "gl_CONDITIONAL_DEPENDENCIES"
5930 if test "$libtool" = true; then
5931 echo "gl_LIBTOOL"
5933 echo "gl_MACRO_PREFIX([$macro_prefix])"
5934 echo "gl_PO_DOMAIN([$po_domain])"
5935 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5936 if test -n "$vc_files"; then
5937 echo "gl_VC_FILES([$vc_files])"
5939 ) > "$tmpfile"
5940 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5941 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
5942 rm -f "$tmpfile"
5943 else
5944 if $doit; then
5945 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5946 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5947 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5948 else
5949 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5950 if false; then
5951 cat "$tmpfile"
5952 echo
5953 echo "# gnulib-cache.m4 ends here"
5955 rm -f "$tmpfile"
5958 else
5959 if $doit; then
5960 echo "Creating $m4base/gnulib-cache.m4"
5961 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5962 else
5963 echo "Create $m4base/gnulib-cache.m4"
5964 cat "$tmpfile"
5965 rm -f "$tmpfile"
5969 # Create m4/gnulib-comp.m4.
5970 func_dest_tmpfilename $m4base/gnulib-comp.m4
5972 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5973 func_emit_copyright_notice
5974 echo "#"
5975 echo "# This file represents the compiled summary of the specification in"
5976 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5977 echo "# to be invoked from configure.ac."
5978 echo "# In projects that use version control, this file can be treated like"
5979 echo "# other built files."
5980 echo
5981 echo
5982 echo "# This macro should be invoked from $configure_ac, in the section"
5983 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5984 echo "# any checks for libraries, header files, types and library functions."
5985 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5986 echo "["
5987 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5988 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5989 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5990 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5992 func_emit_pre_early_macros : ' ' "$final_modules"
5994 if ! $gnu_make && test -n "$uses_subdirs"; then
5995 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5997 for module in $final_modules; do
5998 func_verify_module
5999 if test -n "$module"; then
6000 echo "# Code from module $module:"
6001 func_get_autoconf_early_snippet "$module"
6003 done \
6004 | sed -e '/^$/d;' -e 's/^/ /'
6005 echo "])"
6006 echo
6007 echo "# This macro should be invoked from $configure_ac, in the section"
6008 echo "# \"Check for header files, types and library functions\"."
6009 echo "AC_DEFUN([${macro_prefix}_INIT],"
6010 echo "["
6011 # This AC_CONFIG_LIBOBJ_DIR invocation silences an error from the automake
6012 # front end:
6013 # error: required file './alloca.c' not found
6014 # It is needed because of the last remaining use of AC_LIBSOURCES in
6015 # _AC_LIBOBJ_ALLOCA, invoked from AC_FUNC_ALLOCA.
6016 # All the m4_pushdef/m4_popdef logic in func_emit_initmacro_start/_end
6017 # does not help to avoid this error.
6018 if grep ' lib/alloca\.c$' "$tmp"/new-files >/dev/null; then
6019 # alloca.c will be present in $sourcebase.
6020 echo " AC_CONFIG_LIBOBJ_DIR([$sourcebase])"
6021 else
6022 if grep ' tests=lib/alloca\.c$' "$tmp"/new-files >/dev/null; then
6023 # alloca.c will be present in $testsbase.
6024 echo " AC_CONFIG_LIBOBJ_DIR([$testsbase])"
6027 if test "$libtool" = true; then
6028 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6029 echo " gl_cond_libtool=true"
6030 else
6031 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6032 echo " gl_cond_libtool=false"
6033 echo " gl_libdeps="
6034 echo " gl_ltlibdeps="
6036 if test "$auxdir" != "build-aux"; then
6037 sed_replace_build_aux='
6039 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6040 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6043 else
6044 sed_replace_build_aux="$sed_noop"
6046 echo " gl_m4_base='$m4base'"
6047 func_emit_initmacro_start $macro_prefix false
6048 func_emit_shellvars_init false "$sourcebase"
6049 if test -n "$witness_c_macro"; then
6050 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
6052 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false true
6053 if test -n "$witness_c_macro"; then
6054 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6056 echo " # End of code from modules"
6057 func_emit_initmacro_end $macro_prefix false
6058 echo " gltests_libdeps="
6059 echo " gltests_ltlibdeps="
6060 func_emit_initmacro_start ${macro_prefix}tests $gentests
6061 func_emit_shellvars_init true "$testsbase"
6062 # Define a tests witness macro that depends on the package.
6063 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
6064 # See <https://lists.gnu.org/r/automake/2009-05/msg00145.html>.
6065 echo "changequote(,)dnl"
6066 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"
6067 echo "changequote([, ])dnl"
6068 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6069 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6070 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6071 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true true true
6072 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6073 func_emit_initmacro_end ${macro_prefix}tests $gentests
6074 echo " AC_REQUIRE([gl_CC_GNULIB_WARNINGS])"
6075 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6076 # created using libtool, because libtool already handles the dependencies.
6077 if test "$libtool" != true; then
6078 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6079 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6080 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6081 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6082 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6084 if $use_libtests; then
6085 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6086 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6088 echo "])"
6089 func_emit_initmacro_done $macro_prefix $sourcebase
6090 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6091 echo
6092 echo "# This macro records the list of files which have been installed by"
6093 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
6094 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
6095 echo "$files" | sed -e 's,^, ,'
6096 echo "])"
6097 ) > "$tmpfile"
6098 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
6099 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
6100 rm -f "$tmpfile"
6101 else
6102 if $doit; then
6103 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
6104 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
6105 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
6106 else
6107 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
6108 if false; then
6109 cat "$tmpfile"
6110 echo
6111 echo "# gnulib-comp.m4 ends here"
6113 rm -f "$tmpfile"
6116 else
6117 if $doit; then
6118 echo "Creating $m4base/gnulib-comp.m4"
6119 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
6120 else
6121 echo "Create $m4base/gnulib-comp.m4"
6122 cat "$tmpfile"
6123 rm -f "$tmpfile"
6127 # Create library makefile.
6128 # Do this after creating gnulib-comp.m4, because func_emit_lib_Makefile_am
6129 # can run 'autoconf -t', which reads gnulib-comp.m4.
6130 func_dest_tmpfilename $sourcebase/$source_makefile_am
6131 destfile="$sourcebase/$source_makefile_am"
6132 modules="$main_modules"
6133 if $automake_subdir; then
6134 func_emit_lib_Makefile_am | "$gnulib_dir"/build-aux/prefix-gnulib-mk --from-gnulib-tool --lib-name="$libname" --prefix="$sourcebase/" > "$tmpfile"
6135 else
6136 func_emit_lib_Makefile_am > "$tmpfile"
6138 if test -f "$destdir"/$sourcebase/$source_makefile_am; then
6139 if cmp -s "$destdir"/$sourcebase/$source_makefile_am "$tmpfile"; then
6140 rm -f "$tmpfile"
6141 else
6142 if $doit; then
6143 echo "Updating $sourcebase/$source_makefile_am (backup in $sourcebase/$source_makefile_am~)"
6144 mv -f "$destdir"/$sourcebase/$source_makefile_am "$destdir"/$sourcebase/$source_makefile_am~
6145 mv -f "$tmpfile" "$destdir"/$sourcebase/$source_makefile_am
6146 else
6147 echo "Update $sourcebase/$source_makefile_am (backup in $sourcebase/$source_makefile_am~)"
6148 rm -f "$tmpfile"
6151 else
6152 if $doit; then
6153 echo "Creating $sourcebase/$source_makefile_am"
6154 mv -f "$tmpfile" "$destdir"/$sourcebase/$source_makefile_am
6155 else
6156 echo "Create $sourcebase/$source_makefile_am"
6157 rm -f "$tmpfile"
6159 func_append added_files "$sourcebase/$source_makefile_am$nl"
6162 if $gentests; then
6163 # Create tests makefile.
6164 func_dest_tmpfilename $testsbase/$tests_makefile_am
6165 destfile="$testsbase/$tests_makefile_am"
6166 modules="$testsrelated_modules"
6167 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
6168 if test -f "$destdir"/$testsbase/$tests_makefile_am; then
6169 if cmp -s "$destdir"/$testsbase/$tests_makefile_am "$tmpfile"; then
6170 rm -f "$tmpfile"
6171 else
6172 if $doit; then
6173 echo "Updating $testsbase/$tests_makefile_am (backup in $testsbase/$tests_makefile_am~)"
6174 mv -f "$destdir"/$testsbase/$tests_makefile_am "$destdir"/$testsbase/$tests_makefile_am~
6175 mv -f "$tmpfile" "$destdir"/$testsbase/$tests_makefile_am
6176 else
6177 echo "Update $testsbase/$tests_makefile_am (backup in $testsbase/$tests_makefile_am~)"
6178 rm -f "$tmpfile"
6181 else
6182 if $doit; then
6183 echo "Creating $testsbase/$tests_makefile_am"
6184 mv -f "$tmpfile" "$destdir"/$testsbase/$tests_makefile_am
6185 else
6186 echo "Create $testsbase/$tests_makefile_am"
6187 rm -f "$tmpfile"
6189 func_append added_files "$testsbase/$tests_makefile_am$nl"
6193 if test "$vc_files" != false; then
6194 # Update the .cvsignore and .gitignore files.
6195 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
6196 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
6197 # Treat gnulib-comp.m4 like an added file, even if it already existed.
6198 echo "$m4base/|A|gnulib-comp.m4"
6199 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
6200 { # Rearrange file descriptors. Needed because "while ... done < ..."
6201 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6202 exec 5<&0 < "$tmp"/fileset-changes
6203 func_update_ignorelist ()
6205 ignore="$1"
6206 if test "$ignore" = .gitignore; then
6207 # In a .gitignore file, "foo" applies to the current directory and all
6208 # subdirectories, whereas "/foo" applies to the current directory only.
6209 anchor='/'
6210 escaped_anchor='\/'
6211 doubly_escaped_anchor='\\/'
6212 else
6213 anchor=''
6214 escaped_anchor=''
6215 doubly_escaped_anchor=''
6217 if test -f "$destdir/$dir$ignore"; then
6218 if test -n "$dir_added" || test -n "$dir_removed"; then
6219 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
6220 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
6221 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
6222 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
6223 > "$tmp"/ignore-removed
6225 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
6226 if $doit; then
6227 echo "Updating $dir$ignore (backup in $dir${ignore}~)"
6228 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
6229 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
6230 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
6231 } > "$tmp"/sed-ignore-removed
6232 { cat "$destdir/$dir$ignore"~
6233 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
6234 } | sed -f "$tmp"/sed-ignore-removed \
6235 > "$destdir/$dir$ignore"
6236 else
6237 echo "Update $dir$ignore (backup in $dir${ignore}~)"
6241 else
6242 if test -n "$dir_added"; then
6243 if $doit; then
6244 echo "Creating $dir$ignore"
6246 if test "$ignore" = .cvsignore; then
6247 echo ".deps"
6248 # Automake generates Makefile rules that create .dirstamp files.
6249 echo ".dirstamp"
6251 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
6252 } > "$destdir/$dir$ignore"
6253 else
6254 echo "Create $dir$ignore"
6259 func_done_dir ()
6261 dir="$1"
6262 dir_added="$2"
6263 dir_removed="$3"
6264 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
6265 func_update_ignorelist .cvsignore
6267 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
6268 func_update_ignorelist .gitignore
6271 last_dir=
6272 last_dir_added=
6273 last_dir_removed=
6274 while read line; do
6275 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
6276 next_dir=`echo "$line" | sed -e 's,|.*,,'`
6277 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
6278 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
6279 if test "$next_dir" != "$last_dir"; then
6280 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
6281 last_dir="$next_dir"
6282 last_dir_added=
6283 last_dir_removed=
6285 case $op in
6286 A) func_append last_dir_added "$file$nl";;
6287 R) func_append last_dir_removed "$file$nl";;
6288 esac
6289 done
6290 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
6291 exec 0<&5 5<&-
6295 echo "Finished."
6296 echo
6297 echo "You may need to add #include directives for the following .h files."
6298 # Intersect $specified_modules and $main_modules
6299 # (since $specified_modules is not necessarily of subset of $main_modules
6300 # - some may have been skipped through --avoid, and since the elements of
6301 # $main_modules but not in $specified_modules can go away without explicit
6302 # notice - through changes in the module dependencies).
6303 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
6304 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
6305 # First the #include <...> directives without #ifs, sorted for convenience,
6306 # then the #include "..." directives without #ifs, sorted for convenience,
6307 # then the #include directives that are surrounded by #ifs. Not sorted.
6308 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
6309 include_directive=`func_get_include_directive "$module"`
6310 case "$nl$include_directive" in
6311 *"$nl#if"*)
6312 echo "$include_directive" 1>&5
6315 echo "$include_directive" | grep -v 'include "' 1>&6
6316 echo "$include_directive" | grep 'include "' 1>&7
6318 esac
6319 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
6321 LC_ALL=C sort -u "$tmp"/include-angles
6322 LC_ALL=C sort -u "$tmp"/include-quotes
6323 cat "$tmp"/include-if
6324 ) | sed -e '/^$/d' -e 's/^/ /'
6325 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
6327 for module in $main_modules; do
6328 func_get_link_directive "$module"
6329 done \
6330 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
6331 if test `wc -l < "$tmp"/link` != 0; then
6332 echo
6333 echo "You may need to use the following Makefile variables when linking."
6334 echo "Use them in <program>_LDADD when linking a program, or"
6335 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
6336 cat "$tmp"/link
6338 rm -f "$tmp"/link
6340 echo
6341 echo "Don't forget to"
6342 if test "$source_makefile_am" = Makefile.am; then
6343 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
6344 else
6345 echo " - \"include $source_makefile_am\" from within \"$sourcebase/Makefile.am\","
6347 if test -n "$pobase"; then
6348 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
6350 if $gentests; then
6351 if test "$tests_makefile_am" = Makefile.am; then
6352 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
6353 else
6354 echo " - \"include $tests_makefile_am\" from within \"$testsbase/Makefile.am\","
6357 edit=0
6358 while test $edit != $makefile_am_edits; do
6359 edit=`expr $edit + 1`
6360 eval dir=\"\$makefile_am_edit${edit}_dir\"
6361 eval var=\"\$makefile_am_edit${edit}_var\"
6362 eval val=\"\$makefile_am_edit${edit}_val\"
6363 if test -n "$var"; then
6364 if test "$var" = ACLOCAL_AMFLAGS; then
6365 echo " - mention \"-I ${val}\" in ${var} in ${dir}Makefile.am"
6366 echo " or add an AC_CONFIG_MACRO_DIRS([${val}]) invocation in $configure_ac,"
6367 else
6368 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
6371 done
6372 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
6373 echo " - replace AC_PROG_CC_STDC with AC_PROG_CC in $configure_ac,"
6374 position_early_after=AC_PROG_CC_STDC
6375 else
6376 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
6377 echo " - replace AC_PROG_CC_C99 with AC_PROG_CC in $configure_ac,"
6378 position_early_after=AC_PROG_CC_C99
6379 else
6380 position_early_after=AC_PROG_CC
6383 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
6384 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
6387 # func_create_testdir testdir modules
6388 # Input:
6389 # - local_gnulib_path from --local-dir
6390 # - modcache true or false, from --cache-modules/--no-cache-modules
6391 # - auxdir directory relative to destdir where to place build aux files
6392 # - inctests true if tests should be included, false otherwise
6393 # - incobsolete true if obsolete modules among dependencies should be
6394 # included, blank otherwise
6395 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
6396 # blank otherwise
6397 # - excl_longrunning_tests true if long-runnings tests should be excluded,
6398 # blank otherwise
6399 # - excl_privileged_tests true if tests that require root privileges should be
6400 # excluded, blank otherwise
6401 # - excl_unportable_tests true if tests that fail on some platforms should be
6402 # excluded, blank otherwise
6403 # - single_configure true if a single configure file should be generated,
6404 # false for a separate configure file for the tests
6405 # - avoidlist list of modules to avoid
6406 # - cond_dependencies true if --conditional-dependencies was given, false if
6407 # --no-conditional-dependencies was given, blank otherwise
6408 # - libtool true if --libtool was given, false if --no-libtool was
6409 # given, blank otherwise
6410 # - copymode copy mode for files in general
6411 # - lcopymode copy mode for files from local_gnulib_path
6412 func_create_testdir ()
6414 testdir="$1"
6415 modules="$2"
6416 if test -z "$modules"; then
6417 # All modules together.
6418 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6419 # Except non-recursive-gnulib-prefix-hack, which represents a nonstandard
6420 # way of using Automake.
6421 # Except timevar, which lacks the required file timevar.def.
6422 # Except mountlist, which aborts the configuration on mingw. FIXME.
6423 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
6424 modules=`func_all_modules`
6425 modules=`for m in $modules; do case $m in config-h | non-recursive-gnulib-prefix-hack | timevar | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
6427 specified_modules="$modules"
6429 # Canonicalize the list of specified modules.
6430 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
6432 # Test modules which invoke AC_CONFIG_FILES cannot be used with
6433 # --with-tests --single-configure. Avoid them.
6434 if $inctests && $single_configure; then
6435 avoidlist="$avoidlist havelib-tests"
6438 # Unlike in func_import, here we want to include all kinds of tests for the
6439 # directly specified modules, but not for dependencies.
6440 inc_all_direct_tests=true
6441 inc_all_indirect_tests="$inc_all_tests"
6443 # Check that the license of every module is consistent with the license of
6444 # its dependencies.
6445 saved_inctests="$inctests"
6446 # When computing transitive closures, don't consider $module to depend on
6447 # $module-tests. Need this because tests are implicitly GPL and may depend
6448 # on GPL modules - therefore we don't want a warning in this case.
6449 inctests=false
6450 for requested_module in $specified_modules; do
6451 requested_license=`func_get_license "$requested_module"`
6452 if test "$requested_license" != GPL; then
6453 # Here we use func_modules_transitive_closure, not just
6454 # func_get_dependencies, so that we also detect weird situations like
6455 # an LGPL module which depends on a GPLed build tool module which depends
6456 # on a GPL module.
6457 modules="$requested_module"
6458 func_modules_transitive_closure
6459 for module in $modules; do
6460 license=`func_get_license "$module"`
6461 case "$license" in
6462 'GPLv2+ build tool' | 'GPLed build tool') ;;
6463 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
6465 case "$requested_license" in
6466 GPLv3+ | GPL)
6467 case "$license" in
6468 LGPLv2+ | 'LGPLv3+ or GPLv2+' | LGPLv3+ | LGPL | GPLv2+ | GPLv3+ | GPL) ;;
6469 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6470 esac
6472 GPLv2+)
6473 case "$license" in
6474 LGPLv2+ | 'LGPLv3+ or GPLv2+' | GPLv2+) ;;
6475 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6476 esac
6478 LGPLv3+ | LGPL)
6479 case "$license" in
6480 LGPLv2+ | 'LGPLv3+ or GPLv2+' | LGPLv3+ | LGPL) ;;
6481 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6482 esac
6484 'LGPLv3+ or GPLv2+')
6485 case "$license" in
6486 LGPLv2+ | 'LGPLv3+ or GPLv2+') ;;
6487 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6488 esac
6490 LGPLv2+)
6491 case "$license" in
6492 LGPLv2+) ;;
6493 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6494 esac
6496 esac
6498 esac
6499 done
6501 done
6502 inctests="$saved_inctests"
6504 # Subdirectory names.
6505 sourcebase=gllib
6506 m4base=glm4
6507 pobase=
6508 docbase=gldoc
6509 testsbase=gltests
6510 macro_prefix=gl
6511 po_domain=
6512 witness_c_macro=
6513 vc_files=
6515 # Determine final module list.
6516 modules="$specified_modules"
6517 func_modules_transitive_closure
6518 if test $verbose -ge 0; then
6519 func_show_module_list
6521 final_modules="$modules"
6523 if $single_configure; then
6524 # Determine main module list and tests-related module list separately.
6525 func_modules_transitive_closure_separately
6528 if $single_configure; then
6529 # Determine whether a $testsbase/libtests.a is needed.
6530 func_determine_use_libtests
6533 # Add the dummy module if needed.
6534 if $single_configure; then
6535 func_modules_add_dummy_separately
6536 else
6537 func_modules_add_dummy
6540 # Note:
6541 # If $single_configure, we use the module lists $main_modules and
6542 # $testsrelated_modules; $modules is merely a temporary variable.
6543 # Whereas if ! $single_configure, the module list is $modules.
6545 # Show banner notice of every module.
6546 if $single_configure; then
6547 modules="$main_modules"
6548 func_modules_notice
6549 else
6550 func_modules_notice
6553 # Determine final file list.
6554 if $single_configure; then
6555 func_modules_to_filelist_separately
6556 else
6557 main_modules="$modules"
6558 testsrelated_modules=`for module in $modules; do
6559 if \`func_repeat_module_in_tests\`; then
6560 echo $module
6562 done`
6563 saved_modules="$modules"
6564 func_modules_to_filelist_separately
6565 modules="$saved_modules"
6567 # Add files for which the copy in gnulib is newer than the one that
6568 # "automake --add-missing --copy" would provide.
6569 files="$files build-aux/config.guess"
6570 files="$files build-aux/config.sub"
6571 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
6573 rewritten='%REWRITTEN%'
6574 sed_rewrite_files="\
6575 s,^build-aux/,$rewritten$auxdir/,
6576 s,^doc/,$rewritten$docbase/,
6577 s,^lib/,$rewritten$sourcebase/,
6578 s,^m4/,$rewritten$m4base/,
6579 s,^tests/,$rewritten$testsbase/,
6580 s,^tests=lib/,$rewritten$testsbase/,
6581 s,^top/,$rewritten,
6582 s,^$rewritten,,"
6584 # Create directories.
6585 for f in $files; do echo $f; done \
6586 | sed -e "$sed_rewrite_files" \
6587 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
6588 | LC_ALL=C sort -u \
6589 > "$tmp"/dirs
6590 { # Rearrange file descriptors. Needed because "while ... done < ..."
6591 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6592 exec 5<&0 < "$tmp"/dirs
6593 while read d; do
6594 mkdir -p "$testdir/$d"
6595 done
6596 exec 0<&5 5<&-
6599 # Copy files or make symbolic links or hard links.
6600 delimiter=' '
6601 for f in $files; do echo $f; done \
6602 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
6603 | LC_ALL=C sort \
6604 > "$tmp"/files
6605 { # Rearrange file descriptors. Needed because "while ... done < ..."
6606 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6607 exec 5<&0 < "$tmp"/files
6608 while read g f; do
6609 case "$f" in
6610 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
6611 esac
6612 func_lookup_file "$f"
6613 if test -n "$lookedup_tmp"; then
6614 cp -p "$lookedup_file" "$testdir/$g"
6615 func_ensure_writable "$testdir/$g"
6616 else
6617 func_should_link
6618 if test "$copyaction" = symlink; then
6619 func_symlink "$lookedup_file" "$testdir/$g"
6620 else
6621 if test "$copyaction" = hardlink; then
6622 func_hardlink "$lookedup_file" "$testdir/$g"
6623 else
6624 cp -p "$lookedup_file" "$testdir/$g"
6625 func_ensure_writable "$testdir/$g"
6629 done
6630 exec 0<&5 5<&-
6633 # Determine include_guard_prefix and module_indicator_prefix.
6634 func_compute_include_guard_prefix
6636 # Create Makefile.ams that are for testing.
6637 for_test=true
6639 # No special edits are needed.
6640 makefile_am_edits=0
6642 # Create $sourcebase/Makefile.am.
6643 mkdir -p "$testdir/$sourcebase"
6644 destfile="$sourcebase/Makefile.am"
6645 if $single_configure; then
6646 modules="$main_modules"
6648 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
6649 any_uses_subdirs="$uses_subdirs"
6651 # Create $m4base/Makefile.am.
6652 mkdir -p "$testdir/$m4base"
6653 (echo "## Process this file with automake to produce Makefile.in."
6654 echo
6655 echo "EXTRA_DIST ="
6656 for f in $files; do
6657 case "$f" in
6658 m4/* )
6659 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
6660 esac
6661 done
6662 ) > "$testdir/$m4base/Makefile.am"
6664 subdirs="$sourcebase $m4base"
6665 subdirs_with_configure_ac=""
6667 if false && test -f "$testdir"/$m4base/gettext.m4; then
6668 # Avoid stupid error message from automake:
6669 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
6670 mkdir -p "$testdir/po"
6671 (echo "## Process this file with automake to produce Makefile.in."
6672 ) > "$testdir/po/Makefile.am"
6673 func_append subdirs " po"
6676 if $inctests; then
6677 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
6678 if $single_configure; then
6679 # Create $testsbase/Makefile.am.
6680 destfile="$testsbase/Makefile.am"
6681 modules="$testsrelated_modules"
6682 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
6683 else
6684 # Viewed from the $testsbase subdirectory, $auxdir is different.
6685 saved_auxdir="$auxdir"
6686 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
6687 # Create $testsbase/Makefile.am.
6688 use_libtests=false
6689 destfile="$testsbase/Makefile.am"
6690 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
6691 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
6692 # Create $testsbase/configure.ac.
6693 (echo "# Process this file with autoconf to produce a configure script."
6694 echo "AC_INIT([dummy], [0])"
6695 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6696 echo "AM_INIT_AUTOMAKE"
6697 echo
6698 echo "AC_CONFIG_HEADERS([config.h])"
6699 echo
6700 echo "AC_PROG_CC"
6701 echo "AC_PROG_INSTALL"
6702 echo "AC_PROG_MAKE_SET"
6704 func_emit_pre_early_macros false '' "$modules"
6706 if test -n "$uses_subdirs"; then
6707 echo "AM_PROG_CC_C_O"
6708 echo
6710 for module in $modules; do
6711 func_verify_module
6712 if test -n "$module"; then
6713 case $module in
6714 gnumakefile | maintainer-makefile)
6715 # These modules are meant to be used only in the top-level directory.
6718 func_get_autoconf_early_snippet "$module"
6720 esac
6722 done \
6723 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)])/\1/'
6724 if test "$libtool" = true; then
6725 echo "LT_INIT([win32-dll])"
6726 echo "LT_LANG([C++])"
6727 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6728 echo "gl_cond_libtool=true"
6729 else
6730 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6731 echo "gl_cond_libtool=false"
6732 echo "gl_libdeps="
6733 echo "gl_ltlibdeps="
6735 # Wrap the set of autoconf snippets into an autoconf macro that is then
6736 # invoked. This is needed because autoconf does not support AC_REQUIRE
6737 # at the top level:
6738 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6739 # but we want the AC_REQUIRE to have its normal meaning (provide one
6740 # expansion of the required macro before the current point, and only one
6741 # expansion total).
6742 echo "AC_DEFUN([gl_INIT], ["
6743 sed_replace_build_aux='
6745 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6746 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6749 echo "gl_m4_base='../$m4base'"
6750 func_emit_initmacro_start $macro_prefix true
6751 # We don't have explicit ordering constraints between the various
6752 # autoconf snippets. It's cleanest to put those of the library before
6753 # those of the tests.
6754 func_emit_shellvars_init true "../$sourcebase"
6755 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module false false false
6756 func_emit_shellvars_init true '.'
6757 func_emit_autoconf_snippets "$modules" "$modules" func_verify_tests_module false false false
6758 func_emit_initmacro_end $macro_prefix true
6759 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6760 # created using libtool, because libtool already handles the dependencies.
6761 if test "$libtool" != true; then
6762 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6763 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6764 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6765 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6766 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6768 echo "])"
6769 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
6770 echo
6771 echo "gl_INIT"
6772 echo
6773 # Usually $testsbase/config.h will be a superset of config.h. Verify this
6774 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
6775 echo "AH_TOP([#include \"../config.h\"])"
6776 echo
6777 echo "AC_CONFIG_FILES([Makefile])"
6778 echo "AC_OUTPUT"
6779 ) > "$testdir/$testsbase/configure.ac"
6780 auxdir="$saved_auxdir"
6781 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
6783 func_append subdirs " $testsbase"
6786 # Create Makefile.am.
6787 (echo "## Process this file with automake to produce Makefile.in."
6788 echo
6789 echo "AUTOMAKE_OPTIONS = 1.11 foreign"
6790 echo
6791 echo "SUBDIRS = $subdirs"
6792 echo
6793 echo "ACLOCAL_AMFLAGS = -I $m4base"
6794 ) > "$testdir/Makefile.am"
6796 # Create configure.ac.
6797 (echo "# Process this file with autoconf to produce a configure script."
6798 echo "AC_INIT([dummy], [0])"
6799 if test "$auxdir" != "."; then
6800 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6802 echo "AM_INIT_AUTOMAKE"
6803 echo
6804 echo "AC_CONFIG_HEADERS([config.h])"
6805 echo
6806 echo "AC_PROG_CC"
6807 echo "AC_PROG_INSTALL"
6808 echo "AC_PROG_MAKE_SET"
6809 echo
6810 echo "# For autobuild."
6811 echo "AC_CANONICAL_BUILD"
6812 echo "AC_CANONICAL_HOST"
6813 echo
6814 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
6815 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
6816 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6817 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6819 func_emit_pre_early_macros false '' "$final_modules"
6821 if test -n "$any_uses_subdirs"; then
6822 echo "AM_PROG_CC_C_O"
6823 echo
6825 for module in $final_modules; do
6826 if $single_configure; then
6827 func_verify_module
6828 else
6829 func_verify_nontests_module
6831 if test -n "$module"; then
6832 func_get_autoconf_early_snippet "$module"
6834 done \
6835 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)])/\1/'
6836 if test "$libtool" = true; then
6837 echo "LT_INIT([win32-dll])"
6838 echo "LT_LANG([C++])"
6839 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6840 echo "gl_cond_libtool=true"
6841 else
6842 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6843 echo "gl_cond_libtool=false"
6844 echo "gl_libdeps="
6845 echo "gl_ltlibdeps="
6847 # Wrap the set of autoconf snippets into an autoconf macro that is then
6848 # invoked. This is needed because autoconf does not support AC_REQUIRE
6849 # at the top level:
6850 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6851 # but we want the AC_REQUIRE to have its normal meaning (provide one
6852 # expansion of the required macro before the current point, and only one
6853 # expansion total).
6854 echo "AC_DEFUN([gl_INIT], ["
6855 if test "$auxdir" != "build-aux"; then
6856 sed_replace_build_aux='
6858 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6859 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6862 else
6863 sed_replace_build_aux="$sed_noop"
6865 echo "gl_m4_base='$m4base'"
6866 func_emit_initmacro_start $macro_prefix false
6867 func_emit_shellvars_init false "$sourcebase"
6868 if $single_configure; then
6869 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false false
6870 else
6871 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module true false false
6873 func_emit_initmacro_end $macro_prefix false
6874 if $single_configure; then
6875 echo " gltests_libdeps="
6876 echo " gltests_ltlibdeps="
6877 func_emit_initmacro_start ${macro_prefix}tests true
6878 func_emit_shellvars_init true "$testsbase"
6879 # Define a tests witness macro.
6880 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
6881 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6882 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6883 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6884 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true false false
6885 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6886 func_emit_initmacro_end ${macro_prefix}tests true
6888 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6889 # created using libtool, because libtool already handles the dependencies.
6890 if test "$libtool" != true; then
6891 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6892 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6893 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6894 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6895 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6897 if $single_configure; then
6898 if $use_libtests; then
6899 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6900 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6903 echo "])"
6904 func_emit_initmacro_done $macro_prefix $sourcebase
6905 if $single_configure; then
6906 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6908 echo
6909 echo "gl_INIT"
6910 echo
6911 if test -n "$subdirs_with_configure_ac"; then
6912 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6914 makefiles="Makefile"
6915 for d in $subdirs; do
6916 # For subdirs that have a configure.ac by their own, it's the subdir's
6917 # configure.ac which creates the subdir's Makefile.am, not this one.
6918 case " $subdirs_with_configure_ac " in
6919 *" $d "*) ;;
6920 *) func_append makefiles " $d/Makefile" ;;
6921 esac
6922 done
6923 echo "AC_CONFIG_FILES([$makefiles])"
6924 echo "AC_OUTPUT"
6925 ) > "$testdir/configure.ac"
6927 # Create autogenerated files.
6928 (cd "$testdir"
6929 # Do not use "${AUTORECONF} --force --install", because it may invoke
6930 # autopoint, which brings in older versions of some of our .m4 files.
6931 if test -f $m4base/gettext.m4; then
6932 func_execute_command ${AUTOPOINT} --force || func_exit 1
6933 for f in $m4base/*.m4~; do
6934 if test -f $f; then
6935 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6937 done
6939 if test "$libtool" = true; then
6940 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6942 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6943 if ! test -d build-aux; then
6944 func_execute_command mkdir build-aux || func_exit 1
6946 func_execute_command ${AUTOCONF} || func_exit 1
6947 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6948 func_execute_command ${AUTOHEADER} &&
6949 func_execute_command touch config.h.in ||
6950 func_exit 1
6951 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6952 rm -rf autom4te.cache
6953 ) || func_exit 1
6954 if $inctests && ! $single_configure; then
6955 # Create autogenerated files.
6956 (cd "$testdir/$testsbase" || func_exit 1
6957 # Do not use "${AUTORECONF} --force --install", because it may invoke
6958 # autopoint, which brings in older versions of some of our .m4 files.
6959 if test -f ../$m4base/gettext.m4; then
6960 func_execute_command ${AUTOPOINT} --force || func_exit 1
6961 for f in ../$m4base/*.m4~; do
6962 if test -f $f; then
6963 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6965 done
6967 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6968 if ! test -d ../build-aux; then
6969 func_execute_command mkdir ../build-aux
6971 func_execute_command ${AUTOCONF} || func_exit 1
6972 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6973 func_execute_command ${AUTOHEADER} &&
6974 func_execute_command touch config.h.in ||
6975 func_exit 1
6976 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6977 rm -rf autom4te.cache
6978 ) || func_exit 1
6980 # Need to run configure and make once, to create built files that are to be
6981 # distributed (such as parse-datetime.c).
6982 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6983 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6984 cleaned_files=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6985 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6986 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6987 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6988 # such $(FOO_H) because they don't refer to distributed files.
6989 built_sources=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6990 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6991 | sed -e "$sed_remove_make_variables"`
6992 distributed_built_sources=`for file in $built_sources; do
6993 case "$cleaned_files" in
6994 *" "$file" "*) ;;
6995 *) echo $file ;;
6996 esac;
6997 done`
6998 tests_distributed_built_sources=
6999 if $inctests; then
7000 # Likewise for built files in the $testsbase directory.
7001 tests_cleaned_files=`combine_lines < "$testdir/$testsbase/Makefile.am" \
7002 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
7003 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
7004 tests_built_sources=`combine_lines < "$testdir/$testsbase/Makefile.am" \
7005 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
7006 | sed -e "$sed_remove_make_variables"`
7007 tests_distributed_built_sources=`for file in $tests_built_sources; do
7008 case "$tests_cleaned_files" in
7009 *" "$file" "*) ;;
7010 *) echo $file ;;
7011 esac;
7012 done`
7014 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
7015 (cd "$testdir"
7016 ./configure || func_exit 1
7017 if test -n "$distributed_built_sources"; then
7018 cd "$sourcebase"
7019 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
7020 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
7021 built_sources \
7022 || func_exit 1
7023 cd ..
7025 if test -n "$tests_distributed_built_sources"; then
7026 cd "$testsbase"
7027 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
7028 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
7029 built_sources \
7030 || func_exit 1
7031 cd ..
7033 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
7034 distclean \
7035 || func_exit 1
7036 ) || func_exit 1
7038 (cd "$testdir"
7039 if test -f build-aux/test-driver; then
7040 patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver.diff \
7041 || patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver-1.16.3.diff \
7042 || func_exit 1
7044 ) || func_exit 1
7047 # func_create_megatestdir megatestdir allmodules
7048 # Input:
7049 # - local_gnulib_path from --local-dir
7050 # - modcache true or false, from --cache-modules/--no-cache-modules
7051 # - auxdir directory relative to destdir where to place build aux files
7052 func_create_megatestdir ()
7054 megatestdir="$1"
7055 allmodules="$2"
7056 if test -z "$allmodules"; then
7057 allmodules=`func_all_modules`
7060 megasubdirs=
7061 # First, all modules one by one.
7062 for onemodule in $allmodules; do
7063 func_create_testdir "$megatestdir/$onemodule" $onemodule
7064 func_append megasubdirs "$onemodule "
7065 done
7066 # Then, all modules all together.
7067 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
7068 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
7069 func_create_testdir "$megatestdir/ALL" "$allmodules"
7070 func_append megasubdirs "ALL"
7072 # Create autobuild.
7073 cvsdate=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
7074 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
7075 | sed -e 's,January,01,' -e 's,Jan,01,' \
7076 -e 's,February,02,' -e 's,Feb,02,' \
7077 -e 's,March,03,' -e 's,Mar,03,' \
7078 -e 's,April,04,' -e 's,Apr,04,' \
7079 -e 's,May,05,' \
7080 -e 's,June,06,' -e 's,Jun,06,' \
7081 -e 's,July,07,' -e 's,Jul,07,' \
7082 -e 's,August,08,' -e 's,Aug,08,' \
7083 -e 's,September,09,' -e 's,Sep,09,' \
7084 -e 's,October,10,' -e 's,Oct,10,' \
7085 -e 's,November,11,' -e 's,Nov,11,' \
7086 -e 's,December,12,' -e 's,Dec,12,' \
7087 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
7088 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
7089 (echo '#!/bin/sh'
7090 echo "CVSDATE=$cvsdate"
7091 echo ": \${MAKE=make}"
7092 echo "test -d logs || mkdir logs"
7093 echo "for module in $megasubdirs; do"
7094 echo " echo \"Working on module \$module...\""
7095 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
7096 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
7097 echo " echo"
7098 echo " set -x"
7099 echo " : autobuild project... \$module"
7100 echo " : autobuild revision... cvs-\$CVSDATE-000000"
7101 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
7102 echo " : autobuild hostname... \`hostname\`"
7103 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
7104 echo " echo rc=\$?"
7105 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
7106 echo "done"
7107 ) > "$megatestdir/do-autobuild"
7108 chmod a+x "$megatestdir/do-autobuild"
7110 # Create Makefile.am.
7111 (echo "## Process this file with automake to produce Makefile.in."
7112 echo
7113 echo "AUTOMAKE_OPTIONS = 1.11 foreign"
7114 echo
7115 echo "SUBDIRS = $megasubdirs"
7116 echo
7117 echo "EXTRA_DIST = do-autobuild"
7118 ) > "$megatestdir/Makefile.am"
7120 # Create configure.ac.
7121 (echo "# Process this file with autoconf to produce a configure script."
7122 echo "AC_INIT([dummy], [0])"
7123 if test "$auxdir" != "."; then
7124 echo "AC_CONFIG_AUX_DIR([$auxdir])"
7126 echo "AM_INIT_AUTOMAKE"
7127 echo
7128 echo "AC_PROG_MAKE_SET"
7129 echo
7130 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
7131 echo "AC_CONFIG_FILES([Makefile])"
7132 echo "AC_OUTPUT"
7133 ) > "$megatestdir/configure.ac"
7135 # Create autogenerated files.
7136 (cd "$megatestdir"
7137 # Do not use "${AUTORECONF} --install", because autoreconf operates
7138 # recursively, but the subdirectories are already finished, therefore
7139 # calling autoreconf here would only waste lots of CPU time.
7140 func_execute_command ${ACLOCAL} || func_exit 1
7141 func_execute_command mkdir build-aux
7142 func_execute_command ${AUTOCONF} || func_exit 1
7143 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
7144 rm -rf autom4te.cache
7145 if test -f build-aux/test-driver; then
7146 patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver.diff \
7147 || patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver-1.16.3.diff \
7148 || func_exit 1
7150 ) || func_exit 1
7153 case $mode in
7154 "" )
7155 func_fatal_error "no mode specified" ;;
7157 list )
7158 func_all_modules
7161 find )
7162 # sed expression that converts a literal to a basic regular expression.
7163 # Needs to handle . [ \ * ^ $.
7164 sed_literal_to_basic_regex='s/\\/\\\\/g
7165 s/\[/\\[/g
7166 s/\^/\\^/g
7167 s/\([.*$]\)/[\1]/g'
7168 # func_prefixed_modules_in_dir dir
7169 # outputs all module files in dir to standard output, with dir as prefix.
7170 func_prefixed_modules_in_dir ()
7172 (test -d "$1" && cd "$1" && find modules -type f -print | sed -e "s|^|$1/|")
7174 for filename
7176 if test -f "$gnulib_dir/$filename" \
7177 || func_lookup_local_file "$filename"; then
7178 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
7179 filename_line_regex='^'"$filename_anywhere_regex"'$'
7180 module_candidates=`
7182 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
7183 func_path_foreach "$local_gnulib_path" func_prefixed_modules_in_dir %dir% | xargs -n 100 grep -l "$filename_anywhere_regex" /dev/null | sed -e 's,^.*/modules/,,' -e 's,\.diff$,,'
7185 | func_sanitize_modulelist \
7186 | LC_ALL=C sort -u
7188 for module in $module_candidates; do
7189 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
7190 echo $module
7192 done
7193 else
7194 func_warning "file $filename does not exist"
7196 done
7199 import | add-import | remove-import | update )
7201 # Where to import.
7202 if test -z "$destdir"; then
7203 destdir=.
7205 test -d "$destdir" \
7206 || func_fatal_error "destination directory does not exist: $destdir"
7208 # Prefer configure.ac to configure.in.
7209 if test -f "$destdir"/configure.ac; then
7210 configure_ac="$destdir/configure.ac"
7211 else
7212 if test -f "$destdir"/configure.in; then
7213 configure_ac="$destdir/configure.in"
7214 else
7215 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
7219 # Analyze configure.ac.
7220 guessed_auxdir="."
7221 guessed_libtool=false
7222 guessed_m4dirs=
7223 my_sed_traces='
7224 s,#.*$,,
7225 s,^dnl .*$,,
7226 s, dnl .*$,,
7227 /AC_CONFIG_AUX_DIR/ {
7228 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
7230 /A[CM]_PROG_LIBTOOL/ {
7231 s,^.*$,guessed_libtool=true,p
7233 /AC_CONFIG_MACRO_DIR/ {
7234 s,^.*AC_CONFIG_MACRO_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_m4dirs="${guessed_m4dirs} \1",p
7236 /AC_CONFIG_MACRO_DIRS/ {
7237 s,^.*AC_CONFIG_MACRO_DIRS([[ ]*\([^]"$`\\)]*\).*$,guessed_m4dirs="${guessed_m4dirs} \1",p
7239 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
7241 if test -z "$auxdir"; then
7242 auxdir="$guessed_auxdir"
7245 # Determine where to apply func_import.
7246 if test "$mode" = import; then
7247 # Apply func_import to a particular gnulib directory.
7248 # The command line contains the complete specification; don't look at
7249 # the contents of gnulib-cache.m4.
7250 test -n "$supplied_libname" || supplied_libname=true
7251 test -n "$sourcebase" || sourcebase="lib"
7252 test -n "$m4base" || m4base="m4"
7253 test -n "$docbase" || docbase="doc"
7254 test -n "$testsbase" || testsbase="tests"
7255 test -n "$macro_prefix" || macro_prefix="gl"
7256 func_import "$*"
7257 else
7258 if test -n "$m4base"; then
7259 # Apply func_import to a particular gnulib directory.
7260 # Any number of additional modules can be given.
7261 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
7262 # First use of gnulib in the given m4base.
7263 test -n "$supplied_libname" || supplied_libname=true
7264 test -n "$sourcebase" || sourcebase="lib"
7265 test -n "$docbase" || docbase="doc"
7266 test -n "$testsbase" || testsbase="tests"
7267 test -n "$macro_prefix" || macro_prefix="gl"
7269 func_import "$*"
7270 else
7271 # Apply func_import to all gnulib directories.
7272 # To get this list of directories, look at Makefile.am. (Not at
7273 # configure, because it may be omitted from version control. Also,
7274 # don't run "find $destdir -name gnulib-cache.m4", as it might be
7275 # too expensive.)
7276 m4dirs=
7277 m4dirs_count=0
7278 if test -f "$destdir"/Makefile.am; then
7279 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
7280 m4dir_is_next=
7281 for arg in $aclocal_amflags; do
7282 if test -n "$m4dir_is_next"; then
7283 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
7284 case "$arg" in
7285 /*) ;;
7287 if test -f "$destdir/$arg"/gnulib-cache.m4; then
7288 func_append m4dirs " $arg"
7289 m4dirs_count=`expr $m4dirs_count + 1`
7292 esac
7293 m4dir_is_next=
7294 else
7295 if test "X$arg" = "X-I"; then
7296 m4dir_is_next=yes
7297 else
7298 m4dir_is_next=
7301 done
7302 for arg in $guessed_m4dirs; do
7303 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
7304 case "$arg" in
7305 /*) ;;
7307 if test -f "$destdir/$arg"/gnulib-cache.m4; then
7308 func_append m4dirs " $arg"
7309 m4dirs_count=`expr $m4dirs_count + 1`
7312 esac
7313 done
7314 else
7315 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
7316 if test -f "$destdir"/aclocal.m4; then
7317 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
7318 sedexpr2='s,^[^/]*$,.,'
7319 sedexpr3='s,/[^/]*$,,'
7320 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
7321 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
7322 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
7325 if test $m4dirs_count = 0; then
7326 # First use of gnulib in a package.
7327 # Any number of additional modules can be given.
7328 test -n "$supplied_libname" || supplied_libname=true
7329 test -n "$sourcebase" || sourcebase="lib"
7330 m4base="m4"
7331 test -n "$docbase" || docbase="doc"
7332 test -n "$testsbase" || testsbase="tests"
7333 test -n "$macro_prefix" || macro_prefix="gl"
7334 func_import "$*"
7335 else
7336 if test $m4dirs_count = 1; then
7337 # There's only one use of gnulib here. Assume the user means it.
7338 # Any number of additional modules can be given.
7339 for m4base in $m4dirs; do
7340 func_import "$*"
7341 done
7342 else
7343 # Ambiguous - guess what the user meant.
7344 if test $# = 0; then
7345 # No further arguments. Guess the user wants to update all of them.
7346 for m4base in $m4dirs; do
7347 # Perform func_import in a subshell, so that variable values
7348 # such as
7349 # local_gnulib_path, incobsolete, inc_cxx_tests,
7350 # inc_longrunning_tests, inc_privileged_tests,
7351 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
7352 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
7353 # makefile_name, tests_makefile_name, automake_subdir, libtool,
7354 # macro_prefix, po_domain, witness_c_macro, vc_files
7355 # don't propagate from one directory to another.
7356 (func_import) || func_exit 1
7357 done
7358 else
7359 # Really ambiguous.
7360 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
7368 create-testdir )
7369 if test -z "$destdir"; then
7370 func_fatal_error "please specify --dir option"
7372 mkdir "$destdir"
7373 test -d "$destdir" \
7374 || func_fatal_error "could not create destination directory"
7375 test -n "$auxdir" || auxdir="build-aux"
7376 func_create_testdir "$destdir" "$*"
7379 create-megatestdir )
7380 if test -z "$destdir"; then
7381 func_fatal_error "please specify --dir option"
7383 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7384 test -n "$auxdir" || auxdir="build-aux"
7385 func_create_megatestdir "$destdir" "$*"
7388 test )
7389 test -n "$destdir" || destdir=testdir$$
7390 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7391 test -n "$auxdir" || auxdir="build-aux"
7392 func_create_testdir "$destdir" "$*"
7393 cd "$destdir"
7394 mkdir build
7395 cd build
7396 ../configure || func_exit 1
7397 $MAKE || func_exit 1
7398 $MAKE check || func_exit 1
7399 $MAKE distclean || func_exit 1
7400 remaining=`find . -type f -print`
7401 if test -n "$remaining"; then
7402 echo "Remaining files:" $remaining 1>&2
7403 echo "gnulib-tool: *** Stop." 1>&2
7404 func_exit 1
7406 cd ..
7407 cd ..
7408 rm -rf "$destdir"
7411 megatest )
7412 test -n "$destdir" || destdir=testdir$$
7413 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7414 test -n "$auxdir" || auxdir="build-aux"
7415 func_create_megatestdir "$destdir" "$*"
7416 cd "$destdir"
7417 mkdir build
7418 cd build
7419 ../configure
7420 $MAKE
7421 $MAKE check
7422 $MAKE distclean
7423 remaining=`find . -type f -print`
7424 if test -n "$remaining"; then
7425 echo "Remaining files:" $remaining 1>&2
7426 echo "gnulib-tool: *** Stop." 1>&2
7427 func_exit 1
7429 cd ..
7430 cd ..
7431 rm -rf "$destdir"
7434 extract-description )
7435 for module
7437 func_verify_module
7438 if test -n "$module"; then
7439 func_get_description "$module"
7441 done
7444 extract-comment )
7445 for module
7447 func_verify_module
7448 if test -n "$module"; then
7449 func_get_comment "$module"
7451 done
7454 extract-status )
7455 for module
7457 func_verify_module
7458 if test -n "$module"; then
7459 func_get_status "$module"
7461 done
7464 extract-notice )
7465 for module
7467 func_verify_module
7468 if test -n "$module"; then
7469 func_get_notice "$module"
7471 done
7474 extract-applicability )
7475 for module
7477 func_verify_module
7478 if test -n "$module"; then
7479 func_get_applicability "$module"
7481 done
7484 extract-filelist )
7485 for module
7487 func_verify_module
7488 if test -n "$module"; then
7489 func_get_filelist "$module"
7491 done
7494 extract-dependencies )
7495 if test -n "$avoidlist"; then
7496 func_fatal_error "cannot combine --avoid and --extract-dependencies"
7498 for module
7500 func_verify_module
7501 if test -n "$module"; then
7502 func_get_dependencies "$module"
7504 done
7507 extract-recursive-dependencies )
7508 if test -n "$avoidlist"; then
7509 func_fatal_error "cannot combine --avoid and --extract-recursive-dependencies"
7511 for module
7513 func_verify_module
7514 if test -n "$module"; then
7515 func_get_dependencies_recursively "$module"
7517 done
7520 extract-autoconf-snippet )
7521 for module
7523 func_verify_module
7524 if test -n "$module"; then
7525 func_get_autoconf_snippet "$module"
7527 done
7530 extract-automake-snippet )
7531 for module
7533 func_verify_module
7534 if test -n "$module"; then
7535 func_get_automake_snippet "$module"
7537 done
7540 extract-include-directive )
7541 for module
7543 func_verify_module
7544 if test -n "$module"; then
7545 func_get_include_directive "$module"
7547 done
7550 extract-link-directive )
7551 for module
7553 func_verify_module
7554 if test -n "$module"; then
7555 func_get_link_directive "$module"
7557 done
7560 extract-recursive-link-directive )
7561 if test -n "$avoidlist"; then
7562 func_fatal_error "cannot combine --avoid and --extract-recursive-link-directive"
7564 for module
7566 func_verify_module
7567 if test -n "$module"; then
7568 func_get_link_directive_recursively "$module"
7570 done
7573 extract-license )
7574 for module
7576 func_verify_module
7577 if test -n "$module"; then
7578 func_get_license "$module"
7580 done
7583 extract-maintainer )
7584 for module
7586 func_verify_module
7587 if test -n "$module"; then
7588 func_get_maintainer "$module"
7590 done
7593 extract-tests-module )
7594 for module
7596 func_verify_module
7597 if test -n "$module"; then
7598 func_get_tests_module "$module"
7600 done
7603 copy-file )
7604 # Verify the number of arguments.
7605 if test $# -lt 1 || test $# -gt 2; then
7606 func_fatal_error "invalid number of arguments for --$mode"
7609 # The first argument is the file to be copied.
7610 f="$1"
7611 # Verify the file exists.
7612 func_lookup_file "$f"
7614 # The second argument is the destination; either a directory ot a file.
7615 # It defaults to the current directory.
7616 dest="$2"
7617 test -n "$dest" || dest='.'
7618 test -n "$sourcebase" || sourcebase="lib"
7619 test -n "$m4base" || m4base="m4"
7620 test -n "$docbase" || docbase="doc"
7621 test -n "$testsbase" || testsbase="tests"
7622 test -n "$auxdir" || auxdir="build-aux"
7623 rewritten='%REWRITTEN%'
7624 sed_rewrite_files="\
7625 s,^build-aux/,$rewritten$auxdir/,
7626 s,^doc/,$rewritten$docbase/,
7627 s,^lib/,$rewritten$sourcebase/,
7628 s,^m4/,$rewritten$m4base/,
7629 s,^tests/,$rewritten$testsbase/,
7630 s,^top/,$rewritten,
7631 s,^$rewritten,,"
7632 if test -d "$dest"; then
7633 destdir="$dest"
7634 g=`echo "$f" | sed -e "$sed_rewrite_files"`
7635 else
7636 destdir=`dirname "$dest"`
7637 g=`basename "$dest"`
7640 # Create the directory for destfile.
7641 d=`dirname "$destdir/$g"`
7642 if $doit; then
7643 if test -n "$d" && test ! -d "$d"; then
7644 mkdir -p "$d" || func_fatal_error "failed"
7647 # Copy the file.
7648 func_dest_tmpfilename "$g"
7649 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
7650 func_ensure_writable "$tmpfile"
7651 already_present=true
7652 if test -f "$destdir/$g"; then
7653 # The file already exists.
7654 func_update_file
7655 else
7656 # Install the file.
7657 # Don't protest if the file should be there but isn't: it happens
7658 # frequently that developers don't put autogenerated files under version
7659 # control.
7660 func_add_file
7662 rm -f "$tmpfile"
7666 func_fatal_error "unknown operation mode --$mode" ;;
7667 esac
7669 if test "$copymode" = hardlink -o "$lcopymode" = hardlink; then
7670 # Setting hard links modifies the ctime of files in the gnulib checkout.
7671 # This disturbs the result of the next "gitk" invocation.
7672 # Workaround: Let git scan the files. This can be done through
7673 # "git update-index --refresh" or "git status" or "git diff".
7674 if test -d "$gnulib_dir"/.git \
7675 && (git --version) >/dev/null 2>/dev/null; then
7676 (cd "$gnulib_dir" && git update-index --refresh >/dev/null)
7680 rm -rf "$tmp"
7681 # Undo the effect of the previous 'trap' command. Some shellology:
7682 # We cannot use "trap - EXIT HUP INT QUIT PIPE TERM", because Solaris sh would
7683 # attempt to execute the command "-". "trap '' ..." is fine only for signal EXIT
7684 # (= normal exit); for the others we need to call 'exit' explicitly. The value
7685 # of $? is 128 + signal number and is set before the trap-registered command is
7686 # run.
7687 trap '' EXIT
7688 trap 'func_exit $?' HUP INT QUIT PIPE TERM
7690 exit 0
7692 # Local Variables:
7693 # indent-tabs-mode: nil
7694 # whitespace-check-buffer-indent: nil
7695 # End: