gnulib-tool: Support --import with just a few tests, not --with-tests.
[gnulib.git] / gnulib-tool
blob34d198f6d7fc972a85997b46ab18f452318526f2
1 #! /bin/sh
3 # Copyright (C) 2002-2019 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 progname=$0
23 package=gnulib
24 nl='
26 IFS=" "" $nl"
28 # You can set AUTOCONFPATH to empty if autoconf 2.63 is already in your PATH.
29 AUTOCONFPATH=
30 #case $USER in
31 # bruno )
32 # AUTOCONFBINDIR=/arch/x86-linux/gnu-inst-autoconf/2.63/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
34 # ;;
35 #esac
37 # You can set AUTOMAKEPATH to empty if automake 1.11 is already in your PATH.
38 AUTOMAKEPATH=
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
41 GETTEXTPATH=
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
44 LIBTOOLPATH=
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
74 # You can set MAKE.
75 if test -z "${MAKE}"; then
76 MAKE=make
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <https://lists.gnu.org/r/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
90 *) true;; \
91 esac \
92 ; then
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
109 sed_noop='s,x,x,'
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # AIX 5.3 sed barfs over indented comments.
113 if echo fo | sed -e 's/f/g/
114 # s/o/u/
115 # indented comment
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
117 sed_comments=true
118 else
119 sed_comments=false
122 # func_usage
123 # outputs to stdout the --help usage message.
124 func_usage ()
126 echo "\
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
130 gnulib-tool --add-import [module1 ... moduleN]
131 gnulib-tool --remove-import [module1 ... moduleN]
132 gnulib-tool --update
133 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
134 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
135 gnulib-tool --test --dir=directory module1 ... moduleN
136 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
137 gnulib-tool --extract-description module
138 gnulib-tool --extract-comment module
139 gnulib-tool --extract-status module
140 gnulib-tool --extract-notice module
141 gnulib-tool --extract-applicability module
142 gnulib-tool --extract-filelist module
143 gnulib-tool --extract-dependencies module
144 gnulib-tool --extract-recursive-dependencies module
145 gnulib-tool --extract-autoconf-snippet module
146 gnulib-tool --extract-automake-snippet module
147 gnulib-tool --extract-include-directive module
148 gnulib-tool --extract-link-directive module
149 gnulib-tool --extract-recursive-link-directive module
150 gnulib-tool --extract-license module
151 gnulib-tool --extract-maintainer module
152 gnulib-tool --extract-tests-module module
153 gnulib-tool --copy-file file [destination]
155 Operation modes:
157 --list print the available module names
158 --find find the modules which contain the specified file
159 --import import the given modules into the current package
160 --add-import augment the list of imports from gnulib into the
161 current package, by adding the given modules;
162 if no modules are specified, update the current
163 package from the current gnulib
164 --remove-import reduce the list of imports from gnulib into the
165 current package, by removing the given modules
166 --update update the current package, restore files omitted
167 from version control
168 --create-testdir create a scratch package with the given modules
169 --create-megatestdir create a mega scratch package with the given modules
170 one by one and all together
171 --test test the combination of the given modules
172 (recommended to use CC=\"gcc -Wall\" here)
173 --megatest test the given modules one by one and all together
174 (recommended to use CC=\"gcc -Wall\" here)
175 --extract-description extract the description
176 --extract-comment extract the comment
177 --extract-status extract the status (obsolete etc.)
178 --extract-notice extract the notice or banner
179 --extract-applicability extract the applicability
180 --extract-filelist extract the list of files
181 --extract-dependencies extract the dependencies
182 --extract-recursive-dependencies extract the dependencies of the module
183 and its dependencies, recursively, all
184 together, but without the conditions
185 --extract-autoconf-snippet extract the snippet for configure.ac
186 --extract-automake-snippet extract the snippet for library makefile
187 --extract-include-directive extract the #include directive
188 --extract-link-directive extract the linker directive
189 --extract-recursive-link-directive extract the linker directive of the
190 module and its dependencies,
191 recursively, all together
192 --extract-license report the license terms of the source files
193 under lib/
194 --extract-maintainer report the maintainer(s) inside gnulib
195 --extract-tests-module report the unit test module, if it exists
196 --copy-file copy a file that is not part of any module
197 --help Show this help text.
198 --version Show version and authorship information.
200 General options:
202 --dir=DIRECTORY Specify the target directory.
203 For --import, this specifies where your
204 configure.ac can be found. Defaults to current
205 directory.
206 --local-dir=DIRECTORY Specify a local override directory where to look
207 up files before looking in gnulib's directory.
208 --cache-modules Enable module caching optimization.
209 --no-cache-modules Disable module caching optimization.
210 --verbose Increase verbosity. May be repeated.
211 --quiet Decrease verbosity. May be repeated.
213 Options for --import, --add/remove-import, --update:
215 --dry-run Only print what would have been done.
217 Options for --import, --add/remove-import:
219 --with-tests Include unit tests for the included modules.
221 Options for --create-[mega]testdir, --[mega]test:
223 --without-tests Don't include unit tests for the included modules.
225 Options for --import, --add/remove-import,
226 --create-[mega]testdir, --[mega]test:
228 --with-obsolete Include obsolete modules when they occur among the
229 dependencies. By default, dependencies to obsolete
230 modules are ignored.
231 --with-c++-tests Include even unit tests for C++ interoperability.
232 --without-c++-tests Exclude unit tests for C++ interoperability.
233 --with-longrunning-tests
234 Include even unit tests that are long-runners.
235 --without-longrunning-tests
236 Exclude unit tests that are long-runners.
237 --with-privileged-tests
238 Include even unit tests that require root
239 privileges.
240 --without-privileged-tests
241 Exclude unit tests that require root privileges.
242 --with-unportable-tests
243 Include even unit tests that fail on some platforms.
244 --without-unportable-tests
245 Exclude unit tests that fail on some platforms.
246 --with-all-tests Include all kinds of problematic unit tests.
247 --avoid=MODULE Avoid including the given MODULE. Useful if you
248 have code that provides equivalent functionality.
249 This option can be repeated.
250 --conditional-dependencies
251 Support conditional dependencies (may save configure
252 time and object code).
253 --no-conditional-dependencies
254 Don't use conditional dependencies.
255 --libtool Use libtool rules.
256 --no-libtool Don't use libtool rules.
258 Options for --import, --add/remove-import:
260 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
261 --source-base=DIRECTORY
262 Directory relative to --dir where source code is
263 placed (default \"lib\").
264 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
265 placed (default \"m4\").
266 --po-base=DIRECTORY Directory relative to --dir where *.po files are
267 placed (default \"po\").
268 --doc-base=DIRECTORY Directory relative to --dir where doc files are
269 placed (default \"doc\").
270 --tests-base=DIRECTORY
271 Directory relative to --dir where unit tests are
272 placed (default \"tests\").
273 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
274 tools are placed (default comes from configure.ac).
275 --gnu-make Output for GNU Make instead of for the default
276 Automake
277 --lgpl[=2|=3orGPLv2|=3]
278 Abort if modules aren't available under the LGPL.
279 Also modify license template from GPL to LGPL.
280 The version number of the LGPL can be specified;
281 the default is currently LGPLv3.
282 --makefile-name=NAME Name of makefile in the source-base and tests-base
283 directories (default \"Makefile.am\", or
284 \"Makefile.in\" if --gnu-make).
285 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
286 'gl_INIT'. Default is 'gl'.
287 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
288 the package name. A suffix '-gnulib' is appended.
289 --witness-c-macro=NAME Specify the C macro that is defined when the
290 sources in this directory are compiled or used.
291 --vc-files Update version control related files.
292 --no-vc-files Don't update version control related files
293 (.gitignore and/or .cvsignore).
295 Options for --create-[mega]testdir, --[mega]test:
297 --single-configure Generate a single configure file, not a separate
298 configure file for the tests directory.
300 Options for --import, --add/remove-import, --update,
301 --create-[mega]testdir, --[mega]test:
303 -s, --symbolic, --symlink Make symbolic links instead of copying files.
304 --local-symlink Make symbolic links instead of copying files, only
305 for files from the local override directory.
306 -h, --hardlink Make hard links instead of copying files.
307 --local-hardlink Make hard links instead of copying files, only
308 for files from the local override directory.
310 Options for --import, --add/remove-import, --update:
312 -S, --more-symlinks Make symbolic links instead of copying files, and
313 don't replace copyright notices.
314 -H, --more-hardlinks Make hard links instead of copying files, and
315 don't replace copyright notices.
317 Report bugs to <bug-gnulib@gnu.org>."
320 # func_version
321 # outputs to stdout the --version message.
322 func_version ()
324 func_gnulib_dir
325 if test -d "$gnulib_dir"/.git \
326 && (git --version) >/dev/null 2>/dev/null \
327 && (date --version) >/dev/null 2>/dev/null; then
328 # gnulib checked out from git.
329 sed_extract_first_date='/^Date/{
330 s/^Date:[ ]*//p
333 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
334 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
335 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
336 date=`echo "$date" | sed -e "$sed_year_before_time"`
337 # Use GNU date to compute the time in GMT.
338 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
339 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
340 else
341 # gnulib copy without versioning information.
342 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
343 version=
345 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
346 echo "\
347 gnulib-tool (GNU $package $date)$version
348 Copyright (C) $year Free Software Foundation, Inc.
349 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
350 This is free software: you are free to change and redistribute it.
351 There is NO WARRANTY, to the extent permitted by law.
353 printf "Written by %s, %s, and %s.\n" "Bruno Haible" "Paul Eggert" "Simon Josefsson"
356 # func_emit_copyright_notice
357 # outputs to stdout a header for a generated file.
358 func_emit_copyright_notice ()
360 sed -n -e '/Copyright/ {
363 }' < "$self_abspathname"
364 echo "#"
365 echo "# This file is free software; you can redistribute it and/or modify"
366 echo "# it under the terms of the GNU General Public License as published by"
367 echo "# the Free Software Foundation; either version 3 of the License, or"
368 echo "# (at your option) any later version."
369 echo "#"
370 echo "# This file is distributed in the hope that it will be useful,"
371 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
372 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
373 echo "# GNU General Public License for more details."
374 echo "#"
375 echo "# You should have received a copy of the GNU General Public License"
376 echo "# along with this file. If not, see <https://www.gnu.org/licenses/>."
377 echo "#"
378 echo "# As a special exception to the GNU General Public License,"
379 echo "# this file may be distributed as part of a program that"
380 echo "# contains a configuration script generated by Autoconf, under"
381 echo "# the same distribution terms as the rest of that program."
382 echo "#"
383 echo "# Generated by gnulib-tool."
386 # func_exit STATUS
387 # exits with a given status.
388 # This function needs to be used, rather than 'exit', when a 'trap' handler is
389 # in effect that refers to $?.
390 func_exit ()
392 (exit $1); exit $1
395 # func_gnulib_dir
396 # locates the directory where the gnulib repository lives
397 # Input:
398 # - progname name of this program
399 # Sets variables
400 # - self_abspathname absolute pathname of gnulib-tool
401 # - gnulib_dir absolute pathname of gnulib repository
402 func_gnulib_dir ()
404 case "$progname" in
405 /* | ?:*) self_abspathname="$progname" ;;
406 */*) self_abspathname=`pwd`/"$progname" ;;
408 # Look in $PATH.
409 # Iterate through the elements of $PATH.
410 # We use IFS=: instead of
411 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
412 # because the latter does not work when some PATH element contains spaces.
413 # We use a canonicalized $pathx instead of $PATH, because empty PATH
414 # elements are by definition equivalent to '.', however field splitting
415 # according to IFS=: loses empty fields in many shells:
416 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
417 # beginning, at the end, and in the middle),
418 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
419 # at the beginning and at the end,
420 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
421 # Solaris lose empty fields at the end.
422 # The 'case' statement is an optimization, to avoid evaluating the
423 # explicit canonicalization command when $PATH contains no empty fields.
424 self_abspathname=
425 if test "$PATH_SEPARATOR" = ";"; then
426 # On Windows, programs are searched in "." before $PATH.
427 pathx=".;$PATH"
428 else
429 # On Unix, we have to convert empty PATH elements to ".".
430 pathx="$PATH"
431 case :$PATH: in
432 *::*)
433 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
435 esac
437 save_IFS="$IFS"
438 IFS="$PATH_SEPARATOR"
439 for d in $pathx; do
440 IFS="$save_IFS"
441 test -z "$d" && d=.
442 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
443 self_abspathname="$d/$progname"
444 break
446 done
447 IFS="$save_IFS"
448 if test -z "$self_abspathname"; then
449 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
452 esac
453 while test -h "$self_abspathname"; do
454 # Resolve symbolic link.
455 linkval=`func_readlink "$self_abspathname"`
456 test -n "$linkval" || break
457 case "$linkval" in
458 /* | ?:* ) self_abspathname="$linkval" ;;
459 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
460 esac
461 done
462 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
465 # func_tmpdir
466 # creates a temporary directory.
467 # Input:
468 # - progname name of this program
469 # Sets variable
470 # - tmp pathname of freshly created temporary directory
471 func_tmpdir ()
473 # Use the environment variable TMPDIR, falling back to /tmp. This allows
474 # users to specify a different temporary directory, for example, if their
475 # /tmp is filled up or too small.
476 : ${TMPDIR=/tmp}
478 # Use the mktemp program if available. If not available, hide the error
479 # message.
480 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
481 test -n "$tmp" && test -d "$tmp"
482 } ||
484 # Use a simple mkdir command. It is guaranteed to fail if the directory
485 # already exists. $RANDOM is bash specific and expands to empty in shells
486 # other than bash, ksh and zsh. Its use does not increase security;
487 # rather, it minimizes the probability of failure in a very cluttered /tmp
488 # directory.
489 tmp=$TMPDIR/gl$$-$RANDOM
490 (umask 077 && mkdir "$tmp")
491 } ||
493 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
494 func_exit 1
498 # func_append var value
499 # appends the given value to the shell variable var.
500 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
501 # Use bash's += operator. It reduces complexity of appending repeatedly to
502 # a single variable from O(n^2) to O(n).
503 func_append ()
505 eval "$1+=\"\$2\""
507 fast_func_append=true
508 else
509 func_append ()
511 eval "$1=\"\$$1\$2\""
513 fast_func_append=false
516 # func_remove_prefix var prefix
517 # removes the given prefix from the value of the shell variable var.
518 # var should be the name of a shell variable.
519 # Its value should not contain a newline and not start or end with whitespace.
520 # prefix should not contain the characters "$`\{}[]^|.
521 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
522 func_remove_prefix ()
524 eval "$1=\${$1#\$2}"
526 fast_func_remove_prefix=true
527 else
528 func_remove_prefix ()
530 eval "value=\"\$$1\""
531 prefix="$2"
532 case "$prefix" in
533 *.*)
534 sed_escape_dots='s/\([.]\)/\\\1/g'
535 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
537 esac
538 value=`echo "$value" | sed -e "s|^${prefix}||"`
539 eval "$1=\"\$value\""
541 fast_func_remove_prefix=false
544 # Determine whether we should use ':' or ';' as PATH_SEPARATOR.
545 func_determine_path_separator ()
547 if test "${PATH_SEPARATOR+set}" != set; then
548 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
549 # contains only /bin. Note that ksh looks also at the FPATH variable,
550 # so we have to set that as well for the test.
551 PATH_SEPARATOR=:
552 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
553 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
554 || PATH_SEPARATOR=';'
559 # func_path_append pathvar directory
560 # appends directory to pathvar, delimiting directories by PATH_SEPARATOR.
561 func_path_append ()
563 if eval "test -n \"\$$1\""; then
564 func_append "$1" "$PATH_SEPARATOR$2"
565 else
566 eval "$1=\$2"
570 # func_path_foreach_inner
571 # helper for func_path_foreach because we need new 'args' array
572 # Input:
573 # - fpf_dir directory from local_gnulib_path
574 # - fpf_cb callback to be run for fpf_dir
575 func_path_foreach_inner ()
577 set %start% "$@"
578 for _fpf_arg
580 case "$_fpf_arg" in
581 %start%)
582 set dummy
584 %dir%)
585 set "$@" "$fpf_dir"
588 set "$@" "$_fpf_arg"
590 esac
591 done
592 shift
594 "$fpf_cb" "$@"
597 # func_path_foreach path method args
598 # Execute method for each directory in path. The method will be called
599 # like `method args` while any argument '%dir%' within args will be replaced
600 # with processed directory from path.
601 func_path_foreach ()
603 fpf_dirs="$1"; shift
604 fpf_cb="$1"; shift
605 fpf_rc=false
607 fpf_save_IFS="$IFS"
608 IFS="$PATH_SEPARATOR"
609 for fpf_dir in $fpf_dirs
611 IFS="$fpf_save_IFS"
612 func_path_foreach_inner "$@" && fpf_rc=:
613 done
614 IFS="$fpf_save_IFS"
615 $fpf_rc
618 # func_remove_suffix var suffix
619 # removes the given suffix from the value of the shell variable var.
620 # var should be the name of a shell variable.
621 # Its value should not contain a newline and not start or end with whitespace.
622 # suffix should not contain the characters "$`\{}[]^|.
623 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
624 func_remove_suffix ()
626 eval "$1=\${$1%\$2}"
628 fast_func_remove_suffix=true
629 else
630 func_remove_suffix ()
632 eval "value=\"\$$1\""
633 suffix="$2"
634 case "$suffix" in
635 *.*)
636 sed_escape_dots='s/\([.]\)/\\\1/g'
637 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
639 esac
640 value=`echo "$value" | sed -e "s|${suffix}\$||"`
641 eval "$1=\"\$value\""
643 fast_func_remove_suffix=false
646 # func_fatal_error message
647 # outputs to stderr a fatal error message, and terminates the program.
648 # Input:
649 # - progname name of this program
650 func_fatal_error ()
652 echo "$progname: *** $1" 1>&2
653 echo "$progname: *** Stop." 1>&2
654 func_exit 1
657 # func_warning message
658 # Outputs to stderr a warning message,
659 func_warning ()
661 echo "gnulib-tool: warning: $1" 1>&2
664 # func_readlink SYMLINK
665 # outputs the target of the given symlink.
666 if (type readlink) > /dev/null 2>&1; then
667 func_readlink ()
669 # Use the readlink program from GNU coreutils.
670 readlink "$1"
672 else
673 func_readlink ()
675 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
676 # would do the wrong thing if the link target contains " -> ".
677 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
681 # func_relativize DIR1 DIR2
682 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
683 # Input:
684 # - DIR1 relative pathname, relative to the current directory
685 # - DIR2 relative pathname, relative to the current directory
686 # Output:
687 # - reldir relative pathname of DIR2, relative to DIR1
688 func_relativize ()
690 dir0=`pwd`
691 dir1="$1"
692 dir2="$2"
693 sed_first='s,^\([^/]*\)/.*$,\1,'
694 sed_rest='s,^[^/]*/*,,'
695 sed_last='s,^.*/\([^/]*\)$,\1,'
696 sed_butlast='s,/*[^/]*$,,'
697 while test -n "$dir1"; do
698 first=`echo "$dir1" | sed -e "$sed_first"`
699 if test "$first" != "."; then
700 if test "$first" = ".."; then
701 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
702 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
703 else
704 first2=`echo "$dir2" | sed -e "$sed_first"`
705 if test "$first2" = "$first"; then
706 dir2=`echo "$dir2" | sed -e "$sed_rest"`
707 else
708 dir2="../$dir2"
710 dir0="$dir0"/"$first"
713 dir1=`echo "$dir1" | sed -e "$sed_rest"`
714 done
715 reldir="$dir2"
718 # func_relconcat DIR1 DIR2
719 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
720 # Input:
721 # - DIR1 relative pathname, relative to the current directory
722 # - DIR2 relative pathname, relative to DIR1
723 # Output:
724 # - relconcat DIR1/DIR2, relative to the current directory
725 func_relconcat ()
727 dir1="$1"
728 dir2="$2"
729 sed_first='s,^\([^/]*\)/.*$,\1,'
730 sed_rest='s,^[^/]*/*,,'
731 sed_last='s,^.*/\([^/]*\)$,\1,'
732 sed_butlast='s,/*[^/]*$,,'
733 while true; do
734 first=`echo "$dir2" | sed -e "$sed_first"`
735 if test "$first" = "."; then
736 dir2=`echo "$dir2" | sed -e "$sed_rest"`
737 if test -z "$dir2"; then
738 relconcat="$dir1"
739 break
741 else
742 last=`echo "$dir1" | sed -e "$sed_last"`
743 while test "$last" = "."; do
744 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
745 last=`echo "$dir1" | sed -e "$sed_last"`
746 done
747 if test -z "$dir1"; then
748 relconcat="$dir2"
749 break
751 if test "$first" = ".."; then
752 if test "$last" = ".."; then
753 relconcat="$dir1/$dir2"
754 break
756 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
757 dir2=`echo "$dir2" | sed -e "$sed_rest"`
758 if test -z "$dir1"; then
759 relconcat="$dir2"
760 break
762 if test -z "$dir2"; then
763 relconcat="$dir1"
764 break
766 else
767 relconcat="$dir1/$dir2"
768 break
771 done
774 # func_ln_s SRC DEST
775 # Like ln -s, except use cp -p if ln -s fails.
776 func_ln_s ()
778 ln -s "$1" "$2" || {
779 echo "$progname: ln -s failed; falling back on cp -p" >&2
781 case "$1" in
782 /* | ?:*) # SRC is absolute.
783 cp_src="$1" ;;
784 *) # SRC is relative to the directory of DEST.
785 case "$2" in
786 */*) cp_src="${2%/*}/$1" ;;
787 *) cp_src="$1" ;;
788 esac
790 esac
792 cp -p "$cp_src" "$2"
796 # func_symlink_target SRC DEST
797 # Determines LINK_TARGET such that "ln -s LINK_TARGET DEST" will create a
798 # symbolic link DEST that points to SRC.
799 # Output:
800 # - link_target link target, relative to the directory of DEST
801 func_symlink_target ()
803 case "$1" in
804 /* | ?:*)
805 link_target="$1" ;;
806 *) # SRC is relative.
807 case "$2" in
808 /* | ?:*)
809 link_target="`pwd`/$1" ;;
810 *) # DEST is relative too.
811 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
812 test -n "$ln_destdir" || ln_destdir="."
813 func_relativize "$ln_destdir" "$1"
814 link_target="$reldir"
816 esac
818 esac
821 # func_symlink SRC DEST
822 # Like func_ln_s, except that SRC is given relative to the current directory (or
823 # absolute), not given relative to the directory of DEST.
824 func_symlink ()
826 func_symlink_target "$1" "$2"
827 func_ln_s "$link_target" "$2"
830 # func_symlink_if_changed SRC DEST
831 # Like func_symlink, but avoids munging timestamps if the link is correct.
832 # SRC is given relative to the current directory (or absolute).
833 func_symlink_if_changed ()
835 if test $# -ne 2; then
836 echo "usage: func_symlink_if_changed SRC DEST" >&2
838 func_symlink_target "$1" "$2"
839 ln_target=`func_readlink "$2"`
840 if test -h "$2" && test "$link_target" = "$ln_target"; then
842 else
843 rm -f "$2"
844 func_ln_s "$link_target" "$2"
848 # func_hardlink SRC DEST
849 # Like ln, except use cp -p if ln fails.
850 # SRC is given relative to the current directory (or absolute).
851 func_hardlink ()
853 ln "$1" "$2" || {
854 echo "$progname: ln failed; falling back on cp -p" >&2
855 cp -p "$1" "$2"
859 # Ensure an 'echo' command that
860 # 1. does not interpret backslashes and
861 # 2. does not print an error message "broken pipe" when writing into a pipe
862 # with no writers.
864 # Test cases for problem 1:
865 # echo '\n' | wc -l prints 1 when OK, 2 when KO
866 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
867 # Test cases for problem 2:
868 # echo hi | true frequently prints
869 # "bash: echo: write error: Broken pipe"
870 # to standard error in bash 3.2.
872 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
873 # BSD echo interprets '-n' as an option, which is also not desirable).
874 # Nowadays the problem occurs in 4 situations:
875 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
876 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
877 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
878 # - in zsh, when sh-emulation is not set,
879 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
880 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
881 # - in Solaris /bin/sh and OSF/1 /bin/sh.
882 # We try the following workarounds:
883 # - for all: respawn using $CONFIG_SHELL if that is set and works.
884 # - for bash >= 2.04: unset the shell option xpg_echo.
885 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
886 # - for bash < 2.0: define echo to a function that uses cat of a here document.
887 # - for zsh: turn sh-emulation on.
888 # - for ksh: alias echo to 'print -r'.
889 # - for ksh: alias echo to a function that uses cat of a here document.
890 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
891 # the ksh workaround.
892 # - otherwise: respawn using /bin/sh and rely on the workarounds.
893 # When respawning, we pass --no-reexec as first argument, so as to avoid
894 # turning this script into a fork bomb in unlucky situations.
896 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
897 # the 'printf' built-in. See
898 # <https://lists.gnu.org/r/bug-bash/2008-12/msg00050.html>
899 # <https://lists.gnu.org/r/bug-gnulib/2010-02/msg00154.html>
900 # The workaround is: define echo to a function that uses the printf built-in.
901 have_echo=
902 if echo '\t' | grep t > /dev/null; then
903 have_echo=yes # Lucky!
905 # Try the workarounds.
906 # Respawn using $CONFIG_SHELL if that is set and works.
907 if test -z "$have_echo" \
908 && test "X$1" != "X--no-reexec" \
909 && test -n "$CONFIG_SHELL" \
910 && test -f "$CONFIG_SHELL" \
911 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
912 exec $CONFIG_SHELL "$0" --no-reexec "$@"
913 exit 127
915 # For bash >= 2.04: unset the shell option xpg_echo.
916 if test -z "$have_echo" \
917 && test -n "$BASH_VERSION" \
918 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
919 shopt -o xpg_echo
920 have_echo=yes
922 # For bash >= 2.0: define echo to a function that uses the printf built-in.
923 # For bash < 2.0: define echo to a function that uses cat of a here document.
924 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
925 # Also handle problem 2, specific to bash 3.2, here.
926 if { test -z "$have_echo" \
927 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
929 && test -n "$BASH_VERSION"; then \
930 if type printf 2>/dev/null | grep / > /dev/null; then
931 # 'printf' is not a shell built-in.
932 echo ()
934 cat <<EOF
938 else
939 # 'printf' is a shell built-in.
940 echo ()
942 printf '%s\n' "$*"
945 if echo '\t' | grep t > /dev/null; then
946 have_echo=yes
949 # For zsh: turn sh-emulation on.
950 if test -z "$have_echo" \
951 && test -n "$ZSH_VERSION" \
952 && (emulate sh) >/dev/null 2>&1; then
953 emulate sh
955 # For ksh: alias echo to 'print -r'.
956 if test -z "$have_echo" \
957 && (type print) >/dev/null 2>&1; then
958 # A 'print' command exists.
959 if type print 2>/dev/null | grep / > /dev/null; then
961 else
962 # 'print' is a shell built-in.
963 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
964 # 'print' is the ksh shell built-in.
965 alias echo='print -r'
969 if test -z "$have_echo" \
970 && echo '\t' | grep t > /dev/null; then
971 have_echo=yes
973 # For ksh: alias echo to a function that uses cat of a here document.
974 # The ksh manual page says:
975 # "Aliasing is performed when scripts are read, not while they are executed.
976 # Therefore, for an alias to take effect, the alias definition command has
977 # to be executed before the command which references the alias is read."
978 # Because of this, we have to play strange tricks with have_echo, to ensure
979 # that the top-level statement containing the test starts after the 'alias'
980 # command.
981 if test -z "$have_echo"; then
982 bsd_echo ()
984 cat <<EOF
988 if (alias echo=bsd_echo) 2>/dev/null; then
989 alias echo=bsd_echo 2>/dev/null
992 if test -z "$have_echo" \
993 && echo '\t' | grep t > /dev/null; then
994 have_echo=yes
996 if test -z "$have_echo"; then
997 if (alias echo=bsd_echo) 2>/dev/null; then
998 unalias echo 2>/dev/null
1001 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
1002 if test -z "$have_echo" \
1003 && test "X$1" != "X--no-reexec" \
1004 && test -f /bin/ksh; then
1005 exec /bin/ksh "$0" --no-reexec "$@"
1006 exit 127
1008 # Otherwise: respawn using /bin/sh.
1009 if test -z "$have_echo" \
1010 && test "X$1" != "X--no-reexec" \
1011 && test -f /bin/sh; then
1012 exec /bin/sh "$0" --no-reexec "$@"
1013 exit 127
1015 if test -z "$have_echo"; then
1016 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
1018 if echo '\t' | grep t > /dev/null; then
1019 : # Works fine now.
1020 else
1021 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
1023 if test "X$1" = "X--no-reexec"; then
1024 shift
1027 # Unset CDPATH. Otherwise, output from 'cd dir' can surprise callers.
1028 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1030 # Determine the path separator early because the following option parsing code
1031 # requires that.
1032 func_determine_path_separator
1034 # Command-line option processing.
1035 # Removes the OPTIONS from the arguments. Sets the variables:
1036 # - mode one of: list, find, import, add-import, remove-import,
1037 # update, create-testdir, create-megatestdir, test, megatest,
1038 # copy-file
1039 # - destdir from --dir
1040 # - local_gnulib_path from --local-dir, highest priority dir comes first
1041 # - modcache true or false, from --cache-modules/--no-cache-modules
1042 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1043 # - libname, supplied_libname from --lib
1044 # - sourcebase from --source-base
1045 # - m4base from --m4-base
1046 # - pobase from --po-base
1047 # - docbase from --doc-base
1048 # - testsbase from --tests-base
1049 # - auxdir from --aux-dir
1050 # - inctests true if --with-tests was given, false if --without-tests
1051 # was given, blank otherwise
1052 # - incobsolete true if --with-obsolete was given, blank otherwise
1053 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
1054 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
1055 # otherwise
1056 # - inc_privileged_tests true if --with-privileged-tests was given, blank
1057 # otherwise
1058 # - inc_unportable_tests true if --with-unportable-tests was given, blank
1059 # otherwise
1060 # - inc_all_tests true if --with-all-tests was given, blank otherwise
1061 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
1062 # - excl_longrunning_tests true if --without-longrunning-tests was given,
1063 # blank otherwise
1064 # - excl_privileged_tests true if --without-privileged-tests was given, blank
1065 # otherwise
1066 # - excl_unportable_tests true if --without-unportable-tests was given, blank
1067 # otherwise
1068 # - single_configure true if --single-configure was given, false otherwise
1069 # - avoidlist list of modules to avoid, from --avoid
1070 # - cond_dependencies true if --conditional-dependencies was given, false if
1071 # --no-conditional-dependencies was given, blank otherwise
1072 # - lgpl yes or a number if --lgpl was given, blank otherwise
1073 # - gnu_make true if --gnu-make was given, false otherwise
1074 # - makefile_name from --makefile-name
1075 # - libtool true if --libtool was given, false if --no-libtool was
1076 # given, blank otherwise
1077 # - macro_prefix from --macro-prefix
1078 # - po_domain from --po-domain
1079 # - witness_c_macro from --witness-c-macro
1080 # - vc_files true if --vc-files was given, false if --no-vc-files was
1081 # given, blank otherwise
1082 # - autoconf_minversion minimum supported autoconf version
1083 # - doit : if actions shall be executed, false if only to be printed
1084 # - copymode symlink if --symlink or --more-symlinks was given,
1085 # hardlink if --hardlink or --more-hardlinks was given,
1086 # blank otherwise
1087 # - lcopymode symlink if --local-symlink was given,
1088 # hardlink if --local-hardlink was given,
1089 # blank otherwise
1090 # - do_copyrights blank if --more-symlinks or --more-hardlinks was given,
1091 # true otherwise
1093 mode=
1094 destdir=
1095 local_gnulib_path=
1096 modcache=true
1097 verbose=0
1098 libname=libgnu
1099 supplied_libname=
1100 sourcebase=
1101 m4base=
1102 pobase=
1103 docbase=
1104 testsbase=
1105 auxdir=
1106 inctests=
1107 incobsolete=
1108 inc_cxx_tests=
1109 inc_longrunning_tests=
1110 inc_privileged_tests=
1111 inc_unportable_tests=
1112 inc_all_tests=
1113 excl_cxx_tests=
1114 excl_longrunning_tests=
1115 excl_privileged_tests=
1116 excl_unportable_tests=
1117 single_configure=false
1118 avoidlist=
1119 cond_dependencies=
1120 lgpl=
1121 gnu_make=false
1122 makefile_name=
1123 libtool=
1124 macro_prefix=
1125 po_domain=
1126 witness_c_macro=
1127 vc_files=
1128 doit=:
1129 copymode=
1130 lcopymode=
1131 do_copyrights=true
1133 supplied_opts="$@"
1135 while test $# -gt 0; do
1136 case "$1" in
1137 --list | --lis )
1138 mode=list
1139 shift ;;
1140 --find | --fin | --fi | --f )
1141 mode=find
1142 shift ;;
1143 --import | --impor | --impo | --imp | --im | --i )
1144 mode=import
1145 shift ;;
1146 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1147 mode=add-import
1148 shift ;;
1149 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1150 mode=remove-import
1151 shift ;;
1152 --update | --updat | --upda | --upd | --up | --u )
1153 mode=update
1154 shift ;;
1155 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1156 mode=create-testdir
1157 shift ;;
1158 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1159 mode=create-megatestdir
1160 shift ;;
1161 --test | --tes | --te | --t )
1162 mode=test
1163 shift ;;
1164 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1165 mode=megatest
1166 shift ;;
1167 --extract-* )
1168 mode=`echo "X$1" | sed -e 's/^X--//'`
1169 shift ;;
1170 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1171 mode=copy-file
1172 shift ;;
1173 --dir )
1174 shift
1175 if test $# = 0; then
1176 func_fatal_error "missing argument for --dir"
1178 destdir=$1
1179 shift ;;
1180 --dir=* )
1181 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1182 shift ;;
1183 --local-dir )
1184 shift
1185 if test $# = 0; then
1186 func_fatal_error "missing argument for --local-dir"
1188 func_path_append local_gnulib_path "$1"
1189 shift ;;
1190 --local-dir=* )
1191 local_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1192 func_path_append local_gnulib_path "$local_dir"
1193 shift ;;
1194 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1195 modcache=true
1196 shift ;;
1197 --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 )
1198 modcache=false
1199 shift ;;
1200 --verbose | --verbos | --verbo | --verb )
1201 verbose=`expr $verbose + 1`
1202 shift ;;
1203 --quiet | --quie | --qui | --qu | --q )
1204 verbose=`expr $verbose - 1`
1205 shift ;;
1206 --lib )
1207 shift
1208 if test $# = 0; then
1209 func_fatal_error "missing argument for --lib"
1211 libname=$1
1212 supplied_libname=true
1213 shift ;;
1214 --lib=* )
1215 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1216 supplied_libname=true
1217 shift ;;
1218 --source-base )
1219 shift
1220 if test $# = 0; then
1221 func_fatal_error "missing argument for --source-base"
1223 sourcebase=$1
1224 shift ;;
1225 --source-base=* )
1226 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1227 shift ;;
1228 --m4-base )
1229 shift
1230 if test $# = 0; then
1231 func_fatal_error "missing argument for --m4-base"
1233 m4base=$1
1234 shift ;;
1235 --m4-base=* )
1236 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1237 shift ;;
1238 --po-base )
1239 shift
1240 if test $# = 0; then
1241 func_fatal_error "missing argument for --po-base"
1243 pobase=$1
1244 shift ;;
1245 --po-base=* )
1246 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1247 shift ;;
1248 --doc-base )
1249 shift
1250 if test $# = 0; then
1251 func_fatal_error "missing argument for --doc-base"
1253 docbase=$1
1254 shift ;;
1255 --doc-base=* )
1256 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1257 shift ;;
1258 --tests-base )
1259 shift
1260 if test $# = 0; then
1261 func_fatal_error "missing argument for --tests-base"
1263 testsbase=$1
1264 shift ;;
1265 --tests-base=* )
1266 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1267 shift ;;
1268 --aux-dir )
1269 shift
1270 if test $# = 0; then
1271 func_fatal_error "missing argument for --aux-dir"
1273 auxdir=$1
1274 shift ;;
1275 --aux-dir=* )
1276 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1277 shift ;;
1278 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1279 inctests=true
1280 shift ;;
1281 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1282 incobsolete=true
1283 shift ;;
1284 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1285 inc_cxx_tests=true
1286 shift ;;
1287 --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)
1288 inc_longrunning_tests=true
1289 shift ;;
1290 --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)
1291 inc_privileged_tests=true
1292 shift ;;
1293 --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)
1294 inc_unportable_tests=true
1295 shift ;;
1296 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1297 inc_all_tests=true
1298 shift ;;
1299 --without-tests | --without-test | --without-tes | --without-te | --without-t)
1300 inctests=false
1301 shift ;;
1302 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1303 excl_cxx_tests=true
1304 shift ;;
1305 --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)
1306 excl_longrunning_tests=true
1307 shift ;;
1308 --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)
1309 excl_privileged_tests=true
1310 shift ;;
1311 --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)
1312 excl_unportable_tests=true
1313 shift ;;
1314 --single-configure | --single-configur | --single-configu | --single-config | --single-confi | --single-conf | --single-con | --single-con | --single-co | --single-c | --single- | --single | --singl | --sing | --sin | --si)
1315 single_configure=true
1316 shift ;;
1317 --avoid )
1318 shift
1319 if test $# = 0; then
1320 func_fatal_error "missing argument for --avoid"
1322 func_append avoidlist " $1"
1323 shift ;;
1324 --avoid=* )
1325 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1326 func_append avoidlist " $arg"
1327 shift ;;
1328 --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)
1329 cond_dependencies=true
1330 shift ;;
1331 --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)
1332 cond_dependencies=false
1333 shift ;;
1334 --lgpl )
1335 lgpl=yes
1336 shift ;;
1337 --lgpl=* )
1338 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1339 case "$arg" in
1340 2 | 3orGPLv2 | 3) ;;
1341 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1342 esac
1343 lgpl=$arg
1344 shift ;;
1345 --gnu-make )
1346 gnu_make=true
1347 shift ;;
1348 --makefile-name )
1349 shift
1350 if test $# = 0; then
1351 func_fatal_error "missing argument for --makefile-name"
1353 makefile_name="$1"
1354 shift ;;
1355 --makefile-name=* )
1356 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1357 shift ;;
1358 --libtool )
1359 libtool=true
1360 shift ;;
1361 --no-libtool )
1362 libtool=false
1363 shift ;;
1364 --macro-prefix )
1365 shift
1366 if test $# = 0; then
1367 func_fatal_error "missing argument for --macro-prefix"
1369 macro_prefix="$1"
1370 shift ;;
1371 --macro-prefix=* )
1372 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1373 shift ;;
1374 --po-domain )
1375 shift
1376 if test $# = 0; then
1377 func_fatal_error "missing argument for --po-domain"
1379 po_domain="$1"
1380 shift ;;
1381 --po-domain=* )
1382 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1383 shift ;;
1384 --witness-c-macro )
1385 shift
1386 if test $# = 0; then
1387 func_fatal_error "missing argument for --witness-c-macro"
1389 witness_c_macro="$1"
1390 shift ;;
1391 --witness-c-macro=* )
1392 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1393 shift ;;
1394 --vc-files )
1395 vc_files=true
1396 shift ;;
1397 --no-vc-files )
1398 vc_files=false
1399 shift ;;
1400 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1401 # A no-op for backward compatibility.
1402 shift ;;
1403 --dry-run )
1404 doit=false
1405 shift ;;
1406 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1407 copymode=symlink
1408 shift ;;
1409 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1410 lcopymode=symlink
1411 shift ;;
1412 -h | --hardlink | --hardlin | --hardli | --hardl | --hard | --har | --ha )
1413 copymode=hardlink
1414 shift ;;
1415 --local-hardlink | --local-hardlin | --local-hardli | --local-hardl | --local-hard | --local-har | --local-ha | --local-h )
1416 lcopymode=hardlink
1417 shift ;;
1418 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s )
1419 copymode=symlink
1420 do_copyrights=
1421 shift ;;
1422 -H | --more-hardlinks | --more-hardlink | --more-hardlin | --more-hardli | --more-hardl | --more-hard | --more-har | --more-ha | --more-h )
1423 copymode=hardlink
1424 do_copyrights=
1425 shift ;;
1426 --help | --hel | --he )
1427 func_usage
1428 func_exit $? ;;
1429 --version | --versio | --versi | --vers )
1430 func_version
1431 func_exit $? ;;
1432 -- )
1433 # Stop option processing
1434 shift
1435 break ;;
1436 -* )
1437 echo "gnulib-tool: unknown option $1" 1>&2
1438 echo "Try 'gnulib-tool --help' for more information." 1>&2
1439 func_exit 1 ;;
1441 break ;;
1442 esac
1443 done
1445 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1446 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1447 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1448 || test "$single_configure" != false; then
1449 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1450 echo "Try 'gnulib-tool --help' for more information." 1>&2
1451 func_exit 1
1454 if test "$mode" = update; then
1455 if test $# != 0; then
1456 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1457 echo "Try 'gnulib-tool --help' for more information." 1>&2
1458 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1459 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1460 func_exit 1
1462 if test -n "$local_gnulib_path" || test -n "$supplied_libname" \
1463 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1464 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1465 || test -n "$inctests" || test -n "$incobsolete" \
1466 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1467 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1468 || test -n "$inc_all_tests" \
1469 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1470 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1471 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1472 || test -n "$macro_prefix" || test -n "$po_domain" \
1473 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1474 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1475 echo "Try 'gnulib-tool --help' for more information." 1>&2
1476 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1477 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1478 func_exit 1
1481 if test -n "$pobase" && test -z "$po_domain"; then
1482 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1483 echo "Try 'gnulib-tool --help' for more information." 1>&2
1484 func_exit 1
1486 if test -z "$pobase" && test -n "$po_domain"; then
1487 func_warning "--po-domain has no effect without a --po-base option"
1489 case $mode,$gnu_make in
1490 *test*,true)
1491 echo "gnulib-tool: --gnu-make not supported when including tests"
1492 func_exit 1;;
1493 esac
1494 # Canonicalize the inctests variable.
1495 case "$mode" in
1496 import | add-import | remove-import | update)
1497 if test -z "$inctests"; then
1498 inctests=false
1501 create-testdir | create-megatestdir | test | megatest)
1502 if test -z "$inctests"; then
1503 inctests=true
1506 esac
1507 # Now the only possible values of "$inctests" are true and false
1508 # (or blank but then it is irrelevant).
1510 # Determine the minimum supported autoconf version from the project's
1511 # configure.ac.
1512 DEFAULT_AUTOCONF_MINVERSION="2.63"
1513 autoconf_minversion=
1514 configure_ac=
1515 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1516 && test -n "$destdir"; then
1517 if test -f "$destdir"/configure.ac; then
1518 configure_ac="$destdir/configure.ac"
1519 else
1520 if test -f "$destdir"/configure.in; then
1521 configure_ac="$destdir/configure.in"
1524 else
1525 if test -f configure.ac; then
1526 configure_ac="configure.ac"
1527 else
1528 if test -f configure.in; then
1529 configure_ac="configure.in"
1533 if test -n "$configure_ac"; then
1534 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1535 # because when some m4 files are omitted from a version control repository,
1536 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1537 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1538 # autom4te: m4 failed with exit status: 1
1539 prereqs=
1540 my_sed_traces='
1541 s,#.*$,,
1542 s,^dnl .*$,,
1543 s, dnl .*$,,
1544 /AC_PREREQ/ {
1545 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1547 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1548 if test -n "$prereqs"; then
1549 autoconf_minversion=`
1550 for version in $prereqs; do echo $version; done |
1551 LC_ALL=C sort -nru | sed -e 1q
1555 if test -z "$autoconf_minversion"; then
1556 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1558 case "$autoconf_minversion" in
1559 1.* | 2.[0-5]* | 2.6[0-2]*)
1560 func_fatal_error "minimum supported autoconf version is 2.63. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1561 esac
1563 # Remove trailing slashes from the directory names. This is necessary for
1564 # m4base (to avoid an error in func_import) and optional for the others.
1565 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1566 old_local_gnulib_path="$local_gnulib_path"
1567 local_gnulib_path=
1568 save_IFS="$IFS"
1569 IFS=:
1570 for dir in $old_local_gnulib_path
1572 IFS="$save_IFS"
1573 case "$dir" in
1574 */ ) dir=`echo "$dir" | sed -e "$sed_trimtrailingslashes"` ;;
1575 esac
1576 func_path_append local_gnulib_path "$dir"
1577 done
1578 IFS="$save_IFS"
1579 case "$sourcebase" in
1580 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1581 esac
1582 case "$m4base" in
1583 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1584 esac
1585 case "$pobase" in
1586 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1587 esac
1588 case "$docbase" in
1589 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1590 esac
1591 case "$testsbase" in
1592 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1593 esac
1594 case "$auxdir" in
1595 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1596 esac
1599 func_gnulib_dir
1600 func_tmpdir
1601 trap 'exit_status=$?
1602 if test "$signal" != 0; then
1603 echo "caught signal $signal" >&2
1605 rm -rf "$tmp"
1606 exit $exit_status' 0
1607 for signal in 1 2 3 13 15; do
1608 trap '{ signal='$signal'; func_exit 1; }' $signal
1609 done
1610 signal=0
1612 # Note: The 'eval' silences stderr output in dash.
1613 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1614 # Zsh 4 and Bash 4 have associative arrays.
1615 have_associative=true
1616 else
1617 # For other shells, use 'eval' with computed shell variable names.
1618 have_associative=false
1621 # func_lookup_local_file_cb dir file
1622 # returns true and sets func_lookup_local_file_result if the file $dir/$file
1623 # exists.
1624 func_lookup_local_file_cb ()
1626 test -n "$func_lookup_local_file_result" && return 1 # already found?
1627 test -f "$1/$2" || return 1
1628 func_lookup_local_file_result=$1/$2
1632 # func_lookup_local_file file
1633 # looks up a file in $local_gnulib_path.
1634 # Input:
1635 # - local_gnulib_path from --local-dir
1636 # Output:
1637 # - func_lookup_local_file_result name of the file, valid only when the
1638 # function succeeded.
1639 func_lookup_local_file ()
1641 func_lookup_local_file_result=
1642 func_path_foreach "$local_gnulib_path" func_lookup_local_file_cb %dir% "$1"
1645 # func_lookup_file_cb dir
1646 # does one step in processing the $local_gnulib_path, looking for $dir/$lkfile
1647 # and $dir/$lkfile.diff.
1648 func_lookup_file_cb ()
1650 # If we found the file already in a --local-dir of higher priority, nothing
1651 # more to do.
1652 if test -z "$lookedup_file"; then
1653 # Otherwise, look for $dir/$lkfile and $dir/$lkfile.diff.
1654 if test -f "$1/$lkfile"; then
1655 lookedup_file="$1/$lkfile"
1656 else
1657 if test -f "$1/$lkfile.diff"; then
1658 lkpatches="$1/$lkfile.diff${lkpatches:+$PATH_SEPARATOR$lkpatches}"
1664 # func_lookup_file file
1665 # looks up a file in $local_gnulib_path or $gnulib_dir, or combines it through
1666 # 'patch'.
1667 # Input:
1668 # - local_gnulib_path from --local-dir
1669 # Output:
1670 # - lookedup_file name of the merged (combined) file
1671 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1672 func_lookup_file ()
1674 lkfile="$1"
1675 # Each element in $local_gnulib_path is a directory whose contents overrides
1676 # or amends the result of the lookup in the rest of $local_gnulib_path and
1677 # $gnulib_dir. So, the first element of $local_gnulib_path is the highest
1678 # priority one.
1679 lookedup_file=
1680 lkpatches=
1681 func_path_foreach "$local_gnulib_path" func_lookup_file_cb %dir%
1682 # Treat $gnulib_dir like a lowest-priority --local-dir, except that here we
1683 # don't look for .diff files.
1684 if test -z "$lookedup_file"; then
1685 if test -f "$gnulib_dir/$lkfile"; then
1686 lookedup_file="$gnulib_dir/$lkfile"
1687 else
1688 func_fatal_error "file $gnulib_dir/$lkfile not found"
1691 # Now apply the patches, from lowest-priority to highest-priority.
1692 lookedup_tmp=
1693 if test -n "$lkpatches"; then
1694 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1695 rm -f "$tmp/$lkbase"
1696 cp "$lookedup_file" "$tmp/$lkbase"
1697 save_IFS="$IFS"
1698 IFS="$PATH_SEPARATOR"
1699 for patchfile in $lkpatches; do
1700 IFS="$save_IFS"
1701 patch -s "$tmp/$lkbase" < "$patchfile" >&2 \
1702 || func_fatal_error "patch file $patchfile didn't apply cleanly"
1703 done
1704 IFS="$save_IFS"
1705 lookedup_file="$tmp/$lkbase"
1706 lookedup_tmp=true
1710 # func_sanitize_modulelist
1711 # receives a list of possible module names on standard input, one per line.
1712 # It removes those which are just file names unrelated to modules, and outputs
1713 # the resulting list to standard output, one per line.
1714 func_sanitize_modulelist ()
1716 sed -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1717 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1718 -e '/^README$/d' -e '/\/README$/d' \
1719 -e '/^TEMPLATE$/d' \
1720 -e '/^TEMPLATE-EXTENDED$/d' \
1721 -e '/^TEMPLATE-TESTS$/d' \
1722 -e '/^\..*/d' \
1723 -e '/~$/d'
1727 # func_modules_in_dir dir
1728 # outputs all module files in dir to standard output.
1729 func_modules_in_dir ()
1731 (test -d "$1" && cd "$1" && find modules -type f -print)
1734 # func_all_modules
1735 # Input:
1736 # - local_gnulib_path from --local-dir
1737 func_all_modules ()
1739 # Filter out metainformation files like README, which are not modules.
1740 # Filter out unit test modules; they can be retrieved through
1741 # --extract-tests-module if desired.
1743 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1744 func_path_foreach "$local_gnulib_path" func_modules_in_dir %dir% | sed -e 's,^modules/,,' -e 's,\.diff$,,'
1746 | func_sanitize_modulelist \
1747 | sed -e '/-tests$/d' \
1748 | LC_ALL=C sort -u
1751 # func_exists_local_module dir module
1752 # returns true if module exists in dir
1753 func_exists_local_module ()
1755 test -d "$1/modules" && test -f "$1/modules/$2";
1758 # func_exists_module module
1759 # tests whether a module, given by name, exists
1760 # Input:
1761 # - local_gnulib_path from --local-dir
1762 func_exists_module ()
1764 { test -f "$gnulib_dir/modules/$1" \
1765 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1" ; } \
1766 && test "ChangeLog" != "$1" \
1767 && test "COPYING" != "$1" \
1768 && test "README" != "$1" \
1769 && test "TEMPLATE" != "$1" \
1770 && test "TEMPLATE-EXTENDED" != "$1" \
1771 && test "TEMPLATE-TESTS" != "$1"
1774 # func_verify_module
1775 # verifies a module name
1776 # Input:
1777 # - local_gnulib_path from --local-dir
1778 # - module module name argument
1779 # Output:
1780 # - module unchanged if OK, empty if not OK
1781 # - lookedup_file if OK: name of the merged (combined) module description file
1782 # - lookedup_tmp if OK: true if it is located in the tmp directory, blank otherwise
1783 func_verify_module ()
1785 if func_exists_module "$module"; then
1786 # OK, $module is a correct module name.
1787 # Verify that building the module description with 'patch' succeeds.
1788 func_lookup_file "modules/$module"
1789 else
1790 func_warning "module $module doesn't exist"
1791 module=
1795 # func_verify_nontests_module
1796 # verifies a module name, excluding tests modules
1797 # Input:
1798 # - local_gnulib_path from --local-dir
1799 # - module module name argument
1800 func_verify_nontests_module ()
1802 case "$module" in
1803 *-tests ) module= ;;
1804 * ) func_verify_module ;;
1805 esac
1808 # func_verify_tests_module
1809 # verifies a module name, considering only tests modules
1810 # Input:
1811 # - local_gnulib_path from --local-dir
1812 # - module module name argument
1813 func_verify_tests_module ()
1815 case "$module" in
1816 *-tests ) func_verify_module ;;
1817 * ) module= ;;
1818 esac
1821 # Suffix of a sed expression that extracts a particular field from a
1822 # module description.
1823 # A field starts with a line that contains a keyword, such as 'Description',
1824 # followed by a colon and optional whitespace. All following lines, up to
1825 # the next field (or end of file if there is none) form the contents of the
1826 # field.
1827 # An absent field is equivalent to a field with empty contents.
1828 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1829 sed_extract_prog=':[ ]*$/ {
1832 s/^Description:[ ]*$//
1833 s/^Comment:[ ]*$//
1834 s/^Status:[ ]*$//
1835 s/^Notice:[ ]*$//
1836 s/^Applicability:[ ]*$//
1837 s/^Files:[ ]*$//
1838 s/^Depends-on:[ ]*$//
1839 s/^configure\.ac-early:[ ]*$//
1840 s/^configure\.ac:[ ]*$//
1841 s/^Makefile\.am:[ ]*$//
1842 s/^Include:[ ]*$//
1843 s/^Link:[ ]*$//
1844 s/^License:[ ]*$//
1845 s/^Maintainer:[ ]*$//
1852 # Piece of a sed expression that converts a field header line to a shell
1853 # variable name,
1854 # NOTE: Keep this in sync with sed_extract_prog above!
1855 sed_extract_field_header='
1856 s/^Description:[ ]*$/description/
1857 s/^Comment:[ ]*$/comment/
1858 s/^Status:[ ]*$/status/
1859 s/^Notice:[ ]*$/notice/
1860 s/^Applicability:[ ]*$/applicability/
1861 s/^Files:[ ]*$/files/
1862 s/^Depends-on:[ ]*$/dependson/
1863 s/^configure\.ac-early:[ ]*$/configureac_early/
1864 s/^configure\.ac:[ ]*$/configureac/
1865 s/^Makefile\.am:[ ]*$/makefile/
1866 s/^Include:[ ]*$/include/
1867 s/^Link:[ ]*$/link/
1868 s/^License:[ ]*$/license/
1869 s/^Maintainer:[ ]*$/maintainer/'
1871 if $modcache; then
1873 if $have_associative; then
1875 # Declare the associative arrays.
1876 declare -A modcache_cached
1877 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1878 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1879 eval "$declare_script"
1881 else
1883 # func_cache_var module
1884 # computes the cache variable name corresponding to $module.
1885 # Note: This computation can map different module names to the same
1886 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1887 # to protect against this case.
1888 # Output:
1889 # - cachevar a shell variable name
1890 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1891 # Bash 2.0 and newer, ksh, and zsh support the syntax
1892 # ${param//pattern/replacement}
1893 # as a shorthand for
1894 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1895 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1896 eval 'func_cache_var ()
1898 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1900 else
1901 func_cache_var ()
1903 case $1 in
1904 *[!a-zA-Z0-9_]*)
1905 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1907 cachevar=c_$1 ;;
1908 esac
1914 # func_init_sed_convert_to_cache_statements
1915 # Input:
1916 # - modcachevar_assignment
1917 # Output:
1918 # - sed_convert_to_cache_statements
1919 func_init_sed_convert_to_cache_statements ()
1921 # 'sed' script that turns a module description into shell script
1922 # assignments, suitable to be eval'ed. All active characters are escaped.
1923 # This script turns
1924 # Description:
1925 # Some module's description
1927 # Files:
1928 # lib/file.h
1929 # into:
1930 # modcache_description[$1]=\
1931 # 'Some module'"'"'s description
1933 # modcache_files[$1]=\
1934 # 'lib/file.h'
1935 # or:
1936 # c_MODULE_description_set=set; c_MODULE_description=\
1937 # 'Some module'"'"'s description
1939 # c_MODULE_files_set=set; c_MODULE_files=\
1940 # 'lib/file.h'
1941 # The script consists of two parts:
1942 # 1) Ignore the lines before the first field header.
1943 # 2) A loop, treating non-field-header lines by escaping single quotes
1944 # and adding a closing quote in the last line,
1945 sed_convert_to_cache_statements="
1946 :llla
1947 # Here we have not yet seen a field header.
1949 # See if the current line contains a field header.
1950 t llla1
1951 :llla1
1952 ${sed_extract_field_header}
1953 t lllb
1955 # No field header. Ignore the line.
1957 # Read the next line. Upon EOF, just exit.
1959 b llla
1961 :lllb
1962 # The current line contains a field header.
1964 # Turn it into the beginning of an assignment.
1965 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1967 # Move it to the hold space. Don't print it yet,
1968 # because we want no assignment if the field is empty.
1971 # Read the next line.
1972 # Upon EOF, the field was empty. Print no assignment. Just exit.
1975 # See if the current line contains a field header.
1976 t lllb1
1977 :lllb1
1978 ${sed_extract_field_header}
1979 # If it is, the previous field was empty. Print no assignment.
1980 t lllb
1982 # Not a field header.
1984 # Print the previous line, held in the hold space.
1989 # Transform single quotes.
1990 s/'/'\"'\"'/g
1992 # Prepend a single quote.
1993 s/^/'/
1995 :lllc
1997 # Move it to the hold space.
2000 # Read the next line.
2001 # Upon EOF, branch.
2003 b llle
2007 # See if the current line contains a field header.
2008 t lllc1
2009 :lllc1
2010 ${sed_extract_field_header}
2011 t llld
2013 # Print the previous line, held in the hold space.
2018 # Transform single quotes.
2019 s/'/'\"'\"'/g
2021 b lllc
2023 :llld
2024 # A field header.
2025 # Print the previous line, held in the hold space, with a single quote
2026 # to end the assignment.
2028 s/\$/'/
2032 b lllb
2034 :llle
2035 # EOF seen.
2036 # Print the previous line, held in the hold space, with a single quote
2037 # to end the assignment.
2039 s/\$/'/
2041 # Exit.
2044 if ! $sed_comments; then
2045 # Remove comments.
2046 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
2047 | sed -e 's/^ *//' -e 's/^#.*//'`
2051 if $have_associative; then
2052 # sed_convert_to_cache_statements does not depend on the module.
2053 modcachevar_assignment='modcache_\1[$1]='
2054 func_init_sed_convert_to_cache_statements
2057 # func_cache_lookup_module module
2059 # looks up a module, like 'func_lookup_file modules/$module', and stores all
2060 # of its relevant data in a cache in the memory of the processing shell. If
2061 # already cached, it does not look it up again, thus saving file access time.
2062 # Parameters:
2063 # - module non-empty string
2064 # Output if $have_associative:
2065 # - modcache_cached[$module] set to yes
2066 # - modcache_description[$module] ==
2067 # - modcache_status[$module] \ set to the field's value, minus the
2068 # - ... / final newline,
2069 # - modcache_maintainer[$module] == or unset if the field's value is empty
2070 # Output if ! $have_associative:
2071 # - cachevar a shell variable name
2072 # - ${cachevar}_cached set to $module
2073 # - ${cachevar}_description ==
2074 # - ${cachevar}_status \ set to the field's value, minus the
2075 # - ... / final newline,
2076 # - ${cachevar}_maintainer == or unset if the field's value is empty
2077 # - ${cachevar}_description_set ==
2078 # - ${cachevar}_status_set \ set to non-empty if the field's value
2079 # - ... / is non-empty,
2080 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
2081 func_cache_lookup_module ()
2083 if $have_associative; then
2084 eval 'cached=${modcache_cached[$1]}'
2085 else
2086 func_cache_var "$1"
2087 eval "cached=\"\$${cachevar}_cached\""
2089 if test -z "$cached"; then
2090 # Not found in cache. Look it up on the file system.
2091 func_lookup_file "modules/$1"
2092 if $have_associative; then
2093 eval 'modcache_cached[$1]=yes'
2094 else
2095 eval "${cachevar}_cached=\"\$1\""
2097 if ! $have_associative; then
2098 # sed_convert_to_cache_statements depends on the module.
2099 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
2100 func_init_sed_convert_to_cache_statements
2102 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
2103 eval "$cache_statements"
2104 else
2105 if ! $have_associative; then
2106 if test "$1" != "$cached"; then
2107 func_fatal_error "cache variable collision between $1 and $cached"
2115 # func_get_description module
2116 # Input:
2117 # - local_gnulib_path from --local-dir
2118 # - modcache true or false, from --cache-modules/--no-cache-modules
2119 func_get_description ()
2121 if ! $modcache; then
2122 func_lookup_file "modules/$1"
2123 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
2124 else
2125 func_cache_lookup_module "$1"
2126 # Output the field's value, including the final newline (if any).
2127 if $have_associative; then
2128 if eval 'test -n "${modcache_description[$1]+set}"'; then
2129 eval 'echo "${modcache_description[$1]}"'
2131 else
2132 eval "field_set=\"\$${cachevar}_description_set\""
2133 if test -n "$field_set"; then
2134 eval "field_value=\"\$${cachevar}_description\""
2135 echo "${field_value}"
2141 # func_get_comment module
2142 # Input:
2143 # - local_gnulib_path from --local-dir
2144 # - modcache true or false, from --cache-modules/--no-cache-modules
2145 func_get_comment ()
2147 if ! $modcache; then
2148 func_lookup_file "modules/$1"
2149 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
2150 else
2151 func_cache_lookup_module "$1"
2152 # Output the field's value, including the final newline (if any).
2153 if $have_associative; then
2154 if eval 'test -n "${modcache_comment[$1]+set}"'; then
2155 eval 'echo "${modcache_comment[$1]}"'
2157 else
2158 eval "field_set=\"\$${cachevar}_comment_set\""
2159 if test -n "$field_set"; then
2160 eval "field_value=\"\$${cachevar}_comment\""
2161 echo "${field_value}"
2167 # func_get_status module
2168 # Input:
2169 # - local_gnulib_path from --local-dir
2170 # - modcache true or false, from --cache-modules/--no-cache-modules
2171 func_get_status ()
2173 if ! $modcache; then
2174 func_lookup_file "modules/$1"
2175 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
2176 else
2177 func_cache_lookup_module "$1"
2178 # Output the field's value, including the final newline (if any).
2179 if $have_associative; then
2180 if eval 'test -n "${modcache_status[$1]+set}"'; then
2181 eval 'echo "${modcache_status[$1]}"'
2183 else
2184 eval "field_set=\"\$${cachevar}_status_set\""
2185 if test -n "$field_set"; then
2186 eval "field_value=\"\$${cachevar}_status\""
2187 echo "${field_value}"
2193 # func_get_notice module
2194 # Input:
2195 # - local_gnulib_path from --local-dir
2196 # - modcache true or false, from --cache-modules/--no-cache-modules
2197 func_get_notice ()
2199 if ! $modcache; then
2200 func_lookup_file "modules/$1"
2201 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
2202 else
2203 func_cache_lookup_module "$1"
2204 # Output the field's value, including the final newline (if any).
2205 if $have_associative; then
2206 if eval 'test -n "${modcache_notice[$1]+set}"'; then
2207 eval 'echo "${modcache_notice[$1]}"'
2209 else
2210 eval "field_set=\"\$${cachevar}_notice_set\""
2211 if test -n "$field_set"; then
2212 eval "field_value=\"\$${cachevar}_notice\""
2213 echo "${field_value}"
2219 # func_get_applicability module
2220 # Input:
2221 # - local_gnulib_path from --local-dir
2222 # - modcache true or false, from --cache-modules/--no-cache-modules
2223 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
2224 func_get_applicability ()
2226 if ! $modcache; then
2227 func_lookup_file "modules/$1"
2228 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2229 else
2230 func_cache_lookup_module "$1"
2231 # Get the field's value, without the final newline.
2232 if $have_associative; then
2233 eval 'my_applicability="${modcache_applicability[$1]}"'
2234 else
2235 eval "my_applicability=\"\$${cachevar}_applicability\""
2238 if test -n "$my_applicability"; then
2239 echo $my_applicability
2240 else
2241 # The default is 'main' or 'tests', depending on the module's name.
2242 case $1 in
2243 *-tests) echo "tests";;
2244 *) echo "main";;
2245 esac
2249 # func_get_filelist module
2250 # Input:
2251 # - local_gnulib_path from --local-dir
2252 # - modcache true or false, from --cache-modules/--no-cache-modules
2253 func_get_filelist ()
2255 if ! $modcache; then
2256 func_lookup_file "modules/$1"
2257 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2258 else
2259 func_cache_lookup_module "$1"
2260 # Output the field's value, including the final newline (if any).
2261 if $have_associative; then
2262 if eval 'test -n "${modcache_files[$1]+set}"'; then
2263 eval 'echo "${modcache_files[$1]}"'
2265 else
2266 eval "field_set=\"\$${cachevar}_files_set\""
2267 if test -n "$field_set"; then
2268 eval "field_value=\"\$${cachevar}_files\""
2269 echo "${field_value}"
2273 echo m4/00gnulib.m4
2274 echo m4/gnulib-common.m4
2277 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2278 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2279 # elements starting with prefix and ending with suffix are considered.
2280 # Processing: removed_prefix and removed_suffix are removed from each element,
2281 # added_prefix and added_suffix are added to each element.
2282 # prefix, suffix should not contain shell-special characters.
2283 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2284 # added_prefix, added_suffix should not contain the characters \|&.
2285 func_filter_filelist ()
2287 if test "$2" != "$nl" \
2288 || { $fast_func_append \
2289 && { test -z "$6" || $fast_func_remove_prefix; } \
2290 && { test -z "$7" || $fast_func_remove_suffix; }; \
2291 }; then
2292 ffflist=
2293 for fff in $3; do
2294 # Do not quote possibly-empty parameters in case patterns,
2295 # AIX and HP-UX ksh won't match them if they are empty.
2296 case "$fff" in
2297 $4*$5)
2298 if test -n "$6"; then
2299 func_remove_prefix fff "$6"
2301 if test -n "$7"; then
2302 func_remove_suffix fff "$7"
2304 fff="$8${fff}$9"
2305 if test -z "$ffflist"; then
2306 ffflist="${fff}"
2307 else
2308 func_append ffflist "$2${fff}"
2311 esac
2312 done
2313 else
2314 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2315 ffflist=`for fff in $3; do
2316 case "$fff" in
2317 $4*$5) echo "$fff" ;;
2318 esac
2319 done | sed -e "$sed_fff_filter"`
2321 eval "$1=\"\$ffflist\""
2324 # func_get_dependencies module
2325 # Input:
2326 # - local_gnulib_path from --local-dir
2327 # - modcache true or false, from --cache-modules/--no-cache-modules
2328 func_get_dependencies ()
2330 # ${module}-tests implicitly depends on ${module}, if that module exists.
2331 case "$1" in
2332 *-tests)
2333 fgd1="$1"
2334 func_remove_suffix fgd1 '-tests'
2335 if func_exists_module "$fgd1"; then
2336 echo "$fgd1"
2339 esac
2340 # Then the explicit dependencies listed in the module description.
2341 { if ! $modcache; then
2342 func_lookup_file "modules/$1"
2343 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2344 else
2345 func_cache_lookup_module "$1"
2346 # Output the field's value, including the final newline (if any).
2347 if $have_associative; then
2348 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2349 eval 'echo "${modcache_dependson[$1]}"'
2351 else
2352 eval "field_set=\"\$${cachevar}_dependson_set\""
2353 if test -n "$field_set"; then
2354 eval "field_value=\"\$${cachevar}_dependson\""
2355 echo "${field_value}"
2360 | sed -e '/^#/d'
2363 sed_dependencies_without_conditions='s/ *\[.*//'
2365 # func_get_autoconf_early_snippet module
2366 # Input:
2367 # - local_gnulib_path from --local-dir
2368 # - modcache true or false, from --cache-modules/--no-cache-modules
2369 func_get_autoconf_early_snippet ()
2371 if ! $modcache; then
2372 func_lookup_file "modules/$1"
2373 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2374 else
2375 func_cache_lookup_module "$1"
2376 # Output the field's value, including the final newline (if any).
2377 if $have_associative; then
2378 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2379 eval 'echo "${modcache_configureac_early[$1]}"'
2381 else
2382 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2383 if test -n "$field_set"; then
2384 eval "field_value=\"\$${cachevar}_configureac_early\""
2385 echo "${field_value}"
2391 # func_get_autoconf_snippet module
2392 # Input:
2393 # - local_gnulib_path from --local-dir
2394 # - modcache true or false, from --cache-modules/--no-cache-modules
2395 func_get_autoconf_snippet ()
2397 if ! $modcache; then
2398 func_lookup_file "modules/$1"
2399 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2400 else
2401 func_cache_lookup_module "$1"
2402 # Output the field's value, including the final newline (if any).
2403 if $have_associative; then
2404 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2405 eval 'echo "${modcache_configureac[$1]}"'
2407 else
2408 eval "field_set=\"\$${cachevar}_configureac_set\""
2409 if test -n "$field_set"; then
2410 eval "field_value=\"\$${cachevar}_configureac\""
2411 echo "${field_value}"
2417 # Concatenate lines with trailing slash.
2418 # $1 is an optional filter to restrict the
2419 # concatenation to groups starting with that expression
2420 combine_lines() {
2421 sed -e "/$1.*"'\\$/{
2424 s/\\\n/ /
2425 s/\\$/\\/
2430 # func_get_automake_snippet_conditional module
2431 # returns the part of the Makefile.am snippet that can be put inside Automake
2432 # conditionals.
2433 # Input:
2434 # - local_gnulib_path from --local-dir
2435 # - modcache true or false, from --cache-modules/--no-cache-modules
2436 func_get_automake_snippet_conditional ()
2438 if ! $modcache; then
2439 func_lookup_file "modules/$1"
2440 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2441 else
2442 func_cache_lookup_module "$1"
2443 # Output the field's value, including the final newline (if any).
2444 if $have_associative; then
2445 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2446 eval 'echo "${modcache_makefile[$1]}"'
2448 else
2449 eval "field_set=\"\$${cachevar}_makefile_set\""
2450 if test -n "$field_set"; then
2451 eval "field_value=\"\$${cachevar}_makefile\""
2452 echo "${field_value}"
2458 # func_get_automake_snippet_unconditional module
2459 # returns the part of the Makefile.am snippet that must stay outside of
2460 # Automake conditionals.
2461 # Input:
2462 # - local_gnulib_path from --local-dir
2463 # - modcache true or false, from --cache-modules/--no-cache-modules
2464 func_get_automake_snippet_unconditional ()
2466 case "$1" in
2467 *-tests)
2468 # *-tests module live in tests/, not lib/.
2469 # Synthesize an EXTRA_DIST augmentation.
2470 all_files=`func_get_filelist $1`
2471 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2472 extra_files="$tests_files"
2473 if test -n "$extra_files"; then
2474 echo "EXTRA_DIST +=" $extra_files
2475 echo
2479 # Synthesize an EXTRA_DIST augmentation.
2480 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2481 already_mentioned_files=` \
2482 { if ! $modcache; then
2483 func_lookup_file "modules/$1"
2484 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2485 else
2486 func_cache_lookup_module "$1"
2487 if $have_associative; then
2488 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2489 eval 'echo "${modcache_makefile[$1]}"'
2491 else
2492 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2493 if test -n "$field_set"; then
2494 eval 'field_value="$'"${cachevar}"'_makefile"'
2495 echo "${field_value}"
2500 | combine_lines \
2501 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2502 all_files=`func_get_filelist $1`
2503 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2504 # Remove $already_mentioned_files from $lib_files.
2505 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2506 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2507 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2508 if test -n "$extra_files"; then
2509 echo "EXTRA_DIST +=" $extra_files
2510 echo
2512 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2513 # This is necessary so that automake can generate the right list of
2514 # dependency rules.
2515 # A possible approach would be to use autom4te --trace of the redefined
2516 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2517 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2518 # inside autoconf's built-in macros are not missed).
2519 # But it's simpler and more robust to do it here, based on the file list.
2520 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2521 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2522 # automake will generate a useless dependency; this is harmless.
2523 case "$1" in
2524 relocatable-prog-wrapper) ;;
2525 pt_chown) ;;
2527 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2528 if test -n "$extra_files"; then
2529 echo "EXTRA_lib_SOURCES +=" $extra_files
2530 echo
2533 esac
2534 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2535 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2536 if test -n "$buildaux_files"; then
2537 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2538 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2539 echo
2542 esac
2545 # func_get_automake_snippet module
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 ()
2551 func_get_automake_snippet_conditional "$1"
2552 func_get_automake_snippet_unconditional "$1"
2555 # func_get_include_directive module
2556 # Input:
2557 # - local_gnulib_path from --local-dir
2558 # - modcache true or false, from --cache-modules/--no-cache-modules
2559 func_get_include_directive ()
2562 if ! $modcache; then
2563 func_lookup_file "modules/$1"
2564 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2565 else
2566 func_cache_lookup_module "$1"
2567 # Output the field's value, including the final newline (if any).
2568 if $have_associative; then
2569 if eval 'test -n "${modcache_include[$1]+set}"'; then
2570 eval 'echo "${modcache_include[$1]}"'
2572 else
2573 eval "field_set=\"\$${cachevar}_include_set\""
2574 if test -n "$field_set"; then
2575 eval "field_value=\"\$${cachevar}_include\""
2576 echo "${field_value}"
2580 } | sed -e 's/^\(["<]\)/#include \1/'
2583 # func_get_link_directive module
2584 # Input:
2585 # - local_gnulib_path from --local-dir
2586 # - modcache true or false, from --cache-modules/--no-cache-modules
2587 func_get_link_directive ()
2589 if ! $modcache; then
2590 func_lookup_file "modules/$1"
2591 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2592 else
2593 func_cache_lookup_module "$1"
2594 # Output the field's value, including the final newline (if any).
2595 if $have_associative; then
2596 if eval 'test -n "${modcache_link[$1]+set}"'; then
2597 eval 'echo "${modcache_link[$1]}"'
2599 else
2600 eval "field_set=\"\$${cachevar}_link_set\""
2601 if test -n "$field_set"; then
2602 eval "field_value=\"\$${cachevar}_link\""
2603 echo "${field_value}"
2609 # func_get_license_raw module
2610 # Input:
2611 # - local_gnulib_path from --local-dir
2612 # - modcache true or false, from --cache-modules/--no-cache-modules
2613 func_get_license_raw ()
2615 if ! $modcache; then
2616 func_lookup_file "modules/$1"
2617 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2618 else
2619 func_cache_lookup_module "$1"
2620 # Output the field's value, including the final newline (if any).
2621 if $have_associative; then
2622 if eval 'test -n "${modcache_license[$1]+set}"'; then
2623 eval 'echo "${modcache_license[$1]}"'
2625 else
2626 eval "field_set=\"\$${cachevar}_license_set\""
2627 if test -n "$field_set"; then
2628 eval "field_value=\"\$${cachevar}_license\""
2629 echo "${field_value}"
2635 # func_get_license module
2636 # Input:
2637 # - local_gnulib_path from --local-dir
2638 # - modcache true or false, from --cache-modules/--no-cache-modules
2639 func_get_license ()
2641 # Warn if the License field is missing.
2642 case "$1" in
2643 *-tests ) ;;
2645 license=`func_get_license_raw "$1"`
2646 if test -z "$license"; then
2647 func_warning "module $1 lacks a License"
2650 esac
2651 case "$1" in
2652 parse-datetime )
2653 # These modules are under a weaker license only for the purpose of some
2654 # users who hand-edit it and don't use gnulib-tool. For the regular
2655 # gnulib users they are under a stricter license.
2656 echo "GPL"
2660 func_get_license_raw "$1"
2661 # The default is GPL.
2662 echo "GPL"
2663 } | sed -e 's,^ *$,,' | sed -e 1q
2665 esac
2668 # func_get_maintainer module
2669 # Input:
2670 # - local_gnulib_path from --local-dir
2671 # - modcache true or false, from --cache-modules/--no-cache-modules
2672 func_get_maintainer ()
2674 if ! $modcache; then
2675 func_lookup_file "modules/$1"
2676 sed -n -e "/^Maintainer$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_maintainer[$1]+set}"'; then
2682 eval 'echo "${modcache_maintainer[$1]}"'
2684 else
2685 eval "field_set=\"\$${cachevar}_maintainer_set\""
2686 if test -n "$field_set"; then
2687 eval "field_value=\"\$${cachevar}_maintainer\""
2688 echo "${field_value}"
2694 # func_get_tests_module module
2695 # Input:
2696 # - local_gnulib_path from --local-dir
2697 func_get_tests_module ()
2699 # The naming convention for tests modules is hardwired: ${module}-tests.
2700 if test -f "$gnulib_dir/modules/$1"-tests \
2701 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1-tests"; then
2702 echo "$1"-tests
2706 # func_get_dependencies_recursively module
2707 # Input:
2708 # - local_gnulib_path from --local-dir
2709 # - modcache true or false, from --cache-modules/--no-cache-modules
2710 func_get_dependencies_recursively ()
2712 # In order to process every module only once (for speed), process an "input
2713 # list" of modules, producing an "output list" of modules. During each round,
2714 # more modules can be queued in the input list. Once a module on the input
2715 # list has been processed, it is added to the "handled list", so we can avoid
2716 # to process it again.
2717 handledmodules=
2718 inmodules="$1"
2719 outmodules=
2720 while test -n "$inmodules"; do
2721 inmodules_this_round="$inmodules"
2722 inmodules= # Accumulator, queue for next round
2723 for module in $inmodules_this_round; do
2724 func_verify_module
2725 if test -n "$module"; then
2726 func_append outmodules " $module"
2727 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2728 for dep in $deps; do
2729 func_append inmodules " $dep"
2730 done
2732 done
2733 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2734 # Remove $handledmodules from $inmodules.
2735 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2736 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2737 done
2738 rm -f "$tmp"/queued-modules
2739 for m in $outmodules; do echo $m; done | LC_ALL=C sort -u
2742 # func_get_link_directive_recursively module
2743 # Input:
2744 # - local_gnulib_path from --local-dir
2745 # - modcache true or false, from --cache-modules/--no-cache-modules
2746 func_get_link_directive_recursively ()
2748 # In order to process every module only once (for speed), process an "input
2749 # list" of modules, producing an "output list" of modules. During each round,
2750 # more modules can be queued in the input list. Once a module on the input
2751 # list has been processed, it is added to the "handled list", so we can avoid
2752 # to process it again.
2753 handledmodules=
2754 inmodules="$1"
2755 outmodules=
2756 while test -n "$inmodules"; do
2757 inmodules_this_round="$inmodules"
2758 inmodules= # Accumulator, queue for next round
2759 for module in $inmodules_this_round; do
2760 func_verify_module
2761 if test -n "$module"; then
2762 if grep '^Link:[ ]*$' "$lookedup_file" >/dev/null; then
2763 # The module description has a 'Link:' field. Ignore the dependencies.
2764 func_append outmodules " $module"
2765 else
2766 # The module description has no 'Link:' field. Recurse through the dependencies.
2767 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2768 for dep in $deps; do
2769 func_append inmodules " $dep"
2770 done
2773 done
2774 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2775 # Remove $handledmodules from $inmodules.
2776 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2777 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2778 done
2779 rm -f "$tmp"/queued-modules
2780 for m in $outmodules; do func_get_link_directive "$m"; done | LC_ALL=C sort -u | sed -e '/^$/d'
2783 # func_acceptable module
2784 # tests whether a module is acceptable.
2785 # Input:
2786 # - avoidlist list of modules to avoid
2787 func_acceptable ()
2789 for avoid in $avoidlist; do
2790 if test "$avoid" = "$1"; then
2791 return 1
2793 done
2794 return 0
2797 # sed expression to keep the first 32 characters of each line.
2798 sed_first_32_chars='s/^\(................................\).*/\1/'
2800 # func_module_shellfunc_name module
2801 # computes the shell function name that will contain the m4 macros for the module.
2802 # Input:
2803 # - macro_prefix prefix to use
2804 # Output:
2805 # - shellfunc shell function name
2806 func_module_shellfunc_name ()
2808 case $1 in
2809 *[!a-zA-Z0-9_]*)
2810 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2812 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2813 esac
2816 # func_module_shellvar_name module
2817 # computes the shell variable name the will be set to true once the m4 macros
2818 # for the module have been executed.
2819 # Output:
2820 # - shellvar shell variable name
2821 func_module_shellvar_name ()
2823 case $1 in
2824 *[!a-zA-Z0-9_]*)
2825 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2827 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2828 esac
2831 # func_module_conditional_name module
2832 # computes the automake conditional name for the module.
2833 # Output:
2834 # - conditional name of automake conditional
2835 func_module_conditional_name ()
2837 case $1 in
2838 *[!a-zA-Z0-9_]*)
2839 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2841 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2842 esac
2845 # func_uncond_add_module B
2846 # notes the presence of B as an unconditional module.
2848 # func_conddep_add_module A B cond
2849 # notes the presence of a conditional dependency from module A to module B,
2850 # subject to the condition that A is enabled and cond is true.
2852 # func_cond_module_p B
2853 # tests whether module B is conditional.
2855 # func_cond_module_condition A B
2856 # returns the condition when B should be enabled as a dependency of A, once the
2857 # m4 code for A has been executed.
2858 # Output: - condition
2860 if $have_associative; then
2861 declare -A conddep_isuncond
2862 declare -A conddep_dependers
2863 declare -A conddep_condition
2864 func_uncond_add_module ()
2866 eval 'conddep_isuncond[$1]=true'
2867 eval 'unset conddep_dependers[$1]'
2869 func_conddep_add_module ()
2871 eval 'isuncond="${conddep_isuncond[$2]}"'
2872 if test -z "$isuncond"; then
2873 # No unconditional dependency to B known at this point.
2874 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2875 eval 'conddep_condition[$1---$2]="$3"'
2878 func_cond_module_p ()
2880 eval 'previous_dependers="${conddep_dependers[$1]}"'
2881 test -n "$previous_dependers"
2883 func_cond_module_condition ()
2885 eval 'condition="${conddep_condition[$1---$2]}"'
2887 else
2888 func_uncond_add_module ()
2890 case $1 in
2891 *[!a-zA-Z0-9_]*)
2892 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2894 suffix=$1 ;;
2895 esac
2896 eval 'conddep_isuncond_'"$suffix"'=true'
2897 eval 'unset conddep_dependers_'"$suffix"
2899 func_conddep_add_module ()
2901 case $2 in
2902 *[!a-zA-Z0-9_]*)
2903 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2905 suffix=$2 ;;
2906 esac
2907 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2908 if test -z "$isuncond"; then
2909 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2910 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2911 eval 'conddep_condition_'"$suffix"'="$3"'
2914 func_cond_module_p ()
2916 case $1 in
2917 *[!a-zA-Z0-9_]*)
2918 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2920 suffix=$1 ;;
2921 esac
2922 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2923 test -n "$previous_dependers"
2925 func_cond_module_condition ()
2927 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2928 eval 'condition="${conddep_condition_'"$suffix"'}"'
2932 # func_modules_transitive_closure
2933 # Input:
2934 # - local_gnulib_path from --local-dir
2935 # - gnu_make true if --gnu-make was given, false otherwise
2936 # - modcache true or false, from --cache-modules/--no-cache-modules
2937 # - modules list of specified modules
2938 # - inctests true if tests should be included, false otherwise
2939 # - incobsolete true if obsolete modules among dependencies should be
2940 # included, blank otherwise
2941 # - inc_cxx_tests true if C++ interoperability tests should be included,
2942 # blank otherwise
2943 # - inc_longrunning_tests true if long-runnings tests should be included,
2944 # blank otherwise
2945 # - inc_privileged_tests true if tests that require root privileges should be
2946 # included, blank otherwise
2947 # - inc_unportable_tests true if tests that fail on some platforms should be
2948 # included, blank otherwise
2949 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2950 # the unit tests of the specified modules should be
2951 # included, blank otherwise
2952 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2953 # the unit tests of the dependencies should be
2954 # included, blank otherwise
2955 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2956 # blank otherwise
2957 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2958 # blank otherwise
2959 # - excl_privileged_tests true if tests that require root privileges should be
2960 # excluded, blank otherwise
2961 # - excl_unportable_tests true if tests that fail on some platforms should be
2962 # excluded, blank otherwise
2963 # - avoidlist list of modules to avoid
2964 # - cond_dependencies true if conditional dependencies shall be supported,
2965 # blank otherwise
2966 # - tmp pathname of a temporary directory
2967 # Output:
2968 # - modules list of modules, including dependencies
2969 # - conddep_dependers, conddep_condition information about conditionally
2970 # enabled modules
2971 func_modules_transitive_closure ()
2973 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2974 # In order to process every module only once (for speed), process an "input
2975 # list" of modules, producing an "output list" of modules. During each round,
2976 # more modules can be queued in the input list. Once a module on the input
2977 # list has been processed, it is added to the "handled list", so we can avoid
2978 # to process it again.
2979 handledmodules=
2980 inmodules="$modules"
2981 outmodules=
2982 fmtc_inc_all_tests="$inc_all_direct_tests"
2983 if test "$cond_dependencies" = true; then
2984 for module in $inmodules; do
2985 func_verify_module
2986 if test -n "$module"; then
2987 if func_acceptable $module; then
2988 func_uncond_add_module $module
2991 done
2993 while test -n "$inmodules"; do
2994 inmodules_this_round="$inmodules"
2995 inmodules= # Accumulator, queue for next round
2996 for module in $inmodules_this_round; do
2997 func_verify_module
2998 if test -n "$module"; then
2999 if func_acceptable $module; then
3000 func_append outmodules " $module"
3001 if test "$cond_dependencies" = true; then
3002 if ! $gnu_make \
3003 && func_get_automake_snippet_conditional $module \
3004 | grep '^if ' > /dev/null; then
3005 # A module whose Makefile.am snippet contains a reference to an
3006 # automake conditional. If we were to use it conditionally, we
3007 # would get an error
3008 # configure: error: conditional "..." was never defined.
3009 # because automake 1.11.1 does not handle nested conditionals
3010 # correctly. As a workaround, make the module unconditional.
3011 func_uncond_add_module $module
3013 if func_cond_module_p $module; then
3014 conditional=true
3015 else
3016 conditional=false
3019 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3020 # Duplicate dependencies are harmless, but Jim wants a warning.
3021 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
3022 if test -n "$duplicated_deps"; then
3023 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
3025 if $inctests; then
3026 testsmodule=`func_get_tests_module $module`
3027 if test -n "$testsmodule"; then
3028 deps="$deps $testsmodule"
3031 for dep in $deps; do
3032 # Determine whether to include the dependency or tests module.
3033 inc=true
3034 for word in `func_get_status $dep`; do
3035 case "$word" in
3036 obsolete)
3037 test -n "$incobsolete" \
3038 || inc=false
3040 c++-test)
3041 test -z "$excl_cxx_tests" \
3042 || inc=false
3043 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
3044 || inc=false
3046 longrunning-test)
3047 test -z "$excl_longrunning_tests" \
3048 || inc=false
3049 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
3050 || inc=false
3052 privileged-test)
3053 test -z "$excl_privileged_tests" \
3054 || inc=false
3055 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
3056 || inc=false
3058 unportable-test)
3059 test -z "$excl_unportable_tests" \
3060 || inc=false
3061 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
3062 || inc=false
3064 *-test)
3065 test -n "$fmtc_inc_all_tests" \
3066 || inc=false
3068 esac
3069 done
3070 if $inc && func_acceptable "$dep"; then
3071 func_append inmodules " $dep"
3072 if test "$cond_dependencies" = true; then
3073 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
3074 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
3075 s/^.*$/true/p
3077 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
3078 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
3080 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
3081 if test "$condition" = true; then
3082 condition=
3084 if test -n "$condition"; then
3085 func_conddep_add_module "$module" "$dep" "$condition"
3086 else
3087 if $conditional; then
3088 func_conddep_add_module "$module" "$dep" true
3089 else
3090 func_uncond_add_module "$dep"
3095 done
3098 done
3099 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
3100 # Remove $handledmodules from $inmodules.
3101 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
3102 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
3103 fmtc_inc_all_tests="$inc_all_indirect_tests"
3104 done
3105 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
3106 rm -f "$tmp"/queued-modules
3109 # func_show_module_list
3110 # Input:
3111 # - specified_modules list of specified modules (one per line, sorted)
3112 # - modules complete list of modules (one per line, sorted)
3113 # - tmp pathname of a temporary directory
3114 func_show_module_list ()
3116 if case "$TERM" in
3117 xterm*) test -t 1;;
3118 *) false;;
3119 esac; then
3120 # Assume xterm compatible escape sequences.
3121 bold_on=`printf '\033[1m'`
3122 bold_off=`printf '\033[0m'`
3123 else
3124 bold_on=
3125 bold_off=
3127 echo "Module list with included dependencies (indented):"
3128 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
3129 echo "$modules" | sed -e '/^$/d' \
3130 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
3131 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
3134 # func_modules_transitive_closure_separately
3135 # Determine main module list and tests-related module list separately.
3136 # The main module list is the transitive closure of the specified modules,
3137 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3138 # is specified, it will consist only of LGPLed source.
3139 # The tests-related module list is the transitive closure of the specified
3140 # modules, including tests modules, minus the main module list excluding
3141 # modules of applicability 'all'. Its lib/* sources (brought in through
3142 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3143 # source, even if --lgpl is specified.
3144 # Input:
3145 # - local_gnulib_path from --local-dir
3146 # - modcache true or false, from --cache-modules/--no-cache-modules
3147 # - specified_modules list of specified modules
3148 # - inctests true if tests should be included, false otherwise
3149 # - incobsolete true if obsolete modules among dependencies should be
3150 # included, blank otherwise
3151 # - inc_cxx_tests true if C++ interoperability tests should be included,
3152 # blank otherwise
3153 # - inc_longrunning_tests true if long-runnings tests should be included,
3154 # blank otherwise
3155 # - inc_privileged_tests true if tests that require root privileges should be
3156 # included, blank otherwise
3157 # - inc_unportable_tests true if tests that fail on some platforms should be
3158 # included, blank otherwise
3159 # - inc_all_direct_tests true if all kinds of problematic unit tests among
3160 # the unit tests of the specified modules should be
3161 # included, blank otherwise
3162 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
3163 # the unit tests of the dependencies should be
3164 # included, blank otherwise
3165 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
3166 # blank otherwise
3167 # - excl_longrunning_tests true if long-runnings tests should be excluded,
3168 # blank otherwise
3169 # - excl_privileged_tests true if tests that require root privileges should be
3170 # excluded, blank otherwise
3171 # - excl_unportable_tests true if tests that fail on some platforms should be
3172 # excluded, blank otherwise
3173 # - avoidlist list of modules to avoid
3174 # - cond_dependencies true if conditional dependencies shall be supported,
3175 # blank otherwise
3176 # - tmp pathname of a temporary directory
3177 # Output:
3178 # - main_modules list of modules, including dependencies
3179 # - testsrelated_modules list of tests-related modules, including dependencies
3180 # - conddep_dependers, conddep_condition information about conditionally
3181 # enabled modules
3182 func_modules_transitive_closure_separately ()
3184 # Determine main module list.
3185 saved_inctests="$inctests"
3186 inctests=false
3187 modules="$specified_modules"
3188 func_modules_transitive_closure
3189 main_modules="$modules"
3190 inctests="$saved_inctests"
3191 if test $verbose -ge 1; then
3192 echo "Main module list:"
3193 echo "$main_modules" | sed -e 's/^/ /'
3195 # Determine tests-related module list.
3196 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3197 testsrelated_modules=`for module in $main_modules; do
3198 if test \`func_get_applicability $module\` = main; then
3199 echo $module
3201 done \
3202 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3203 # If testsrelated_modules consists only of modules with applicability 'all',
3204 # set it to empty (because such modules are only helper modules for other modules).
3205 have_nontrivial_testsrelated_modules=
3206 for module in $testsrelated_modules; do
3207 if test `func_get_applicability $module` != all; then
3208 have_nontrivial_testsrelated_modules=yes
3209 break
3211 done
3212 if test -z "$have_nontrivial_testsrelated_modules"; then
3213 testsrelated_modules=
3215 if test $verbose -ge 1; then
3216 echo "Tests-related module list:"
3217 echo "$testsrelated_modules" | sed -e 's/^/ /'
3221 # func_determine_use_libtests
3222 # Determines whether a $testsbase/libtests.a is needed.
3223 # Input:
3224 # - local_gnulib_path from --local-dir
3225 # - modcache true or false, from --cache-modules/--no-cache-modules
3226 # - testsrelated_modules list of tests-related modules, including dependencies
3227 # Output:
3228 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3229 func_determine_use_libtests ()
3231 use_libtests=false
3232 for module in $testsrelated_modules; do
3233 func_verify_nontests_module
3234 if test -n "$module"; then
3235 all_files=`func_get_filelist $module`
3236 # Test whether some file in $all_files lies in lib/.
3237 for f in $all_files; do
3238 case $f in
3239 lib/*)
3240 use_libtests=true
3241 break 2
3243 esac
3244 done
3246 done
3249 # func_modules_add_dummy
3250 # Input:
3251 # - local_gnulib_path from --local-dir
3252 # - modcache true or false, from --cache-modules/--no-cache-modules
3253 # - modules list of modules, including dependencies
3254 # Output:
3255 # - modules list of modules, including 'dummy' if needed
3256 func_modules_add_dummy ()
3258 # Determine whether any module provides a lib_SOURCES augmentation.
3259 have_lib_SOURCES=
3260 for module in $modules; do
3261 func_verify_nontests_module
3262 if test -n "$module"; then
3263 # Extract the value of "lib_SOURCES += ...".
3264 for file in `func_get_automake_snippet "$module" | combine_lines |
3265 sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
3266 # Ignore .h files since they are not compiled.
3267 case "$file" in
3268 *.h) ;;
3270 have_lib_SOURCES=yes
3271 break 2
3273 esac
3274 done
3276 done
3277 # Add the dummy module, to make sure the library will be non-empty.
3278 if test -z "$have_lib_SOURCES"; then
3279 if func_acceptable "dummy"; then
3280 func_append modules " dummy"
3285 # func_modules_add_dummy_separately
3286 # Input:
3287 # - local_gnulib_path from --local-dir
3288 # - modcache true or false, from --cache-modules/--no-cache-modules
3289 # - main_modules list of modules, including dependencies
3290 # - testsrelated_modules list of tests-related modules, including dependencies
3291 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3292 # Output:
3293 # - main_modules list of modules, including 'dummy' if needed
3294 # - testsrelated_modules list of tests-related modules, including 'dummy' if
3295 # needed
3296 func_modules_add_dummy_separately ()
3298 # Add the dummy module to the main module list if needed.
3299 modules="$main_modules"
3300 func_modules_add_dummy
3301 main_modules="$modules"
3303 # Add the dummy module to the tests-related module list if needed.
3304 if $use_libtests; then
3305 modules="$testsrelated_modules"
3306 func_modules_add_dummy
3307 testsrelated_modules="$modules"
3311 # func_modules_notice
3312 # Input:
3313 # - local_gnulib_path from --local-dir
3314 # - modcache true or false, from --cache-modules/--no-cache-modules
3315 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3316 # - modules list of modules, including dependencies
3317 func_modules_notice ()
3319 if test $verbose -ge -1; then
3320 for module in $modules; do
3321 func_verify_module
3322 if test -n "$module"; then
3323 msg=`func_get_notice $module`
3324 if test -n "$msg"; then
3325 echo "Notice from module $module:"
3326 echo "$msg" | sed -e 's/^/ /'
3329 done
3333 # func_modules_to_filelist
3334 # Input:
3335 # - local_gnulib_path from --local-dir
3336 # - modcache true or false, from --cache-modules/--no-cache-modules
3337 # - modules list of modules, including dependencies
3338 # Output:
3339 # - files list of files
3340 func_modules_to_filelist ()
3342 files=
3343 for module in $modules; do
3344 func_verify_module
3345 if test -n "$module"; then
3346 fs=`func_get_filelist $module`
3347 func_append files " $fs"
3349 done
3350 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3353 # func_modules_to_filelist_separately
3354 # Determine the final file lists.
3355 # They must be computed separately, because files in lib/* go into
3356 # $sourcebase/ if they are in the main file list but into $testsbase/
3357 # if they are in the tests-related file list. Furthermore lib/dummy.c
3358 # can be in both.
3359 # Input:
3360 # - local_gnulib_path from --local-dir
3361 # - modcache true or false, from --cache-modules/--no-cache-modules
3362 # - main_modules list of modules, including dependencies
3363 # - testsrelated_modules list of tests-related modules, including dependencies
3364 func_modules_to_filelist_separately ()
3366 # Determine final main file list.
3367 modules="$main_modules"
3368 func_modules_to_filelist
3369 main_files="$files"
3370 # Determine final tests-related file list.
3371 modules="$testsrelated_modules"
3372 func_modules_to_filelist
3373 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3374 # Merge both file lists.
3375 sed_remove_empty_lines='/^$/d'
3376 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3377 if test $verbose -ge 0; then
3378 echo "File list:"
3379 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3380 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3384 # func_compute_include_guard_prefix
3385 # Determine include_guard_prefix.
3386 # Input:
3387 # - macro_prefix prefix of gl_LIBOBJS macros to use
3388 # Output:
3389 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3390 # - sed_replace_include_guard_prefix
3391 # sed expression for resolving ${gl_include_guard_prefix}
3392 func_compute_include_guard_prefix ()
3394 if test "$macro_prefix" = gl; then
3395 include_guard_prefix='GL'
3396 else
3397 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3399 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3402 # func_execute_command command [args...]
3403 # Executes a command.
3404 # Uses also the variables
3405 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3406 func_execute_command ()
3408 if test $verbose -ge 0; then
3409 echo "executing $*"
3410 "$@"
3411 else
3412 # Commands like automake produce output to stderr even when they succeed.
3413 # Turn this output off if the command succeeds.
3414 "$@" > "$tmp"/cmdout 2>&1
3415 cmdret=$?
3416 if test $cmdret = 0; then
3417 rm -f "$tmp"/cmdout
3418 else
3419 echo "executing $*"
3420 cat "$tmp"/cmdout 1>&2
3421 rm -f "$tmp"/cmdout
3422 (exit $cmdret)
3427 # func_dest_tmpfilename file
3428 # determines the name of a temporary file (file is relative to destdir).
3429 # Input:
3430 # - destdir target directory
3431 # - doit : if actions shall be executed, false if only to be printed
3432 # - tmp pathname of a temporary directory
3433 # Sets variable:
3434 # - tmpfile absolute filename of the temporary file
3435 func_dest_tmpfilename ()
3437 if $doit; then
3438 # Put the new contents of $file in a file in the same directory (needed
3439 # to guarantee that an 'mv' to "$destdir/$file" works).
3440 tmpfile="$destdir/$1.tmp"
3441 else
3442 # Put the new contents of $file in a file in a temporary directory
3443 # (because the directory of "$file" might not exist).
3444 tmpfile="$tmp"/`basename "$1"`.tmp
3448 # func_is_local_file lookedup_file file
3449 # check whether file should be instantiated from local gnulib directory
3450 func_is_local_file ()
3452 dname=$1
3453 func_remove_suffix dname "/$2"
3454 func_path_foreach "$local_gnulib_path" test %dir% = "$dname"
3457 # func_should_link
3458 # determines whether the file $f should be copied, symlinked, or hardlinked.
3459 # Input:
3460 # - copymode copy mode for files in general
3461 # - lcopymode copy mode for files from local_gnulib_path
3462 # - f the original file name
3463 # - lookedup_file name of the merged (combined) file
3464 # Sets variable:
3465 # - copyaction copy or symlink or hardlink
3466 func_should_link ()
3468 if test -n "$lcopymode" && func_is_local_file "$lookedup_file" "$f"; then
3469 copyaction="$lcopymode"
3470 else
3471 if test -n "$copymode"; then
3472 copyaction="$copymode"
3473 else
3474 copyaction=copy
3479 # func_add_file
3480 # copies a file from gnulib into the destination directory. The destination
3481 # is known to not exist.
3482 # Input:
3483 # - destdir target directory
3484 # - local_gnulib_path from --local-dir
3485 # - modcache true or false, from --cache-modules/--no-cache-modules
3486 # - f the original file name
3487 # - lookedup_file name of the merged (combined) file
3488 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3489 # - g the rewritten file name
3490 # - tmpfile absolute filename of the temporary file
3491 # - doit : if actions shall be executed, false if only to be printed
3492 # - copymode copy mode for files in general
3493 # - lcopymode copy mode for files from local_gnulib_path
3494 func_add_file ()
3496 if $doit; then
3497 echo "Copying file $g"
3498 func_should_link
3499 if test "$copyaction" = symlink \
3500 && test -z "$lookedup_tmp" \
3501 && cmp -s "$lookedup_file" "$tmpfile"; then
3502 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3503 else
3504 if test "$copyaction" = hardlink \
3505 && test -z "$lookedup_tmp" \
3506 && cmp -s "$lookedup_file" "$tmpfile"; then
3507 func_hardlink "$lookedup_file" "$destdir/$g"
3508 else
3509 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3512 else
3513 echo "Copy file $g"
3517 # func_update_file
3518 # copies a file from gnulib into the destination directory. The destination
3519 # is known to exist.
3520 # Input:
3521 # - destdir target directory
3522 # - local_gnulib_path from --local-dir
3523 # - modcache true or false, from --cache-modules/--no-cache-modules
3524 # - f the original file name
3525 # - lookedup_file name of the merged (combined) file
3526 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3527 # - g the rewritten file name
3528 # - tmpfile absolute filename of the temporary file
3529 # - doit : if actions shall be executed, false if only to be printed
3530 # - copymode copy mode for files in general
3531 # - lcopymode copy mode for files from local_gnulib_path
3532 # - already_present nonempty if the file should already exist, empty otherwise
3533 func_update_file ()
3535 if cmp -s "$destdir/$g" "$tmpfile"; then
3536 : # The file has not changed.
3537 else
3538 # Replace the file.
3539 if $doit; then
3540 if test -n "$already_present"; then
3541 echo "Updating file $g (backup in ${g}~)"
3542 else
3543 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3545 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3546 func_should_link
3547 if test "$copyaction" = symlink \
3548 && test -z "$lookedup_tmp" \
3549 && cmp -s "$lookedup_file" "$tmpfile"; then
3550 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3551 else
3552 if test "$copyaction" = hardlink \
3553 && test -z "$lookedup_tmp" \
3554 && cmp -s "$lookedup_file" "$tmpfile"; then
3555 func_hardlink "$lookedup_file" "$destdir/$g"
3556 else
3557 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3560 else
3561 if test -n "$already_present"; then
3562 echo "Update file $g (backup in ${g}~)"
3563 else
3564 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3570 # func_emit_lib_Makefile_am
3571 # emits the contents of library makefile to standard output.
3572 # Input:
3573 # - local_gnulib_path from --local-dir
3574 # - modcache true or false, from --cache-modules/--no-cache-modules
3575 # - modules list of modules, including dependencies
3576 # - libname library name
3577 # - pobase directory relative to destdir where to place *.po files
3578 # - auxdir directory relative to destdir where to place build aux files
3579 # - gnu_make true if --gnu-make was given, false otherwise
3580 # - makefile_name from --makefile-name
3581 # - libtool true if libtool will be used, false or blank otherwise
3582 # - macro_prefix prefix of gl_LIBOBJS macros to use
3583 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3584 # - witness_c_macro from --witness-c-macro
3585 # - actioncmd (optional) command that will reproduce this invocation
3586 # - for_test true if creating a package for testing, false otherwise
3587 # - sed_replace_include_guard_prefix
3588 # sed expression for resolving ${gl_include_guard_prefix}
3589 # - destfile filename relative to destdir of makefile being generated
3590 # Input/Output:
3591 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
3592 # list of edits to be done to Makefile.am variables
3593 # Output:
3594 # - uses_subdirs nonempty if object files in subdirs exist
3595 func_emit_lib_Makefile_am ()
3598 # When using GNU make, or when creating an includable Makefile.am snippet,
3599 # augment variables with += instead of assigning them.
3600 if $gnu_make || test -n "$makefile_name"; then
3601 assign='+='
3602 else
3603 assign='='
3605 if test "$libtool" = true; then
3606 libext=la
3607 perhapsLT=LT
3608 sed_eliminate_LDFLAGS="$sed_noop"
3609 else
3610 libext=a
3611 perhapsLT=
3612 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3614 if $for_test; then
3615 # When creating a package for testing: Attempt to provoke failures,
3616 # especially link errors, already during "make" rather than during
3617 # "make check", because "make check" is not possible in a cross-compiling
3618 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3619 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3620 else
3621 sed_transform_check_PROGRAMS="$sed_noop"
3623 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3624 $gnu_make ||
3625 echo "## Process this file with automake to produce Makefile.in."
3626 func_emit_copyright_notice
3627 if test -n "$actioncmd"; then
3628 printf '# Reproduce by:\n%s\n' "$actioncmd"
3630 echo
3631 uses_subdirs=
3633 for module in $modules; do
3634 func_verify_nontests_module
3635 if test -n "$module"; then
3637 func_get_automake_snippet_conditional "$module" |
3638 LC_ALL=C \
3639 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3640 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3641 -e "$sed_eliminate_LDFLAGS" \
3642 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3643 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3644 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3645 -e "$sed_transform_check_PROGRAMS" \
3646 -e "$sed_replace_include_guard_prefix"
3647 if test "$module" = 'alloca'; then
3648 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3649 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3651 } | combine_lines "${libname}_${libext}_SOURCES" > "$tmp"/amsnippet1
3653 func_get_automake_snippet_unconditional "$module" |
3654 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3655 } > "$tmp"/amsnippet2
3656 # Skip the contents if it's entirely empty.
3657 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3658 echo "## begin gnulib module $module"
3659 if $gnu_make; then
3660 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
3661 convert_to_gnu_make='s/^if \(.*\)/ifneq (,$(\1))/'
3662 else
3663 convert_to_gnu_make=
3665 echo
3666 if test "$cond_dependencies" = true; then
3667 if func_cond_module_p "$module"; then
3668 func_module_conditional_name "$module"
3669 if $gnu_make; then
3670 echo "ifneq (,\$($conditional))"
3671 else
3672 echo "if $conditional"
3676 sed "$convert_to_gnu_make" "$tmp"/amsnippet1
3677 if test "$cond_dependencies" = true; then
3678 if func_cond_module_p "$module"; then
3679 echo "endif"
3682 sed "$convert_to_gnu_make" "$tmp"/amsnippet2
3683 if $gnu_make; then
3684 echo "endif"
3686 echo "## end gnulib module $module"
3687 echo
3689 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3690 # Test whether there are some source files in subdirectories.
3691 for f in `func_get_filelist "$module"`; do
3692 case $f in
3693 lib/*/*.c)
3694 uses_subdirs=yes
3695 break
3697 esac
3698 done
3700 done
3701 } > "$tmp"/allsnippets
3702 if test -z "$makefile_name"; then
3703 # If there are source files in subdirectories, prevent collision of the
3704 # object files (example: hash.c and libxml/hash.c).
3705 subdir_options=
3706 if test -n "$uses_subdirs"; then
3707 subdir_options=' subdir-objects'
3709 echo "AUTOMAKE_OPTIONS = 1.11 gnits${subdir_options}"
3711 echo
3712 if test -z "$makefile_name"; then
3713 echo "SUBDIRS ="
3714 echo "noinst_HEADERS ="
3715 echo "noinst_LIBRARIES ="
3716 echo "noinst_LTLIBRARIES ="
3717 # Automake versions < 1.11.4 create an empty pkgdatadir at
3718 # installation time if you specify pkgdata_DATA to empty.
3719 # See automake bugs #10997 and #11030:
3720 # * https://debbugs.gnu.org/10997
3721 # * https://debbugs.gnu.org/11030
3722 # So we need this workaround.
3723 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3724 echo "pkgdata_DATA ="
3726 echo "EXTRA_DIST ="
3727 echo "BUILT_SOURCES ="
3728 echo "SUFFIXES ="
3730 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3731 if test -z "$makefile_name"; then
3732 echo "MOSTLYCLEANDIRS ="
3733 echo "CLEANFILES ="
3734 echo "DISTCLEANFILES ="
3735 echo "MAINTAINERCLEANFILES ="
3737 if $gnu_make; then
3738 echo "# Start of GNU Make output."
3740 # Put autoconf output into a temporary file, so that its exit status
3741 # can be checked from the shell. Signal any error by putting a
3742 # syntax error into the output makefile.
3743 ${AUTOCONF} -t 'AC_SUBST:$1 = @$1@' "$configure_ac" \
3744 >"$tmp"/makeout 2>"$tmp"/makeout2 &&
3745 LC_ALL=C sort -u "$tmp"/makeout || {
3746 echo "== gnulib-tool GNU Make output failed as follows =="
3747 sed 's/^/# stderr: /' "$tmp"/makeout2
3749 rm -f "$tmp"/makeout "$tmp"/makeout2
3751 echo "# End of GNU Make output."
3752 else
3753 echo "# No GNU Make output."
3755 # Execute edits that apply to the Makefile.am being generated.
3756 edit=0
3757 while test $edit != $makefile_am_edits; do
3758 edit=`expr $edit + 1`
3759 eval dir=\"\$makefile_am_edit${edit}_dir\"
3760 eval var=\"\$makefile_am_edit${edit}_var\"
3761 eval val=\"\$makefile_am_edit${edit}_val\"
3762 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
3763 if test -n "$var"; then
3764 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3765 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
3766 # The added subdirectory ${val} needs to be mentioned after '.'.
3767 # Since we don't have '.' among SUBDIRS so far, add it now.
3768 val=". ${val}"
3770 echo "${var} += ${val}"
3771 eval "makefile_am_edit${edit}_var="
3774 done
3775 if test -n "$witness_c_macro"; then
3776 cppflags_part1=" -D$witness_c_macro=1"
3777 else
3778 cppflags_part1=
3780 if $for_test; then
3781 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3782 else
3783 cppflags_part2=
3785 if test -z "$makefile_name"; then
3786 echo
3787 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3788 echo "AM_CFLAGS ="
3789 else
3790 if test -n "$cppflags_part1$cppflags_part2"; then
3791 echo
3792 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3795 echo
3796 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3797 || { test -n "$makefile_name" \
3798 && test -f "$sourcebase/Makefile.am" \
3799 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3800 }; then
3801 # One of the snippets or the user's Makefile.am already specifies an
3802 # installation location for the library. Don't confuse automake by saying
3803 # it should not be installed.
3805 else
3806 # By default, the generated library should not be installed.
3807 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3809 echo
3810 echo "${libname}_${libext}_SOURCES ="
3811 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3812 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3813 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3814 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3815 echo "EXTRA_${libname}_${libext}_SOURCES ="
3816 if test "$libtool" = true; then
3817 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3818 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3819 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3820 # the link dependencies of all modules.
3821 for module in $modules; do
3822 func_verify_nontests_module
3823 if test -n "$module"; then
3824 func_get_link_directive "$module"
3826 done \
3827 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3828 | LC_ALL=C sort -u \
3829 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3831 echo
3832 if test -n "$pobase"; then
3833 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3834 echo
3836 cat "$tmp"/allsnippets \
3837 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3838 echo
3839 echo "mostlyclean-local: mostlyclean-generic"
3840 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3841 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3842 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3843 echo " fi; \\"
3844 echo " done; \\"
3845 echo " :"
3846 rm -f "$tmp"/allsnippets
3849 # func_emit_po_Makevars
3850 # emits the contents of po/ makefile parameterization to standard output.
3851 # Input:
3852 # - local_gnulib_path from --local-dir
3853 # - modcache true or false, from --cache-modules/--no-cache-modules
3854 # - sourcebase directory relative to destdir where to place source code
3855 # - pobase directory relative to destdir where to place *.po files
3856 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3857 func_emit_po_Makevars ()
3859 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3860 func_emit_copyright_notice
3861 echo
3862 echo "# Usually the message domain is the same as the package name."
3863 echo "# But here it has a '-gnulib' suffix."
3864 echo "DOMAIN = ${po_domain}-gnulib"
3865 echo
3866 echo "# These two variables depend on the location of this directory."
3867 echo "subdir = ${pobase}"
3868 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3869 echo
3870 cat <<\EOF
3871 # These options get passed to xgettext.
3872 XGETTEXT_OPTIONS = \
3873 --keyword=_ --flag=_:1:pass-c-format \
3874 --keyword=N_ --flag=N_:1:pass-c-format \
3875 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3876 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3877 --flag=error:3:c-format --flag=error_at_line:5:c-format
3879 # This is the copyright holder that gets inserted into the header of the
3880 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3881 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3883 # This is the email address or URL to which the translators shall report
3884 # bugs in the untranslated strings:
3885 # - Strings which are not entire sentences, see the maintainer guidelines
3886 # in the GNU gettext documentation, section 'Preparing Strings'.
3887 # - Strings which use unclear terms or require additional context to be
3888 # understood.
3889 # - Strings which make invalid assumptions about notation of date, time or
3890 # money.
3891 # - Pluralisation problems.
3892 # - Incorrect English spelling.
3893 # - Incorrect formatting.
3894 # It can be your email address, or a mailing list address where translators
3895 # can write to without being subscribed, or the URL of a web page through
3896 # which the translators can contact you.
3897 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3899 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3900 # message catalogs shall be used. It is usually empty.
3901 EXTRA_LOCALE_CATEGORIES =
3903 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3904 # context. Possible values are "yes" and "no". Set this to yes if the
3905 # package uses functions taking also a message context, like pgettext(), or
3906 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3907 USE_MSGCTXT = no
3911 # func_emit_po_POTFILES_in
3912 # emits the file list to be passed to xgettext to standard output.
3913 # Input:
3914 # - local_gnulib_path from --local-dir
3915 # - modcache true or false, from --cache-modules/--no-cache-modules
3916 # - sourcebase directory relative to destdir where to place source code
3917 # - files list of new files
3918 func_emit_po_POTFILES_in ()
3920 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3921 func_emit_copyright_notice
3922 echo
3923 echo "# List of files which contain translatable strings."
3924 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3927 # func_emit_tests_Makefile_am witness_macro
3928 # emits the contents of tests makefile to standard output.
3929 # Input:
3930 # - local_gnulib_path from --local-dir
3931 # - modcache true or false, from --cache-modules/--no-cache-modules
3932 # - modules list of modules, including dependencies
3933 # - libname library name
3934 # - auxdir directory relative to destdir where to place build aux files
3935 # - gnu_make true if --gnu-make was given, false otherwise
3936 # - makefile_name from --makefile-name
3937 # - libtool true if libtool will be used, false or blank otherwise
3938 # - sourcebase relative directory containing lib source code
3939 # - m4base relative directory containing autoconf macros
3940 # - testsbase relative directory containing unit test code
3941 # - macro_prefix prefix of gl_LIBOBJS macros to use
3942 # - witness_c_macro from --witness-c-macro
3943 # - for_test true if creating a package for testing, false otherwise
3944 # - single_configure true if a single configure file should be generated,
3945 # false for a separate configure file for the tests
3946 # - use_libtests true if a libtests.a should be built, false otherwise
3947 # - sed_replace_include_guard_prefix
3948 # sed expression for resolving ${gl_include_guard_prefix}
3949 # - destfile filename relative to destdir of makefile being generated
3950 # Input/Output:
3951 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
3952 # list of edits to be done to Makefile.am variables
3953 # Output:
3954 # - uses_subdirs nonempty if object files in subdirs exist
3955 func_emit_tests_Makefile_am ()
3957 witness_macro="$1"
3958 if test "$libtool" = true; then
3959 libext=la
3960 perhapsLT=LT
3961 sed_eliminate_LDFLAGS="$sed_noop"
3962 else
3963 libext=a
3964 perhapsLT=
3965 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3967 if $for_test; then
3968 # When creating a package for testing: Attempt to provoke failures,
3969 # especially link errors, already during "make" rather than during
3970 # "make check", because "make check" is not possible in a cross-compiling
3971 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3972 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3973 else
3974 sed_transform_check_PROGRAMS="$sed_noop"
3976 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3977 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3978 echo "## Process this file with automake to produce Makefile.in."
3979 func_emit_copyright_notice
3980 echo
3981 uses_subdirs=
3983 for module in $modules; do
3984 if $for_test && ! $single_configure; then
3985 func_verify_tests_module
3986 else
3987 func_verify_module
3989 if test -n "$module"; then
3991 func_get_automake_snippet "$module" |
3992 LC_ALL=C \
3993 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3994 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3995 -e "$sed_eliminate_LDFLAGS" \
3996 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3997 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3998 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3999 -e "$sed_transform_check_PROGRAMS" \
4000 -e "$sed_replace_include_guard_prefix"
4001 if $use_libtests && test "$module" = 'alloca'; then
4002 echo "libtests_a_LIBADD += @ALLOCA@"
4003 echo "libtests_a_DEPENDENCIES += @ALLOCA@"
4005 } > "$tmp"/amsnippet
4006 # Skip the contents if it's entirely empty.
4007 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
4008 # Mention long-running tests at the end.
4009 ofd=3
4010 for word in `func_get_status "$module"`; do
4011 if test "$word" = 'longrunning-test'; then
4012 ofd=4
4013 break
4015 done
4016 { echo "## begin gnulib module $module"
4017 if $gnu_make; then
4018 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
4020 echo
4021 cat "$tmp"/amsnippet
4022 if $gnu_make; then
4023 echo "endif"
4025 echo "## end gnulib module $module"
4026 echo
4027 } >&$ofd
4029 rm -f "$tmp"/amsnippet
4030 # Test whether there are some source files in subdirectories.
4031 for f in `func_get_filelist "$module"`; do
4032 case $f in
4033 lib/*/*.c | tests/*/*.c)
4034 uses_subdirs=yes
4035 break
4037 esac
4038 done
4040 done
4041 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
4042 # Generate dependencies here, since it eases the debugging of test failures.
4043 # If there are source files in subdirectories, prevent collision of the
4044 # object files (example: hash.c and libxml/hash.c).
4045 subdir_options=
4046 if test -n "$uses_subdirs"; then
4047 subdir_options=' subdir-objects'
4049 echo "AUTOMAKE_OPTIONS = 1.11 foreign${subdir_options}"
4050 echo
4051 if $for_test && ! $single_configure; then
4052 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
4053 echo
4055 # Nothing is being added to SUBDIRS; nevertheless the existence of this
4056 # variable is needed to avoid an error from automake:
4057 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
4058 echo "SUBDIRS = ."
4059 echo "TESTS ="
4060 echo "XFAIL_TESTS ="
4061 echo "TESTS_ENVIRONMENT ="
4062 echo "noinst_PROGRAMS ="
4063 if ! $for_test; then
4064 echo "check_PROGRAMS ="
4066 echo "EXTRA_PROGRAMS ="
4067 echo "noinst_HEADERS ="
4068 echo "noinst_LIBRARIES ="
4069 if $use_libtests; then
4070 if $for_test; then
4071 echo "noinst_LIBRARIES += libtests.a"
4072 else
4073 echo "check_LIBRARIES = libtests.a"
4076 # Automake versions < 1.11.4 create an empty pkgdatadir at
4077 # installation time if you specify pkgdata_DATA to empty.
4078 # See automake bugs #10997 and #11030:
4079 # * https://debbugs.gnu.org/10997
4080 # * https://debbugs.gnu.org/11030
4081 # So we need this workaround.
4082 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
4083 echo "pkgdata_DATA ="
4085 echo "EXTRA_DIST ="
4086 echo "BUILT_SOURCES ="
4087 echo "SUFFIXES ="
4088 echo "MOSTLYCLEANFILES = core *.stackdump"
4089 echo "MOSTLYCLEANDIRS ="
4090 echo "CLEANFILES ="
4091 echo "DISTCLEANFILES ="
4092 echo "MAINTAINERCLEANFILES ="
4093 # Execute edits that apply to the Makefile.am being generated.
4094 edit=0
4095 while test $edit != $makefile_am_edits; do
4096 edit=`expr $edit + 1`
4097 eval dir=\"\$makefile_am_edit${edit}_dir\"
4098 eval var=\"\$makefile_am_edit${edit}_var\"
4099 eval val=\"\$makefile_am_edit${edit}_val\"
4100 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
4101 if test -n "$var"; then
4102 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
4103 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
4104 # The added subdirectory ${val} needs to be mentioned after '.'.
4105 # But we have '.' among SUBDIRS already, so do nothing.
4108 echo "${var} += ${val}"
4109 eval "makefile_am_edit${edit}_var="
4112 done
4113 echo
4114 echo "AM_CPPFLAGS = \\"
4115 if $for_test; then
4116 echo " -DGNULIB_STRICT_CHECKING=1 \\"
4118 if test -n "$witness_c_macro"; then
4119 echo " -D$witness_c_macro=1 \\"
4121 if test -n "${witness_macro}"; then
4122 echo " -D@${witness_macro}@=1 \\"
4124 echo " -I. -I\$(srcdir) \\"
4125 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
4126 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
4127 echo
4128 local_ldadd_before=''
4129 local_ldadd_after=''
4130 if $use_libtests; then
4131 # All test programs need to be linked with libtests.a.
4132 # It needs to be passed to the linker before ${libname}.${libext}, since
4133 # the tests-related modules depend on the main modules.
4134 # It also needs to be passed to the linker after ${libname}.${libext}
4135 # because the latter might contain incomplete modules (such as the 'error'
4136 # module whose dependency to 'progname' is voluntarily omitted).
4137 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
4138 # not matter.
4139 local_ldadd_before=' libtests.a'
4140 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
4142 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
4143 echo
4144 if $use_libtests; then
4145 echo "libtests_a_SOURCES ="
4146 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
4147 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
4148 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
4149 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
4150 echo "EXTRA_libtests_a_SOURCES ="
4151 # The circular dependency in LDADD requires this.
4152 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
4153 echo
4155 # Many test scripts use ${EXEEXT} or ${srcdir}.
4156 # EXEEXT is defined by AC_PROG_CC through autoconf.
4157 # srcdir is defined by autoconf and automake.
4158 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
4159 echo
4160 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
4161 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
4162 echo "# Clean up after Solaris cc."
4163 echo "clean-local:"
4164 echo " rm -rf SunWS_cache"
4165 echo
4166 echo "mostlyclean-local: mostlyclean-generic"
4167 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
4168 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
4169 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
4170 echo " fi; \\"
4171 echo " done; \\"
4172 echo " :"
4173 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
4176 # func_emit_initmacro_start macro_prefix
4177 # emits the first few statements of the gl_INIT macro to standard output.
4178 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4179 func_emit_initmacro_start ()
4181 macro_prefix_arg="$1"
4182 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
4183 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
4184 # LIBOBJS. The purpose is to allow several gnulib instantiations under
4185 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
4186 # flexibility.)
4187 # Furthermore it avoids an automake error like this when a Makefile.am
4188 # that uses pieces of gnulib also uses $(LIBOBJ):
4189 # automatically discovered file `error.c' should not be explicitly mentioned
4190 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
4191 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
4192 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
4193 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
4194 # automatically discovered file `error.c' should not be explicitly mentioned
4195 # We let automake know about the files to be distributed through the
4196 # EXTRA_lib_SOURCES variable.
4197 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
4198 # Create data variables for checking the presence of files that are mentioned
4199 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
4200 # because we want the check to happen when the configure file is created,
4201 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
4202 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
4203 # in which to expect them.
4204 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
4205 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
4206 echo " gl_COMMON"
4209 # func_emit_initmacro_end macro_prefix
4210 # emits the last few statements of the gl_INIT macro to standard output.
4211 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4212 func_emit_initmacro_end ()
4214 macro_prefix_arg="$1"
4215 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
4216 # The check is performed only when autoconf is run from the directory where
4217 # the configure.ac resides; if it is run from a different directory, the
4218 # check is skipped.
4219 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
4220 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
4221 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
4222 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
4223 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
4224 echo " exit 1"
4225 echo " fi"
4226 echo " done])dnl"
4227 echo " m4_if(m4_sysval, [0], [],"
4228 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
4229 echo " ])"
4230 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
4231 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
4232 echo " m4_popdef([AC_LIBSOURCES])"
4233 echo " m4_popdef([AC_REPLACE_FUNCS])"
4234 echo " m4_popdef([AC_LIBOBJ])"
4235 echo " AC_CONFIG_COMMANDS_PRE(["
4236 echo " ${macro_prefix_arg}_libobjs="
4237 echo " ${macro_prefix_arg}_ltlibobjs="
4238 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
4239 echo " # Remove the extension."
4240 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
4241 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
4242 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
4243 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
4244 echo " done"
4245 echo " fi"
4246 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
4247 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
4248 echo " ])"
4251 # func_emit_initmacro_done macro_prefix sourcebase
4252 # emits a few statements after the gl_INIT macro to standard output.
4253 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4254 # - sourcebase directory relative to destdir where to place source code
4255 func_emit_initmacro_done ()
4257 macro_prefix_arg="$1"
4258 sourcebase_arg="$2"
4259 echo
4260 echo "# Like AC_LIBOBJ, except that the module name goes"
4261 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4262 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
4263 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
4264 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
4265 echo "])"
4266 echo
4267 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
4268 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4269 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
4270 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
4271 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
4272 echo "])"
4273 echo
4274 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
4275 echo "# expected is derived from the gnulib-tool parameterization,"
4276 echo "# and alloca is special cased (for the alloca-opt module)."
4277 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
4278 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
4279 echo " m4_foreach([_gl_NAME], [\$1], ["
4280 echo " m4_if(_gl_NAME, [alloca.c], [], ["
4281 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
4282 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
4283 echo " ])"
4284 echo " ])"
4285 echo "])"
4288 # func_emit_autoconf_snippet indentation
4289 # emits the autoconf snippet of a module.
4290 # Input:
4291 # - indentation spaces to prepend on each line
4292 # - local_gnulib_path from --local-dir
4293 # - modcache true or false, from --cache-modules/--no-cache-modules
4294 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4295 # - sed_replace_include_guard_prefix
4296 # sed expression for resolving ${gl_include_guard_prefix}
4297 # - module the module name
4298 # - toplevel true or false. 'false' means a subordinate use of
4299 # gnulib-tool.
4300 # - disable_libtool true or false. It tells whether to disable libtool
4301 # handling even if it has been specified through the
4302 # command line options.
4303 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4304 # invocations.
4305 func_emit_autoconf_snippet ()
4307 indentation="$1"
4308 if { case $module in
4309 gnumakefile | maintainer-makefile)
4310 # These modules are meant to be used only in the top-level directory.
4311 $toplevel ;;
4313 true ;;
4314 esac
4315 }; then
4316 func_get_autoconf_snippet "$module" \
4317 | sed -e '/^$/d;' -e "s/^/$indentation/" \
4318 -e "$sed_replace_build_aux" \
4319 -e "$sed_replace_include_guard_prefix" \
4320 | { if $disable_libtool; then
4321 sed -e 's/\$gl_cond_libtool/false/g' \
4322 -e 's/gl_libdeps/gltests_libdeps/g' \
4323 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4324 else
4328 | { if $disable_gettext; then
4329 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
4330 else
4331 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
4332 # autopoint through at least GNU gettext version 0.18.2.
4333 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
4336 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
4337 echo 'changequote(,)dnl'
4338 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4339 echo 'changequote([, ])dnl'
4340 echo 'AC_SUBST([LTALLOCA])'
4345 # func_emit_autoconf_snippets modules referenceable_modules verifier toplevel disable_libtool disable_gettext
4346 # collects and emit the autoconf snippets of a set of modules.
4347 # Input:
4348 # - local_gnulib_path from --local-dir
4349 # - modcache true or false, from --cache-modules/--no-cache-modules
4350 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4351 # - sed_replace_include_guard_prefix
4352 # sed expression for resolving ${gl_include_guard_prefix}
4353 # - modules the list of modules.
4354 # - referenceable_modules the list of modules which may be referenced as dependencies.
4355 # - verifier one of func_verify_module, func_verify_nontests_module,
4356 # func_verify_tests_module. It selects the subset of
4357 # $modules to consider.
4358 # - toplevel true or false. 'false' means a subordinate use of
4359 # gnulib-tool.
4360 # - disable_libtool true or false. It tells whether to disable libtool
4361 # handling even if it has been specified through the
4362 # command line options.
4363 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4364 # invocations.
4365 func_emit_autoconf_snippets ()
4367 referenceable_modules="$2"
4368 verifier="$3"
4369 toplevel="$4"
4370 disable_libtool="$5"
4371 disable_gettext="$6"
4372 if test "$cond_dependencies" = true; then
4373 for m in $referenceable_modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
4374 # Emit the autoconf code for the unconditional modules.
4375 for module in $1; do
4376 eval $verifier
4377 if test -n "$module"; then
4378 if func_cond_module_p "$module"; then
4380 else
4381 func_emit_autoconf_snippet " "
4384 done
4385 # Initialize the shell variables indicating that the modules are enabled.
4386 for module in $1; do
4387 eval $verifier
4388 if test -n "$module"; then
4389 if func_cond_module_p "$module"; then
4390 func_module_shellvar_name "$module"
4391 echo " $shellvar=false"
4394 done
4395 # Emit the autoconf code for the conditional modules, each in a separate
4396 # function. This makes it possible to support cycles among conditional
4397 # modules.
4398 for module in $1; do
4399 eval $verifier
4400 if test -n "$module"; then
4401 if func_cond_module_p "$module"; then
4402 func_module_shellfunc_name "$module"
4403 func_module_shellvar_name "$module"
4404 echo " $shellfunc ()"
4405 echo ' {'
4406 echo " if ! \$$shellvar; then"
4407 func_emit_autoconf_snippet " "
4408 echo " $shellvar=true"
4409 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4410 # Intersect $deps with the modules list $1.
4411 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4412 for dep in $deps; do
4413 if func_cond_module_p "$dep"; then
4414 func_module_shellfunc_name "$dep"
4415 func_cond_module_condition "$module" "$dep"
4416 if test "$condition" != true; then
4417 echo " if $condition; then"
4418 echo " $shellfunc"
4419 echo ' fi'
4420 else
4421 echo " $shellfunc"
4423 else
4424 # The autoconf code for $dep has already been emitted above and
4425 # therefore is already executed when this function is run.
4428 done
4429 echo ' fi'
4430 echo ' }'
4433 done
4434 # Emit the dependencies from the unconditional to the conditional modules.
4435 for module in $1; do
4436 eval $verifier
4437 if test -n "$module"; then
4438 if func_cond_module_p "$module"; then
4440 else
4441 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4442 # Intersect $deps with the modules list $1.
4443 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4444 for dep in $deps; do
4445 if func_cond_module_p "$dep"; then
4446 func_module_shellfunc_name "$dep"
4447 func_cond_module_condition "$module" "$dep"
4448 if test "$condition" != true; then
4449 echo " if $condition; then"
4450 echo " $shellfunc"
4451 echo ' fi'
4452 else
4453 echo " $shellfunc"
4455 else
4456 # The autoconf code for $dep has already been emitted above and
4457 # therefore is already executed when this code is run.
4460 done
4463 done
4464 # Define the Automake conditionals.
4465 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4466 for module in $1; do
4467 eval $verifier
4468 if test -n "$module"; then
4469 if func_cond_module_p "$module"; then
4470 func_module_conditional_name "$module"
4471 func_module_shellvar_name "$module"
4472 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4475 done
4476 else
4477 # Ignore the conditions, and enable all modules unconditionally.
4478 for module in $1; do
4479 eval $verifier
4480 if test -n "$module"; then
4481 func_emit_autoconf_snippet " "
4483 done
4487 # func_emit_pre_early_macros require indentation modules
4488 # The require parameter can be ':' (AC_REQUIRE) or 'false' (direct call).
4489 func_emit_pre_early_macros ()
4491 echo
4492 echo "${2}# Pre-early section."
4493 if $1; then
4494 _pre_early_snippet="echo \"${2}AC_REQUIRE([\$_pre_early_macro])\""
4495 else
4496 _pre_early_snippet="echo \"${2}\$_pre_early_macro\""
4499 # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB. Doing
4500 # AC_REQUIRE in configure-ac.early is not early enough.
4501 _pre_early_macro="gl_USE_SYSTEM_EXTENSIONS"
4502 case "${nl}${3}${nl}" in
4503 *${nl}extensions${nl}*) eval "$_pre_early_snippet" ;;
4504 esac
4506 _pre_early_macro="gl_PROG_AR_RANLIB"
4507 eval "$_pre_early_snippet"
4508 echo
4511 # func_reconstruct_cached_dir
4512 # callback for func_reconstruct_cached_local_gnulib_path
4513 # Input:
4514 # - destdir from --dir
4515 # Output:
4516 # - local_gnulib_path restored '--local-dir' path from cache
4517 func_reconstruct_cached_dir ()
4519 cached_dir=$1
4520 if test -n "$cached_dir"; then
4521 case "$destdir" in
4523 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4525 case "$cached_dir" in
4527 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4529 func_relconcat "$destdir" "$cached_dir"
4530 func_path_append local_gnulib_path "$relconcat" ;;
4531 esac ;;
4532 esac
4536 # func_reconstruct_cached_local_gnulib_path
4537 # reconstruct local_gnulib_path from cached_local_gnulib_path to be set
4538 # relatively to $destdir again.
4539 # Input:
4540 # - cached_local_gnulib_path local_gnulib_path stored within gnulib-cache.m4
4541 # - destdir from --dir
4542 # Output:
4543 # - local_gnulib_path restored '--local-dir' path from cache
4544 func_reconstruct_cached_local_gnulib_path ()
4546 func_path_foreach "$cached_local_gnulib_path" func_reconstruct_cached_dir %dir%
4549 # func_import modules
4550 # Uses also the variables
4551 # - mode import or add-import or remove-import or update
4552 # - destdir target directory
4553 # - local_gnulib_path from --local-dir
4554 # - modcache true or false, from --cache-modules/--no-cache-modules
4555 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4556 # - libname library name
4557 # - supplied_libname true if --lib was given, blank otherwise
4558 # - sourcebase directory relative to destdir where to place source code
4559 # - m4base directory relative to destdir where to place *.m4 macros
4560 # - pobase directory relative to destdir where to place *.po files
4561 # - docbase directory relative to destdir where to place doc files
4562 # - testsbase directory relative to destdir where to place unit test code
4563 # - auxdir directory relative to destdir where to place build aux files
4564 # - inctests true if --with-tests was given, false otherwise
4565 # - incobsolete true if --with-obsolete was given, blank otherwise
4566 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4567 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4568 # otherwise
4569 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4570 # otherwise
4571 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4572 # otherwise
4573 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4574 # - avoidlist list of modules to avoid, from --avoid
4575 # - cond_dependencies true if --conditional-dependencies was given, false if
4576 # --no-conditional-dependencies was given, blank otherwise
4577 # - lgpl yes or a number if library's license shall be LGPL,
4578 # blank otherwise
4579 # - makefile_name from --makefile-name
4580 # - libtool true if --libtool was given, false if --no-libtool was
4581 # given, blank otherwise
4582 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4583 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4584 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4585 # - witness_c_macro from --witness-c-macro
4586 # - vc_files true if --vc-files was given, false if --no-vc-files was
4587 # given, blank otherwise
4588 # - autoconf_minversion minimum supported autoconf version
4589 # - doit : if actions shall be executed, false if only to be printed
4590 # - copymode copy mode for files in general
4591 # - lcopymode copy mode for files from local_gnulib_path
4592 # - do_copyrights true if copyright notices in files should be replaced,
4593 # blank otherwise
4594 func_import ()
4596 # Get the cached settings.
4597 # In 'import' mode, we read them only for the purpose of knowing the old
4598 # installed file list, and don't use them as defaults.
4599 cached_local_gnulib_path=
4600 cached_specified_modules=
4601 cached_incobsolete=
4602 cached_inc_cxx_tests=
4603 cached_inc_longrunning_tests=
4604 cached_inc_privileged_tests=
4605 cached_inc_unportable_tests=
4606 cached_inc_all_tests=
4607 cached_avoidlist=
4608 cached_sourcebase=
4609 cached_m4base=
4610 cached_pobase=
4611 cached_docbase=
4612 cached_testsbase=
4613 cached_inctests=
4614 cached_libname=
4615 cached_lgpl=
4616 cached_makefile_name=
4617 cached_cond_dependencies=
4618 cached_libtool=
4619 cached_macro_prefix=
4620 cached_po_domain=
4621 cached_witness_c_macro=
4622 cached_vc_files=
4623 cached_files=
4624 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4625 cached_libtool=false
4626 my_sed_traces='
4627 s,#.*$,,
4628 s,^dnl .*$,,
4629 s, dnl .*$,,
4630 /gl_LOCAL_DIR(/ {
4631 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_path="\1",p
4633 /gl_MODULES(/ {
4636 s/)/)/
4641 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4643 /gl_WITH_OBSOLETE/ {
4644 s,^.*$,cached_incobsolete=true,p
4646 /gl_WITH_CXX_TESTS/ {
4647 s,^.*$,cached_inc_cxx_tests=true,p
4649 /gl_WITH_LONGRUNNING_TESTS/ {
4650 s,^.*$,cached_inc_longrunning_tests=true,p
4652 /gl_WITH_PRIVILEGED_TESTS/ {
4653 s,^.*$,cached_inc_privileged_tests=true,p
4655 /gl_WITH_UNPORTABLE_TESTS/ {
4656 s,^.*$,cached_inc_unportable_tests=true,p
4658 /gl_WITH_ALL_TESTS/ {
4659 s,^.*$,cached_inc_all_tests=true,p
4661 /gl_AVOID(/ {
4662 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4664 /gl_SOURCE_BASE(/ {
4665 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4667 /gl_M4_BASE(/ {
4668 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4670 /gl_PO_BASE(/ {
4671 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4673 /gl_DOC_BASE(/ {
4674 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4676 /gl_TESTS_BASE(/ {
4677 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4679 /gl_WITH_TESTS/ {
4680 s,^.*$,cached_inctests=true,p
4682 /gl_LIB(/ {
4683 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4685 /gl_LGPL(/ {
4686 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4688 /gl_LGPL/ {
4689 s,^.*$,cached_lgpl=yes,p
4691 /gl_MAKEFILE_NAME(/ {
4692 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4694 /gl_CONDITIONAL_DEPENDENCIES/ {
4695 s,^.*$,cached_cond_dependencies=true,p
4697 /gl_LIBTOOL/ {
4698 s,^.*$,cached_libtool=true,p
4700 /gl_MACRO_PREFIX(/ {
4701 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4703 /gl_PO_DOMAIN(/ {
4704 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4706 /gl_WITNESS_C_MACRO(/ {
4707 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4709 /gl_VC_FILES(/ {
4710 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4712 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4713 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4714 my_sed_traces='
4715 s,#.*$,,
4716 s,^dnl .*$,,
4717 s, dnl .*$,,
4718 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4719 s,^.*$,cached_files=",p
4723 s,^\]).*$,",
4725 s,["$`\\],,g
4732 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4736 if test "$mode" = import; then
4737 # In 'import' mode, the new set of specified modules overrides the cached
4738 # set of modules. Ignore the cached settings.
4739 specified_modules="$1"
4740 else
4741 # Merge the cached settings with the specified ones.
4742 # The m4base must be the same as expected from the pathname.
4743 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4744 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4746 # The local_gnulib_path defaults to the cached one. Recall that the cached one
4747 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4748 if test -z "$local_gnulib_path"; then
4749 func_reconstruct_cached_local_gnulib_path
4751 case $mode in
4752 add-import)
4753 # Append the cached and the specified module names. So that
4754 # "gnulib-tool --add-import foo" means to add the module foo.
4755 specified_modules="$cached_specified_modules $1"
4757 remove-import)
4758 # Take the cached module names, minus the specified module names.
4759 specified_modules=
4760 if $have_associative; then
4761 # Use an associative array, for O(N) worst-case run time.
4762 declare -A to_remove
4763 for m in $1; do
4764 eval 'to_remove[$m]=yes'
4765 done
4766 for module in $cached_specified_modules; do
4767 if eval 'test -z "${to_remove[$module]}"'; then
4768 func_append specified_modules "$module "
4770 done
4771 else
4772 # This loop has O(N**2) worst-case run time.
4773 for module in $cached_specified_modules; do
4774 to_remove=
4775 for m in $1; do
4776 if test "$m" = "$module"; then
4777 to_remove=yes
4778 break
4780 done
4781 if test -z "$to_remove"; then
4782 func_append specified_modules "$module "
4784 done
4787 update)
4788 # Take the cached module names. There are no specified module names.
4789 specified_modules="$cached_specified_modules"
4791 esac
4792 # Included obsolete modules among the dependencies if specified either way.
4793 if test -z "$incobsolete"; then
4794 incobsolete="$cached_incobsolete"
4796 # Included special kinds of tests modules among the dependencies if specified
4797 # either way.
4798 if test -z "$inc_cxx_tests"; then
4799 inc_cxx_tests="$cached_inc_cxx_tests"
4801 if test -z "$inc_longrunning_tests"; then
4802 inc_longrunning_tests="$cached_inc_longrunning_tests"
4804 if test -z "$inc_privileged_tests"; then
4805 inc_privileged_tests="$cached_inc_privileged_tests"
4807 if test -z "$inc_unportable_tests"; then
4808 inc_unportable_tests="$cached_inc_unportable_tests"
4810 if test -z "$inc_all_tests"; then
4811 inc_all_tests="$cached_inc_all_tests"
4813 # Append the cached and the specified avoidlist. This is probably better
4814 # than dropping the cached one when --avoid is specified at least once.
4815 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4816 avoidlist=`echo $avoidlist`
4818 # The sourcebase defaults to the cached one.
4819 if test -z "$sourcebase"; then
4820 sourcebase="$cached_sourcebase"
4821 if test -z "$sourcebase"; then
4822 func_fatal_error "missing --source-base option"
4825 # The pobase defaults to the cached one.
4826 if test -z "$pobase"; then
4827 pobase="$cached_pobase"
4829 # The docbase defaults to the cached one.
4830 if test -z "$docbase"; then
4831 docbase="$cached_docbase"
4832 if test -z "$docbase"; then
4833 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."
4836 # The testsbase defaults to the cached one.
4837 if test -z "$testsbase"; then
4838 testsbase="$cached_testsbase"
4839 if test -z "$testsbase"; then
4840 func_fatal_error "missing --tests-base option"
4843 # Require the tests if specified either way.
4844 if ! $inctests; then
4845 inctests="$cached_inctests"
4846 if test -z "$inctests"; then
4847 inctests=false
4850 # The libname defaults to the cached one.
4851 if test -z "$supplied_libname"; then
4852 libname="$cached_libname"
4853 if test -z "$libname"; then
4854 func_fatal_error "missing --lib option"
4857 # Require LGPL if specified either way.
4858 if test -z "$lgpl"; then
4859 lgpl="$cached_lgpl"
4861 # The makefile_name defaults to the cached one.
4862 if test -z "$makefile_name"; then
4863 makefile_name="$cached_makefile_name"
4865 # Use conditional dependencies if specified either way.
4866 if test -z "$cond_dependencies"; then
4867 cond_dependencies="$cached_cond_dependencies"
4869 # Use libtool if specified either way, or if guessed.
4870 if test -z "$libtool"; then
4871 if test -n "$cached_m4base"; then
4872 libtool="$cached_libtool"
4873 else
4874 libtool="$guessed_libtool"
4877 # The macro_prefix defaults to the cached one.
4878 if test -z "$macro_prefix"; then
4879 macro_prefix="$cached_macro_prefix"
4880 if test -z "$macro_prefix"; then
4881 func_fatal_error "missing --macro-prefix option"
4884 # The po_domain defaults to the cached one.
4885 if test -z "$po_domain"; then
4886 po_domain="$cached_po_domain"
4888 # The witness_c_macro defaults to the cached one.
4889 if test -z "$witness_c_macro"; then
4890 witness_c_macro="$cached_witness_c_macro"
4892 # The vc_files defaults to the cached one.
4893 if test -z "$vc_files"; then
4894 vc_files="$cached_vc_files"
4896 # Ensure constraints.
4897 if test "$cond_dependencies" = true && $inctests; then
4898 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4899 func_exit 1
4902 # --without-*-tests options are not supported here.
4903 excl_cxx_tests=
4904 excl_longrunning_tests=
4905 excl_privileged_tests=
4906 excl_unportable_tests=
4908 # Canonicalize the list of specified modules.
4909 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4911 # Include all kinds of tests modules if --with-all-tests was specified.
4912 inc_all_direct_tests="$inc_all_tests"
4913 inc_all_indirect_tests="$inc_all_tests"
4915 # Determine final module list.
4916 modules="$specified_modules"
4917 func_modules_transitive_closure
4918 if test $verbose -ge 0; then
4919 func_show_module_list
4921 final_modules="$modules"
4923 # Determine main module list and tests-related module list separately.
4924 func_modules_transitive_closure_separately
4926 # Determine whether a $testsbase/libtests.a is needed.
4927 func_determine_use_libtests
4929 # Add the dummy module to the main module list or to the tests-related module
4930 # list if needed.
4931 func_modules_add_dummy_separately
4933 # If --lgpl, verify that the licenses of modules are compatible.
4934 if test -n "$lgpl"; then
4935 license_incompatibilities=
4936 for module in $main_modules; do
4937 license=`func_get_license $module`
4938 case $license in
4939 'GPLed build tool') ;;
4940 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4942 case "$lgpl" in
4943 yes | 3)
4944 case $license in
4945 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
4946 *) func_append license_incompatibilities "$module $license$nl" ;;
4947 esac
4949 3orGPLv2)
4950 case $license in
4951 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
4952 *) func_append license_incompatibilities "$module $license$nl" ;;
4953 esac
4956 case $license in
4957 LGPLv2+) ;;
4958 *) func_append license_incompatibilities "$module $license$nl" ;;
4959 esac
4961 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4962 esac
4964 esac
4965 done
4966 if test -n "$license_incompatibilities"; then
4967 # Format the license incompatibilities as a table.
4968 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4969 s,^\(.................................................[^ ]*\) *, \1 ,'
4970 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4971 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4975 # Show banner notice of every module.
4976 modules="$main_modules"
4977 func_modules_notice
4979 # Determine script to apply to imported library files.
4980 sed_transform_lib_file=
4981 for module in $main_modules; do
4982 if test $module = config-h; then
4983 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4984 sed_transform_lib_file=$sed_transform_lib_file'
4985 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4987 break
4989 done
4990 sed_transform_main_lib_file="$sed_transform_lib_file"
4991 if test -n "$do_copyrights"; then
4992 if test -n "$lgpl"; then
4993 # Update license.
4994 case "$lgpl" in
4995 yes | 3)
4996 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4997 s/GNU General/GNU Lesser General/g
4998 s/General Public License/Lesser General Public License/g
4999 s/Lesser Lesser General Public License/Lesser General Public License/g
5002 3orGPLv2)
5003 sed_transform_main_lib_file=$sed_transform_main_lib_file'
5004 /^ *This program is free software/i\
5005 This program is free software: you can redistribute it and\/or\
5006 modify it under the terms of either:\
5008 * the GNU Lesser General Public License as published by the Free\
5009 Software Foundation; either version 3 of the License, or (at your\
5010 option) any later version.\
5014 * the GNU General Public License as published by the Free\
5015 Software Foundation; either version 2 of the License, or (at your\
5016 option) any later version.\
5018 or both in parallel, as here.
5019 /^ *This program is free software/,/^$/d
5023 sed_transform_main_lib_file=$sed_transform_main_lib_file'
5024 s/GNU General/GNU Lesser General/g
5025 s/General Public License/Lesser General Public License/g
5026 s/Lesser Lesser General Public License/Lesser General Public License/g
5028 s/version [23]\([ ,]\)/version 2.1\1/g
5031 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
5032 esac
5033 else
5034 # Update license.
5035 sed_transform_main_lib_file=$sed_transform_main_lib_file'
5036 s/GNU Lesser General/GNU General/g
5037 s/Lesser General Public License/General Public License/g
5039 s/GNU Library General/GNU General/g
5040 s/Library General Public License/General Public License/g
5042 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
5047 # Determine script to apply to auxiliary files that go into $auxdir/.
5048 sed_transform_build_aux_file=
5049 if test -n "$do_copyrights"; then
5050 # Update license.
5051 sed_transform_build_aux_file=$sed_transform_build_aux_file'
5052 s/GNU Lesser General/GNU General/g
5053 s/Lesser General Public License/General Public License/g
5055 s/GNU Library General/GNU General/g
5056 s/Library General Public License/General Public License/g
5058 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
5062 # Determine script to apply to library files that go into $testsbase/.
5063 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
5064 if test -n "$do_copyrights"; then
5065 # Update license.
5066 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
5067 s/GNU Lesser General/GNU General/g
5068 s/Lesser General Public License/General Public License/g
5070 s/GNU Library General/GNU General/g
5071 s/Library General Public License/General Public License/g
5073 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
5077 # Determine the final file lists.
5078 func_modules_to_filelist_separately
5080 test -n "$files" \
5081 || func_fatal_error "refusing to do nothing"
5083 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
5084 new_files="$files m4/gnulib-tool.m4"
5085 old_files="$cached_files"
5086 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
5087 func_append old_files " m4/gnulib-tool.m4"
5090 rewritten='%REWRITTEN%'
5091 sed_rewrite_old_files="\
5092 s,^build-aux/,$rewritten$auxdir/,
5093 s,^doc/,$rewritten$cached_docbase/,
5094 s,^lib/,$rewritten$cached_sourcebase/,
5095 s,^m4/,$rewritten$cached_m4base/,
5096 s,^tests/,$rewritten$cached_testsbase/,
5097 s,^tests=lib/,$rewritten$cached_testsbase/,
5098 s,^top/,$rewritten,
5099 s,^$rewritten,,"
5100 sed_rewrite_new_files="\
5101 s,^build-aux/,$rewritten$auxdir/,
5102 s,^doc/,$rewritten$docbase/,
5103 s,^lib/,$rewritten$sourcebase/,
5104 s,^m4/,$rewritten$m4base/,
5105 s,^tests/,$rewritten$testsbase/,
5106 s,^tests=lib/,$rewritten$testsbase/,
5107 s,^top/,$rewritten,
5108 s,^$rewritten,,"
5110 # Determine whether to put anything into $testsbase.
5111 testsfiles=`echo "$files" | sed -n -e 's,^tests/,,p' -e 's,^tests=lib/,,p'`
5112 if test -n "$testsfiles"; then
5113 gentests=true
5114 else
5115 gentests=false
5118 # Create directories.
5119 { echo "$sourcebase"
5120 echo "$m4base"
5121 if test -n "$pobase"; then
5122 echo "$pobase"
5124 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
5125 if test -n "$docfiles"; then
5126 echo "$docbase"
5128 if $gentests; then
5129 echo "$testsbase"
5131 echo "$auxdir"
5132 for f in $files; do echo $f; done \
5133 | sed -e "$sed_rewrite_new_files" \
5134 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5135 | LC_ALL=C sort -u
5136 } > "$tmp"/dirs
5137 { # Rearrange file descriptors. Needed because "while ... done < ..."
5138 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5139 exec 5<&0 < "$tmp"/dirs
5140 while read d; do
5141 if test ! -d "$destdir/$d"; then
5142 if $doit; then
5143 echo "Creating directory $destdir/$d"
5144 mkdir -p "$destdir/$d" || func_fatal_error "failed"
5145 else
5146 echo "Create directory $destdir/$d"
5149 done
5150 exec 0<&5 5<&-
5153 # Copy files or make symbolic links or hard links. Remove obsolete files.
5154 added_files=''
5155 removed_files=''
5156 delimiter=' '
5157 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5158 # representing the files according to the last gnulib-tool invocation.
5159 for f in $old_files; do echo $f; done \
5160 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
5161 | LC_ALL=C sort \
5162 > "$tmp"/old-files
5163 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5164 # representing the files after this gnulib-tool invocation.
5165 for f in $new_files; do echo $f; done \
5166 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
5167 | LC_ALL=C sort \
5168 > "$tmp"/new-files
5169 # First the files that are in old-files, but not in new-files:
5170 sed_take_first_column='s,'"$delimiter"'.*,,'
5171 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
5172 # Remove the file. Do nothing if the user already removed it.
5173 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
5174 if $doit; then
5175 echo "Removing file $g (backup in ${g}~)"
5176 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
5177 else
5178 echo "Remove file $g (backup in ${g}~)"
5180 func_append removed_files "$g$nl"
5182 done
5183 # func_add_or_update handles a file that ought to be present afterwards.
5184 # Uses parameters
5185 # - f the original file name
5186 # - g the rewritten file name
5187 # - already_present nonempty if the file should already exist, empty
5188 # otherwise
5189 func_add_or_update ()
5191 of="$f"
5192 case "$f" in
5193 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5194 esac
5195 func_dest_tmpfilename "$g"
5196 func_lookup_file "$f"
5197 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5198 case "$f" in
5199 *.class | *.mo )
5200 # Don't process binary files with sed.
5203 if test -n "$sed_transform_main_lib_file"; then
5204 case "$of" in
5205 lib/*)
5206 sed -e "$sed_transform_main_lib_file" \
5207 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5209 esac
5211 if test -n "$sed_transform_build_aux_file"; then
5212 case "$of" in
5213 build-aux/*)
5214 sed -e "$sed_transform_build_aux_file" \
5215 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5217 esac
5219 if test -n "$sed_transform_testsrelated_lib_file"; then
5220 case "$of" in
5221 tests=lib/*)
5222 sed -e "$sed_transform_testsrelated_lib_file" \
5223 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5225 esac
5228 esac
5229 if test -f "$destdir/$g"; then
5230 # The file already exists.
5231 func_update_file
5232 else
5233 # Install the file.
5234 # Don't protest if the file should be there but isn't: it happens
5235 # frequently that developers don't put autogenerated files under version control.
5236 func_add_file
5237 func_append added_files "$g$nl"
5239 rm -f "$tmpfile"
5241 # Then the files that are in new-files, but not in old-files:
5242 sed_take_last_column='s,^.*'"$delimiter"',,'
5243 already_present=
5244 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
5245 | sed -e "$sed_take_last_column" \
5246 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
5247 { # Rearrange file descriptors. Needed because "while ... done < ..."
5248 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5249 exec 5<&0 < "$tmp"/added-files
5250 while read g f; do
5251 func_add_or_update
5252 done
5253 exec 0<&5 5<&-
5255 # Then the files that are in new-files and in old-files:
5256 already_present=true
5257 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
5258 | sed -e "$sed_take_last_column" \
5259 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
5260 { # Rearrange file descriptors. Needed because "while ... done < ..."
5261 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5262 exec 5<&0 < "$tmp"/kept-files
5263 while read g f; do
5264 func_add_or_update
5265 done
5266 exec 0<&5 5<&-
5269 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
5270 actioncmd="# gnulib-tool --import"
5272 # Local helper.
5273 func_append_local_dir ()
5275 func_append "$1" " --local-dir=$2"
5277 func_path_foreach "$local_gnulib_path" func_append_local_dir actioncmd %dir%
5279 # Break the action command log into multiple lines.
5280 # Emacs puts some gnulib-tool log lines in its source repository, and
5281 # git send-email rejects patch lines longer than 998 characters.
5282 # Also, config.status uses awk, and the HP-UX 11.00 awk fails if a
5283 # line has length >= 3071; similarly, the IRIX 6.5 awk fails if a
5284 # line has length >= 3072.
5285 func_append_actionarg ()
5287 func_append actioncmd " \\$nl# $1"
5289 func_append_actionarg "--lib=$libname"
5290 func_append_actionarg "--source-base=$sourcebase"
5291 func_append_actionarg "--m4-base=$m4base"
5292 if test -n "$pobase"; then
5293 func_append_actionarg "--po-base=$pobase"
5295 func_append_actionarg "--doc-base=$docbase"
5296 func_append_actionarg "--tests-base=$testsbase"
5297 func_append_actionarg "--aux-dir=$auxdir"
5298 if $inctests; then
5299 func_append_actionarg "--with-tests"
5301 if test -n "$incobsolete"; then
5302 func_append_actionarg "--with-obsolete"
5304 if test -n "$inc_cxx_tests"; then
5305 func_append_actionarg "--with-c++-tests"
5307 if test -n "$inc_longrunning_tests"; then
5308 func_append_actionarg "--with-longrunning-tests"
5310 if test -n "$inc_privileged_tests"; then
5311 func_append_actionarg "--with-privileged-tests"
5313 if test -n "$inc_unportable_tests"; then
5314 func_append_actionarg "--with-unportable-tests"
5316 if test -n "$inc_all_tests"; then
5317 func_append_actionarg "--with-all-tests"
5319 if test -n "$lgpl"; then
5320 if test "$lgpl" = yes; then
5321 func_append_actionarg "--lgpl"
5322 else
5323 func_append_actionarg "--lgpl=$lgpl"
5326 if $gnu_make; then
5327 func_append_actionarg "--gnu-make"
5329 if test -n "$makefile_name"; then
5330 func_append_actionarg "--makefile-name=$makefile_name"
5332 if test "$cond_dependencies" = true; then
5333 func_append_actionarg "--conditional-dependencies"
5334 else
5335 func_append_actionarg "--no-conditional-dependencies"
5337 if test "$libtool" = true; then
5338 func_append_actionarg "--libtool"
5339 else
5340 func_append_actionarg "--no-libtool"
5342 func_append_actionarg "--macro-prefix=$macro_prefix"
5343 if test -n "$po_domain"; then
5344 func_append_actionarg "--po-domain=$po_domain"
5346 if test -n "$witness_c_macro"; then
5347 func_append_actionarg "--witness-c-macro=$witness_c_macro"
5349 if test -n "$vc_files"; then
5350 if test "$vc_files" = true; then
5351 func_append_actionarg "--vc-files"
5352 else
5353 func_append_actionarg "--no-vc-files"
5356 for module in $avoidlist; do
5357 func_append_actionarg "--avoid=$module"
5358 done
5359 for module in $specified_modules; do
5360 func_append_actionarg "$module"
5361 done
5363 # Determine include_guard_prefix.
5364 func_compute_include_guard_prefix
5366 # Default the makefile name to Makefile.am.
5367 if test -n "$makefile_name"; then
5368 makefile_am=$makefile_name
5369 else
5370 makefile_am=Makefile.am
5373 # Create normal Makefile.ams.
5374 for_test=false
5376 # Setup list of Makefile.am edits that are to be performed afterwards.
5377 # Some of these edits apply to files that we will generate; others are
5378 # under the responsibility of the developer.
5379 makefile_am_edits=0
5380 # func_note_Makefile_am_edit dir var value [dotfirst]
5381 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
5382 # ${value}.
5383 # If ${dotfirst} is non-empty, this mention needs to be present after '.'.
5384 # This is a special hack for the SUBDIRS variable, cf.
5385 # <https://www.gnu.org/software/automake/manual/html_node/Subdirectories.html>.
5386 func_note_Makefile_am_edit ()
5388 makefile_am_edits=`expr $makefile_am_edits + 1`
5389 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
5390 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
5391 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
5392 eval makefile_am_edit${makefile_am_edits}_dotfirst=\"\$4\"
5394 if test "$makefile_am" = Makefile.am; then
5395 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
5396 sourcebase_base=`basename "$sourcebase"`
5397 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
5399 if test -n "$pobase"; then
5400 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
5401 pobase_base=`basename "$pobase"`
5402 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
5404 if $inctests; then
5405 if test "$makefile_am" = Makefile.am; then
5406 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
5407 testsbase_base=`basename "$testsbase"`
5408 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base" true
5411 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
5413 # Find the first parent directory of $m4base that contains or will contain
5414 # a Makefile.am.
5415 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
5416 s,//*$,/,'
5417 sed_butlast='s,[^/][^/]*//*$,,'
5418 dir1="${m4base}/"; dir2=""
5419 while test -n "$dir1" \
5420 && ! { test -f "${destdir}/${dir1}Makefile.am" \
5421 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5422 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5423 || { $gentests \
5424 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
5425 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
5426 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
5427 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
5428 done
5429 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
5432 # Create library makefile.
5433 func_dest_tmpfilename $sourcebase/$makefile_am
5434 destfile="$sourcebase/$makefile_am"
5435 modules="$main_modules"
5436 func_emit_lib_Makefile_am > "$tmpfile"
5437 if test -f "$destdir"/$sourcebase/$makefile_am; then
5438 if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
5439 rm -f "$tmpfile"
5440 else
5441 if $doit; then
5442 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5443 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
5444 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5445 else
5446 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5447 rm -f "$tmpfile"
5450 else
5451 if $doit; then
5452 echo "Creating $sourcebase/$makefile_am"
5453 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5454 else
5455 echo "Create $sourcebase/$makefile_am"
5456 rm -f "$tmpfile"
5458 func_append added_files "$sourcebase/$makefile_am$nl"
5461 # Create po/ directory.
5462 if test -n "$pobase"; then
5463 # Create po makefile and auxiliary files.
5464 for file in Makefile.in.in remove-potcdate.sin; do
5465 func_dest_tmpfilename $pobase/$file
5466 func_lookup_file build-aux/po/$file
5467 cat "$lookedup_file" > "$tmpfile"
5468 if test -f "$destdir"/$pobase/$file; then
5469 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
5470 rm -f "$tmpfile"
5471 else
5472 if $doit; then
5473 echo "Updating $pobase/$file (backup in $pobase/$file~)"
5474 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
5475 mv -f "$tmpfile" "$destdir"/$pobase/$file
5476 else
5477 echo "Update $pobase/$file (backup in $pobase/$file~)"
5478 rm -f "$tmpfile"
5481 else
5482 if $doit; then
5483 echo "Creating $pobase/$file"
5484 mv -f "$tmpfile" "$destdir"/$pobase/$file
5485 else
5486 echo "Create $pobase/$file"
5487 rm -f "$tmpfile"
5489 func_append added_files "$pobase/$file$nl"
5491 done
5492 # Create po makefile parameterization, part 1.
5493 func_dest_tmpfilename $pobase/Makevars
5494 func_emit_po_Makevars > "$tmpfile"
5495 if test -f "$destdir"/$pobase/Makevars; then
5496 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
5497 rm -f "$tmpfile"
5498 else
5499 if $doit; then
5500 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
5501 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
5502 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5503 else
5504 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
5505 rm -f "$tmpfile"
5508 else
5509 if $doit; then
5510 echo "Creating $pobase/Makevars"
5511 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5512 else
5513 echo "Create $pobase/Makevars"
5514 rm -f "$tmpfile"
5516 func_append added_files "$pobase/Makevars$nl"
5518 # Create po makefile parameterization, part 2.
5519 func_dest_tmpfilename $pobase/POTFILES.in
5520 func_emit_po_POTFILES_in > "$tmpfile"
5521 if test -f "$destdir"/$pobase/POTFILES.in; then
5522 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5523 rm -f "$tmpfile"
5524 else
5525 if $doit; then
5526 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5527 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5528 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5529 else
5530 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5531 rm -f "$tmpfile"
5534 else
5535 if $doit; then
5536 echo "Creating $pobase/POTFILES.in"
5537 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5538 else
5539 echo "Create $pobase/POTFILES.in"
5540 rm -f "$tmpfile"
5542 func_append added_files "$pobase/POTFILES.in$nl"
5544 # Fetch PO files.
5545 TP_URL="https://translationproject.org/latest/"
5546 if $doit; then
5547 echo "Fetching gnulib PO files from $TP_URL"
5548 (cd "$destdir"/$pobase \
5549 && wget --no-verbose --mirror --level=1 -nd -A.po -P . "${TP_URL}gnulib/"
5551 else
5552 echo "Fetch gnulib PO files from $TP_URL"
5554 # Create po/LINGUAS.
5555 if $doit; then
5556 func_dest_tmpfilename $pobase/LINGUAS
5557 (cd "$destdir"/$pobase \
5558 && { echo '# Set of available languages.'
5559 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5561 ) > "$tmpfile"
5562 if test -f "$destdir"/$pobase/LINGUAS; then
5563 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5564 rm -f "$tmpfile"
5565 else
5566 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5567 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5568 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5570 else
5571 echo "Creating $pobase/LINGUAS"
5572 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5573 func_append added_files "$pobase/LINGUAS$nl"
5575 else
5576 if test -f "$destdir"/$pobase/LINGUAS; then
5577 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5578 else
5579 echo "Create $pobase/LINGUAS"
5584 # func_count_relative_local_gnulib_path
5585 # gl_LOCAL_DIR requires local_gnulib_path to be set relatively to destdir
5586 # Input:
5587 # - local_gnulib_path from --local-dir
5588 # - destdir from --dir
5589 # Output:
5590 # - relative_local_dir path to be stored into gl_LOCAL_DIR
5591 func_count_relative_local_gnulib_path ()
5593 relative_local_gnulib_path=
5594 save_IFS="$IFS"
5595 IFS="$PATH_SEPARATOR"
5596 for local_dir in $local_gnulib_path
5598 IFS="$save_IFS"
5599 # Store the local_dir relative to destdir.
5600 case "$local_dir" in
5601 "" | /*)
5602 relative_local_dir="$local_dir" ;;
5604 case "$destdir" in
5605 /*) relative_local_dir="$local_dir" ;;
5607 # destdir, local_dir are both relative.
5608 func_relativize "$destdir" "$local_dir"
5609 relative_local_dir="$reldir" ;;
5610 esac ;;
5611 esac
5612 func_path_append relative_local_gnulib_path "$relative_local_dir"
5613 done
5614 IFS="$save_IFS"
5617 # Create m4/gnulib-cache.m4.
5618 func_dest_tmpfilename $m4base/gnulib-cache.m4
5620 func_emit_copyright_notice
5621 echo "#"
5622 echo "# This file represents the specification of how gnulib-tool is used."
5623 echo "# It acts as a cache: It is written and read by gnulib-tool."
5624 echo "# In projects that use version control, this file is meant to be put under"
5625 echo "# version control, like the configure.ac and various Makefile.am files."
5626 echo
5627 echo
5628 echo "# Specification in the form of a command-line invocation:"
5629 printf '%s\n' "$actioncmd"
5630 echo
5631 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5632 func_count_relative_local_gnulib_path
5633 echo "gl_LOCAL_DIR([$relative_local_gnulib_path])"
5634 echo "gl_MODULES(["
5635 echo "$specified_modules" | sed -e 's/^/ /g'
5636 echo "])"
5637 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5638 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5639 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5640 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5641 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5642 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5643 echo "gl_AVOID([$avoidlist])"
5644 echo "gl_SOURCE_BASE([$sourcebase])"
5645 echo "gl_M4_BASE([$m4base])"
5646 echo "gl_PO_BASE([$pobase])"
5647 echo "gl_DOC_BASE([$docbase])"
5648 echo "gl_TESTS_BASE([$testsbase])"
5649 if $inctests; then
5650 echo "gl_WITH_TESTS"
5652 echo "gl_LIB([$libname])"
5653 if test -n "$lgpl"; then
5654 if test "$lgpl" = yes; then
5655 echo "gl_LGPL"
5656 else
5657 echo "gl_LGPL([$lgpl])"
5660 echo "gl_MAKEFILE_NAME([$makefile_name])"
5661 if test "$cond_dependencies" = true; then
5662 echo "gl_CONDITIONAL_DEPENDENCIES"
5664 if test "$libtool" = true; then
5665 echo "gl_LIBTOOL"
5667 echo "gl_MACRO_PREFIX([$macro_prefix])"
5668 echo "gl_PO_DOMAIN([$po_domain])"
5669 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5670 if test -n "$vc_files"; then
5671 echo "gl_VC_FILES([$vc_files])"
5673 ) > "$tmpfile"
5674 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5675 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
5676 rm -f "$tmpfile"
5677 else
5678 if $doit; then
5679 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5680 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5681 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5682 else
5683 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5684 if false; then
5685 cat "$tmpfile"
5686 echo
5687 echo "# gnulib-cache.m4 ends here"
5689 rm -f "$tmpfile"
5692 else
5693 if $doit; then
5694 echo "Creating $m4base/gnulib-cache.m4"
5695 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5696 else
5697 echo "Create $m4base/gnulib-cache.m4"
5698 cat "$tmpfile"
5699 rm -f "$tmpfile"
5703 # Create m4/gnulib-comp.m4.
5704 func_dest_tmpfilename $m4base/gnulib-comp.m4
5706 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5707 func_emit_copyright_notice
5708 echo "#"
5709 echo "# This file represents the compiled summary of the specification in"
5710 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5711 echo "# to be invoked from configure.ac."
5712 echo "# In projects that use version control, this file can be treated like"
5713 echo "# other built files."
5714 echo
5715 echo
5716 echo "# This macro should be invoked from $configure_ac, in the section"
5717 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5718 echo "# any checks for libraries, header files, types and library functions."
5719 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5720 echo "["
5721 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5722 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5723 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5724 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5726 func_emit_pre_early_macros : ' ' "$final_modules"
5728 if ! $gnu_make && test -n "$uses_subdirs"; then
5729 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5731 for module in $final_modules; do
5732 func_verify_module
5733 if test -n "$module"; then
5734 echo "# Code from module $module:"
5735 func_get_autoconf_early_snippet "$module"
5737 done \
5738 | sed -e '/^$/d;' -e 's/^/ /'
5739 echo "])"
5740 echo
5741 echo "# This macro should be invoked from $configure_ac, in the section"
5742 echo "# \"Check for header files, types and library functions\"."
5743 echo "AC_DEFUN([${macro_prefix}_INIT],"
5744 echo "["
5745 if test "$libtool" = true; then
5746 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5747 echo " gl_cond_libtool=true"
5748 else
5749 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5750 echo " gl_cond_libtool=false"
5751 echo " gl_libdeps="
5752 echo " gl_ltlibdeps="
5754 if test "$auxdir" != "build-aux"; then
5755 sed_replace_build_aux='
5757 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5758 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5761 else
5762 sed_replace_build_aux="$sed_noop"
5764 echo " gl_m4_base='$m4base'"
5765 func_emit_initmacro_start $macro_prefix
5766 echo " gl_source_base='$sourcebase'"
5767 if test -n "$witness_c_macro"; then
5768 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5770 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false true
5771 if test -n "$witness_c_macro"; then
5772 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5774 echo " # End of code from modules"
5775 func_emit_initmacro_end $macro_prefix
5776 echo " gltests_libdeps="
5777 echo " gltests_ltlibdeps="
5778 func_emit_initmacro_start ${macro_prefix}tests
5779 echo " gl_source_base='$testsbase'"
5780 # Define a tests witness macro that depends on the package.
5781 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5782 # See <https://lists.gnu.org/r/automake/2009-05/msg00145.html>.
5783 echo "changequote(,)dnl"
5784 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"
5785 echo "changequote([, ])dnl"
5786 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5787 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5788 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5789 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true true true
5790 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5791 func_emit_initmacro_end ${macro_prefix}tests
5792 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5793 # created using libtool, because libtool already handles the dependencies.
5794 if test "$libtool" != true; then
5795 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5796 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5797 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5798 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5799 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5801 if $use_libtests; then
5802 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5803 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5805 echo "])"
5806 func_emit_initmacro_done $macro_prefix $sourcebase
5807 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5808 echo
5809 echo "# This macro records the list of files which have been installed by"
5810 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5811 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5812 echo "$files" | sed -e 's,^, ,'
5813 echo "])"
5814 ) > "$tmpfile"
5815 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5816 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
5817 rm -f "$tmpfile"
5818 else
5819 if $doit; then
5820 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5821 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5822 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5823 else
5824 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5825 if false; then
5826 cat "$tmpfile"
5827 echo
5828 echo "# gnulib-comp.m4 ends here"
5830 rm -f "$tmpfile"
5833 else
5834 if $doit; then
5835 echo "Creating $m4base/gnulib-comp.m4"
5836 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5837 else
5838 echo "Create $m4base/gnulib-comp.m4"
5839 cat "$tmpfile"
5840 rm -f "$tmpfile"
5844 if $gentests; then
5845 # Create tests makefile.
5846 func_dest_tmpfilename $testsbase/$makefile_am
5847 destfile="$testsbase/$makefile_am"
5848 modules="$testsrelated_modules"
5849 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5850 if test -f "$destdir"/$testsbase/$makefile_am; then
5851 if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
5852 rm -f "$tmpfile"
5853 else
5854 if $doit; then
5855 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5856 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5857 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5858 else
5859 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5860 rm -f "$tmpfile"
5863 else
5864 if $doit; then
5865 echo "Creating $testsbase/$makefile_am"
5866 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5867 else
5868 echo "Create $testsbase/$makefile_am"
5869 rm -f "$tmpfile"
5871 func_append added_files "$testsbase/$makefile_am$nl"
5875 if test "$vc_files" != false; then
5876 # Update the .cvsignore and .gitignore files.
5877 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5878 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5879 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5880 echo "$m4base/|A|gnulib-comp.m4"
5881 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5882 { # Rearrange file descriptors. Needed because "while ... done < ..."
5883 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5884 exec 5<&0 < "$tmp"/fileset-changes
5885 func_update_ignorelist ()
5887 ignore="$1"
5888 if test "$ignore" = .gitignore; then
5889 # In a .gitignore file, "foo" applies to the current directory and all
5890 # subdirectories, whereas "/foo" applies to the current directory only.
5891 anchor='/'
5892 escaped_anchor='\/'
5893 doubly_escaped_anchor='\\/'
5894 else
5895 anchor=''
5896 escaped_anchor=''
5897 doubly_escaped_anchor=''
5899 if test -f "$destdir/$dir$ignore"; then
5900 if test -n "$dir_added" || test -n "$dir_removed"; then
5901 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5902 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5903 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5904 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5905 > "$tmp"/ignore-removed
5907 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5908 if $doit; then
5909 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5910 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5911 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5912 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5913 } > "$tmp"/sed-ignore-removed
5914 { cat "$destdir/$dir$ignore"~
5915 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5916 } | sed -f "$tmp"/sed-ignore-removed \
5917 > "$destdir/$dir$ignore"
5918 else
5919 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5923 else
5924 if test -n "$dir_added"; then
5925 if $doit; then
5926 echo "Creating $destdir/$dir$ignore"
5928 if test "$ignore" = .cvsignore; then
5929 echo ".deps"
5930 # Automake generates Makefile rules that create .dirstamp files.
5931 echo ".dirstamp"
5933 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5934 } > "$destdir/$dir$ignore"
5935 else
5936 echo "Create $destdir/$dir$ignore"
5941 func_done_dir ()
5943 dir="$1"
5944 dir_added="$2"
5945 dir_removed="$3"
5946 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5947 func_update_ignorelist .cvsignore
5949 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5950 func_update_ignorelist .gitignore
5953 last_dir=
5954 last_dir_added=
5955 last_dir_removed=
5956 while read line; do
5957 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5958 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5959 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5960 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5961 if test "$next_dir" != "$last_dir"; then
5962 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5963 last_dir="$next_dir"
5964 last_dir_added=
5965 last_dir_removed=
5967 case $op in
5968 A) func_append last_dir_added "$file$nl";;
5969 R) func_append last_dir_removed "$file$nl";;
5970 esac
5971 done
5972 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5973 exec 0<&5 5<&-
5977 echo "Finished."
5978 echo
5979 echo "You may need to add #include directives for the following .h files."
5980 # Intersect $specified_modules and $main_modules
5981 # (since $specified_modules is not necessarily of subset of $main_modules
5982 # - some may have been skipped through --avoid, and since the elements of
5983 # $main_modules but not in $specified_modules can go away without explicit
5984 # notice - through changes in the module dependencies).
5985 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5986 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5987 # First the #include <...> directives without #ifs, sorted for convenience,
5988 # then the #include "..." directives without #ifs, sorted for convenience,
5989 # then the #include directives that are surrounded by #ifs. Not sorted.
5990 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5991 include_directive=`func_get_include_directive "$module"`
5992 case "$nl$include_directive" in
5993 *"$nl#if"*)
5994 echo "$include_directive" 1>&5
5997 echo "$include_directive" | grep -v 'include "' 1>&6
5998 echo "$include_directive" | grep 'include "' 1>&7
6000 esac
6001 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
6003 LC_ALL=C sort -u "$tmp"/include-angles
6004 LC_ALL=C sort -u "$tmp"/include-quotes
6005 cat "$tmp"/include-if
6006 ) | sed -e '/^$/d' -e 's/^/ /'
6007 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
6009 for module in $main_modules; do
6010 func_get_link_directive "$module"
6011 done \
6012 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
6013 if test `wc -l < "$tmp"/link` != 0; then
6014 echo
6015 echo "You may need to use the following Makefile variables when linking."
6016 echo "Use them in <program>_LDADD when linking a program, or"
6017 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
6018 cat "$tmp"/link
6020 rm -f "$tmp"/link
6022 echo
6023 echo "Don't forget to"
6024 if test "$makefile_am" = Makefile.am; then
6025 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
6026 else
6027 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
6029 if test -n "$pobase"; then
6030 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
6032 if $gentests; then
6033 if test "$makefile_am" = Makefile.am; then
6034 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
6035 else
6036 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
6039 edit=0
6040 while test $edit != $makefile_am_edits; do
6041 edit=`expr $edit + 1`
6042 eval dir=\"\$makefile_am_edit${edit}_dir\"
6043 eval var=\"\$makefile_am_edit${edit}_var\"
6044 eval val=\"\$makefile_am_edit${edit}_val\"
6045 if test -n "$var"; then
6046 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
6048 done
6049 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
6050 position_early_after=AC_PROG_CC_STDC
6051 else
6052 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
6053 position_early_after=AC_PROG_CC_C99
6054 else
6055 position_early_after=AC_PROG_CC
6058 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
6059 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
6062 # func_create_testdir testdir modules
6063 # Input:
6064 # - local_gnulib_path from --local-dir
6065 # - modcache true or false, from --cache-modules/--no-cache-modules
6066 # - auxdir directory relative to destdir where to place build aux files
6067 # - inctests true if tests should be included, false otherwise
6068 # - incobsolete true if obsolete modules among dependencies should be
6069 # included, blank otherwise
6070 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
6071 # blank otherwise
6072 # - excl_longrunning_tests true if long-runnings tests should be excluded,
6073 # blank otherwise
6074 # - excl_privileged_tests true if tests that require root privileges should be
6075 # excluded, blank otherwise
6076 # - excl_unportable_tests true if tests that fail on some platforms should be
6077 # excluded, blank otherwise
6078 # - single_configure true if a single configure file should be generated,
6079 # false for a separate configure file for the tests
6080 # - avoidlist list of modules to avoid
6081 # - cond_dependencies true if --conditional-dependencies was given, false if
6082 # --no-conditional-dependencies was given, blank otherwise
6083 # - libtool true if --libtool was given, false if --no-libtool was
6084 # given, blank otherwise
6085 # - copymode copy mode for files in general
6086 # - lcopymode copy mode for files from local_gnulib_path
6087 func_create_testdir ()
6089 testdir="$1"
6090 modules="$2"
6091 if test -z "$modules"; then
6092 # All modules together.
6093 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6094 # Except non-recursive-gnulib-prefix-hack, which represents a nonstandard
6095 # way of using Automake.
6096 # Except timevar, which lacks the required file timevar.def.
6097 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
6098 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
6099 modules=`func_all_modules`
6100 modules=`for m in $modules; do case $m in config-h | non-recursive-gnulib-prefix-hack | timevar | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
6102 specified_modules="$modules"
6104 # Canonicalize the list of specified modules.
6105 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
6107 # Test modules which invoke AC_CONFIG_FILES cannot be used with
6108 # --with-tests --single-configure. Avoid them.
6109 if $inctests && $single_configure; then
6110 avoidlist="$avoidlist havelib-tests"
6113 # Unlike in func_import, here we want to include all kinds of tests for the
6114 # directly specified modules, but not for dependencies.
6115 inc_all_direct_tests=true
6116 inc_all_indirect_tests="$inc_all_tests"
6118 # Check that the license of every module is consistent with the license of
6119 # its dependencies.
6120 saved_inctests="$inctests"
6121 # When computing transitive closures, don't consider $module to depend on
6122 # $module-tests. Need this because tests are implicitly GPL and may depend
6123 # on GPL modules - therefore we don't want a warning in this case.
6124 inctests=false
6125 for requested_module in $specified_modules; do
6126 requested_license=`func_get_license "$requested_module"`
6127 if test "$requested_license" != GPL; then
6128 # Here we use func_modules_transitive_closure, not just
6129 # func_get_dependencies, so that we also detect weird situations like
6130 # an LGPL module which depends on a GPLed build tool module which depends
6131 # on a GPL module.
6132 modules="$requested_module"
6133 func_modules_transitive_closure
6134 for module in $modules; do
6135 license=`func_get_license "$module"`
6136 case "$license" in
6137 'GPLed build tool') ;;
6138 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
6140 case "$requested_license" in
6141 GPLv3+ | GPL)
6142 case "$license" in
6143 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL | GPLv2+ | GPLv3+ | GPL) ;;
6144 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6145 esac
6147 GPLv2+)
6148 case "$license" in
6149 LGPLv2+ | 'LGPLv3+ or GPLv2' | GPLv2+) ;;
6150 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6151 esac
6153 LGPLv3+ | LGPL)
6154 case "$license" in
6155 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
6156 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6157 esac
6159 'LGPLv3+ or GPLv2')
6160 case "$license" in
6161 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
6162 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6163 esac
6165 LGPLv2+)
6166 case "$license" in
6167 LGPLv2+) ;;
6168 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6169 esac
6171 esac
6173 esac
6174 done
6176 done
6177 inctests="$saved_inctests"
6179 # Subdirectory names.
6180 sourcebase=gllib
6181 m4base=glm4
6182 pobase=
6183 docbase=gldoc
6184 testsbase=gltests
6185 macro_prefix=gl
6186 po_domain=
6187 witness_c_macro=
6188 vc_files=
6190 # Determine final module list.
6191 modules="$specified_modules"
6192 func_modules_transitive_closure
6193 if test $verbose -ge 0; then
6194 func_show_module_list
6196 final_modules="$modules"
6198 if $single_configure; then
6199 # Determine main module list and tests-related module list separately.
6200 func_modules_transitive_closure_separately
6203 if $single_configure; then
6204 # Determine whether a $testsbase/libtests.a is needed.
6205 func_determine_use_libtests
6208 # Add the dummy module if needed.
6209 if $single_configure; then
6210 func_modules_add_dummy_separately
6211 else
6212 func_modules_add_dummy
6215 # Note:
6216 # If $single_configure, we use the module lists $main_modules and
6217 # $testsrelated_modules; $modules is merely a temporary variable.
6218 # Whereas if ! $configure, the module list is $modules.
6220 # Show banner notice of every module.
6221 if $single_configure; then
6222 modules="$main_modules"
6223 func_modules_notice
6224 else
6225 func_modules_notice
6228 # Determine final file list.
6229 if $single_configure; then
6230 func_modules_to_filelist_separately
6231 else
6232 func_modules_to_filelist
6233 if test $verbose -ge 0; then
6234 echo "File list:"
6235 echo "$files" | sed -e 's/^/ /'
6238 # Add files for which the copy in gnulib is newer than the one that
6239 # "automake --add-missing --copy" would provide.
6240 files="$files build-aux/config.guess"
6241 files="$files build-aux/config.sub"
6242 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
6244 rewritten='%REWRITTEN%'
6245 sed_rewrite_files="\
6246 s,^build-aux/,$rewritten$auxdir/,
6247 s,^doc/,$rewritten$docbase/,
6248 s,^lib/,$rewritten$sourcebase/,
6249 s,^m4/,$rewritten$m4base/,
6250 s,^tests/,$rewritten$testsbase/,
6251 s,^tests=lib/,$rewritten$testsbase/,
6252 s,^top/,$rewritten,
6253 s,^$rewritten,,"
6255 # Create directories.
6256 for f in $files; do echo $f; done \
6257 | sed -e "$sed_rewrite_files" \
6258 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
6259 | LC_ALL=C sort -u \
6260 > "$tmp"/dirs
6261 { # Rearrange file descriptors. Needed because "while ... done < ..."
6262 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6263 exec 5<&0 < "$tmp"/dirs
6264 while read d; do
6265 mkdir -p "$testdir/$d"
6266 done
6267 exec 0<&5 5<&-
6270 # Copy files or make symbolic links or hard links.
6271 delimiter=' '
6272 for f in $files; do echo $f; done \
6273 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
6274 | LC_ALL=C sort \
6275 > "$tmp"/files
6276 { # Rearrange file descriptors. Needed because "while ... done < ..."
6277 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6278 exec 5<&0 < "$tmp"/files
6279 while read g f; do
6280 case "$f" in
6281 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
6282 esac
6283 func_lookup_file "$f"
6284 if test -n "$lookedup_tmp"; then
6285 cp -p "$lookedup_file" "$testdir/$g"
6286 else
6287 func_should_link
6288 if test "$copyaction" = symlink; then
6289 func_symlink "$lookedup_file" "$testdir/$g"
6290 else
6291 if test "$copyaction" = hardlink; then
6292 func_hardlink "$lookedup_file" "$testdir/$g"
6293 else
6294 cp -p "$lookedup_file" "$testdir/$g"
6298 done
6299 exec 0<&5 5<&-
6302 # Determine include_guard_prefix.
6303 func_compute_include_guard_prefix
6305 # Create Makefile.ams that are for testing.
6306 for_test=true
6308 # No special edits are needed.
6309 makefile_am_edits=0
6311 # Create $sourcebase/Makefile.am.
6312 mkdir -p "$testdir/$sourcebase"
6313 destfile="$sourcebase/Makefile.am"
6314 if $single_configure; then
6315 modules="$main_modules"
6317 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
6318 any_uses_subdirs="$uses_subdirs"
6320 # Create $m4base/Makefile.am.
6321 mkdir -p "$testdir/$m4base"
6322 (echo "## Process this file with automake to produce Makefile.in."
6323 echo
6324 echo "EXTRA_DIST ="
6325 for f in $files; do
6326 case "$f" in
6327 m4/* )
6328 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
6329 esac
6330 done
6331 ) > "$testdir/$m4base/Makefile.am"
6333 subdirs="$sourcebase $m4base"
6334 subdirs_with_configure_ac=""
6336 if false && test -f "$testdir"/$m4base/gettext.m4; then
6337 # Avoid stupid error message from automake:
6338 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
6339 mkdir -p "$testdir/po"
6340 (echo "## Process this file with automake to produce Makefile.in."
6341 ) > "$testdir/po/Makefile.am"
6342 func_append subdirs " po"
6345 if $inctests; then
6346 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
6347 if $single_configure; then
6348 # Create $testsbase/Makefile.am.
6349 destfile="$testsbase/Makefile.am"
6350 modules="$testsrelated_modules"
6351 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
6352 else
6353 # Viewed from the $testsbase subdirectory, $auxdir is different.
6354 saved_auxdir="$auxdir"
6355 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
6356 # Create $testsbase/Makefile.am.
6357 use_libtests=false
6358 destfile="$testsbase/Makefile.am"
6359 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
6360 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
6361 # Create $testsbase/configure.ac.
6362 (echo "# Process this file with autoconf to produce a configure script."
6363 echo "AC_INIT([dummy], [0])"
6364 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6365 echo "AM_INIT_AUTOMAKE"
6366 echo
6367 echo "AC_CONFIG_HEADERS([config.h])"
6368 echo
6369 echo "AC_PROG_CC"
6370 echo "AC_PROG_INSTALL"
6371 echo "AC_PROG_MAKE_SET"
6373 func_emit_pre_early_macros false '' "$modules"
6375 if test -n "$uses_subdirs"; then
6376 echo "AM_PROG_CC_C_O"
6377 echo
6379 for module in $modules; do
6380 func_verify_module
6381 if test -n "$module"; then
6382 case $module in
6383 gnumakefile | maintainer-makefile)
6384 # These modules are meant to be used only in the top-level directory.
6387 func_get_autoconf_early_snippet "$module"
6389 esac
6391 done \
6392 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6393 if test "$libtool" = true; then
6394 echo "LT_INIT([win32-dll])"
6395 echo "LT_LANG([C++])"
6396 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6397 echo "gl_cond_libtool=true"
6398 else
6399 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6400 echo "gl_cond_libtool=false"
6401 echo "gl_libdeps="
6402 echo "gl_ltlibdeps="
6404 # Wrap the set of autoconf snippets into an autoconf macro that is then
6405 # invoked. This is needed because autoconf does not support AC_REQUIRE
6406 # at the top level:
6407 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6408 # but we want the AC_REQUIRE to have its normal meaning (provide one
6409 # expansion of the required macro before the current point, and only one
6410 # expansion total).
6411 echo "AC_DEFUN([gl_INIT], ["
6412 sed_replace_build_aux='
6414 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6415 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6418 echo "gl_m4_base='../$m4base'"
6419 func_emit_initmacro_start $macro_prefix
6420 # We don't have explicit ordering constraints between the various
6421 # autoconf snippets. It's cleanest to put those of the library before
6422 # those of the tests.
6423 echo "gl_source_base='../$sourcebase'"
6424 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module false false false
6425 echo "gl_source_base='.'"
6426 func_emit_autoconf_snippets "$modules" "$modules" func_verify_tests_module false false false
6427 func_emit_initmacro_end $macro_prefix
6428 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6429 # created using libtool, because libtool already handles the dependencies.
6430 if test "$libtool" != true; then
6431 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6432 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6433 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6434 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6435 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6437 echo "])"
6438 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
6439 echo
6440 echo "gl_INIT"
6441 echo
6442 # Usually $testsbase/config.h will be a superset of config.h. Verify this
6443 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
6444 echo "AH_TOP([#include \"../config.h\"])"
6445 echo
6446 echo "AC_CONFIG_FILES([Makefile])"
6447 echo "AC_OUTPUT"
6448 ) > "$testdir/$testsbase/configure.ac"
6449 auxdir="$saved_auxdir"
6450 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
6452 func_append subdirs " $testsbase"
6455 # Create Makefile.am.
6456 (echo "## Process this file with automake to produce Makefile.in."
6457 echo
6458 echo "AUTOMAKE_OPTIONS = 1.11 foreign"
6459 echo
6460 echo "SUBDIRS = $subdirs"
6461 echo
6462 echo "ACLOCAL_AMFLAGS = -I $m4base"
6463 ) > "$testdir/Makefile.am"
6465 # Create configure.ac.
6466 (echo "# Process this file with autoconf to produce a configure script."
6467 echo "AC_INIT([dummy], [0])"
6468 if test "$auxdir" != "."; then
6469 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6471 echo "AM_INIT_AUTOMAKE"
6472 echo
6473 echo "AC_CONFIG_HEADERS([config.h])"
6474 echo
6475 echo "AC_PROG_CC"
6476 echo "AC_PROG_INSTALL"
6477 echo "AC_PROG_MAKE_SET"
6478 echo
6479 echo "# For autobuild."
6480 echo "AC_CANONICAL_BUILD"
6481 echo "AC_CANONICAL_HOST"
6482 echo
6483 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
6484 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
6485 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6486 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6488 func_emit_pre_early_macros false '' "$final_modules"
6490 if test -n "$any_uses_subdirs"; then
6491 echo "AM_PROG_CC_C_O"
6492 echo
6494 for module in $final_modules; do
6495 if $single_configure; then
6496 func_verify_module
6497 else
6498 func_verify_nontests_module
6500 if test -n "$module"; then
6501 func_get_autoconf_early_snippet "$module"
6503 done \
6504 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6505 if test "$libtool" = true; then
6506 echo "LT_INIT([win32-dll])"
6507 echo "LT_LANG([C++])"
6508 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6509 echo "gl_cond_libtool=true"
6510 else
6511 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6512 echo "gl_cond_libtool=false"
6513 echo "gl_libdeps="
6514 echo "gl_ltlibdeps="
6516 # Wrap the set of autoconf snippets into an autoconf macro that is then
6517 # invoked. This is needed because autoconf does not support AC_REQUIRE
6518 # at the top level:
6519 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6520 # but we want the AC_REQUIRE to have its normal meaning (provide one
6521 # expansion of the required macro before the current point, and only one
6522 # expansion total).
6523 echo "AC_DEFUN([gl_INIT], ["
6524 if test "$auxdir" != "build-aux"; then
6525 sed_replace_build_aux='
6527 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6528 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6531 else
6532 sed_replace_build_aux="$sed_noop"
6534 echo "gl_m4_base='$m4base'"
6535 func_emit_initmacro_start $macro_prefix
6536 echo "gl_source_base='$sourcebase'"
6537 if $single_configure; then
6538 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false false
6539 else
6540 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module true false false
6542 func_emit_initmacro_end $macro_prefix
6543 if $single_configure; then
6544 echo " gltests_libdeps="
6545 echo " gltests_ltlibdeps="
6546 func_emit_initmacro_start ${macro_prefix}tests
6547 echo " gl_source_base='$testsbase'"
6548 # Define a tests witness macro.
6549 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
6550 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6551 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6552 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6553 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true false false
6554 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6555 func_emit_initmacro_end ${macro_prefix}tests
6557 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6558 # created using libtool, because libtool already handles the dependencies.
6559 if test "$libtool" != true; then
6560 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6561 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6562 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6563 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6564 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6566 if $single_configure; then
6567 if $use_libtests; then
6568 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6569 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6572 echo "])"
6573 func_emit_initmacro_done $macro_prefix $sourcebase
6574 if $single_configure; then
6575 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6577 echo
6578 echo "gl_INIT"
6579 echo
6580 if test -n "$subdirs_with_configure_ac"; then
6581 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6583 makefiles="Makefile"
6584 for d in $subdirs; do
6585 # For subdirs that have a configure.ac by their own, it's the subdir's
6586 # configure.ac which creates the subdir's Makefile.am, not this one.
6587 case " $subdirs_with_configure_ac " in
6588 *" $d "*) ;;
6589 *) func_append makefiles " $d/Makefile" ;;
6590 esac
6591 done
6592 echo "AC_CONFIG_FILES([$makefiles])"
6593 echo "AC_OUTPUT"
6594 ) > "$testdir/configure.ac"
6596 # Create autogenerated files.
6597 (cd "$testdir"
6598 # Do not use "${AUTORECONF} --force --install", because it may invoke
6599 # autopoint, which brings in older versions of some of our .m4 files.
6600 if test -f $m4base/gettext.m4; then
6601 func_execute_command ${AUTOPOINT} --force || func_exit 1
6602 for f in $m4base/*.m4~; do
6603 if test -f $f; then
6604 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6606 done
6608 if test "$libtool" = true; then
6609 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6611 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6612 if ! test -d build-aux; then
6613 func_execute_command mkdir build-aux || func_exit 1
6615 func_execute_command ${AUTOCONF} || func_exit 1
6616 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6617 func_execute_command ${AUTOHEADER} &&
6618 func_execute_command touch config.h.in ||
6619 func_exit 1
6620 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6621 rm -rf autom4te.cache
6622 ) || func_exit 1
6623 if $inctests && ! $single_configure; then
6624 # Create autogenerated files.
6625 (cd "$testdir/$testsbase" || func_exit 1
6626 # Do not use "${AUTORECONF} --force --install", because it may invoke
6627 # autopoint, which brings in older versions of some of our .m4 files.
6628 if test -f ../$m4base/gettext.m4; then
6629 func_execute_command ${AUTOPOINT} --force || func_exit 1
6630 for f in ../$m4base/*.m4~; do
6631 if test -f $f; then
6632 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6634 done
6636 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6637 if ! test -d ../build-aux; then
6638 func_execute_command mkdir ../build-aux
6640 func_execute_command ${AUTOCONF} || func_exit 1
6641 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6642 func_execute_command ${AUTOHEADER} &&
6643 func_execute_command touch config.h.in ||
6644 func_exit 1
6645 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6646 rm -rf autom4te.cache
6647 ) || func_exit 1
6649 # Need to run configure and make once, to create built files that are to be
6650 # distributed (such as parse-datetime.c).
6651 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6652 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6653 cleaned_files=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6654 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6655 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6656 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6657 # such $(FOO_H) because they don't refer to distributed files.
6658 built_sources=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6659 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6660 | sed -e "$sed_remove_make_variables"`
6661 distributed_built_sources=`for file in $built_sources; do
6662 case "$cleaned_files" in
6663 *" "$file" "*) ;;
6664 *) echo $file ;;
6665 esac;
6666 done`
6667 tests_distributed_built_sources=
6668 if $inctests; then
6669 # Likewise for built files in the $testsbase directory.
6670 tests_cleaned_files=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6671 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6672 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6673 tests_built_sources=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6674 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6675 | sed -e "$sed_remove_make_variables"`
6676 tests_distributed_built_sources=`for file in $tests_built_sources; do
6677 case "$tests_cleaned_files" in
6678 *" "$file" "*) ;;
6679 *) echo $file ;;
6680 esac;
6681 done`
6683 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6684 (cd "$testdir"
6685 ./configure || func_exit 1
6686 if test -n "$distributed_built_sources"; then
6687 cd "$sourcebase"
6688 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6689 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6690 built_sources \
6691 || func_exit 1
6692 cd ..
6694 if test -n "$tests_distributed_built_sources"; then
6695 cd "$testsbase"
6696 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6697 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6698 built_sources \
6699 || func_exit 1
6700 cd ..
6702 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6703 distclean \
6704 || func_exit 1
6705 ) || func_exit 1
6707 (cd "$testdir"
6708 if test -f build-aux/test-driver; then
6709 patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver.diff || func_exit 1
6711 ) || func_exit 1
6714 # func_create_megatestdir megatestdir allmodules
6715 # Input:
6716 # - local_gnulib_path from --local-dir
6717 # - modcache true or false, from --cache-modules/--no-cache-modules
6718 # - auxdir directory relative to destdir where to place build aux files
6719 func_create_megatestdir ()
6721 megatestdir="$1"
6722 allmodules="$2"
6723 if test -z "$allmodules"; then
6724 allmodules=`func_all_modules`
6727 megasubdirs=
6728 # First, all modules one by one.
6729 for onemodule in $allmodules; do
6730 func_create_testdir "$megatestdir/$onemodule" $onemodule
6731 func_append megasubdirs "$onemodule "
6732 done
6733 # Then, all modules all together.
6734 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6735 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6736 func_create_testdir "$megatestdir/ALL" "$allmodules"
6737 func_append megasubdirs "ALL"
6739 # Create autobuild.
6740 cvsdate=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6741 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6742 | sed -e 's,January,01,' -e 's,Jan,01,' \
6743 -e 's,February,02,' -e 's,Feb,02,' \
6744 -e 's,March,03,' -e 's,Mar,03,' \
6745 -e 's,April,04,' -e 's,Apr,04,' \
6746 -e 's,May,05,' \
6747 -e 's,June,06,' -e 's,Jun,06,' \
6748 -e 's,July,07,' -e 's,Jul,07,' \
6749 -e 's,August,08,' -e 's,Aug,08,' \
6750 -e 's,September,09,' -e 's,Sep,09,' \
6751 -e 's,October,10,' -e 's,Oct,10,' \
6752 -e 's,November,11,' -e 's,Nov,11,' \
6753 -e 's,December,12,' -e 's,Dec,12,' \
6754 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6755 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6756 (echo '#!/bin/sh'
6757 echo "CVSDATE=$cvsdate"
6758 echo ": \${MAKE=make}"
6759 echo "test -d logs || mkdir logs"
6760 echo "for module in $megasubdirs; do"
6761 echo " echo \"Working on module \$module...\""
6762 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6763 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6764 echo " echo"
6765 echo " set -x"
6766 echo " : autobuild project... \$module"
6767 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6768 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6769 echo " : autobuild hostname... \`hostname\`"
6770 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6771 echo " echo rc=\$?"
6772 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6773 echo "done"
6774 ) > "$megatestdir/do-autobuild"
6775 chmod a+x "$megatestdir/do-autobuild"
6777 # Create Makefile.am.
6778 (echo "## Process this file with automake to produce Makefile.in."
6779 echo
6780 echo "AUTOMAKE_OPTIONS = 1.11 foreign"
6781 echo
6782 echo "SUBDIRS = $megasubdirs"
6783 echo
6784 echo "EXTRA_DIST = do-autobuild"
6785 ) > "$megatestdir/Makefile.am"
6787 # Create configure.ac.
6788 (echo "# Process this file with autoconf to produce a configure script."
6789 echo "AC_INIT([dummy], [0])"
6790 if test "$auxdir" != "."; then
6791 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6793 echo "AM_INIT_AUTOMAKE"
6794 echo
6795 echo "AC_PROG_MAKE_SET"
6796 echo
6797 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6798 echo "AC_CONFIG_FILES([Makefile])"
6799 echo "AC_OUTPUT"
6800 ) > "$megatestdir/configure.ac"
6802 # Create autogenerated files.
6803 (cd "$megatestdir"
6804 # Do not use "${AUTORECONF} --install", because autoreconf operates
6805 # recursively, but the subdirectories are already finished, therefore
6806 # calling autoreconf here would only waste lots of CPU time.
6807 func_execute_command ${ACLOCAL} || func_exit 1
6808 func_execute_command mkdir build-aux
6809 func_execute_command ${AUTOCONF} || func_exit 1
6810 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6811 rm -rf autom4te.cache
6812 if test -f build-aux/test-driver; then
6813 patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver.diff || func_exit 1
6815 ) || func_exit 1
6818 case $mode in
6819 "" )
6820 func_fatal_error "no mode specified" ;;
6822 list )
6823 func_all_modules
6826 find )
6827 # sed expression that converts a literal to a basic regular expression.
6828 # Needs to handle . [ \ * ^ $.
6829 sed_literal_to_basic_regex='s/\\/\\\\/g
6830 s/\[/\\[/g
6831 s/\^/\\^/g
6832 s/\([.*$]\)/[\1]/g'
6833 for filename
6835 if test -f "$gnulib_dir/$filename" \
6836 || func_lookup_local_file "$filename"; then
6837 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6838 filename_line_regex='^'"$filename_anywhere_regex"'$'
6839 module_candidates=`
6841 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6842 func_path_foreach "$local_gnulib_path" func_modules_in_dir %dir% | xargs -n 100 grep -l "$filename_anywhere_regex" /dev/null | sed -e 's,^modules/,,' -e 's,\.diff$,,'
6844 | func_sanitize_modulelist \
6845 | LC_ALL=C sort -u
6847 for module in $module_candidates; do
6848 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6849 echo $module
6851 done
6852 else
6853 func_warning "file $filename does not exist"
6855 done
6858 import | add-import | remove-import | update )
6860 # Where to import.
6861 if test -z "$destdir"; then
6862 destdir=.
6864 test -d "$destdir" \
6865 || func_fatal_error "destination directory does not exist: $destdir"
6867 # Prefer configure.ac to configure.in.
6868 if test -f "$destdir"/configure.ac; then
6869 configure_ac="$destdir/configure.ac"
6870 else
6871 if test -f "$destdir"/configure.in; then
6872 configure_ac="$destdir/configure.in"
6873 else
6874 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6878 # Analyze configure.ac.
6879 guessed_auxdir="."
6880 guessed_libtool=false
6881 my_sed_traces='
6882 s,#.*$,,
6883 s,^dnl .*$,,
6884 s, dnl .*$,,
6885 /AC_CONFIG_AUX_DIR/ {
6886 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6888 /A[CM]_PROG_LIBTOOL/ {
6889 s,^.*$,guessed_libtool=true,p
6891 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6893 if test -z "$auxdir"; then
6894 auxdir="$guessed_auxdir"
6897 # Determine where to apply func_import.
6898 if test "$mode" = import; then
6899 # Apply func_import to a particular gnulib directory.
6900 # The command line contains the complete specification; don't look at
6901 # the contents of gnulib-cache.m4.
6902 test -n "$supplied_libname" || supplied_libname=true
6903 test -n "$sourcebase" || sourcebase="lib"
6904 test -n "$m4base" || m4base="m4"
6905 test -n "$docbase" || docbase="doc"
6906 test -n "$testsbase" || testsbase="tests"
6907 test -n "$macro_prefix" || macro_prefix="gl"
6908 func_import "$*"
6909 else
6910 if test -n "$m4base"; then
6911 # Apply func_import to a particular gnulib directory.
6912 # Any number of additional modules can be given.
6913 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6914 # First use of gnulib in the given m4base.
6915 test -n "$supplied_libname" || supplied_libname=true
6916 test -n "$sourcebase" || sourcebase="lib"
6917 test -n "$docbase" || docbase="doc"
6918 test -n "$testsbase" || testsbase="tests"
6919 test -n "$macro_prefix" || macro_prefix="gl"
6921 func_import "$*"
6922 else
6923 # Apply func_import to all gnulib directories.
6924 # To get this list of directories, look at Makefile.am. (Not at
6925 # configure, because it may be omitted from version control. Also,
6926 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6927 # too expensive.)
6928 m4dirs=
6929 m4dirs_count=0
6930 if test -f "$destdir"/Makefile.am; then
6931 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6932 m4dir_is_next=
6933 for arg in $aclocal_amflags; do
6934 if test -n "$m4dir_is_next"; then
6935 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6936 case "$arg" in
6937 /*) ;;
6939 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6940 func_append m4dirs " $arg"
6941 m4dirs_count=`expr $m4dirs_count + 1`
6944 esac
6945 m4dir_is_next=
6946 else
6947 if test "X$arg" = "X-I"; then
6948 m4dir_is_next=yes
6949 else
6950 m4dir_is_next=
6953 done
6954 else
6955 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6956 if test -f "$destdir"/aclocal.m4; then
6957 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6958 sedexpr2='s,^[^/]*$,.,'
6959 sedexpr3='s,/[^/]*$,,'
6960 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6961 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6962 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6965 if test $m4dirs_count = 0; then
6966 # First use of gnulib in a package.
6967 # Any number of additional modules can be given.
6968 test -n "$supplied_libname" || supplied_libname=true
6969 test -n "$sourcebase" || sourcebase="lib"
6970 m4base="m4"
6971 test -n "$docbase" || docbase="doc"
6972 test -n "$testsbase" || testsbase="tests"
6973 test -n "$macro_prefix" || macro_prefix="gl"
6974 func_import "$*"
6975 else
6976 if test $m4dirs_count = 1; then
6977 # There's only one use of gnulib here. Assume the user means it.
6978 # Any number of additional modules can be given.
6979 for m4base in $m4dirs; do
6980 func_import "$*"
6981 done
6982 else
6983 # Ambiguous - guess what the user meant.
6984 if test $# = 0; then
6985 # No further arguments. Guess the user wants to update all of them.
6986 for m4base in $m4dirs; do
6987 # Perform func_import in a subshell, so that variable values
6988 # such as
6989 # local_gnulib_path, incobsolete, inc_cxx_tests,
6990 # inc_longrunning_tests, inc_privileged_tests,
6991 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6992 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6993 # makefile_name, libtool, macro_prefix, po_domain,
6994 # witness_c_macro, vc_files
6995 # don't propagate from one directory to another.
6996 (func_import) || func_exit 1
6997 done
6998 else
6999 # Really ambiguous.
7000 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
7008 create-testdir )
7009 if test -z "$destdir"; then
7010 func_fatal_error "please specify --dir option"
7012 mkdir "$destdir"
7013 test -d "$destdir" \
7014 || func_fatal_error "could not create destination directory"
7015 test -n "$auxdir" || auxdir="build-aux"
7016 func_create_testdir "$destdir" "$*"
7019 create-megatestdir )
7020 if test -z "$destdir"; then
7021 func_fatal_error "please specify --dir option"
7023 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7024 test -n "$auxdir" || auxdir="build-aux"
7025 func_create_megatestdir "$destdir" "$*"
7028 test )
7029 test -n "$destdir" || destdir=testdir$$
7030 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7031 test -n "$auxdir" || auxdir="build-aux"
7032 func_create_testdir "$destdir" "$*"
7033 cd "$destdir"
7034 mkdir build
7035 cd build
7036 ../configure || func_exit 1
7037 $MAKE || func_exit 1
7038 $MAKE check || func_exit 1
7039 $MAKE distclean || func_exit 1
7040 remaining=`find . -type f -print`
7041 if test -n "$remaining"; then
7042 echo "Remaining files:" $remaining 1>&2
7043 echo "gnulib-tool: *** Stop." 1>&2
7044 func_exit 1
7046 cd ..
7047 cd ..
7048 rm -rf "$destdir"
7051 megatest )
7052 test -n "$destdir" || destdir=testdir$$
7053 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7054 test -n "$auxdir" || auxdir="build-aux"
7055 func_create_megatestdir "$destdir" "$*"
7056 cd "$destdir"
7057 mkdir build
7058 cd build
7059 ../configure
7060 $MAKE
7061 $MAKE check
7062 $MAKE distclean
7063 remaining=`find . -type f -print`
7064 if test -n "$remaining"; then
7065 echo "Remaining files:" $remaining 1>&2
7066 echo "gnulib-tool: *** Stop." 1>&2
7067 func_exit 1
7069 cd ..
7070 cd ..
7071 rm -rf "$destdir"
7074 extract-description )
7075 for module
7077 func_verify_module
7078 if test -n "$module"; then
7079 func_get_description "$module"
7081 done
7084 extract-comment )
7085 for module
7087 func_verify_module
7088 if test -n "$module"; then
7089 func_get_comment "$module"
7091 done
7094 extract-status )
7095 for module
7097 func_verify_module
7098 if test -n "$module"; then
7099 func_get_status "$module"
7101 done
7104 extract-notice )
7105 for module
7107 func_verify_module
7108 if test -n "$module"; then
7109 func_get_notice "$module"
7111 done
7114 extract-applicability )
7115 for module
7117 func_verify_module
7118 if test -n "$module"; then
7119 func_get_applicability "$module"
7121 done
7124 extract-filelist )
7125 for module
7127 func_verify_module
7128 if test -n "$module"; then
7129 func_get_filelist "$module"
7131 done
7134 extract-dependencies )
7135 if test -n "$avoidlist"; then
7136 func_fatal_error "cannot combine --avoid and --extract-dependencies"
7138 for module
7140 func_verify_module
7141 if test -n "$module"; then
7142 func_get_dependencies "$module"
7144 done
7147 extract-recursive-dependencies )
7148 if test -n "$avoidlist"; then
7149 func_fatal_error "cannot combine --avoid and --extract-recursive-dependencies"
7151 for module
7153 func_verify_module
7154 if test -n "$module"; then
7155 func_get_dependencies_recursively "$module"
7157 done
7160 extract-autoconf-snippet )
7161 for module
7163 func_verify_module
7164 if test -n "$module"; then
7165 func_get_autoconf_snippet "$module"
7167 done
7170 extract-automake-snippet )
7171 for module
7173 func_verify_module
7174 if test -n "$module"; then
7175 func_get_automake_snippet "$module"
7177 done
7180 extract-include-directive )
7181 for module
7183 func_verify_module
7184 if test -n "$module"; then
7185 func_get_include_directive "$module"
7187 done
7190 extract-link-directive )
7191 for module
7193 func_verify_module
7194 if test -n "$module"; then
7195 func_get_link_directive "$module"
7197 done
7200 extract-recursive-link-directive )
7201 if test -n "$avoidlist"; then
7202 func_fatal_error "cannot combine --avoid and --extract-recursive-link-directive"
7204 for module
7206 func_verify_module
7207 if test -n "$module"; then
7208 func_get_link_directive_recursively "$module"
7210 done
7213 extract-license )
7214 for module
7216 func_verify_module
7217 if test -n "$module"; then
7218 func_get_license "$module"
7220 done
7223 extract-maintainer )
7224 for module
7226 func_verify_module
7227 if test -n "$module"; then
7228 func_get_maintainer "$module"
7230 done
7233 extract-tests-module )
7234 for module
7236 func_verify_module
7237 if test -n "$module"; then
7238 func_get_tests_module "$module"
7240 done
7243 copy-file )
7244 # Verify the number of arguments.
7245 if test $# -lt 1 || test $# -gt 2; then
7246 func_fatal_error "invalid number of arguments for --$mode"
7249 # The first argument is the file to be copied.
7250 f="$1"
7251 # Verify the file exists.
7252 func_lookup_file "$f"
7254 # The second argument is the destination; either a directory ot a file.
7255 # It defaults to the current directory.
7256 dest="$2"
7257 test -n "$dest" || dest='.'
7258 test -n "$sourcebase" || sourcebase="lib"
7259 test -n "$m4base" || m4base="m4"
7260 test -n "$docbase" || docbase="doc"
7261 test -n "$testsbase" || testsbase="tests"
7262 test -n "$auxdir" || auxdir="build-aux"
7263 rewritten='%REWRITTEN%'
7264 sed_rewrite_files="\
7265 s,^build-aux/,$rewritten$auxdir/,
7266 s,^doc/,$rewritten$docbase/,
7267 s,^lib/,$rewritten$sourcebase/,
7268 s,^m4/,$rewritten$m4base/,
7269 s,^tests/,$rewritten$testsbase/,
7270 s,^top/,$rewritten,
7271 s,^$rewritten,,"
7272 if test -d "$dest"; then
7273 destdir="$dest"
7274 g=`echo "$f" | sed -e "$sed_rewrite_files"`
7275 else
7276 destdir=`dirname "$dest"`
7277 g=`basename "$dest"`
7280 # Create the directory for destfile.
7281 d=`dirname "$destdir/$g"`
7282 if $doit; then
7283 if test -n "$d" && test ! -d "$d"; then
7284 mkdir -p "$d" || func_fatal_error "failed"
7287 # Copy the file.
7288 func_dest_tmpfilename "$g"
7289 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
7290 already_present=true
7291 if test -f "$destdir/$g"; then
7292 # The file already exists.
7293 func_update_file
7294 else
7295 # Install the file.
7296 # Don't protest if the file should be there but isn't: it happens
7297 # frequently that developers don't put autogenerated files under version
7298 # control.
7299 func_add_file
7301 rm -f "$tmpfile"
7305 func_fatal_error "unknown operation mode --$mode" ;;
7306 esac
7308 if test "$copymode" = hardlink -o "$lcopymode" = hardlink; then
7309 # Setting hard links modifies the ctime of files in the gnulib checkout.
7310 # This disturbs the result of the next "gitk" invocation.
7311 # Workaround: Let git scan the files. This can be done through
7312 # "git update-index --refresh" or "git status" or "git diff".
7313 if test -d "$gnulib_dir"/.git \
7314 && (git --version) >/dev/null 2>/dev/null; then
7315 (cd "$gnulib_dir" && git update-index --refresh >/dev/null)
7319 rm -rf "$tmp"
7320 # Undo the effect of the previous 'trap' command. Some shellology:
7321 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
7322 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
7323 # exit); for the others we need to call 'exit' explicitly. The value of $? is
7324 # 128 + signal number and is set before the trap-registered command is run.
7325 trap '' 0
7326 trap 'func_exit $?' 1 2 3 13 15
7328 exit 0
7330 # Local Variables:
7331 # indent-tabs-mode: nil
7332 # whitespace-check-buffer-indent: nil
7333 # End: