Clarify meaning of 'Link' section in module description.
[gnulib.git] / gnulib-tool
blob97dd6341736d1bee69bf1dc0a839334d68d8a171
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-autoconf-snippet module
145 gnulib-tool --extract-automake-snippet module
146 gnulib-tool --extract-include-directive module
147 gnulib-tool --extract-link-directive module
148 gnulib-tool --extract-license module
149 gnulib-tool --extract-maintainer module
150 gnulib-tool --extract-tests-module module
151 gnulib-tool --copy-file file [destination]
153 Operation modes:
155 --list print the available module names
156 --find find the modules which contain the specified file
157 --import import the given modules into the current package
158 --add-import augment the list of imports from gnulib into the
159 current package, by adding the given modules;
160 if no modules are specified, update the current
161 package from the current gnulib
162 --remove-import reduce the list of imports from gnulib into the
163 current package, by removing the given modules
164 --update update the current package, restore files omitted
165 from version control
166 --create-testdir create a scratch package with the given modules
167 --create-megatestdir create a mega scratch package with the given modules
168 one by one and all together
169 --test test the combination of the given modules
170 (recommended to use CC=\"gcc -Wall\" here)
171 --megatest test the given modules one by one and all together
172 (recommended to use CC=\"gcc -Wall\" here)
173 --extract-description extract the description
174 --extract-comment extract the comment
175 --extract-status extract the status (obsolete etc.)
176 --extract-notice extract the notice or banner
177 --extract-applicability extract the applicability
178 --extract-filelist extract the list of files
179 --extract-dependencies extract the dependencies
180 --extract-autoconf-snippet extract the snippet for configure.ac
181 --extract-automake-snippet extract the snippet for library makefile
182 --extract-include-directive extract the #include directive
183 --extract-link-directive extract the linker directive
184 --extract-license report the license terms of the source files
185 under lib/
186 --extract-maintainer report the maintainer(s) inside gnulib
187 --extract-tests-module report the unit test module, if it exists
188 --copy-file copy a file that is not part of any module
189 --help Show this help text.
190 --version Show version and authorship information.
192 General options:
194 --dir=DIRECTORY Specify the target directory.
195 For --import, this specifies where your
196 configure.ac can be found. Defaults to current
197 directory.
198 --local-dir=DIRECTORY Specify a local override directory where to look
199 up files before looking in gnulib's directory.
200 --cache-modules Enable module caching optimization.
201 --no-cache-modules Disable module caching optimization.
202 --verbose Increase verbosity. May be repeated.
203 --quiet Decrease verbosity. May be repeated.
205 Options for --import, --add/remove-import, --update:
207 --dry-run Only print what would have been done.
209 Options for --import, --add/remove-import:
211 --with-tests Include unit tests for the included modules.
213 Options for --create-[mega]testdir, --[mega]test:
215 --without-tests Don't include unit tests for the included modules.
217 Options for --import, --add/remove-import,
218 --create-[mega]testdir, --[mega]test:
220 --with-obsolete Include obsolete modules when they occur among the
221 dependencies. By default, dependencies to obsolete
222 modules are ignored.
223 --with-c++-tests Include even unit tests for C++ interoperability.
224 --without-c++-tests Exclude unit tests for C++ interoperability.
225 --with-longrunning-tests
226 Include even unit tests that are long-runners.
227 --without-longrunning-tests
228 Exclude unit tests that are long-runners.
229 --with-privileged-tests
230 Include even unit tests that require root
231 privileges.
232 --without-privileged-tests
233 Exclude unit tests that require root privileges.
234 --with-unportable-tests
235 Include even unit tests that fail on some platforms.
236 --without-unportable-tests
237 Exclude unit tests that fail on some platforms.
238 --with-all-tests Include all kinds of problematic unit tests.
239 --avoid=MODULE Avoid including the given MODULE. Useful if you
240 have code that provides equivalent functionality.
241 This option can be repeated.
242 --conditional-dependencies
243 Support conditional dependencies (may save configure
244 time and object code).
245 --no-conditional-dependencies
246 Don't use conditional dependencies.
247 --libtool Use libtool rules.
248 --no-libtool Don't use libtool rules.
250 Options for --import, --add/remove-import:
252 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
253 --source-base=DIRECTORY
254 Directory relative to --dir where source code is
255 placed (default \"lib\").
256 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
257 placed (default \"m4\").
258 --po-base=DIRECTORY Directory relative to --dir where *.po files are
259 placed (default \"po\").
260 --doc-base=DIRECTORY Directory relative to --dir where doc files are
261 placed (default \"doc\").
262 --tests-base=DIRECTORY
263 Directory relative to --dir where unit tests are
264 placed (default \"tests\").
265 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
266 tools are placed (default comes from configure.ac).
267 --gnu-make Output for GNU Make instead of for the default
268 Automake
269 --lgpl[=2|=3orGPLv2|=3]
270 Abort if modules aren't available under the LGPL.
271 Also modify license template from GPL to LGPL.
272 The version number of the LGPL can be specified;
273 the default is currently LGPLv3.
274 --makefile-name=NAME Name of makefile in the source-base and tests-base
275 directories (default \"Makefile.am\", or
276 \"Makefile.in\" if --gnu-make).
277 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
278 'gl_INIT'. Default is 'gl'.
279 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
280 the package name. A suffix '-gnulib' is appended.
281 --witness-c-macro=NAME Specify the C macro that is defined when the
282 sources in this directory are compiled or used.
283 --vc-files Update version control related files.
284 --no-vc-files Don't update version control related files
285 (.gitignore and/or .cvsignore).
287 Options for --create-[mega]testdir, --[mega]test:
289 --single-configure Generate a single configure file, not a separate
290 configure file for the tests directory.
292 Options for --import, --add/remove-import, --update,
293 --create-[mega]testdir, --[mega]test:
295 -s, --symbolic, --symlink Make symbolic links instead of copying files.
296 --local-symlink Make symbolic links instead of copying files, only
297 for files from the local override directory.
298 -h, --hardlink Make hard links instead of copying files.
299 --local-hardlink Make hard links instead of copying files, only
300 for files from the local override directory.
302 Options for --import, --add/remove-import, --update:
304 -S, --more-symlinks Make symbolic links instead of copying files, and
305 don't replace copyright notices.
306 -H, --more-hardlinks Make hard links instead of copying files, and
307 don't replace copyright notices.
309 Report bugs to <bug-gnulib@gnu.org>."
312 # func_version
313 # outputs to stdout the --version message.
314 func_version ()
316 func_gnulib_dir
317 if test -d "$gnulib_dir"/.git \
318 && (git --version) >/dev/null 2>/dev/null \
319 && (date --version) >/dev/null 2>/dev/null; then
320 # gnulib checked out from git.
321 sed_extract_first_date='/^Date/{
322 s/^Date:[ ]*//p
325 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
326 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
327 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
328 date=`echo "$date" | sed -e "$sed_year_before_time"`
329 # Use GNU date to compute the time in GMT.
330 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
331 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
332 else
333 # gnulib copy without versioning information.
334 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
335 version=
337 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
338 echo "\
339 gnulib-tool (GNU $package $date)$version
340 Copyright (C) $year Free Software Foundation, Inc.
341 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
342 This is free software: you are free to change and redistribute it.
343 There is NO WARRANTY, to the extent permitted by law.
345 printf "Written by %s, %s, and %s.\n" "Bruno Haible" "Paul Eggert" "Simon Josefsson"
348 # func_emit_copyright_notice
349 # outputs to stdout a header for a generated file.
350 func_emit_copyright_notice ()
352 sed -n -e '/Copyright/ {
355 }' < "$self_abspathname"
356 echo "#"
357 echo "# This file is free software; you can redistribute it and/or modify"
358 echo "# it under the terms of the GNU General Public License as published by"
359 echo "# the Free Software Foundation; either version 3 of the License, or"
360 echo "# (at your option) any later version."
361 echo "#"
362 echo "# This file is distributed in the hope that it will be useful,"
363 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
364 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
365 echo "# GNU General Public License for more details."
366 echo "#"
367 echo "# You should have received a copy of the GNU General Public License"
368 echo "# along with this file. If not, see <https://www.gnu.org/licenses/>."
369 echo "#"
370 echo "# As a special exception to the GNU General Public License,"
371 echo "# this file may be distributed as part of a program that"
372 echo "# contains a configuration script generated by Autoconf, under"
373 echo "# the same distribution terms as the rest of that program."
374 echo "#"
375 echo "# Generated by gnulib-tool."
378 # func_exit STATUS
379 # exits with a given status.
380 # This function needs to be used, rather than 'exit', when a 'trap' handler is
381 # in effect that refers to $?.
382 func_exit ()
384 (exit $1); exit $1
387 # func_gnulib_dir
388 # locates the directory where the gnulib repository lives
389 # Input:
390 # - progname name of this program
391 # Sets variables
392 # - self_abspathname absolute pathname of gnulib-tool
393 # - gnulib_dir absolute pathname of gnulib repository
394 func_gnulib_dir ()
396 case "$progname" in
397 /* | ?:*) self_abspathname="$progname" ;;
398 */*) self_abspathname=`pwd`/"$progname" ;;
400 # Look in $PATH.
401 # Iterate through the elements of $PATH.
402 # We use IFS=: instead of
403 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
404 # because the latter does not work when some PATH element contains spaces.
405 # We use a canonicalized $pathx instead of $PATH, because empty PATH
406 # elements are by definition equivalent to '.', however field splitting
407 # according to IFS=: loses empty fields in many shells:
408 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
409 # beginning, at the end, and in the middle),
410 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
411 # at the beginning and at the end,
412 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
413 # Solaris lose empty fields at the end.
414 # The 'case' statement is an optimization, to avoid evaluating the
415 # explicit canonicalization command when $PATH contains no empty fields.
416 self_abspathname=
417 if test "$PATH_SEPARATOR" = ";"; then
418 # On Windows, programs are searched in "." before $PATH.
419 pathx=".;$PATH"
420 else
421 # On Unix, we have to convert empty PATH elements to ".".
422 pathx="$PATH"
423 case :$PATH: in
424 *::*)
425 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
427 esac
429 save_IFS="$IFS"
430 IFS="$PATH_SEPARATOR"
431 for d in $pathx; do
432 IFS="$save_IFS"
433 test -z "$d" && d=.
434 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
435 self_abspathname="$d/$progname"
436 break
438 done
439 IFS="$save_IFS"
440 if test -z "$self_abspathname"; then
441 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
444 esac
445 while test -h "$self_abspathname"; do
446 # Resolve symbolic link.
447 linkval=`func_readlink "$self_abspathname"`
448 test -n "$linkval" || break
449 case "$linkval" in
450 /* | ?:* ) self_abspathname="$linkval" ;;
451 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
452 esac
453 done
454 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
457 # func_tmpdir
458 # creates a temporary directory.
459 # Input:
460 # - progname name of this program
461 # Sets variable
462 # - tmp pathname of freshly created temporary directory
463 func_tmpdir ()
465 # Use the environment variable TMPDIR, falling back to /tmp. This allows
466 # users to specify a different temporary directory, for example, if their
467 # /tmp is filled up or too small.
468 : ${TMPDIR=/tmp}
470 # Use the mktemp program if available. If not available, hide the error
471 # message.
472 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
473 test -n "$tmp" && test -d "$tmp"
474 } ||
476 # Use a simple mkdir command. It is guaranteed to fail if the directory
477 # already exists. $RANDOM is bash specific and expands to empty in shells
478 # other than bash, ksh and zsh. Its use does not increase security;
479 # rather, it minimizes the probability of failure in a very cluttered /tmp
480 # directory.
481 tmp=$TMPDIR/gl$$-$RANDOM
482 (umask 077 && mkdir "$tmp")
483 } ||
485 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
486 func_exit 1
490 # func_append var value
491 # appends the given value to the shell variable var.
492 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
493 # Use bash's += operator. It reduces complexity of appending repeatedly to
494 # a single variable from O(n^2) to O(n).
495 func_append ()
497 eval "$1+=\"\$2\""
499 fast_func_append=true
500 else
501 func_append ()
503 eval "$1=\"\$$1\$2\""
505 fast_func_append=false
508 # func_remove_prefix var prefix
509 # removes the given prefix from the value of the shell variable var.
510 # var should be the name of a shell variable.
511 # Its value should not contain a newline and not start or end with whitespace.
512 # prefix should not contain the characters "$`\{}[]^|.
513 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
514 func_remove_prefix ()
516 eval "$1=\${$1#\$2}"
518 fast_func_remove_prefix=true
519 else
520 func_remove_prefix ()
522 eval "value=\"\$$1\""
523 prefix="$2"
524 case "$prefix" in
525 *.*)
526 sed_escape_dots='s/\([.]\)/\\\1/g'
527 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
529 esac
530 value=`echo "$value" | sed -e "s|^${prefix}||"`
531 eval "$1=\"\$value\""
533 fast_func_remove_prefix=false
536 # Determine whether we should use ':' or ';' as PATH_SEPARATOR.
537 func_determine_path_separator ()
539 if test "${PATH_SEPARATOR+set}" != set; then
540 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
541 # contains only /bin. Note that ksh looks also at the FPATH variable,
542 # so we have to set that as well for the test.
543 PATH_SEPARATOR=:
544 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
545 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
546 || PATH_SEPARATOR=';'
551 # func_path_prepend pathvar directory
552 # puts directory before pathvar, delimiting directories by PATH_SEPARATOR.
553 # Newly added directory into pathvar has the highest priority.
554 func_path_prepend ()
556 if eval "test -n \"\$$1\""; then
557 eval "$1=\$2\$PATH_SEPARATOR\$$1"
558 else
559 eval "$1=\$2"
563 # func_path_append pathvar directory
564 # Similar to func_path_prepend except that the newest directory has the lowest
565 # priority.
566 func_path_append ()
568 if eval "test -n \"\$$1\""; then
569 func_append "$1" "$PATH_SEPARATOR$2"
570 else
571 eval "$1=\$2"
575 # func_path_foreach_inner
576 # helper for func_path_foreach because we need new 'args' array
577 # Input:
578 # - fpf_dir directory from local_gnulib_path
579 # - fpf_cb callback to be run for fpf_dir
580 func_path_foreach_inner ()
582 set %start% "$@"
583 for _fpf_arg
585 case $_fpf_arg in
586 %start%)
587 set dummy
589 %dir%)
590 set "$@" "$fpf_dir"
593 set "$@" "$_fpf_arg"
595 esac
596 done
597 shift
599 "$fpf_cb" "$@"
602 # func_path_foreach path method args
603 # Execute method for each directory in path. The method will be called
604 # like `method args` while any argument '%dir%' within args will be replaced
605 # with processed directory from path.
606 func_path_foreach ()
608 fpf_save_IFS=$IFS
609 fpf_dirs=$1 ; shift
610 fpf_cb=$1 ; shift
611 fpf_rc=false
613 IFS=$PATH_SEPARATOR
614 for fpf_dir in $fpf_dirs
616 func_path_foreach_inner "$@" && fpf_rc=:
617 done
618 IFS=$fpf_save_IFS
619 $fpf_rc
622 # func_remove_suffix var suffix
623 # removes the given suffix from the value of the shell variable var.
624 # var should be the name of a shell variable.
625 # Its value should not contain a newline and not start or end with whitespace.
626 # suffix should not contain the characters "$`\{}[]^|.
627 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
628 func_remove_suffix ()
630 eval "$1=\${$1%\$2}"
632 fast_func_remove_suffix=true
633 else
634 func_remove_suffix ()
636 eval "value=\"\$$1\""
637 suffix="$2"
638 case "$suffix" in
639 *.*)
640 sed_escape_dots='s/\([.]\)/\\\1/g'
641 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
643 esac
644 value=`echo "$value" | sed -e "s|${suffix}\$||"`
645 eval "$1=\"\$value\""
647 fast_func_remove_suffix=false
650 # func_fatal_error message
651 # outputs to stderr a fatal error message, and terminates the program.
652 # Input:
653 # - progname name of this program
654 func_fatal_error ()
656 echo "$progname: *** $1" 1>&2
657 echo "$progname: *** Stop." 1>&2
658 func_exit 1
661 # func_warning message
662 # Outputs to stderr a warning message,
663 func_warning ()
665 echo "gnulib-tool: warning: $1" 1>&2
668 # func_readlink SYMLINK
669 # outputs the target of the given symlink.
670 if (type readlink) > /dev/null 2>&1; then
671 func_readlink ()
673 # Use the readlink program from GNU coreutils.
674 readlink "$1"
676 else
677 func_readlink ()
679 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
680 # would do the wrong thing if the link target contains " -> ".
681 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
685 # func_relativize DIR1 DIR2
686 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
687 # Input:
688 # - DIR1 relative pathname, relative to the current directory
689 # - DIR2 relative pathname, relative to the current directory
690 # Output:
691 # - reldir relative pathname of DIR2, relative to DIR1
692 func_relativize ()
694 dir0=`pwd`
695 dir1="$1"
696 dir2="$2"
697 sed_first='s,^\([^/]*\)/.*$,\1,'
698 sed_rest='s,^[^/]*/*,,'
699 sed_last='s,^.*/\([^/]*\)$,\1,'
700 sed_butlast='s,/*[^/]*$,,'
701 while test -n "$dir1"; do
702 first=`echo "$dir1" | sed -e "$sed_first"`
703 if test "$first" != "."; then
704 if test "$first" = ".."; then
705 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
706 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
707 else
708 first2=`echo "$dir2" | sed -e "$sed_first"`
709 if test "$first2" = "$first"; then
710 dir2=`echo "$dir2" | sed -e "$sed_rest"`
711 else
712 dir2="../$dir2"
714 dir0="$dir0"/"$first"
717 dir1=`echo "$dir1" | sed -e "$sed_rest"`
718 done
719 reldir="$dir2"
722 # func_relconcat DIR1 DIR2
723 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
724 # Input:
725 # - DIR1 relative pathname, relative to the current directory
726 # - DIR2 relative pathname, relative to DIR1
727 # Output:
728 # - relconcat DIR1/DIR2, relative to the current directory
729 func_relconcat ()
731 dir1="$1"
732 dir2="$2"
733 sed_first='s,^\([^/]*\)/.*$,\1,'
734 sed_rest='s,^[^/]*/*,,'
735 sed_last='s,^.*/\([^/]*\)$,\1,'
736 sed_butlast='s,/*[^/]*$,,'
737 while true; do
738 first=`echo "$dir2" | sed -e "$sed_first"`
739 if test "$first" = "."; then
740 dir2=`echo "$dir2" | sed -e "$sed_rest"`
741 if test -z "$dir2"; then
742 relconcat="$dir1"
743 break
745 else
746 last=`echo "$dir1" | sed -e "$sed_last"`
747 while test "$last" = "."; do
748 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
749 last=`echo "$dir1" | sed -e "$sed_last"`
750 done
751 if test -z "$dir1"; then
752 relconcat="$dir2"
753 break
755 if test "$first" = ".."; then
756 if test "$last" = ".."; then
757 relconcat="$dir1/$dir2"
758 break
760 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
761 dir2=`echo "$dir2" | sed -e "$sed_rest"`
762 if test -z "$dir1"; then
763 relconcat="$dir2"
764 break
766 if test -z "$dir2"; then
767 relconcat="$dir1"
768 break
770 else
771 relconcat="$dir1/$dir2"
772 break
775 done
778 # func_ln_s SRC DEST
779 # Like ln -s, except use cp -p if ln -s fails.
780 func_ln_s ()
782 ln -s "$1" "$2" || {
783 echo "$progname: ln -s failed; falling back on cp -p" >&2
785 case "$1" in
786 /* | ?:*) # SRC is absolute.
787 cp_src="$1" ;;
788 *) # SRC is relative to the directory of DEST.
789 case "$2" in
790 */*) cp_src="${2%/*}/$1" ;;
791 *) cp_src="$1" ;;
792 esac
794 esac
796 cp -p "$cp_src" "$2"
800 # func_symlink_target SRC DEST
801 # Determines LINK_TARGET such that "ln -s LINK_TARGET DEST" will create a
802 # symbolic link DEST that points to SRC.
803 # Output:
804 # - link_target link target, relative to the directory of DEST
805 func_symlink_target ()
807 case "$1" in
808 /* | ?:*)
809 link_target="$1" ;;
810 *) # SRC is relative.
811 case "$2" in
812 /* | ?:*)
813 link_target="`pwd`/$1" ;;
814 *) # DEST is relative too.
815 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
816 test -n "$ln_destdir" || ln_destdir="."
817 func_relativize "$ln_destdir" "$1"
818 link_target="$reldir"
820 esac
822 esac
825 # func_symlink SRC DEST
826 # Like func_ln_s, except that SRC is given relative to the current directory (or
827 # absolute), not given relative to the directory of DEST.
828 func_symlink ()
830 func_symlink_target "$1" "$2"
831 func_ln_s "$link_target" "$2"
834 # func_symlink_if_changed SRC DEST
835 # Like func_symlink, but avoids munging timestamps if the link is correct.
836 # SRC is given relative to the current directory (or absolute).
837 func_symlink_if_changed ()
839 if test $# -ne 2; then
840 echo "usage: func_symlink_if_changed SRC DEST" >&2
842 func_symlink_target "$1" "$2"
843 ln_target=`func_readlink "$2"`
844 if test -h "$2" && test "$link_target" = "$ln_target"; then
846 else
847 rm -f "$2"
848 func_ln_s "$link_target" "$2"
852 # func_hardlink SRC DEST
853 # Like ln, except use cp -p if ln fails.
854 # SRC is given relative to the current directory (or absolute).
855 func_hardlink ()
857 ln "$1" "$2" || {
858 echo "$progname: ln failed; falling back on cp -p" >&2
859 cp -p "$1" "$2"
863 # Ensure an 'echo' command that
864 # 1. does not interpret backslashes and
865 # 2. does not print an error message "broken pipe" when writing into a pipe
866 # with no writers.
868 # Test cases for problem 1:
869 # echo '\n' | wc -l prints 1 when OK, 2 when KO
870 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
871 # Test cases for problem 2:
872 # echo hi | true frequently prints
873 # "bash: echo: write error: Broken pipe"
874 # to standard error in bash 3.2.
876 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
877 # BSD echo interprets '-n' as an option, which is also not desirable).
878 # Nowadays the problem occurs in 4 situations:
879 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
880 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
881 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
882 # - in zsh, when sh-emulation is not set,
883 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
884 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
885 # - in Solaris /bin/sh and OSF/1 /bin/sh.
886 # We try the following workarounds:
887 # - for all: respawn using $CONFIG_SHELL if that is set and works.
888 # - for bash >= 2.04: unset the shell option xpg_echo.
889 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
890 # - for bash < 2.0: define echo to a function that uses cat of a here document.
891 # - for zsh: turn sh-emulation on.
892 # - for ksh: alias echo to 'print -r'.
893 # - for ksh: alias echo to a function that uses cat of a here document.
894 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
895 # the ksh workaround.
896 # - otherwise: respawn using /bin/sh and rely on the workarounds.
897 # When respawning, we pass --no-reexec as first argument, so as to avoid
898 # turning this script into a fork bomb in unlucky situations.
900 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
901 # the 'printf' built-in. See
902 # <https://lists.gnu.org/r/bug-bash/2008-12/msg00050.html>
903 # <https://lists.gnu.org/r/bug-gnulib/2010-02/msg00154.html>
904 # The workaround is: define echo to a function that uses the printf built-in.
905 have_echo=
906 if echo '\t' | grep t > /dev/null; then
907 have_echo=yes # Lucky!
909 # Try the workarounds.
910 # Respawn using $CONFIG_SHELL if that is set and works.
911 if test -z "$have_echo" \
912 && test "X$1" != "X--no-reexec" \
913 && test -n "$CONFIG_SHELL" \
914 && test -f "$CONFIG_SHELL" \
915 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
916 exec $CONFIG_SHELL "$0" --no-reexec "$@"
917 exit 127
919 # For bash >= 2.04: unset the shell option xpg_echo.
920 if test -z "$have_echo" \
921 && test -n "$BASH_VERSION" \
922 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
923 shopt -o xpg_echo
924 have_echo=yes
926 # For bash >= 2.0: define echo to a function that uses the printf built-in.
927 # For bash < 2.0: define echo to a function that uses cat of a here document.
928 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
929 # Also handle problem 2, specific to bash 3.2, here.
930 if { test -z "$have_echo" \
931 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
933 && test -n "$BASH_VERSION"; then \
934 if type printf 2>/dev/null | grep / > /dev/null; then
935 # 'printf' is not a shell built-in.
936 echo ()
938 cat <<EOF
942 else
943 # 'printf' is a shell built-in.
944 echo ()
946 printf '%s\n' "$*"
949 if echo '\t' | grep t > /dev/null; then
950 have_echo=yes
953 # For zsh: turn sh-emulation on.
954 if test -z "$have_echo" \
955 && test -n "$ZSH_VERSION" \
956 && (emulate sh) >/dev/null 2>&1; then
957 emulate sh
959 # For ksh: alias echo to 'print -r'.
960 if test -z "$have_echo" \
961 && (type print) >/dev/null 2>&1; then
962 # A 'print' command exists.
963 if type print 2>/dev/null | grep / > /dev/null; then
965 else
966 # 'print' is a shell built-in.
967 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
968 # 'print' is the ksh shell built-in.
969 alias echo='print -r'
973 if test -z "$have_echo" \
974 && echo '\t' | grep t > /dev/null; then
975 have_echo=yes
977 # For ksh: alias echo to a function that uses cat of a here document.
978 # The ksh manual page says:
979 # "Aliasing is performed when scripts are read, not while they are executed.
980 # Therefore, for an alias to take effect, the alias definition command has
981 # to be executed before the command which references the alias is read."
982 # Because of this, we have to play strange tricks with have_echo, to ensure
983 # that the top-level statement containing the test starts after the 'alias'
984 # command.
985 if test -z "$have_echo"; then
986 bsd_echo ()
988 cat <<EOF
992 if (alias echo=bsd_echo) 2>/dev/null; then
993 alias echo=bsd_echo 2>/dev/null
996 if test -z "$have_echo" \
997 && echo '\t' | grep t > /dev/null; then
998 have_echo=yes
1000 if test -z "$have_echo"; then
1001 if (alias echo=bsd_echo) 2>/dev/null; then
1002 unalias echo 2>/dev/null
1005 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
1006 if test -z "$have_echo" \
1007 && test "X$1" != "X--no-reexec" \
1008 && test -f /bin/ksh; then
1009 exec /bin/ksh "$0" --no-reexec "$@"
1010 exit 127
1012 # Otherwise: respawn using /bin/sh.
1013 if test -z "$have_echo" \
1014 && test "X$1" != "X--no-reexec" \
1015 && test -f /bin/sh; then
1016 exec /bin/sh "$0" --no-reexec "$@"
1017 exit 127
1019 if test -z "$have_echo"; then
1020 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
1022 if echo '\t' | grep t > /dev/null; then
1023 : # Works fine now.
1024 else
1025 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
1027 if test "X$1" = "X--no-reexec"; then
1028 shift
1031 # Unset CDPATH. Otherwise, output from 'cd dir' can surprise callers.
1032 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1034 # Determine the path separator early because the following option parsing code
1035 # requires that.
1036 func_determine_path_separator
1038 # Command-line option processing.
1039 # Removes the OPTIONS from the arguments. Sets the variables:
1040 # - mode one of: list, find, import, add-import, remove-import,
1041 # update, create-testdir, create-megatestdir, test, megatest,
1042 # copy-file
1043 # - destdir from --dir
1044 # - local_gnulib_path from --local-dir
1045 # - modcache true or false, from --cache-modules/--no-cache-modules
1046 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1047 # - libname, supplied_libname from --lib
1048 # - sourcebase from --source-base
1049 # - m4base from --m4-base
1050 # - pobase from --po-base
1051 # - docbase from --doc-base
1052 # - testsbase from --tests-base
1053 # - auxdir from --aux-dir
1054 # - inctests true if --with-tests was given, false if --without-tests
1055 # was given, blank otherwise
1056 # - incobsolete true if --with-obsolete was given, blank otherwise
1057 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
1058 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
1059 # otherwise
1060 # - inc_privileged_tests true if --with-privileged-tests was given, blank
1061 # otherwise
1062 # - inc_unportable_tests true if --with-unportable-tests was given, blank
1063 # otherwise
1064 # - inc_all_tests true if --with-all-tests was given, blank otherwise
1065 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
1066 # - excl_longrunning_tests true if --without-longrunning-tests was given,
1067 # blank otherwise
1068 # - excl_privileged_tests true if --without-privileged-tests was given, blank
1069 # otherwise
1070 # - excl_unportable_tests true if --without-unportable-tests was given, blank
1071 # otherwise
1072 # - single_configure true if --single-configure was given, false otherwise
1073 # - avoidlist list of modules to avoid, from --avoid
1074 # - cond_dependencies true if --conditional-dependencies was given, false if
1075 # --no-conditional-dependencies was given, blank otherwise
1076 # - lgpl yes or a number if --lgpl was given, blank otherwise
1077 # - gnu_make true if --gnu-make was given, false otherwise
1078 # - makefile_name from --makefile-name
1079 # - libtool true if --libtool was given, false if --no-libtool was
1080 # given, blank otherwise
1081 # - macro_prefix from --macro-prefix
1082 # - po_domain from --po-domain
1083 # - witness_c_macro from --witness-c-macro
1084 # - vc_files true if --vc-files was given, false if --no-vc-files was
1085 # given, blank otherwise
1086 # - autoconf_minversion minimum supported autoconf version
1087 # - doit : if actions shall be executed, false if only to be printed
1088 # - copymode symlink if --symlink or --more-symlinks was given,
1089 # hardlink if --hardlink or --more-hardlinks was given,
1090 # blank otherwise
1091 # - lcopymode symlink if --local-symlink was given,
1092 # hardlink if --local-hardlink was given,
1093 # blank otherwise
1094 # - do_copyrights blank if --more-symlinks or --more-hardlinks was given,
1095 # true otherwise
1097 mode=
1098 destdir=
1099 local_gnulib_path=
1100 modcache=true
1101 verbose=0
1102 libname=libgnu
1103 supplied_libname=
1104 sourcebase=
1105 m4base=
1106 pobase=
1107 docbase=
1108 testsbase=
1109 auxdir=
1110 inctests=
1111 incobsolete=
1112 inc_cxx_tests=
1113 inc_longrunning_tests=
1114 inc_privileged_tests=
1115 inc_unportable_tests=
1116 inc_all_tests=
1117 excl_cxx_tests=
1118 excl_longrunning_tests=
1119 excl_privileged_tests=
1120 excl_unportable_tests=
1121 single_configure=false
1122 avoidlist=
1123 cond_dependencies=
1124 lgpl=
1125 gnu_make=false
1126 makefile_name=
1127 libtool=
1128 macro_prefix=
1129 po_domain=
1130 witness_c_macro=
1131 vc_files=
1132 doit=:
1133 copymode=
1134 lcopymode=
1135 do_copyrights=true
1137 supplied_opts="$@"
1139 while test $# -gt 0; do
1140 case "$1" in
1141 --list | --lis )
1142 mode=list
1143 shift ;;
1144 --find | --fin | --fi | --f )
1145 mode=find
1146 shift ;;
1147 --import | --impor | --impo | --imp | --im | --i )
1148 mode=import
1149 shift ;;
1150 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1151 mode=add-import
1152 shift ;;
1153 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1154 mode=remove-import
1155 shift ;;
1156 --update | --updat | --upda | --upd | --up | --u )
1157 mode=update
1158 shift ;;
1159 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1160 mode=create-testdir
1161 shift ;;
1162 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1163 mode=create-megatestdir
1164 shift ;;
1165 --test | --tes | --te | --t )
1166 mode=test
1167 shift ;;
1168 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1169 mode=megatest
1170 shift ;;
1171 --extract-* )
1172 mode=`echo "X$1" | sed -e 's/^X--//'`
1173 shift ;;
1174 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1175 mode=copy-file
1176 shift ;;
1177 --dir )
1178 shift
1179 if test $# = 0; then
1180 func_fatal_error "missing argument for --dir"
1182 destdir=$1
1183 shift ;;
1184 --dir=* )
1185 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1186 shift ;;
1187 --local-dir )
1188 shift
1189 if test $# = 0; then
1190 func_fatal_error "missing argument for --local-dir"
1192 func_path_prepend local_gnulib_path "$1"
1193 shift ;;
1194 --local-dir=* )
1195 local_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1196 func_path_prepend local_gnulib_path "$local_dir"
1197 shift ;;
1198 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1199 modcache=true
1200 shift ;;
1201 --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 )
1202 modcache=false
1203 shift ;;
1204 --verbose | --verbos | --verbo | --verb )
1205 verbose=`expr $verbose + 1`
1206 shift ;;
1207 --quiet | --quie | --qui | --qu | --q )
1208 verbose=`expr $verbose - 1`
1209 shift ;;
1210 --lib )
1211 shift
1212 if test $# = 0; then
1213 func_fatal_error "missing argument for --lib"
1215 libname=$1
1216 supplied_libname=true
1217 shift ;;
1218 --lib=* )
1219 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1220 supplied_libname=true
1221 shift ;;
1222 --source-base )
1223 shift
1224 if test $# = 0; then
1225 func_fatal_error "missing argument for --source-base"
1227 sourcebase=$1
1228 shift ;;
1229 --source-base=* )
1230 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1231 shift ;;
1232 --m4-base )
1233 shift
1234 if test $# = 0; then
1235 func_fatal_error "missing argument for --m4-base"
1237 m4base=$1
1238 shift ;;
1239 --m4-base=* )
1240 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1241 shift ;;
1242 --po-base )
1243 shift
1244 if test $# = 0; then
1245 func_fatal_error "missing argument for --po-base"
1247 pobase=$1
1248 shift ;;
1249 --po-base=* )
1250 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1251 shift ;;
1252 --doc-base )
1253 shift
1254 if test $# = 0; then
1255 func_fatal_error "missing argument for --doc-base"
1257 docbase=$1
1258 shift ;;
1259 --doc-base=* )
1260 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1261 shift ;;
1262 --tests-base )
1263 shift
1264 if test $# = 0; then
1265 func_fatal_error "missing argument for --tests-base"
1267 testsbase=$1
1268 shift ;;
1269 --tests-base=* )
1270 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1271 shift ;;
1272 --aux-dir )
1273 shift
1274 if test $# = 0; then
1275 func_fatal_error "missing argument for --aux-dir"
1277 auxdir=$1
1278 shift ;;
1279 --aux-dir=* )
1280 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1281 shift ;;
1282 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1283 inctests=true
1284 shift ;;
1285 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1286 incobsolete=true
1287 shift ;;
1288 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1289 inc_cxx_tests=true
1290 shift ;;
1291 --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)
1292 inc_longrunning_tests=true
1293 shift ;;
1294 --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)
1295 inc_privileged_tests=true
1296 shift ;;
1297 --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)
1298 inc_unportable_tests=true
1299 shift ;;
1300 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1301 inc_all_tests=true
1302 shift ;;
1303 --without-tests | --without-test | --without-tes | --without-te | --without-t)
1304 inctests=false
1305 shift ;;
1306 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1307 excl_cxx_tests=true
1308 shift ;;
1309 --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)
1310 excl_longrunning_tests=true
1311 shift ;;
1312 --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)
1313 excl_privileged_tests=true
1314 shift ;;
1315 --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)
1316 excl_unportable_tests=true
1317 shift ;;
1318 --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)
1319 single_configure=true
1320 shift ;;
1321 --avoid )
1322 shift
1323 if test $# = 0; then
1324 func_fatal_error "missing argument for --avoid"
1326 func_append avoidlist " $1"
1327 shift ;;
1328 --avoid=* )
1329 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1330 func_append avoidlist " $arg"
1331 shift ;;
1332 --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)
1333 cond_dependencies=true
1334 shift ;;
1335 --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)
1336 cond_dependencies=false
1337 shift ;;
1338 --lgpl )
1339 lgpl=yes
1340 shift ;;
1341 --lgpl=* )
1342 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1343 case "$arg" in
1344 2 | 3orGPLv2 | 3) ;;
1345 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1346 esac
1347 lgpl=$arg
1348 shift ;;
1349 --gnu-make )
1350 gnu_make=true
1351 shift ;;
1352 --makefile-name )
1353 shift
1354 if test $# = 0; then
1355 func_fatal_error "missing argument for --makefile-name"
1357 makefile_name="$1"
1358 shift ;;
1359 --makefile-name=* )
1360 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1361 shift ;;
1362 --libtool )
1363 libtool=true
1364 shift ;;
1365 --no-libtool )
1366 libtool=false
1367 shift ;;
1368 --macro-prefix )
1369 shift
1370 if test $# = 0; then
1371 func_fatal_error "missing argument for --macro-prefix"
1373 macro_prefix="$1"
1374 shift ;;
1375 --macro-prefix=* )
1376 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1377 shift ;;
1378 --po-domain )
1379 shift
1380 if test $# = 0; then
1381 func_fatal_error "missing argument for --po-domain"
1383 po_domain="$1"
1384 shift ;;
1385 --po-domain=* )
1386 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1387 shift ;;
1388 --witness-c-macro )
1389 shift
1390 if test $# = 0; then
1391 func_fatal_error "missing argument for --witness-c-macro"
1393 witness_c_macro="$1"
1394 shift ;;
1395 --witness-c-macro=* )
1396 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1397 shift ;;
1398 --vc-files )
1399 vc_files=true
1400 shift ;;
1401 --no-vc-files )
1402 vc_files=false
1403 shift ;;
1404 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1405 # A no-op for backward compatibility.
1406 shift ;;
1407 --dry-run )
1408 doit=false
1409 shift ;;
1410 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1411 copymode=symlink
1412 shift ;;
1413 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1414 lcopymode=symlink
1415 shift ;;
1416 -h | --hardlink | --hardlin | --hardli | --hardl | --hard | --har | --ha )
1417 copymode=hardlink
1418 shift ;;
1419 --local-hardlink | --local-hardlin | --local-hardli | --local-hardl | --local-hard | --local-har | --local-ha | --local-h )
1420 lcopymode=hardlink
1421 shift ;;
1422 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s )
1423 copymode=symlink
1424 do_copyrights=
1425 shift ;;
1426 -H | --more-hardlinks | --more-hardlink | --more-hardlin | --more-hardli | --more-hardl | --more-hard | --more-har | --more-ha | --more-h )
1427 copymode=hardlink
1428 do_copyrights=
1429 shift ;;
1430 --help | --hel | --he )
1431 func_usage
1432 func_exit $? ;;
1433 --version | --versio | --versi | --vers )
1434 func_version
1435 func_exit $? ;;
1436 -- )
1437 # Stop option processing
1438 shift
1439 break ;;
1440 -* )
1441 echo "gnulib-tool: unknown option $1" 1>&2
1442 echo "Try 'gnulib-tool --help' for more information." 1>&2
1443 func_exit 1 ;;
1445 break ;;
1446 esac
1447 done
1449 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1450 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1451 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1452 || test "$single_configure" != false; then
1453 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1454 echo "Try 'gnulib-tool --help' for more information." 1>&2
1455 func_exit 1
1458 if test "$mode" = update; then
1459 if test $# != 0; then
1460 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1461 echo "Try 'gnulib-tool --help' for more information." 1>&2
1462 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1463 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1464 func_exit 1
1466 if test -n "$local_gnulib_path" || test -n "$supplied_libname" \
1467 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1468 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1469 || test -n "$inctests" || test -n "$incobsolete" \
1470 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1471 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1472 || test -n "$inc_all_tests" \
1473 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1474 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1475 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1476 || test -n "$macro_prefix" || test -n "$po_domain" \
1477 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1478 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1479 echo "Try 'gnulib-tool --help' for more information." 1>&2
1480 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1481 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1482 func_exit 1
1485 if test -n "$pobase" && test -z "$po_domain"; then
1486 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1487 echo "Try 'gnulib-tool --help' for more information." 1>&2
1488 func_exit 1
1490 if test -z "$pobase" && test -n "$po_domain"; then
1491 func_warning "--po-domain has no effect without a --po-base option"
1493 case $mode,$gnu_make in
1494 *test*,true)
1495 echo "gnulib-tool: --gnu-make not supported when including tests"
1496 func_exit 1;;
1497 esac
1498 # Canonicalize the inctests variable.
1499 case "$mode" in
1500 import | add-import | remove-import | update)
1501 if test -z "$inctests"; then
1502 inctests=false
1505 create-testdir | create-megatestdir | test | megatest)
1506 if test -z "$inctests"; then
1507 inctests=true
1510 esac
1511 # Now the only possible values of "$inctests" are true and false
1512 # (or blank but then it is irrelevant).
1514 # Determine the minimum supported autoconf version from the project's
1515 # configure.ac.
1516 DEFAULT_AUTOCONF_MINVERSION="2.63"
1517 autoconf_minversion=
1518 configure_ac=
1519 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1520 && test -n "$destdir"; then
1521 if test -f "$destdir"/configure.ac; then
1522 configure_ac="$destdir/configure.ac"
1523 else
1524 if test -f "$destdir"/configure.in; then
1525 configure_ac="$destdir/configure.in"
1528 else
1529 if test -f configure.ac; then
1530 configure_ac="configure.ac"
1531 else
1532 if test -f configure.in; then
1533 configure_ac="configure.in"
1537 if test -n "$configure_ac"; then
1538 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1539 # because when some m4 files are omitted from a version control repository,
1540 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1541 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1542 # autom4te: m4 failed with exit status: 1
1543 prereqs=
1544 my_sed_traces='
1545 s,#.*$,,
1546 s,^dnl .*$,,
1547 s, dnl .*$,,
1548 /AC_PREREQ/ {
1549 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1551 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1552 if test -n "$prereqs"; then
1553 autoconf_minversion=`
1554 for version in $prereqs; do echo $version; done |
1555 LC_ALL=C sort -nru | sed -e 1q
1559 if test -z "$autoconf_minversion"; then
1560 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1562 case "$autoconf_minversion" in
1563 1.* | 2.[0-5]* | 2.6[0-2]*)
1564 func_fatal_error "minimum supported autoconf version is 2.63. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1565 esac
1567 # Remove trailing slashes from the directory names. This is necessary for
1568 # m4base (to avoid an error in func_import) and optional for the others.
1569 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1570 old_local_gnulib_path=$local_gnulib_path
1571 save_IFS=$IFS
1572 IFS=:
1573 local_gnulib_path=
1574 for dir in $old_local_gnulib_path
1576 case "$dir" in
1577 */ ) dir=`echo "$dir" | sed -e "$sed_trimtrailingslashes"` ;;
1578 esac
1579 func_path_append local_gnulib_path "$dir"
1580 done
1581 IFS=$save_IFS
1582 case "$sourcebase" in
1583 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1584 esac
1585 case "$m4base" in
1586 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1587 esac
1588 case "$pobase" in
1589 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1590 esac
1591 case "$docbase" in
1592 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1593 esac
1594 case "$testsbase" in
1595 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1596 esac
1597 case "$auxdir" in
1598 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1599 esac
1602 func_gnulib_dir
1603 func_tmpdir
1604 trap 'exit_status=$?
1605 if test "$signal" != 0; then
1606 echo "caught signal $signal" >&2
1608 rm -rf "$tmp"
1609 exit $exit_status' 0
1610 for signal in 1 2 3 13 15; do
1611 trap '{ signal='$signal'; func_exit 1; }' $signal
1612 done
1613 signal=0
1615 # Note: The 'eval' silences stderr output in dash.
1616 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1617 # Zsh 4 and Bash 4 have associative arrays.
1618 have_associative=true
1619 else
1620 # For other shells, use 'eval' with computed shell variable names.
1621 have_associative=false
1624 # func_lookup_local_file_cb dir file
1625 # return true and set func_lookup_local_file_result if the file 'dir/file'
1626 # exists
1627 func_lookup_local_file_cb ()
1629 test -n "$func_lookup_local_file_result" && return 1 # already found?
1630 test -f "$1/$2" || return 1
1631 func_lookup_local_file_result=$1/$2
1635 # func_lookup_local_file file
1636 # looks up a file in $local_gnulib_path.
1637 # Input:
1638 # - local_gnulib_path from --local-dir
1639 # Output:
1640 # - func_lookup_local_file_result name of the file, valid only when the
1641 # function succeeded.
1642 func_lookup_local_file ()
1644 func_lookup_local_file_result=
1645 func_path_foreach "$local_gnulib_path" func_lookup_local_file_cb %dir% "$1"
1648 # func_lookup_file file
1649 # looks up a file in $local_gnulib_path or $gnulib_dir, or combines it through
1650 # 'patch'.
1651 # Input:
1652 # - local_gnulib_path from --local-dir
1653 # Output:
1654 # - lookedup_file name of the merged (combined) file
1655 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1656 func_lookup_file ()
1658 lkfile="$1"
1659 if func_lookup_local_file "$lkfile"; then
1660 lookedup_file=$func_lookup_local_file_result
1661 lookedup_tmp=
1662 else
1663 if test -f "$gnulib_dir/$lkfile"; then
1664 if func_lookup_local_file "$lkfile.diff"; then
1665 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1666 rm -f "$tmp/$lkbase"
1667 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1668 patch -s "$tmp/$lkbase" < "$func_lookup_local_file_result" >&2 \
1669 || func_fatal_error "patch file $func_lookup_local_file_result didn't apply cleanly"
1670 lookedup_file="$tmp/$lkbase"
1671 lookedup_tmp=true
1672 else
1673 lookedup_file="$gnulib_dir/$lkfile"
1674 lookedup_tmp=
1676 else
1677 func_fatal_error "file $gnulib_dir/$lkfile not found"
1682 # func_sanitize_modulelist
1683 # receives a list of possible module names on standard input, one per line.
1684 # It removes those which are just file names unrelated to modules, and outputs
1685 # the resulting list to standard output, one per line.
1686 func_sanitize_modulelist ()
1688 sed -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1689 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1690 -e '/^README$/d' -e '/\/README$/d' \
1691 -e '/^TEMPLATE$/d' \
1692 -e '/^TEMPLATE-EXTENDED$/d' \
1693 -e '/^TEMPLATE-TESTS$/d' \
1694 -e '/^\..*/d' \
1695 -e '/~$/d'
1699 # func_modules_in_dir dir
1700 # outputs all module files in dir to standard output.
1701 func_modules_in_dir ()
1703 (test -d "$1" && cd "$1" && find modules -type f -print)
1706 # func_all_modules
1707 # Input:
1708 # - local_gnulib_path from --local-dir
1709 func_all_modules ()
1711 # Filter out metainformation files like README, which are not modules.
1712 # Filter out unit test modules; they can be retrieved through
1713 # --extract-tests-module if desired.
1715 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1716 func_path_foreach "$local_gnulib_path" func_modules_in_dir %dir% | sed -e 's,^modules/,,' -e 's,\.diff$,,'
1718 | func_sanitize_modulelist \
1719 | sed -e '/-tests$/d' \
1720 | LC_ALL=C sort -u
1723 # func_exists_local_module dir module
1724 # returns true if module exists in dir
1725 func_exists_local_module ()
1727 test -d "$1/modules" && test -f "$1/modules/$2";
1730 # func_exists_module module
1731 # tests whether a module, given by name, exists
1732 # Input:
1733 # - local_gnulib_path from --local-dir
1734 func_exists_module ()
1736 { test -f "$gnulib_dir/modules/$1" \
1737 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1" ; } \
1738 && test "ChangeLog" != "$1" \
1739 && test "COPYING" != "$1" \
1740 && test "README" != "$1" \
1741 && test "TEMPLATE" != "$1" \
1742 && test "TEMPLATE-EXTENDED" != "$1" \
1743 && test "TEMPLATE-TESTS" != "$1"
1746 # func_verify_module
1747 # verifies a module name
1748 # Input:
1749 # - local_gnulib_path from --local-dir
1750 # - module module name argument
1751 func_verify_module ()
1753 if func_exists_module "$module"; then
1754 # OK, $module is a correct module name.
1755 # Verify that building the module description with 'patch' succeeds.
1756 func_lookup_file "modules/$module"
1757 else
1758 func_warning "module $module doesn't exist"
1759 module=
1763 # func_verify_nontests_module
1764 # verifies a module name, excluding tests modules
1765 # Input:
1766 # - local_gnulib_path from --local-dir
1767 # - module module name argument
1768 func_verify_nontests_module ()
1770 case "$module" in
1771 *-tests ) module= ;;
1772 * ) func_verify_module ;;
1773 esac
1776 # func_verify_tests_module
1777 # verifies a module name, considering only tests modules
1778 # Input:
1779 # - local_gnulib_path from --local-dir
1780 # - module module name argument
1781 func_verify_tests_module ()
1783 case "$module" in
1784 *-tests ) func_verify_module ;;
1785 * ) module= ;;
1786 esac
1789 # Suffix of a sed expression that extracts a particular field from a
1790 # module description.
1791 # A field starts with a line that contains a keyword, such as 'Description',
1792 # followed by a colon and optional whitespace. All following lines, up to
1793 # the next field (or end of file if there is none) form the contents of the
1794 # field.
1795 # An absent field is equivalent to a field with empty contents.
1796 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1797 sed_extract_prog=':[ ]*$/ {
1800 s/^Description:[ ]*$//
1801 s/^Comment:[ ]*$//
1802 s/^Status:[ ]*$//
1803 s/^Notice:[ ]*$//
1804 s/^Applicability:[ ]*$//
1805 s/^Files:[ ]*$//
1806 s/^Depends-on:[ ]*$//
1807 s/^configure\.ac-early:[ ]*$//
1808 s/^configure\.ac:[ ]*$//
1809 s/^Makefile\.am:[ ]*$//
1810 s/^Include:[ ]*$//
1811 s/^Link:[ ]*$//
1812 s/^License:[ ]*$//
1813 s/^Maintainer:[ ]*$//
1820 # Piece of a sed expression that converts a field header line to a shell
1821 # variable name,
1822 # NOTE: Keep this in sync with sed_extract_prog above!
1823 sed_extract_field_header='
1824 s/^Description:[ ]*$/description/
1825 s/^Comment:[ ]*$/comment/
1826 s/^Status:[ ]*$/status/
1827 s/^Notice:[ ]*$/notice/
1828 s/^Applicability:[ ]*$/applicability/
1829 s/^Files:[ ]*$/files/
1830 s/^Depends-on:[ ]*$/dependson/
1831 s/^configure\.ac-early:[ ]*$/configureac_early/
1832 s/^configure\.ac:[ ]*$/configureac/
1833 s/^Makefile\.am:[ ]*$/makefile/
1834 s/^Include:[ ]*$/include/
1835 s/^Link:[ ]*$/link/
1836 s/^License:[ ]*$/license/
1837 s/^Maintainer:[ ]*$/maintainer/'
1839 if $modcache; then
1841 if $have_associative; then
1843 # Declare the associative arrays.
1844 declare -A modcache_cached
1845 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1846 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1847 eval "$declare_script"
1849 else
1851 # func_cache_var module
1852 # computes the cache variable name corresponding to $module.
1853 # Note: This computation can map different module names to the same
1854 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1855 # to protect against this case.
1856 # Output:
1857 # - cachevar a shell variable name
1858 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1859 # Bash 2.0 and newer, ksh, and zsh support the syntax
1860 # ${param//pattern/replacement}
1861 # as a shorthand for
1862 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1863 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1864 eval 'func_cache_var ()
1866 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1868 else
1869 func_cache_var ()
1871 case $1 in
1872 *[!a-zA-Z0-9_]*)
1873 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1875 cachevar=c_$1 ;;
1876 esac
1882 # func_init_sed_convert_to_cache_statements
1883 # Input:
1884 # - modcachevar_assignment
1885 # Output:
1886 # - sed_convert_to_cache_statements
1887 func_init_sed_convert_to_cache_statements ()
1889 # 'sed' script that turns a module description into shell script
1890 # assignments, suitable to be eval'ed. All active characters are escaped.
1891 # This script turns
1892 # Description:
1893 # Some module's description
1895 # Files:
1896 # lib/file.h
1897 # into:
1898 # modcache_description[$1]=\
1899 # 'Some module'"'"'s description
1901 # modcache_files[$1]=\
1902 # 'lib/file.h'
1903 # or:
1904 # c_MODULE_description_set=set; c_MODULE_description=\
1905 # 'Some module'"'"'s description
1907 # c_MODULE_files_set=set; c_MODULE_files=\
1908 # 'lib/file.h'
1909 # The script consists of two parts:
1910 # 1) Ignore the lines before the first field header.
1911 # 2) A loop, treating non-field-header lines by escaping single quotes
1912 # and adding a closing quote in the last line,
1913 sed_convert_to_cache_statements="
1914 :llla
1915 # Here we have not yet seen a field header.
1917 # See if the current line contains a field header.
1918 t llla1
1919 :llla1
1920 ${sed_extract_field_header}
1921 t lllb
1923 # No field header. Ignore the line.
1925 # Read the next line. Upon EOF, just exit.
1927 b llla
1929 :lllb
1930 # The current line contains a field header.
1932 # Turn it into the beginning of an assignment.
1933 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1935 # Move it to the hold space. Don't print it yet,
1936 # because we want no assignment if the field is empty.
1939 # Read the next line.
1940 # Upon EOF, the field was empty. Print no assignment. Just exit.
1943 # See if the current line contains a field header.
1944 t lllb1
1945 :lllb1
1946 ${sed_extract_field_header}
1947 # If it is, the previous field was empty. Print no assignment.
1948 t lllb
1950 # Not a field header.
1952 # Print the previous line, held in the hold space.
1957 # Transform single quotes.
1958 s/'/'\"'\"'/g
1960 # Prepend a single quote.
1961 s/^/'/
1963 :lllc
1965 # Move it to the hold space.
1968 # Read the next line.
1969 # Upon EOF, branch.
1971 b llle
1975 # See if the current line contains a field header.
1976 t lllc1
1977 :lllc1
1978 ${sed_extract_field_header}
1979 t llld
1981 # Print the previous line, held in the hold space.
1986 # Transform single quotes.
1987 s/'/'\"'\"'/g
1989 b lllc
1991 :llld
1992 # A field header.
1993 # Print the previous line, held in the hold space, with a single quote
1994 # to end the assignment.
1996 s/\$/'/
2000 b lllb
2002 :llle
2003 # EOF seen.
2004 # Print the previous line, held in the hold space, with a single quote
2005 # to end the assignment.
2007 s/\$/'/
2009 # Exit.
2012 if ! $sed_comments; then
2013 # Remove comments.
2014 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
2015 | sed -e 's/^ *//' -e 's/^#.*//'`
2019 if $have_associative; then
2020 # sed_convert_to_cache_statements does not depend on the module.
2021 modcachevar_assignment='modcache_\1[$1]='
2022 func_init_sed_convert_to_cache_statements
2025 # func_cache_lookup_module module
2027 # looks up a module, like 'func_lookup_file modules/$module', and stores all
2028 # of its relevant data in a cache in the memory of the processing shell. If
2029 # already cached, it does not look it up again, thus saving file access time.
2030 # Parameters:
2031 # - module non-empty string
2032 # Output if $have_associative:
2033 # - modcache_cached[$module] set to yes
2034 # - modcache_description[$module] ==
2035 # - modcache_status[$module] \ set to the field's value, minus the
2036 # - ... / final newline,
2037 # - modcache_maintainer[$module] == or unset if the field's value is empty
2038 # Output if ! $have_associative:
2039 # - cachevar a shell variable name
2040 # - ${cachevar}_cached set to $module
2041 # - ${cachevar}_description ==
2042 # - ${cachevar}_status \ set to the field's value, minus the
2043 # - ... / final newline,
2044 # - ${cachevar}_maintainer == or unset if the field's value is empty
2045 # - ${cachevar}_description_set ==
2046 # - ${cachevar}_status_set \ set to non-empty if the field's value
2047 # - ... / is non-empty,
2048 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
2049 func_cache_lookup_module ()
2051 if $have_associative; then
2052 eval 'cached=${modcache_cached[$1]}'
2053 else
2054 func_cache_var "$1"
2055 eval "cached=\"\$${cachevar}_cached\""
2057 if test -z "$cached"; then
2058 # Not found in cache. Look it up on the file system.
2059 func_lookup_file "modules/$1"
2060 if $have_associative; then
2061 eval 'modcache_cached[$1]=yes'
2062 else
2063 eval "${cachevar}_cached=\"\$1\""
2065 if ! $have_associative; then
2066 # sed_convert_to_cache_statements depends on the module.
2067 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
2068 func_init_sed_convert_to_cache_statements
2070 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
2071 eval "$cache_statements"
2072 else
2073 if ! $have_associative; then
2074 if test "$1" != "$cached"; then
2075 func_fatal_error "cache variable collision between $1 and $cached"
2083 # func_get_description module
2084 # Input:
2085 # - local_gnulib_path from --local-dir
2086 # - modcache true or false, from --cache-modules/--no-cache-modules
2087 func_get_description ()
2089 if ! $modcache; then
2090 func_lookup_file "modules/$1"
2091 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
2092 else
2093 func_cache_lookup_module "$1"
2094 # Output the field's value, including the final newline (if any).
2095 if $have_associative; then
2096 if eval 'test -n "${modcache_description[$1]+set}"'; then
2097 eval 'echo "${modcache_description[$1]}"'
2099 else
2100 eval "field_set=\"\$${cachevar}_description_set\""
2101 if test -n "$field_set"; then
2102 eval "field_value=\"\$${cachevar}_description\""
2103 echo "${field_value}"
2109 # func_get_comment module
2110 # Input:
2111 # - local_gnulib_path from --local-dir
2112 # - modcache true or false, from --cache-modules/--no-cache-modules
2113 func_get_comment ()
2115 if ! $modcache; then
2116 func_lookup_file "modules/$1"
2117 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
2118 else
2119 func_cache_lookup_module "$1"
2120 # Output the field's value, including the final newline (if any).
2121 if $have_associative; then
2122 if eval 'test -n "${modcache_comment[$1]+set}"'; then
2123 eval 'echo "${modcache_comment[$1]}"'
2125 else
2126 eval "field_set=\"\$${cachevar}_comment_set\""
2127 if test -n "$field_set"; then
2128 eval "field_value=\"\$${cachevar}_comment\""
2129 echo "${field_value}"
2135 # func_get_status module
2136 # Input:
2137 # - local_gnulib_path from --local-dir
2138 # - modcache true or false, from --cache-modules/--no-cache-modules
2139 func_get_status ()
2141 if ! $modcache; then
2142 func_lookup_file "modules/$1"
2143 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
2144 else
2145 func_cache_lookup_module "$1"
2146 # Output the field's value, including the final newline (if any).
2147 if $have_associative; then
2148 if eval 'test -n "${modcache_status[$1]+set}"'; then
2149 eval 'echo "${modcache_status[$1]}"'
2151 else
2152 eval "field_set=\"\$${cachevar}_status_set\""
2153 if test -n "$field_set"; then
2154 eval "field_value=\"\$${cachevar}_status\""
2155 echo "${field_value}"
2161 # func_get_notice module
2162 # Input:
2163 # - local_gnulib_path from --local-dir
2164 # - modcache true or false, from --cache-modules/--no-cache-modules
2165 func_get_notice ()
2167 if ! $modcache; then
2168 func_lookup_file "modules/$1"
2169 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
2170 else
2171 func_cache_lookup_module "$1"
2172 # Output the field's value, including the final newline (if any).
2173 if $have_associative; then
2174 if eval 'test -n "${modcache_notice[$1]+set}"'; then
2175 eval 'echo "${modcache_notice[$1]}"'
2177 else
2178 eval "field_set=\"\$${cachevar}_notice_set\""
2179 if test -n "$field_set"; then
2180 eval "field_value=\"\$${cachevar}_notice\""
2181 echo "${field_value}"
2187 # func_get_applicability module
2188 # Input:
2189 # - local_gnulib_path from --local-dir
2190 # - modcache true or false, from --cache-modules/--no-cache-modules
2191 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
2192 func_get_applicability ()
2194 if ! $modcache; then
2195 func_lookup_file "modules/$1"
2196 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2197 else
2198 func_cache_lookup_module "$1"
2199 # Get the field's value, without the final newline.
2200 if $have_associative; then
2201 eval 'my_applicability="${modcache_applicability[$1]}"'
2202 else
2203 eval "my_applicability=\"\$${cachevar}_applicability\""
2206 if test -n "$my_applicability"; then
2207 echo $my_applicability
2208 else
2209 # The default is 'main' or 'tests', depending on the module's name.
2210 case $1 in
2211 *-tests) echo "tests";;
2212 *) echo "main";;
2213 esac
2217 # func_get_filelist module
2218 # Input:
2219 # - local_gnulib_path from --local-dir
2220 # - modcache true or false, from --cache-modules/--no-cache-modules
2221 func_get_filelist ()
2223 if ! $modcache; then
2224 func_lookup_file "modules/$1"
2225 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2226 else
2227 func_cache_lookup_module "$1"
2228 # Output the field's value, including the final newline (if any).
2229 if $have_associative; then
2230 if eval 'test -n "${modcache_files[$1]+set}"'; then
2231 eval 'echo "${modcache_files[$1]}"'
2233 else
2234 eval "field_set=\"\$${cachevar}_files_set\""
2235 if test -n "$field_set"; then
2236 eval "field_value=\"\$${cachevar}_files\""
2237 echo "${field_value}"
2241 echo m4/00gnulib.m4
2242 echo m4/gnulib-common.m4
2245 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2246 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2247 # elements starting with prefix and ending with suffix are considered.
2248 # Processing: removed_prefix and removed_suffix are removed from each element,
2249 # added_prefix and added_suffix are added to each element.
2250 # prefix, suffix should not contain shell-special characters.
2251 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2252 # added_prefix, added_suffix should not contain the characters \|&.
2253 func_filter_filelist ()
2255 if test "$2" != "$nl" \
2256 || { $fast_func_append \
2257 && { test -z "$6" || $fast_func_remove_prefix; } \
2258 && { test -z "$7" || $fast_func_remove_suffix; }; \
2259 }; then
2260 ffflist=
2261 for fff in $3; do
2262 # Do not quote possibly-empty parameters in case patterns,
2263 # AIX and HP-UX ksh won't match them if they are empty.
2264 case "$fff" in
2265 $4*$5)
2266 if test -n "$6"; then
2267 func_remove_prefix fff "$6"
2269 if test -n "$7"; then
2270 func_remove_suffix fff "$7"
2272 fff="$8${fff}$9"
2273 if test -z "$ffflist"; then
2274 ffflist="${fff}"
2275 else
2276 func_append ffflist "$2${fff}"
2279 esac
2280 done
2281 else
2282 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2283 ffflist=`for fff in $3; do
2284 case "$fff" in
2285 $4*$5) echo "$fff" ;;
2286 esac
2287 done | sed -e "$sed_fff_filter"`
2289 eval "$1=\"\$ffflist\""
2292 # func_get_dependencies module
2293 # Input:
2294 # - local_gnulib_path from --local-dir
2295 # - modcache true or false, from --cache-modules/--no-cache-modules
2296 func_get_dependencies ()
2298 # ${module}-tests implicitly depends on ${module}, if that module exists.
2299 case "$1" in
2300 *-tests)
2301 fgd1="$1"
2302 func_remove_suffix fgd1 '-tests'
2303 if func_exists_module "$fgd1"; then
2304 echo "$fgd1"
2307 esac
2308 # Then the explicit dependencies listed in the module description.
2309 { if ! $modcache; then
2310 func_lookup_file "modules/$1"
2311 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2312 else
2313 func_cache_lookup_module "$1"
2314 # Output the field's value, including the final newline (if any).
2315 if $have_associative; then
2316 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2317 eval 'echo "${modcache_dependson[$1]}"'
2319 else
2320 eval "field_set=\"\$${cachevar}_dependson_set\""
2321 if test -n "$field_set"; then
2322 eval "field_value=\"\$${cachevar}_dependson\""
2323 echo "${field_value}"
2328 | sed -e '/^#/d'
2331 # func_get_autoconf_early_snippet module
2332 # Input:
2333 # - local_gnulib_path from --local-dir
2334 # - modcache true or false, from --cache-modules/--no-cache-modules
2335 func_get_autoconf_early_snippet ()
2337 if ! $modcache; then
2338 func_lookup_file "modules/$1"
2339 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2340 else
2341 func_cache_lookup_module "$1"
2342 # Output the field's value, including the final newline (if any).
2343 if $have_associative; then
2344 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2345 eval 'echo "${modcache_configureac_early[$1]}"'
2347 else
2348 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2349 if test -n "$field_set"; then
2350 eval "field_value=\"\$${cachevar}_configureac_early\""
2351 echo "${field_value}"
2357 # func_get_autoconf_snippet module
2358 # Input:
2359 # - local_gnulib_path from --local-dir
2360 # - modcache true or false, from --cache-modules/--no-cache-modules
2361 func_get_autoconf_snippet ()
2363 if ! $modcache; then
2364 func_lookup_file "modules/$1"
2365 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2366 else
2367 func_cache_lookup_module "$1"
2368 # Output the field's value, including the final newline (if any).
2369 if $have_associative; then
2370 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2371 eval 'echo "${modcache_configureac[$1]}"'
2373 else
2374 eval "field_set=\"\$${cachevar}_configureac_set\""
2375 if test -n "$field_set"; then
2376 eval "field_value=\"\$${cachevar}_configureac\""
2377 echo "${field_value}"
2383 # Concatenate lines with trailing slash.
2384 # $1 is an optional filter to restrict the
2385 # concatenation to groups starting with that expression
2386 combine_lines() {
2387 sed -e "/$1.*"'\\$/{
2390 s/\\\n/ /
2391 s/\\$/\\/
2396 # func_get_automake_snippet_conditional module
2397 # returns the part of the Makefile.am snippet that can be put inside Automake
2398 # conditionals.
2399 # Input:
2400 # - local_gnulib_path from --local-dir
2401 # - modcache true or false, from --cache-modules/--no-cache-modules
2402 func_get_automake_snippet_conditional ()
2404 if ! $modcache; then
2405 func_lookup_file "modules/$1"
2406 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2407 else
2408 func_cache_lookup_module "$1"
2409 # Output the field's value, including the final newline (if any).
2410 if $have_associative; then
2411 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2412 eval 'echo "${modcache_makefile[$1]}"'
2414 else
2415 eval "field_set=\"\$${cachevar}_makefile_set\""
2416 if test -n "$field_set"; then
2417 eval "field_value=\"\$${cachevar}_makefile\""
2418 echo "${field_value}"
2424 # func_get_automake_snippet_unconditional module
2425 # returns the part of the Makefile.am snippet that must stay outside of
2426 # Automake conditionals.
2427 # Input:
2428 # - local_gnulib_path from --local-dir
2429 # - modcache true or false, from --cache-modules/--no-cache-modules
2430 func_get_automake_snippet_unconditional ()
2432 case "$1" in
2433 *-tests)
2434 # *-tests module live in tests/, not lib/.
2435 # Synthesize an EXTRA_DIST augmentation.
2436 all_files=`func_get_filelist $1`
2437 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2438 extra_files="$tests_files"
2439 if test -n "$extra_files"; then
2440 echo "EXTRA_DIST +=" $extra_files
2441 echo
2445 # Synthesize an EXTRA_DIST augmentation.
2446 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2447 already_mentioned_files=` \
2448 { if ! $modcache; then
2449 func_lookup_file "modules/$1"
2450 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2451 else
2452 func_cache_lookup_module "$1"
2453 if $have_associative; then
2454 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2455 eval 'echo "${modcache_makefile[$1]}"'
2457 else
2458 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2459 if test -n "$field_set"; then
2460 eval 'field_value="$'"${cachevar}"'_makefile"'
2461 echo "${field_value}"
2466 | combine_lines \
2467 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2468 all_files=`func_get_filelist $1`
2469 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2470 # Remove $already_mentioned_files from $lib_files.
2471 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2472 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2473 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2474 if test -n "$extra_files"; then
2475 echo "EXTRA_DIST +=" $extra_files
2476 echo
2478 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2479 # This is necessary so that automake can generate the right list of
2480 # dependency rules.
2481 # A possible approach would be to use autom4te --trace of the redefined
2482 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2483 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2484 # inside autoconf's built-in macros are not missed).
2485 # But it's simpler and more robust to do it here, based on the file list.
2486 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2487 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2488 # automake will generate a useless dependency; this is harmless.
2489 case "$1" in
2490 relocatable-prog-wrapper) ;;
2491 pt_chown) ;;
2493 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2494 if test -n "$extra_files"; then
2495 echo "EXTRA_lib_SOURCES +=" $extra_files
2496 echo
2499 esac
2500 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2501 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2502 if test -n "$buildaux_files"; then
2503 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2504 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2505 echo
2508 esac
2511 # func_get_automake_snippet module
2512 # Input:
2513 # - local_gnulib_path from --local-dir
2514 # - modcache true or false, from --cache-modules/--no-cache-modules
2515 func_get_automake_snippet ()
2517 func_get_automake_snippet_conditional "$1"
2518 func_get_automake_snippet_unconditional "$1"
2521 # func_get_include_directive module
2522 # Input:
2523 # - local_gnulib_path from --local-dir
2524 # - modcache true or false, from --cache-modules/--no-cache-modules
2525 func_get_include_directive ()
2528 if ! $modcache; then
2529 func_lookup_file "modules/$1"
2530 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2531 else
2532 func_cache_lookup_module "$1"
2533 # Output the field's value, including the final newline (if any).
2534 if $have_associative; then
2535 if eval 'test -n "${modcache_include[$1]+set}"'; then
2536 eval 'echo "${modcache_include[$1]}"'
2538 else
2539 eval "field_set=\"\$${cachevar}_include_set\""
2540 if test -n "$field_set"; then
2541 eval "field_value=\"\$${cachevar}_include\""
2542 echo "${field_value}"
2546 } | sed -e 's/^\(["<]\)/#include \1/'
2549 # func_get_link_directive module
2550 # Input:
2551 # - local_gnulib_path from --local-dir
2552 # - modcache true or false, from --cache-modules/--no-cache-modules
2553 func_get_link_directive ()
2555 if ! $modcache; then
2556 func_lookup_file "modules/$1"
2557 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2558 else
2559 func_cache_lookup_module "$1"
2560 # Output the field's value, including the final newline (if any).
2561 if $have_associative; then
2562 if eval 'test -n "${modcache_link[$1]+set}"'; then
2563 eval 'echo "${modcache_link[$1]}"'
2565 else
2566 eval "field_set=\"\$${cachevar}_link_set\""
2567 if test -n "$field_set"; then
2568 eval "field_value=\"\$${cachevar}_link\""
2569 echo "${field_value}"
2575 # func_get_license_raw module
2576 # Input:
2577 # - local_gnulib_path from --local-dir
2578 # - modcache true or false, from --cache-modules/--no-cache-modules
2579 func_get_license_raw ()
2581 if ! $modcache; then
2582 func_lookup_file "modules/$1"
2583 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2584 else
2585 func_cache_lookup_module "$1"
2586 # Output the field's value, including the final newline (if any).
2587 if $have_associative; then
2588 if eval 'test -n "${modcache_license[$1]+set}"'; then
2589 eval 'echo "${modcache_license[$1]}"'
2591 else
2592 eval "field_set=\"\$${cachevar}_license_set\""
2593 if test -n "$field_set"; then
2594 eval "field_value=\"\$${cachevar}_license\""
2595 echo "${field_value}"
2601 # func_get_license module
2602 # Input:
2603 # - local_gnulib_path from --local-dir
2604 # - modcache true or false, from --cache-modules/--no-cache-modules
2605 func_get_license ()
2607 # Warn if the License field is missing.
2608 case "$1" in
2609 *-tests ) ;;
2611 license=`func_get_license_raw "$1"`
2612 if test -z "$license"; then
2613 func_warning "module $1 lacks a License"
2616 esac
2617 case "$1" in
2618 parse-datetime )
2619 # These modules are under a weaker license only for the purpose of some
2620 # users who hand-edit it and don't use gnulib-tool. For the regular
2621 # gnulib users they are under a stricter license.
2622 echo "GPL"
2626 func_get_license_raw "$1"
2627 # The default is GPL.
2628 echo "GPL"
2629 } | sed -e 's,^ *$,,' | sed -e 1q
2631 esac
2634 # func_get_maintainer module
2635 # Input:
2636 # - local_gnulib_path from --local-dir
2637 # - modcache true or false, from --cache-modules/--no-cache-modules
2638 func_get_maintainer ()
2640 if ! $modcache; then
2641 func_lookup_file "modules/$1"
2642 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2643 else
2644 func_cache_lookup_module "$1"
2645 # Output the field's value, including the final newline (if any).
2646 if $have_associative; then
2647 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2648 eval 'echo "${modcache_maintainer[$1]}"'
2650 else
2651 eval "field_set=\"\$${cachevar}_maintainer_set\""
2652 if test -n "$field_set"; then
2653 eval "field_value=\"\$${cachevar}_maintainer\""
2654 echo "${field_value}"
2660 # func_get_tests_module module
2661 # Input:
2662 # - local_gnulib_path from --local-dir
2663 func_get_tests_module ()
2665 # The naming convention for tests modules is hardwired: ${module}-tests.
2666 if test -f "$gnulib_dir/modules/$1"-tests \
2667 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1-tests"; then
2668 echo "$1"-tests
2672 # func_acceptable module
2673 # tests whether a module is acceptable.
2674 # Input:
2675 # - avoidlist list of modules to avoid
2676 func_acceptable ()
2678 for avoid in $avoidlist; do
2679 if test "$avoid" = "$1"; then
2680 return 1
2682 done
2683 return 0
2686 # sed expression to keep the first 32 characters of each line.
2687 sed_first_32_chars='s/^\(................................\).*/\1/'
2689 # func_module_shellfunc_name module
2690 # computes the shell function name that will contain the m4 macros for the module.
2691 # Input:
2692 # - macro_prefix prefix to use
2693 # Output:
2694 # - shellfunc shell function name
2695 func_module_shellfunc_name ()
2697 case $1 in
2698 *[!a-zA-Z0-9_]*)
2699 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2701 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2702 esac
2705 # func_module_shellvar_name module
2706 # computes the shell variable name the will be set to true once the m4 macros
2707 # for the module have been executed.
2708 # Output:
2709 # - shellvar shell variable name
2710 func_module_shellvar_name ()
2712 case $1 in
2713 *[!a-zA-Z0-9_]*)
2714 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2716 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2717 esac
2720 # func_module_conditional_name module
2721 # computes the automake conditional name for the module.
2722 # Output:
2723 # - conditional name of automake conditional
2724 func_module_conditional_name ()
2726 case $1 in
2727 *[!a-zA-Z0-9_]*)
2728 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2730 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2731 esac
2734 # func_uncond_add_module B
2735 # notes the presence of B as an unconditional module.
2737 # func_conddep_add_module A B cond
2738 # notes the presence of a conditional dependency from module A to module B,
2739 # subject to the condition that A is enabled and cond is true.
2741 # func_cond_module_p B
2742 # tests whether module B is conditional.
2744 # func_cond_module_condition A B
2745 # returns the condition when B should be enabled as a dependency of A, once the
2746 # m4 code for A has been executed.
2747 # Output: - condition
2749 if $have_associative; then
2750 declare -A conddep_isuncond
2751 declare -A conddep_dependers
2752 declare -A conddep_condition
2753 func_uncond_add_module ()
2755 eval 'conddep_isuncond[$1]=true'
2756 eval 'unset conddep_dependers[$1]'
2758 func_conddep_add_module ()
2760 eval 'isuncond="${conddep_isuncond[$2]}"'
2761 if test -z "$isuncond"; then
2762 # No unconditional dependency to B known at this point.
2763 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2764 eval 'conddep_condition[$1---$2]="$3"'
2767 func_cond_module_p ()
2769 eval 'previous_dependers="${conddep_dependers[$1]}"'
2770 test -n "$previous_dependers"
2772 func_cond_module_condition ()
2774 eval 'condition="${conddep_condition[$1---$2]}"'
2776 else
2777 func_uncond_add_module ()
2779 case $1 in
2780 *[!a-zA-Z0-9_]*)
2781 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2783 suffix=$1 ;;
2784 esac
2785 eval 'conddep_isuncond_'"$suffix"'=true'
2786 eval 'unset conddep_dependers_'"$suffix"
2788 func_conddep_add_module ()
2790 case $2 in
2791 *[!a-zA-Z0-9_]*)
2792 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2794 suffix=$2 ;;
2795 esac
2796 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2797 if test -z "$isuncond"; then
2798 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2799 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2800 eval 'conddep_condition_'"$suffix"'="$3"'
2803 func_cond_module_p ()
2805 case $1 in
2806 *[!a-zA-Z0-9_]*)
2807 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2809 suffix=$1 ;;
2810 esac
2811 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2812 test -n "$previous_dependers"
2814 func_cond_module_condition ()
2816 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2817 eval 'condition="${conddep_condition_'"$suffix"'}"'
2821 sed_dependencies_without_conditions='s/ *\[.*//'
2823 # func_modules_transitive_closure
2824 # Input:
2825 # - local_gnulib_path from --local-dir
2826 # - gnu_make true if --gnu-make was given, false otherwise
2827 # - modcache true or false, from --cache-modules/--no-cache-modules
2828 # - modules list of specified modules
2829 # - inctests true if tests should be included, false otherwise
2830 # - incobsolete true if obsolete modules among dependencies should be
2831 # included, blank otherwise
2832 # - inc_cxx_tests true if C++ interoperability tests should be included,
2833 # blank otherwise
2834 # - inc_longrunning_tests true if long-runnings tests should be included,
2835 # blank otherwise
2836 # - inc_privileged_tests true if tests that require root privileges should be
2837 # included, blank otherwise
2838 # - inc_unportable_tests true if tests that fail on some platforms should be
2839 # included, blank otherwise
2840 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2841 # the unit tests of the specified modules should be
2842 # included, blank otherwise
2843 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2844 # the unit tests of the dependencies should be
2845 # included, blank otherwise
2846 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2847 # blank otherwise
2848 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2849 # blank otherwise
2850 # - excl_privileged_tests true if tests that require root privileges should be
2851 # excluded, blank otherwise
2852 # - excl_unportable_tests true if tests that fail on some platforms should be
2853 # excluded, blank otherwise
2854 # - avoidlist list of modules to avoid
2855 # - cond_dependencies true if conditional dependencies shall be supported,
2856 # blank otherwise
2857 # - tmp pathname of a temporary directory
2858 # Output:
2859 # - modules list of modules, including dependencies
2860 # - conddep_dependers, conddep_condition information about conditionally
2861 # enabled modules
2862 func_modules_transitive_closure ()
2864 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2865 # In order to process every module only once (for speed), process an "input
2866 # list" of modules, producing an "output list" of modules. During each round,
2867 # more modules can be queued in the input list. Once a module on the input
2868 # list has been processed, it is added to the "handled list", so we can avoid
2869 # to process it again.
2870 handledmodules=
2871 inmodules="$modules"
2872 outmodules=
2873 fmtc_inc_all_tests="$inc_all_direct_tests"
2874 if test "$cond_dependencies" = true; then
2875 for module in $inmodules; do
2876 func_verify_module
2877 if test -n "$module"; then
2878 if func_acceptable $module; then
2879 func_uncond_add_module $module
2882 done
2884 while test -n "$inmodules"; do
2885 inmodules_this_round="$inmodules"
2886 inmodules= # Accumulator, queue for next round
2887 for module in $inmodules_this_round; do
2888 func_verify_module
2889 if test -n "$module"; then
2890 if func_acceptable $module; then
2891 func_append outmodules " $module"
2892 if test "$cond_dependencies" = true; then
2893 if ! $gnu_make \
2894 && func_get_automake_snippet_conditional $module \
2895 | grep '^if ' > /dev/null; then
2896 # A module whose Makefile.am snippet contains a reference to an
2897 # automake conditional. If we were to use it conditionally, we
2898 # would get an error
2899 # configure: error: conditional "..." was never defined.
2900 # because automake 1.11.1 does not handle nested conditionals
2901 # correctly. As a workaround, make the module unconditional.
2902 func_uncond_add_module $module
2904 if func_cond_module_p $module; then
2905 conditional=true
2906 else
2907 conditional=false
2910 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2911 # Duplicate dependencies are harmless, but Jim wants a warning.
2912 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2913 if test -n "$duplicated_deps"; then
2914 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2916 if $inctests; then
2917 testsmodule=`func_get_tests_module $module`
2918 if test -n "$testsmodule"; then
2919 deps="$deps $testsmodule"
2922 for dep in $deps; do
2923 # Determine whether to include the dependency or tests module.
2924 inc=true
2925 for word in `func_get_status $dep`; do
2926 case "$word" in
2927 obsolete)
2928 test -n "$incobsolete" \
2929 || inc=false
2931 c++-test)
2932 test -z "$excl_cxx_tests" \
2933 || inc=false
2934 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2935 || inc=false
2937 longrunning-test)
2938 test -z "$excl_longrunning_tests" \
2939 || inc=false
2940 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2941 || inc=false
2943 privileged-test)
2944 test -z "$excl_privileged_tests" \
2945 || inc=false
2946 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2947 || inc=false
2949 unportable-test)
2950 test -z "$excl_unportable_tests" \
2951 || inc=false
2952 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2953 || inc=false
2955 *-test)
2956 test -n "$fmtc_inc_all_tests" \
2957 || inc=false
2959 esac
2960 done
2961 if $inc && func_acceptable "$dep"; then
2962 func_append inmodules " $dep"
2963 if test "$cond_dependencies" = true; then
2964 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2965 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2966 s/^.*$/true/p
2968 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2969 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2971 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2972 if test "$condition" = true; then
2973 condition=
2975 if test -n "$condition"; then
2976 func_conddep_add_module "$module" "$dep" "$condition"
2977 else
2978 if $conditional; then
2979 func_conddep_add_module "$module" "$dep" true
2980 else
2981 func_uncond_add_module "$dep"
2986 done
2989 done
2990 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2991 # Remove $handledmodules from $inmodules.
2992 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2993 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2994 fmtc_inc_all_tests="$inc_all_indirect_tests"
2995 done
2996 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2997 rm -f "$tmp"/queued-modules
3000 # func_show_module_list
3001 # Input:
3002 # - specified_modules list of specified modules (one per line, sorted)
3003 # - modules complete list of modules (one per line, sorted)
3004 # - tmp pathname of a temporary directory
3005 func_show_module_list ()
3007 if case "$TERM" in
3008 xterm*) test -t 1;;
3009 *) false;;
3010 esac; then
3011 # Assume xterm compatible escape sequences.
3012 bold_on=`printf '\033[1m'`
3013 bold_off=`printf '\033[0m'`
3014 else
3015 bold_on=
3016 bold_off=
3018 echo "Module list with included dependencies (indented):"
3019 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
3020 echo "$modules" | sed -e '/^$/d' \
3021 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
3022 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
3025 # func_modules_transitive_closure_separately
3026 # Determine main module list and tests-related module list separately.
3027 # The main module list is the transitive closure of the specified modules,
3028 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3029 # is specified, it will consist only of LGPLed source.
3030 # The tests-related module list is the transitive closure of the specified
3031 # modules, including tests modules, minus the main module list excluding
3032 # modules of applicability 'all'. Its lib/* sources (brought in through
3033 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3034 # source, even if --lgpl is specified.
3035 # Input:
3036 # - local_gnulib_path from --local-dir
3037 # - modcache true or false, from --cache-modules/--no-cache-modules
3038 # - specified_modules list of specified modules
3039 # - inctests true if tests should be included, false otherwise
3040 # - incobsolete true if obsolete modules among dependencies should be
3041 # included, blank otherwise
3042 # - inc_cxx_tests true if C++ interoperability tests should be included,
3043 # blank otherwise
3044 # - inc_longrunning_tests true if long-runnings tests should be included,
3045 # blank otherwise
3046 # - inc_privileged_tests true if tests that require root privileges should be
3047 # included, blank otherwise
3048 # - inc_unportable_tests true if tests that fail on some platforms should be
3049 # included, blank otherwise
3050 # - inc_all_direct_tests true if all kinds of problematic unit tests among
3051 # the unit tests of the specified modules should be
3052 # included, blank otherwise
3053 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
3054 # the unit tests of the dependencies should be
3055 # included, blank otherwise
3056 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
3057 # blank otherwise
3058 # - excl_longrunning_tests true if long-runnings tests should be excluded,
3059 # blank otherwise
3060 # - excl_privileged_tests true if tests that require root privileges should be
3061 # excluded, blank otherwise
3062 # - excl_unportable_tests true if tests that fail on some platforms should be
3063 # excluded, blank otherwise
3064 # - avoidlist list of modules to avoid
3065 # - cond_dependencies true if conditional dependencies shall be supported,
3066 # blank otherwise
3067 # - tmp pathname of a temporary directory
3068 # Output:
3069 # - main_modules list of modules, including dependencies
3070 # - testsrelated_modules list of tests-related modules, including dependencies
3071 # - conddep_dependers, conddep_condition information about conditionally
3072 # enabled modules
3073 func_modules_transitive_closure_separately ()
3075 # Determine main module list.
3076 saved_inctests="$inctests"
3077 inctests=false
3078 modules="$specified_modules"
3079 func_modules_transitive_closure
3080 main_modules="$modules"
3081 inctests="$saved_inctests"
3082 if test $verbose -ge 1; then
3083 echo "Main module list:"
3084 echo "$main_modules" | sed -e 's/^/ /'
3086 # Determine tests-related module list.
3087 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3088 testsrelated_modules=`for module in $main_modules; do
3089 if test \`func_get_applicability $module\` = main; then
3090 echo $module
3092 done \
3093 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3094 # If testsrelated_modules consists only of modules with applicability 'all',
3095 # set it to empty (because such modules are only helper modules for other modules).
3096 have_nontrivial_testsrelated_modules=
3097 for module in $testsrelated_modules; do
3098 if test `func_get_applicability $module` != all; then
3099 have_nontrivial_testsrelated_modules=yes
3100 break
3102 done
3103 if test -z "$have_nontrivial_testsrelated_modules"; then
3104 testsrelated_modules=
3106 if test $verbose -ge 1; then
3107 echo "Tests-related module list:"
3108 echo "$testsrelated_modules" | sed -e 's/^/ /'
3112 # func_determine_use_libtests
3113 # Determines whether a $testsbase/libtests.a is needed.
3114 # Input:
3115 # - local_gnulib_path from --local-dir
3116 # - modcache true or false, from --cache-modules/--no-cache-modules
3117 # - testsrelated_modules list of tests-related modules, including dependencies
3118 # Output:
3119 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3120 func_determine_use_libtests ()
3122 use_libtests=false
3123 for module in $testsrelated_modules; do
3124 func_verify_nontests_module
3125 if test -n "$module"; then
3126 all_files=`func_get_filelist $module`
3127 # Test whether some file in $all_files lies in lib/.
3128 for f in $all_files; do
3129 case $f in
3130 lib/*)
3131 use_libtests=true
3132 break 2
3134 esac
3135 done
3137 done
3140 # func_modules_add_dummy
3141 # Input:
3142 # - local_gnulib_path from --local-dir
3143 # - modcache true or false, from --cache-modules/--no-cache-modules
3144 # - modules list of modules, including dependencies
3145 # Output:
3146 # - modules list of modules, including 'dummy' if needed
3147 func_modules_add_dummy ()
3149 # Determine whether any module provides a lib_SOURCES augmentation.
3150 have_lib_SOURCES=
3151 for module in $modules; do
3152 func_verify_nontests_module
3153 if test -n "$module"; then
3154 # Extract the value of "lib_SOURCES += ...".
3155 for file in `func_get_automake_snippet "$module" | combine_lines |
3156 sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
3157 # Ignore .h files since they are not compiled.
3158 case "$file" in
3159 *.h) ;;
3161 have_lib_SOURCES=yes
3162 break 2
3164 esac
3165 done
3167 done
3168 # Add the dummy module, to make sure the library will be non-empty.
3169 if test -z "$have_lib_SOURCES"; then
3170 if func_acceptable "dummy"; then
3171 func_append modules " dummy"
3176 # func_modules_add_dummy_separately
3177 # Input:
3178 # - local_gnulib_path from --local-dir
3179 # - modcache true or false, from --cache-modules/--no-cache-modules
3180 # - main_modules list of modules, including dependencies
3181 # - testsrelated_modules list of tests-related modules, including dependencies
3182 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3183 # Output:
3184 # - main_modules list of modules, including 'dummy' if needed
3185 # - testsrelated_modules list of tests-related modules, including 'dummy' if
3186 # needed
3187 func_modules_add_dummy_separately ()
3189 # Add the dummy module to the main module list if needed.
3190 modules="$main_modules"
3191 func_modules_add_dummy
3192 main_modules="$modules"
3194 # Add the dummy module to the tests-related module list if needed.
3195 if $use_libtests; then
3196 modules="$testsrelated_modules"
3197 func_modules_add_dummy
3198 testsrelated_modules="$modules"
3202 # func_modules_notice
3203 # Input:
3204 # - local_gnulib_path from --local-dir
3205 # - modcache true or false, from --cache-modules/--no-cache-modules
3206 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3207 # - modules list of modules, including dependencies
3208 func_modules_notice ()
3210 if test $verbose -ge -1; then
3211 for module in $modules; do
3212 func_verify_module
3213 if test -n "$module"; then
3214 msg=`func_get_notice $module`
3215 if test -n "$msg"; then
3216 echo "Notice from module $module:"
3217 echo "$msg" | sed -e 's/^/ /'
3220 done
3224 # func_modules_to_filelist
3225 # Input:
3226 # - local_gnulib_path from --local-dir
3227 # - modcache true or false, from --cache-modules/--no-cache-modules
3228 # - modules list of modules, including dependencies
3229 # Output:
3230 # - files list of files
3231 func_modules_to_filelist ()
3233 files=
3234 for module in $modules; do
3235 func_verify_module
3236 if test -n "$module"; then
3237 fs=`func_get_filelist $module`
3238 func_append files " $fs"
3240 done
3241 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3244 # func_modules_to_filelist_separately
3245 # Determine the final file lists.
3246 # They must be computed separately, because files in lib/* go into
3247 # $sourcebase/ if they are in the main file list but into $testsbase/
3248 # if they are in the tests-related file list. Furthermore lib/dummy.c
3249 # can be in both.
3250 # Input:
3251 # - local_gnulib_path from --local-dir
3252 # - modcache true or false, from --cache-modules/--no-cache-modules
3253 # - main_modules list of modules, including dependencies
3254 # - testsrelated_modules list of tests-related modules, including dependencies
3255 func_modules_to_filelist_separately ()
3257 # Determine final main file list.
3258 modules="$main_modules"
3259 func_modules_to_filelist
3260 main_files="$files"
3261 # Determine final tests-related file list.
3262 modules="$testsrelated_modules"
3263 func_modules_to_filelist
3264 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3265 # Merge both file lists.
3266 sed_remove_empty_lines='/^$/d'
3267 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3268 if test $verbose -ge 0; then
3269 echo "File list:"
3270 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3271 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3275 # func_compute_include_guard_prefix
3276 # Determine include_guard_prefix.
3277 # Input:
3278 # - macro_prefix prefix of gl_LIBOBJS macros to use
3279 # Output:
3280 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3281 # - sed_replace_include_guard_prefix
3282 # sed expression for resolving ${gl_include_guard_prefix}
3283 func_compute_include_guard_prefix ()
3285 if test "$macro_prefix" = gl; then
3286 include_guard_prefix='GL'
3287 else
3288 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3290 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3293 # func_execute_command command [args...]
3294 # Executes a command.
3295 # Uses also the variables
3296 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3297 func_execute_command ()
3299 if test $verbose -ge 0; then
3300 echo "executing $*"
3301 "$@"
3302 else
3303 # Commands like automake produce output to stderr even when they succeed.
3304 # Turn this output off if the command succeeds.
3305 "$@" > "$tmp"/cmdout 2>&1
3306 cmdret=$?
3307 if test $cmdret = 0; then
3308 rm -f "$tmp"/cmdout
3309 else
3310 echo "executing $*"
3311 cat "$tmp"/cmdout 1>&2
3312 rm -f "$tmp"/cmdout
3313 (exit $cmdret)
3318 # func_dest_tmpfilename file
3319 # determines the name of a temporary file (file is relative to destdir).
3320 # Input:
3321 # - destdir target directory
3322 # - doit : if actions shall be executed, false if only to be printed
3323 # - tmp pathname of a temporary directory
3324 # Sets variable:
3325 # - tmpfile absolute filename of the temporary file
3326 func_dest_tmpfilename ()
3328 if $doit; then
3329 # Put the new contents of $file in a file in the same directory (needed
3330 # to guarantee that an 'mv' to "$destdir/$file" works).
3331 tmpfile="$destdir/$1.tmp"
3332 else
3333 # Put the new contents of $file in a file in a temporary directory
3334 # (because the directory of "$file" might not exist).
3335 tmpfile="$tmp"/`basename "$1"`.tmp
3339 # func_is_local_file lookedup_file file
3340 # check whether file should be instantiated from local gnulib directory
3341 func_is_local_file ()
3343 dname=$1
3344 func_remove_suffix dname "/$2"
3345 func_path_foreach "$local_gnulib_path" test %dir% = "$dname"
3348 # func_should_link
3349 # determines whether the file $f should be copied, symlinked, or hardlinked.
3350 # Input:
3351 # - copymode copy mode for files in general
3352 # - lcopymode copy mode for files from local_gnulib_path
3353 # - f the original file name
3354 # - lookedup_file name of the merged (combined) file
3355 # Sets variable:
3356 # - copyaction copy or symlink or hardlink
3357 func_should_link ()
3359 if test -n "$lcopymode" && func_is_local_file "$lookedup_file" "$f"; then
3360 copyaction="$lcopymode"
3361 else
3362 if test -n "$copymode"; then
3363 copyaction="$copymode"
3364 else
3365 copyaction=copy
3370 # func_add_file
3371 # copies a file from gnulib into the destination directory. The destination
3372 # is known to not exist.
3373 # Input:
3374 # - destdir target directory
3375 # - local_gnulib_path from --local-dir
3376 # - modcache true or false, from --cache-modules/--no-cache-modules
3377 # - f the original file name
3378 # - lookedup_file name of the merged (combined) file
3379 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3380 # - g the rewritten file name
3381 # - tmpfile absolute filename of the temporary file
3382 # - doit : if actions shall be executed, false if only to be printed
3383 # - copymode copy mode for files in general
3384 # - lcopymode copy mode for files from local_gnulib_path
3385 func_add_file ()
3387 if $doit; then
3388 echo "Copying file $g"
3389 func_should_link
3390 if test "$copyaction" = symlink \
3391 && test -z "$lookedup_tmp" \
3392 && cmp -s "$lookedup_file" "$tmpfile"; then
3393 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3394 else
3395 if test "$copyaction" = hardlink \
3396 && test -z "$lookedup_tmp" \
3397 && cmp -s "$lookedup_file" "$tmpfile"; then
3398 func_hardlink "$lookedup_file" "$destdir/$g"
3399 else
3400 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3403 else
3404 echo "Copy file $g"
3408 # func_update_file
3409 # copies a file from gnulib into the destination directory. The destination
3410 # is known to exist.
3411 # Input:
3412 # - destdir target directory
3413 # - local_gnulib_path from --local-dir
3414 # - modcache true or false, from --cache-modules/--no-cache-modules
3415 # - f the original file name
3416 # - lookedup_file name of the merged (combined) file
3417 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3418 # - g the rewritten file name
3419 # - tmpfile absolute filename of the temporary file
3420 # - doit : if actions shall be executed, false if only to be printed
3421 # - copymode copy mode for files in general
3422 # - lcopymode copy mode for files from local_gnulib_path
3423 # - already_present nonempty if the file should already exist, empty otherwise
3424 func_update_file ()
3426 if cmp -s "$destdir/$g" "$tmpfile"; then
3427 : # The file has not changed.
3428 else
3429 # Replace the file.
3430 if $doit; then
3431 if test -n "$already_present"; then
3432 echo "Updating file $g (backup in ${g}~)"
3433 else
3434 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3436 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3437 func_should_link
3438 if test "$copyaction" = symlink \
3439 && test -z "$lookedup_tmp" \
3440 && cmp -s "$lookedup_file" "$tmpfile"; then
3441 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3442 else
3443 if test "$copyaction" = hardlink \
3444 && test -z "$lookedup_tmp" \
3445 && cmp -s "$lookedup_file" "$tmpfile"; then
3446 func_hardlink "$lookedup_file" "$destdir/$g"
3447 else
3448 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3451 else
3452 if test -n "$already_present"; then
3453 echo "Update file $g (backup in ${g}~)"
3454 else
3455 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3461 # func_emit_lib_Makefile_am
3462 # emits the contents of library makefile to standard output.
3463 # Input:
3464 # - local_gnulib_path from --local-dir
3465 # - modcache true or false, from --cache-modules/--no-cache-modules
3466 # - modules list of modules, including dependencies
3467 # - libname library name
3468 # - pobase directory relative to destdir where to place *.po files
3469 # - auxdir directory relative to destdir where to place build aux files
3470 # - gnu_make true if --gnu-make was given, false otherwise
3471 # - makefile_name from --makefile-name
3472 # - libtool true if libtool will be used, false or blank otherwise
3473 # - macro_prefix prefix of gl_LIBOBJS macros to use
3474 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3475 # - witness_c_macro from --witness-c-macro
3476 # - actioncmd (optional) command that will reproduce this invocation
3477 # - for_test true if creating a package for testing, false otherwise
3478 # - sed_replace_include_guard_prefix
3479 # sed expression for resolving ${gl_include_guard_prefix}
3480 # - destfile filename relative to destdir of makefile being generated
3481 # Input/Output:
3482 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
3483 # list of edits to be done to Makefile.am variables
3484 # Output:
3485 # - uses_subdirs nonempty if object files in subdirs exist
3486 func_emit_lib_Makefile_am ()
3489 # When using GNU make, or when creating an includable Makefile.am snippet,
3490 # augment variables with += instead of assigning them.
3491 if $gnu_make || test -n "$makefile_name"; then
3492 assign='+='
3493 else
3494 assign='='
3496 if test "$libtool" = true; then
3497 libext=la
3498 perhapsLT=LT
3499 sed_eliminate_LDFLAGS="$sed_noop"
3500 else
3501 libext=a
3502 perhapsLT=
3503 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3505 if $for_test; then
3506 # When creating a package for testing: Attempt to provoke failures,
3507 # especially link errors, already during "make" rather than during
3508 # "make check", because "make check" is not possible in a cross-compiling
3509 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3510 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3511 else
3512 sed_transform_check_PROGRAMS="$sed_noop"
3514 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3515 $gnu_make ||
3516 echo "## Process this file with automake to produce Makefile.in."
3517 func_emit_copyright_notice
3518 if test -n "$actioncmd"; then
3519 printf '# Reproduce by:\n%s\n' "$actioncmd"
3521 echo
3522 uses_subdirs=
3524 for module in $modules; do
3525 func_verify_nontests_module
3526 if test -n "$module"; then
3528 func_get_automake_snippet_conditional "$module" |
3529 LC_ALL=C \
3530 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3531 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3532 -e "$sed_eliminate_LDFLAGS" \
3533 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3534 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3535 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3536 -e "$sed_transform_check_PROGRAMS" \
3537 -e "$sed_replace_include_guard_prefix"
3538 if test "$module" = 'alloca'; then
3539 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3540 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3542 } | combine_lines "${libname}_${libext}_SOURCES" > "$tmp"/amsnippet1
3544 func_get_automake_snippet_unconditional "$module" |
3545 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3546 } > "$tmp"/amsnippet2
3547 # Skip the contents if it's entirely empty.
3548 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3549 echo "## begin gnulib module $module"
3550 if $gnu_make; then
3551 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
3552 convert_to_gnu_make='s/^if \(.*\)/ifneq (,$(\1))/'
3553 else
3554 convert_to_gnu_make=
3556 echo
3557 if test "$cond_dependencies" = true; then
3558 if func_cond_module_p "$module"; then
3559 func_module_conditional_name "$module"
3560 if $gnu_make; then
3561 echo "ifneq (,\$($conditional))"
3562 else
3563 echo "if $conditional"
3567 sed "$convert_to_gnu_make" "$tmp"/amsnippet1
3568 if test "$cond_dependencies" = true; then
3569 if func_cond_module_p "$module"; then
3570 echo "endif"
3573 sed "$convert_to_gnu_make" "$tmp"/amsnippet2
3574 if $gnu_make; then
3575 echo "endif"
3577 echo "## end gnulib module $module"
3578 echo
3580 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3581 # Test whether there are some source files in subdirectories.
3582 for f in `func_get_filelist "$module"`; do
3583 case $f in
3584 lib/*/*.c)
3585 uses_subdirs=yes
3586 break
3588 esac
3589 done
3591 done
3592 } > "$tmp"/allsnippets
3593 if test -z "$makefile_name"; then
3594 # If there are source files in subdirectories, prevent collision of the
3595 # object files (example: hash.c and libxml/hash.c).
3596 subdir_options=
3597 if test -n "$uses_subdirs"; then
3598 subdir_options=' subdir-objects'
3600 echo "AUTOMAKE_OPTIONS = 1.11 gnits${subdir_options}"
3602 echo
3603 if test -z "$makefile_name"; then
3604 echo "SUBDIRS ="
3605 echo "noinst_HEADERS ="
3606 echo "noinst_LIBRARIES ="
3607 echo "noinst_LTLIBRARIES ="
3608 # Automake versions < 1.11.4 create an empty pkgdatadir at
3609 # installation time if you specify pkgdata_DATA to empty.
3610 # See automake bugs #10997 and #11030:
3611 # * https://debbugs.gnu.org/10997
3612 # * https://debbugs.gnu.org/11030
3613 # So we need this workaround.
3614 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3615 echo "pkgdata_DATA ="
3617 echo "EXTRA_DIST ="
3618 echo "BUILT_SOURCES ="
3619 echo "SUFFIXES ="
3621 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3622 if test -z "$makefile_name"; then
3623 echo "MOSTLYCLEANDIRS ="
3624 echo "CLEANFILES ="
3625 echo "DISTCLEANFILES ="
3626 echo "MAINTAINERCLEANFILES ="
3628 if $gnu_make; then
3629 echo "# Start of GNU Make output."
3631 # Put autoconf output into a temporary file, so that its exit status
3632 # can be checked from the shell. Signal any error by putting a
3633 # syntax error into the output makefile.
3634 ${AUTOCONF} -t 'AC_SUBST:$1 = @$1@' "$configure_ac" \
3635 >"$tmp"/makeout 2>"$tmp"/makeout2 &&
3636 LC_ALL=C sort -u "$tmp"/makeout || {
3637 echo "== gnulib-tool GNU Make output failed as follows =="
3638 sed 's/^/# stderr: /' "$tmp"/makeout2
3640 rm -f "$tmp"/makeout "$tmp"/makeout2
3642 echo "# End of GNU Make output."
3643 else
3644 echo "# No GNU Make output."
3646 # Execute edits that apply to the Makefile.am being generated.
3647 edit=0
3648 while test $edit != $makefile_am_edits; do
3649 edit=`expr $edit + 1`
3650 eval dir=\"\$makefile_am_edit${edit}_dir\"
3651 eval var=\"\$makefile_am_edit${edit}_var\"
3652 eval val=\"\$makefile_am_edit${edit}_val\"
3653 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
3654 if test -n "$var"; then
3655 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3656 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
3657 # The added subdirectory ${val} needs to be mentioned after '.'.
3658 # Since we don't have '.' among SUBDIRS so far, add it now.
3659 val=". ${val}"
3661 echo "${var} += ${val}"
3662 eval "makefile_am_edit${edit}_var="
3665 done
3666 if test -n "$witness_c_macro"; then
3667 cppflags_part1=" -D$witness_c_macro=1"
3668 else
3669 cppflags_part1=
3671 if $for_test; then
3672 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3673 else
3674 cppflags_part2=
3676 if test -z "$makefile_name"; then
3677 echo
3678 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3679 echo "AM_CFLAGS ="
3680 else
3681 if test -n "$cppflags_part1$cppflags_part2"; then
3682 echo
3683 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3686 echo
3687 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3688 || { test -n "$makefile_name" \
3689 && test -f "$sourcebase/Makefile.am" \
3690 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3691 }; then
3692 # One of the snippets or the user's Makefile.am already specifies an
3693 # installation location for the library. Don't confuse automake by saying
3694 # it should not be installed.
3696 else
3697 # By default, the generated library should not be installed.
3698 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3700 echo
3701 echo "${libname}_${libext}_SOURCES ="
3702 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3703 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3704 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3705 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3706 echo "EXTRA_${libname}_${libext}_SOURCES ="
3707 if test "$libtool" = true; then
3708 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3709 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3710 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3711 # the link dependencies of all modules.
3712 for module in $modules; do
3713 func_verify_nontests_module
3714 if test -n "$module"; then
3715 func_get_link_directive "$module"
3717 done \
3718 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3719 | LC_ALL=C sort -u \
3720 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3722 echo
3723 if test -n "$pobase"; then
3724 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3725 echo
3727 cat "$tmp"/allsnippets \
3728 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3729 echo
3730 echo "mostlyclean-local: mostlyclean-generic"
3731 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3732 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3733 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3734 echo " fi; \\"
3735 echo " done; \\"
3736 echo " :"
3737 rm -f "$tmp"/allsnippets
3740 # func_emit_po_Makevars
3741 # emits the contents of po/ makefile parameterization to standard output.
3742 # Input:
3743 # - local_gnulib_path from --local-dir
3744 # - modcache true or false, from --cache-modules/--no-cache-modules
3745 # - sourcebase directory relative to destdir where to place source code
3746 # - pobase directory relative to destdir where to place *.po files
3747 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3748 func_emit_po_Makevars ()
3750 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3751 func_emit_copyright_notice
3752 echo
3753 echo "# Usually the message domain is the same as the package name."
3754 echo "# But here it has a '-gnulib' suffix."
3755 echo "DOMAIN = ${po_domain}-gnulib"
3756 echo
3757 echo "# These two variables depend on the location of this directory."
3758 echo "subdir = ${pobase}"
3759 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3760 echo
3761 cat <<\EOF
3762 # These options get passed to xgettext.
3763 XGETTEXT_OPTIONS = \
3764 --keyword=_ --flag=_:1:pass-c-format \
3765 --keyword=N_ --flag=N_:1:pass-c-format \
3766 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3767 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3768 --flag=error:3:c-format --flag=error_at_line:5:c-format
3770 # This is the copyright holder that gets inserted into the header of the
3771 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3772 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3774 # This is the email address or URL to which the translators shall report
3775 # bugs in the untranslated strings:
3776 # - Strings which are not entire sentences, see the maintainer guidelines
3777 # in the GNU gettext documentation, section 'Preparing Strings'.
3778 # - Strings which use unclear terms or require additional context to be
3779 # understood.
3780 # - Strings which make invalid assumptions about notation of date, time or
3781 # money.
3782 # - Pluralisation problems.
3783 # - Incorrect English spelling.
3784 # - Incorrect formatting.
3785 # It can be your email address, or a mailing list address where translators
3786 # can write to without being subscribed, or the URL of a web page through
3787 # which the translators can contact you.
3788 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3790 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3791 # message catalogs shall be used. It is usually empty.
3792 EXTRA_LOCALE_CATEGORIES =
3794 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3795 # context. Possible values are "yes" and "no". Set this to yes if the
3796 # package uses functions taking also a message context, like pgettext(), or
3797 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3798 USE_MSGCTXT = no
3802 # func_emit_po_POTFILES_in
3803 # emits the file list to be passed to xgettext to standard output.
3804 # Input:
3805 # - local_gnulib_path from --local-dir
3806 # - modcache true or false, from --cache-modules/--no-cache-modules
3807 # - sourcebase directory relative to destdir where to place source code
3808 # - files list of new files
3809 func_emit_po_POTFILES_in ()
3811 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3812 func_emit_copyright_notice
3813 echo
3814 echo "# List of files which contain translatable strings."
3815 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3818 # func_emit_tests_Makefile_am witness_macro
3819 # emits the contents of tests makefile to standard output.
3820 # Input:
3821 # - local_gnulib_path from --local-dir
3822 # - modcache true or false, from --cache-modules/--no-cache-modules
3823 # - modules list of modules, including dependencies
3824 # - libname library name
3825 # - auxdir directory relative to destdir where to place build aux files
3826 # - gnu_make true if --gnu-make was given, false otherwise
3827 # - makefile_name from --makefile-name
3828 # - libtool true if libtool will be used, false or blank otherwise
3829 # - sourcebase relative directory containing lib source code
3830 # - m4base relative directory containing autoconf macros
3831 # - testsbase relative directory containing unit test code
3832 # - macro_prefix prefix of gl_LIBOBJS macros to use
3833 # - witness_c_macro from --witness-c-macro
3834 # - for_test true if creating a package for testing, false otherwise
3835 # - single_configure true if a single configure file should be generated,
3836 # false for a separate configure file for the tests
3837 # - use_libtests true if a libtests.a should be built, false otherwise
3838 # - sed_replace_include_guard_prefix
3839 # sed expression for resolving ${gl_include_guard_prefix}
3840 # - destfile filename relative to destdir of makefile being generated
3841 # Input/Output:
3842 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
3843 # list of edits to be done to Makefile.am variables
3844 # Output:
3845 # - uses_subdirs nonempty if object files in subdirs exist
3846 func_emit_tests_Makefile_am ()
3848 witness_macro="$1"
3849 if test "$libtool" = true; then
3850 libext=la
3851 perhapsLT=LT
3852 sed_eliminate_LDFLAGS="$sed_noop"
3853 else
3854 libext=a
3855 perhapsLT=
3856 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3858 if $for_test; then
3859 # When creating a package for testing: Attempt to provoke failures,
3860 # especially link errors, already during "make" rather than during
3861 # "make check", because "make check" is not possible in a cross-compiling
3862 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3863 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3864 else
3865 sed_transform_check_PROGRAMS="$sed_noop"
3867 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3868 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3869 echo "## Process this file with automake to produce Makefile.in."
3870 func_emit_copyright_notice
3871 echo
3872 uses_subdirs=
3874 for module in $modules; do
3875 if $for_test && ! $single_configure; then
3876 func_verify_tests_module
3877 else
3878 func_verify_module
3880 if test -n "$module"; then
3882 func_get_automake_snippet "$module" |
3883 LC_ALL=C \
3884 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3885 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3886 -e "$sed_eliminate_LDFLAGS" \
3887 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3888 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3889 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3890 -e "$sed_transform_check_PROGRAMS" \
3891 -e "$sed_replace_include_guard_prefix"
3892 if $use_libtests && test "$module" = 'alloca'; then
3893 echo "libtests_a_LIBADD += @ALLOCA@"
3894 echo "libtests_a_DEPENDENCIES += @ALLOCA@"
3896 } > "$tmp"/amsnippet
3897 # Skip the contents if it's entirely empty.
3898 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3899 # Mention long-running tests at the end.
3900 ofd=3
3901 for word in `func_get_status "$module"`; do
3902 if test "$word" = 'longrunning-test'; then
3903 ofd=4
3904 break
3906 done
3907 { echo "## begin gnulib module $module"
3908 if $gnu_make; then
3909 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
3911 echo
3912 cat "$tmp"/amsnippet
3913 if $gnu_make; then
3914 echo "endif"
3916 echo "## end gnulib module $module"
3917 echo
3918 } >&$ofd
3920 rm -f "$tmp"/amsnippet
3921 # Test whether there are some source files in subdirectories.
3922 for f in `func_get_filelist "$module"`; do
3923 case $f in
3924 lib/*/*.c | tests/*/*.c)
3925 uses_subdirs=yes
3926 break
3928 esac
3929 done
3931 done
3932 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3933 # Generate dependencies here, since it eases the debugging of test failures.
3934 # If there are source files in subdirectories, prevent collision of the
3935 # object files (example: hash.c and libxml/hash.c).
3936 subdir_options=
3937 if test -n "$uses_subdirs"; then
3938 subdir_options=' subdir-objects'
3940 echo "AUTOMAKE_OPTIONS = 1.11 foreign${subdir_options}"
3941 echo
3942 if $for_test && ! $single_configure; then
3943 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3944 echo
3946 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3947 # variable is needed to avoid an error from automake:
3948 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3949 echo "SUBDIRS = ."
3950 echo "TESTS ="
3951 echo "XFAIL_TESTS ="
3952 echo "TESTS_ENVIRONMENT ="
3953 echo "noinst_PROGRAMS ="
3954 if ! $for_test; then
3955 echo "check_PROGRAMS ="
3957 echo "EXTRA_PROGRAMS ="
3958 echo "noinst_HEADERS ="
3959 echo "noinst_LIBRARIES ="
3960 if $use_libtests; then
3961 if $for_test; then
3962 echo "noinst_LIBRARIES += libtests.a"
3963 else
3964 echo "check_LIBRARIES = libtests.a"
3967 # Automake versions < 1.11.4 create an empty pkgdatadir at
3968 # installation time if you specify pkgdata_DATA to empty.
3969 # See automake bugs #10997 and #11030:
3970 # * https://debbugs.gnu.org/10997
3971 # * https://debbugs.gnu.org/11030
3972 # So we need this workaround.
3973 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3974 echo "pkgdata_DATA ="
3976 echo "EXTRA_DIST ="
3977 echo "BUILT_SOURCES ="
3978 echo "SUFFIXES ="
3979 echo "MOSTLYCLEANFILES = core *.stackdump"
3980 echo "MOSTLYCLEANDIRS ="
3981 echo "CLEANFILES ="
3982 echo "DISTCLEANFILES ="
3983 echo "MAINTAINERCLEANFILES ="
3984 # Execute edits that apply to the Makefile.am being generated.
3985 edit=0
3986 while test $edit != $makefile_am_edits; do
3987 edit=`expr $edit + 1`
3988 eval dir=\"\$makefile_am_edit${edit}_dir\"
3989 eval var=\"\$makefile_am_edit${edit}_var\"
3990 eval val=\"\$makefile_am_edit${edit}_val\"
3991 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
3992 if test -n "$var"; then
3993 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3994 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
3995 # The added subdirectory ${val} needs to be mentioned after '.'.
3996 # But we have '.' among SUBDIRS already, so do nothing.
3999 echo "${var} += ${val}"
4000 eval "makefile_am_edit${edit}_var="
4003 done
4004 echo
4005 echo "AM_CPPFLAGS = \\"
4006 if $for_test; then
4007 echo " -DGNULIB_STRICT_CHECKING=1 \\"
4009 if test -n "$witness_c_macro"; then
4010 echo " -D$witness_c_macro=1 \\"
4012 if test -n "${witness_macro}"; then
4013 echo " -D@${witness_macro}@=1 \\"
4015 echo " -I. -I\$(srcdir) \\"
4016 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
4017 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
4018 echo
4019 local_ldadd_before=''
4020 local_ldadd_after=''
4021 if $use_libtests; then
4022 # All test programs need to be linked with libtests.a.
4023 # It needs to be passed to the linker before ${libname}.${libext}, since
4024 # the tests-related modules depend on the main modules.
4025 # It also needs to be passed to the linker after ${libname}.${libext}
4026 # because the latter might contain incomplete modules (such as the 'error'
4027 # module whose dependency to 'progname' is voluntarily omitted).
4028 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
4029 # not matter.
4030 local_ldadd_before=' libtests.a'
4031 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
4033 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
4034 echo
4035 if $use_libtests; then
4036 echo "libtests_a_SOURCES ="
4037 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
4038 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
4039 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
4040 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
4041 echo "EXTRA_libtests_a_SOURCES ="
4042 # The circular dependency in LDADD requires this.
4043 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
4044 echo
4046 # Many test scripts use ${EXEEXT} or ${srcdir}.
4047 # EXEEXT is defined by AC_PROG_CC through autoconf.
4048 # srcdir is defined by autoconf and automake.
4049 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
4050 echo
4051 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
4052 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
4053 echo "# Clean up after Solaris cc."
4054 echo "clean-local:"
4055 echo " rm -rf SunWS_cache"
4056 echo
4057 echo "mostlyclean-local: mostlyclean-generic"
4058 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
4059 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
4060 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
4061 echo " fi; \\"
4062 echo " done; \\"
4063 echo " :"
4064 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
4067 # func_emit_initmacro_start macro_prefix
4068 # emits the first few statements of the gl_INIT macro to standard output.
4069 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4070 func_emit_initmacro_start ()
4072 macro_prefix_arg="$1"
4073 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
4074 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
4075 # LIBOBJS. The purpose is to allow several gnulib instantiations under
4076 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
4077 # flexibility.)
4078 # Furthermore it avoids an automake error like this when a Makefile.am
4079 # that uses pieces of gnulib also uses $(LIBOBJ):
4080 # automatically discovered file `error.c' should not be explicitly mentioned
4081 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
4082 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
4083 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
4084 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
4085 # automatically discovered file `error.c' should not be explicitly mentioned
4086 # We let automake know about the files to be distributed through the
4087 # EXTRA_lib_SOURCES variable.
4088 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
4089 # Create data variables for checking the presence of files that are mentioned
4090 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
4091 # because we want the check to happen when the configure file is created,
4092 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
4093 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
4094 # in which to expect them.
4095 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
4096 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
4097 echo " gl_COMMON"
4100 # func_emit_initmacro_end macro_prefix
4101 # emits the last few statements of the gl_INIT macro to standard output.
4102 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4103 func_emit_initmacro_end ()
4105 macro_prefix_arg="$1"
4106 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
4107 # The check is performed only when autoconf is run from the directory where
4108 # the configure.ac resides; if it is run from a different directory, the
4109 # check is skipped.
4110 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
4111 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
4112 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
4113 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
4114 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
4115 echo " exit 1"
4116 echo " fi"
4117 echo " done])dnl"
4118 echo " m4_if(m4_sysval, [0], [],"
4119 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
4120 echo " ])"
4121 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
4122 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
4123 echo " m4_popdef([AC_LIBSOURCES])"
4124 echo " m4_popdef([AC_REPLACE_FUNCS])"
4125 echo " m4_popdef([AC_LIBOBJ])"
4126 echo " AC_CONFIG_COMMANDS_PRE(["
4127 echo " ${macro_prefix_arg}_libobjs="
4128 echo " ${macro_prefix_arg}_ltlibobjs="
4129 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
4130 echo " # Remove the extension."
4131 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
4132 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
4133 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
4134 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
4135 echo " done"
4136 echo " fi"
4137 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
4138 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
4139 echo " ])"
4142 # func_emit_initmacro_done macro_prefix sourcebase
4143 # emits a few statements after the gl_INIT macro to standard output.
4144 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4145 # - sourcebase directory relative to destdir where to place source code
4146 func_emit_initmacro_done ()
4148 macro_prefix_arg="$1"
4149 sourcebase_arg="$2"
4150 echo
4151 echo "# Like AC_LIBOBJ, except that the module name goes"
4152 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4153 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
4154 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
4155 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
4156 echo "])"
4157 echo
4158 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
4159 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4160 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
4161 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
4162 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
4163 echo "])"
4164 echo
4165 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
4166 echo "# expected is derived from the gnulib-tool parameterization,"
4167 echo "# and alloca is special cased (for the alloca-opt module)."
4168 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
4169 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
4170 echo " m4_foreach([_gl_NAME], [\$1], ["
4171 echo " m4_if(_gl_NAME, [alloca.c], [], ["
4172 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
4173 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
4174 echo " ])"
4175 echo " ])"
4176 echo "])"
4179 # func_emit_autoconf_snippet indentation
4180 # emits the autoconf snippet of a module.
4181 # Input:
4182 # - indentation spaces to prepend on each line
4183 # - local_gnulib_path from --local-dir
4184 # - modcache true or false, from --cache-modules/--no-cache-modules
4185 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4186 # - sed_replace_include_guard_prefix
4187 # sed expression for resolving ${gl_include_guard_prefix}
4188 # - module the module name
4189 # - toplevel true or false. 'false' means a subordinate use of
4190 # gnulib-tool.
4191 # - disable_libtool true or false. It tells whether to disable libtool
4192 # handling even if it has been specified through the
4193 # command line options.
4194 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4195 # invocations.
4196 func_emit_autoconf_snippet ()
4198 indentation="$1"
4199 if { case $module in
4200 gnumakefile | maintainer-makefile)
4201 # These modules are meant to be used only in the top-level directory.
4202 $toplevel ;;
4204 true ;;
4205 esac
4206 }; then
4207 func_get_autoconf_snippet "$module" \
4208 | sed -e '/^$/d;' -e "s/^/$indentation/" \
4209 -e "$sed_replace_build_aux" \
4210 -e "$sed_replace_include_guard_prefix" \
4211 | { if $disable_libtool; then
4212 sed -e 's/\$gl_cond_libtool/false/g' \
4213 -e 's/gl_libdeps/gltests_libdeps/g' \
4214 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4215 else
4219 | { if $disable_gettext; then
4220 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
4221 else
4222 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
4223 # autopoint through at least GNU gettext version 0.18.2.
4224 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
4227 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
4228 echo 'changequote(,)dnl'
4229 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4230 echo 'changequote([, ])dnl'
4231 echo 'AC_SUBST([LTALLOCA])'
4236 # func_emit_autoconf_snippets modules referenceable_modules verifier toplevel disable_libtool disable_gettext
4237 # collects and emit the autoconf snippets of a set of modules.
4238 # Input:
4239 # - local_gnulib_path from --local-dir
4240 # - modcache true or false, from --cache-modules/--no-cache-modules
4241 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4242 # - sed_replace_include_guard_prefix
4243 # sed expression for resolving ${gl_include_guard_prefix}
4244 # - modules the list of modules.
4245 # - referenceable_modules the list of modules which may be referenced as dependencies.
4246 # - verifier one of func_verify_module, func_verify_nontests_module,
4247 # func_verify_tests_module. It selects the subset of
4248 # $modules to consider.
4249 # - toplevel true or false. 'false' means a subordinate use of
4250 # gnulib-tool.
4251 # - disable_libtool true or false. It tells whether to disable libtool
4252 # handling even if it has been specified through the
4253 # command line options.
4254 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4255 # invocations.
4256 func_emit_autoconf_snippets ()
4258 referenceable_modules="$2"
4259 verifier="$3"
4260 toplevel="$4"
4261 disable_libtool="$5"
4262 disable_gettext="$6"
4263 if test "$cond_dependencies" = true; then
4264 for m in $referenceable_modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
4265 # Emit the autoconf code for the unconditional modules.
4266 for module in $1; do
4267 eval $verifier
4268 if test -n "$module"; then
4269 if func_cond_module_p "$module"; then
4271 else
4272 func_emit_autoconf_snippet " "
4275 done
4276 # Initialize the shell variables indicating that the modules are enabled.
4277 for module in $1; do
4278 eval $verifier
4279 if test -n "$module"; then
4280 if func_cond_module_p "$module"; then
4281 func_module_shellvar_name "$module"
4282 echo " $shellvar=false"
4285 done
4286 # Emit the autoconf code for the conditional modules, each in a separate
4287 # function. This makes it possible to support cycles among conditional
4288 # modules.
4289 for module in $1; do
4290 eval $verifier
4291 if test -n "$module"; then
4292 if func_cond_module_p "$module"; then
4293 func_module_shellfunc_name "$module"
4294 func_module_shellvar_name "$module"
4295 echo " $shellfunc ()"
4296 echo ' {'
4297 echo " if ! \$$shellvar; then"
4298 func_emit_autoconf_snippet " "
4299 echo " $shellvar=true"
4300 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4301 # Intersect $deps with the modules list $1.
4302 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4303 for dep in $deps; do
4304 if func_cond_module_p "$dep"; then
4305 func_module_shellfunc_name "$dep"
4306 func_cond_module_condition "$module" "$dep"
4307 if test "$condition" != true; then
4308 echo " if $condition; then"
4309 echo " $shellfunc"
4310 echo ' fi'
4311 else
4312 echo " $shellfunc"
4314 else
4315 # The autoconf code for $dep has already been emitted above and
4316 # therefore is already executed when this function is run.
4319 done
4320 echo ' fi'
4321 echo ' }'
4324 done
4325 # Emit the dependencies from the unconditional to the conditional modules.
4326 for module in $1; do
4327 eval $verifier
4328 if test -n "$module"; then
4329 if func_cond_module_p "$module"; then
4331 else
4332 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4333 # Intersect $deps with the modules list $1.
4334 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4335 for dep in $deps; do
4336 if func_cond_module_p "$dep"; then
4337 func_module_shellfunc_name "$dep"
4338 func_cond_module_condition "$module" "$dep"
4339 if test "$condition" != true; then
4340 echo " if $condition; then"
4341 echo " $shellfunc"
4342 echo ' fi'
4343 else
4344 echo " $shellfunc"
4346 else
4347 # The autoconf code for $dep has already been emitted above and
4348 # therefore is already executed when this code is run.
4351 done
4354 done
4355 # Define the Automake conditionals.
4356 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4357 for module in $1; do
4358 eval $verifier
4359 if test -n "$module"; then
4360 if func_cond_module_p "$module"; then
4361 func_module_conditional_name "$module"
4362 func_module_shellvar_name "$module"
4363 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4366 done
4367 else
4368 # Ignore the conditions, and enable all modules unconditionally.
4369 for module in $1; do
4370 eval $verifier
4371 if test -n "$module"; then
4372 func_emit_autoconf_snippet " "
4374 done
4378 # func_emit_pre_early_macros require indentation modules
4379 # The require parameter can be ':' (AC_REQUIRE) or 'false' (direct call).
4380 func_emit_pre_early_macros ()
4382 echo
4383 echo "${2}# Pre-early section."
4384 if $1; then
4385 _pre_early_snippet="echo \"${2}AC_REQUIRE([\$_pre_early_macro])\""
4386 else
4387 _pre_early_snippet="echo \"${2}\$_pre_early_macro\""
4390 # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB. Doing
4391 # AC_REQUIRE in configure-ac.early is not early enough.
4392 _pre_early_macro="gl_USE_SYSTEM_EXTENSIONS"
4393 case "${nl}${3}${nl}" in
4394 *${nl}extensions${nl}*) eval "$_pre_early_snippet" ;;
4395 esac
4397 _pre_early_macro="gl_PROG_AR_RANLIB"
4398 eval "$_pre_early_snippet"
4399 echo
4402 # func_reconstruct_cached_dir
4403 # callback for func_reconstruct_cached_local_gnulib_path
4404 # Input:
4405 # - destdir from --dir
4406 # Output:
4407 # - local_gnulib_path restored '--local-dir' path from cache
4408 func_reconstruct_cached_dir ()
4410 cached_dir=$1
4411 if test -n "$cached_dir"; then
4412 case "$destdir" in
4414 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4416 case "$cached_dir" in
4418 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4420 func_relconcat "$destdir" "$cached_dir"
4421 func_path_append local_gnulib_path "$relconcat" ;;
4422 esac ;;
4423 esac
4427 # func_reconstruct_cached_local_gnulib_path
4428 # reconstruct local_gnulib_path from cached_local_gnulib_path to be set
4429 # relatively to $destdir again.
4430 # Input:
4431 # - cached_local_gnulib_path local_gnulib_path stored within gnulib-cache.m4
4432 # - destdir from --dir
4433 # Output:
4434 # - local_gnulib_path restored '--local-dir' path from cache
4435 func_reconstruct_cached_local_gnulib_path ()
4437 func_path_foreach "$cached_local_gnulib_path" func_reconstruct_cached_dir %dir%
4440 # func_import modules
4441 # Uses also the variables
4442 # - mode import or add-import or remove-import or update
4443 # - destdir target directory
4444 # - local_gnulib_path from --local-dir
4445 # - modcache true or false, from --cache-modules/--no-cache-modules
4446 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4447 # - libname library name
4448 # - supplied_libname true if --lib was given, blank otherwise
4449 # - sourcebase directory relative to destdir where to place source code
4450 # - m4base directory relative to destdir where to place *.m4 macros
4451 # - pobase directory relative to destdir where to place *.po files
4452 # - docbase directory relative to destdir where to place doc files
4453 # - testsbase directory relative to destdir where to place unit test code
4454 # - auxdir directory relative to destdir where to place build aux files
4455 # - inctests true if --with-tests was given, false otherwise
4456 # - incobsolete true if --with-obsolete was given, blank otherwise
4457 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4458 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4459 # otherwise
4460 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4461 # otherwise
4462 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4463 # otherwise
4464 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4465 # - avoidlist list of modules to avoid, from --avoid
4466 # - cond_dependencies true if --conditional-dependencies was given, false if
4467 # --no-conditional-dependencies was given, blank otherwise
4468 # - lgpl yes or a number if library's license shall be LGPL,
4469 # blank otherwise
4470 # - makefile_name from --makefile-name
4471 # - libtool true if --libtool was given, false if --no-libtool was
4472 # given, blank otherwise
4473 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4474 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4475 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4476 # - witness_c_macro from --witness-c-macro
4477 # - vc_files true if --vc-files was given, false if --no-vc-files was
4478 # given, blank otherwise
4479 # - autoconf_minversion minimum supported autoconf version
4480 # - doit : if actions shall be executed, false if only to be printed
4481 # - copymode copy mode for files in general
4482 # - lcopymode copy mode for files from local_gnulib_path
4483 # - do_copyrights true if copyright notices in files should be replaced,
4484 # blank otherwise
4485 func_import ()
4487 # Get the cached settings.
4488 # In 'import' mode, we read them only for the purpose of knowing the old
4489 # installed file list, and don't use them as defaults.
4490 cached_local_gnulib_path=
4491 cached_specified_modules=
4492 cached_incobsolete=
4493 cached_inc_cxx_tests=
4494 cached_inc_longrunning_tests=
4495 cached_inc_privileged_tests=
4496 cached_inc_unportable_tests=
4497 cached_inc_all_tests=
4498 cached_avoidlist=
4499 cached_sourcebase=
4500 cached_m4base=
4501 cached_pobase=
4502 cached_docbase=
4503 cached_testsbase=
4504 cached_inctests=
4505 cached_libname=
4506 cached_lgpl=
4507 cached_makefile_name=
4508 cached_cond_dependencies=
4509 cached_libtool=
4510 cached_macro_prefix=
4511 cached_po_domain=
4512 cached_witness_c_macro=
4513 cached_vc_files=
4514 cached_files=
4515 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4516 cached_libtool=false
4517 my_sed_traces='
4518 s,#.*$,,
4519 s,^dnl .*$,,
4520 s, dnl .*$,,
4521 /gl_LOCAL_DIR(/ {
4522 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_path="\1",p
4524 /gl_MODULES(/ {
4527 s/)/)/
4532 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4534 /gl_WITH_OBSOLETE/ {
4535 s,^.*$,cached_incobsolete=true,p
4537 /gl_WITH_CXX_TESTS/ {
4538 s,^.*$,cached_inc_cxx_tests=true,p
4540 /gl_WITH_LONGRUNNING_TESTS/ {
4541 s,^.*$,cached_inc_longrunning_tests=true,p
4543 /gl_WITH_PRIVILEGED_TESTS/ {
4544 s,^.*$,cached_inc_privileged_tests=true,p
4546 /gl_WITH_UNPORTABLE_TESTS/ {
4547 s,^.*$,cached_inc_unportable_tests=true,p
4549 /gl_WITH_ALL_TESTS/ {
4550 s,^.*$,cached_inc_all_tests=true,p
4552 /gl_AVOID(/ {
4553 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4555 /gl_SOURCE_BASE(/ {
4556 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4558 /gl_M4_BASE(/ {
4559 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4561 /gl_PO_BASE(/ {
4562 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4564 /gl_DOC_BASE(/ {
4565 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4567 /gl_TESTS_BASE(/ {
4568 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4570 /gl_WITH_TESTS/ {
4571 s,^.*$,cached_inctests=true,p
4573 /gl_LIB(/ {
4574 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4576 /gl_LGPL(/ {
4577 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4579 /gl_LGPL/ {
4580 s,^.*$,cached_lgpl=yes,p
4582 /gl_MAKEFILE_NAME(/ {
4583 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4585 /gl_CONDITIONAL_DEPENDENCIES/ {
4586 s,^.*$,cached_cond_dependencies=true,p
4588 /gl_LIBTOOL/ {
4589 s,^.*$,cached_libtool=true,p
4591 /gl_MACRO_PREFIX(/ {
4592 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4594 /gl_PO_DOMAIN(/ {
4595 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4597 /gl_WITNESS_C_MACRO(/ {
4598 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4600 /gl_VC_FILES(/ {
4601 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4603 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4604 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4605 my_sed_traces='
4606 s,#.*$,,
4607 s,^dnl .*$,,
4608 s, dnl .*$,,
4609 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4610 s,^.*$,cached_files=",p
4614 s,^\]).*$,",
4616 s,["$`\\],,g
4623 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4627 if test "$mode" = import; then
4628 # In 'import' mode, the new set of specified modules overrides the cached
4629 # set of modules. Ignore the cached settings.
4630 specified_modules="$1"
4631 else
4632 # Merge the cached settings with the specified ones.
4633 # The m4base must be the same as expected from the pathname.
4634 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4635 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4637 # The local_gnulib_path defaults to the cached one. Recall that the cached one
4638 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4639 if test -z "$local_gnulib_path"; then
4640 func_reconstruct_cached_local_gnulib_path
4642 case $mode in
4643 add-import)
4644 # Append the cached and the specified module names. So that
4645 # "gnulib-tool --add-import foo" means to add the module foo.
4646 specified_modules="$cached_specified_modules $1"
4648 remove-import)
4649 # Take the cached module names, minus the specified module names.
4650 specified_modules=
4651 if $have_associative; then
4652 # Use an associative array, for O(N) worst-case run time.
4653 declare -A to_remove
4654 for m in $1; do
4655 eval 'to_remove[$m]=yes'
4656 done
4657 for module in $cached_specified_modules; do
4658 if eval 'test -z "${to_remove[$module]}"'; then
4659 func_append specified_modules "$module "
4661 done
4662 else
4663 # This loop has O(N**2) worst-case run time.
4664 for module in $cached_specified_modules; do
4665 to_remove=
4666 for m in $1; do
4667 if test "$m" = "$module"; then
4668 to_remove=yes
4669 break
4671 done
4672 if test -z "$to_remove"; then
4673 func_append specified_modules "$module "
4675 done
4678 update)
4679 # Take the cached module names. There are no specified module names.
4680 specified_modules="$cached_specified_modules"
4682 esac
4683 # Included obsolete modules among the dependencies if specified either way.
4684 if test -z "$incobsolete"; then
4685 incobsolete="$cached_incobsolete"
4687 # Included special kinds of tests modules among the dependencies if specified
4688 # either way.
4689 if test -z "$inc_cxx_tests"; then
4690 inc_cxx_tests="$cached_inc_cxx_tests"
4692 if test -z "$inc_longrunning_tests"; then
4693 inc_longrunning_tests="$cached_inc_longrunning_tests"
4695 if test -z "$inc_privileged_tests"; then
4696 inc_privileged_tests="$cached_inc_privileged_tests"
4698 if test -z "$inc_unportable_tests"; then
4699 inc_unportable_tests="$cached_inc_unportable_tests"
4701 if test -z "$inc_all_tests"; then
4702 inc_all_tests="$cached_inc_all_tests"
4704 # Append the cached and the specified avoidlist. This is probably better
4705 # than dropping the cached one when --avoid is specified at least once.
4706 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4707 avoidlist=`echo $avoidlist`
4709 # The sourcebase defaults to the cached one.
4710 if test -z "$sourcebase"; then
4711 sourcebase="$cached_sourcebase"
4712 if test -z "$sourcebase"; then
4713 func_fatal_error "missing --source-base option"
4716 # The pobase defaults to the cached one.
4717 if test -z "$pobase"; then
4718 pobase="$cached_pobase"
4720 # The docbase defaults to the cached one.
4721 if test -z "$docbase"; then
4722 docbase="$cached_docbase"
4723 if test -z "$docbase"; then
4724 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."
4727 # The testsbase defaults to the cached one.
4728 if test -z "$testsbase"; then
4729 testsbase="$cached_testsbase"
4730 if test -z "$testsbase"; then
4731 func_fatal_error "missing --tests-base option"
4734 # Require the tests if specified either way.
4735 if ! $inctests; then
4736 inctests="$cached_inctests"
4737 if test -z "$inctests"; then
4738 inctests=false
4741 # The libname defaults to the cached one.
4742 if test -z "$supplied_libname"; then
4743 libname="$cached_libname"
4744 if test -z "$libname"; then
4745 func_fatal_error "missing --lib option"
4748 # Require LGPL if specified either way.
4749 if test -z "$lgpl"; then
4750 lgpl="$cached_lgpl"
4752 # The makefile_name defaults to the cached one.
4753 if test -z "$makefile_name"; then
4754 makefile_name="$cached_makefile_name"
4756 # Use conditional dependencies if specified either way.
4757 if test -z "$cond_dependencies"; then
4758 cond_dependencies="$cached_cond_dependencies"
4760 # Use libtool if specified either way, or if guessed.
4761 if test -z "$libtool"; then
4762 if test -n "$cached_m4base"; then
4763 libtool="$cached_libtool"
4764 else
4765 libtool="$guessed_libtool"
4768 # The macro_prefix defaults to the cached one.
4769 if test -z "$macro_prefix"; then
4770 macro_prefix="$cached_macro_prefix"
4771 if test -z "$macro_prefix"; then
4772 func_fatal_error "missing --macro-prefix option"
4775 # The po_domain defaults to the cached one.
4776 if test -z "$po_domain"; then
4777 po_domain="$cached_po_domain"
4779 # The witness_c_macro defaults to the cached one.
4780 if test -z "$witness_c_macro"; then
4781 witness_c_macro="$cached_witness_c_macro"
4783 # The vc_files defaults to the cached one.
4784 if test -z "$vc_files"; then
4785 vc_files="$cached_vc_files"
4787 # Ensure constraints.
4788 if test "$cond_dependencies" = true && $inctests; then
4789 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4790 func_exit 1
4793 # --without-*-tests options are not supported here.
4794 excl_cxx_tests=
4795 excl_longrunning_tests=
4796 excl_privileged_tests=
4797 excl_unportable_tests=
4799 # Canonicalize the list of specified modules.
4800 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4802 # Include all kinds of tests modules if --with-all-tests was specified.
4803 inc_all_direct_tests="$inc_all_tests"
4804 inc_all_indirect_tests="$inc_all_tests"
4806 # Determine final module list.
4807 modules="$specified_modules"
4808 func_modules_transitive_closure
4809 if test $verbose -ge 0; then
4810 func_show_module_list
4812 final_modules="$modules"
4814 # Determine main module list and tests-related module list separately.
4815 func_modules_transitive_closure_separately
4817 # Determine whether a $testsbase/libtests.a is needed.
4818 func_determine_use_libtests
4820 # Add the dummy module to the main module list or to the tests-related module
4821 # list if needed.
4822 func_modules_add_dummy_separately
4824 # If --lgpl, verify that the licenses of modules are compatible.
4825 if test -n "$lgpl"; then
4826 license_incompatibilities=
4827 for module in $main_modules; do
4828 license=`func_get_license $module`
4829 case $license in
4830 'GPLed build tool') ;;
4831 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4833 case "$lgpl" in
4834 yes | 3)
4835 case $license in
4836 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
4837 *) func_append license_incompatibilities "$module $license$nl" ;;
4838 esac
4840 3orGPLv2)
4841 case $license in
4842 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
4843 *) func_append license_incompatibilities "$module $license$nl" ;;
4844 esac
4847 case $license in
4848 LGPLv2+) ;;
4849 *) func_append license_incompatibilities "$module $license$nl" ;;
4850 esac
4852 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4853 esac
4855 esac
4856 done
4857 if test -n "$license_incompatibilities"; then
4858 # Format the license incompatibilities as a table.
4859 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4860 s,^\(.................................................[^ ]*\) *, \1 ,'
4861 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4862 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4866 # Show banner notice of every module.
4867 modules="$main_modules"
4868 func_modules_notice
4870 # Determine script to apply to imported library files.
4871 sed_transform_lib_file=
4872 for module in $main_modules; do
4873 if test $module = config-h; then
4874 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4875 sed_transform_lib_file=$sed_transform_lib_file'
4876 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4878 break
4880 done
4881 sed_transform_main_lib_file="$sed_transform_lib_file"
4882 if test -n "$do_copyrights"; then
4883 if test -n "$lgpl"; then
4884 # Update license.
4885 case "$lgpl" in
4886 yes | 3)
4887 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4888 s/GNU General/GNU Lesser General/g
4889 s/General Public License/Lesser General Public License/g
4890 s/Lesser Lesser General Public License/Lesser General Public License/g
4893 3orGPLv2)
4894 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4895 /^ *This program is free software/i\
4896 This program is free software: you can redistribute it and\/or\
4897 modify it under the terms of either:\
4899 * the GNU Lesser General Public License as published by the Free\
4900 Software Foundation; either version 3 of the License, or (at your\
4901 option) any later version.\
4905 * the GNU General Public License as published by the Free\
4906 Software Foundation; either version 2 of the License, or (at your\
4907 option) any later version.\
4909 or both in parallel, as here.
4910 /^ *This program is free software/,/^$/d
4914 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4915 s/GNU General/GNU Lesser General/g
4916 s/General Public License/Lesser General Public License/g
4917 s/Lesser Lesser General Public License/Lesser General Public License/g
4919 s/version [23]\([ ,]\)/version 2.1\1/g
4922 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4923 esac
4924 else
4925 # Update license.
4926 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4927 s/GNU Lesser General/GNU General/g
4928 s/Lesser General Public License/General Public License/g
4930 s/GNU Library General/GNU General/g
4931 s/Library General Public License/General Public License/g
4933 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4938 # Determine script to apply to auxiliary files that go into $auxdir/.
4939 sed_transform_build_aux_file=
4940 if test -n "$do_copyrights"; then
4941 # Update license.
4942 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4943 s/GNU Lesser General/GNU General/g
4944 s/Lesser General Public License/General Public License/g
4946 s/GNU Library General/GNU General/g
4947 s/Library General Public License/General Public License/g
4949 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4953 # Determine script to apply to library files that go into $testsbase/.
4954 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4955 if test -n "$do_copyrights"; then
4956 # Update license.
4957 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4958 s/GNU Lesser General/GNU General/g
4959 s/Lesser General Public License/General Public License/g
4961 s/GNU Library General/GNU General/g
4962 s/Library General Public License/General Public License/g
4964 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4968 # Determine the final file lists.
4969 func_modules_to_filelist_separately
4971 test -n "$files" \
4972 || func_fatal_error "refusing to do nothing"
4974 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4975 new_files="$files m4/gnulib-tool.m4"
4976 old_files="$cached_files"
4977 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4978 func_append old_files " m4/gnulib-tool.m4"
4981 rewritten='%REWRITTEN%'
4982 sed_rewrite_old_files="\
4983 s,^build-aux/,$rewritten$auxdir/,
4984 s,^doc/,$rewritten$cached_docbase/,
4985 s,^lib/,$rewritten$cached_sourcebase/,
4986 s,^m4/,$rewritten$cached_m4base/,
4987 s,^tests/,$rewritten$cached_testsbase/,
4988 s,^tests=lib/,$rewritten$cached_testsbase/,
4989 s,^top/,$rewritten,
4990 s,^$rewritten,,"
4991 sed_rewrite_new_files="\
4992 s,^build-aux/,$rewritten$auxdir/,
4993 s,^doc/,$rewritten$docbase/,
4994 s,^lib/,$rewritten$sourcebase/,
4995 s,^m4/,$rewritten$m4base/,
4996 s,^tests/,$rewritten$testsbase/,
4997 s,^tests=lib/,$rewritten$testsbase/,
4998 s,^top/,$rewritten,
4999 s,^$rewritten,,"
5001 # Create directories.
5002 { echo "$sourcebase"
5003 echo "$m4base"
5004 if test -n "$pobase"; then
5005 echo "$pobase"
5007 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
5008 if test -n "$docfiles"; then
5009 echo "$docbase"
5011 if $inctests; then
5012 echo "$testsbase"
5014 echo "$auxdir"
5015 for f in $files; do echo $f; done \
5016 | sed -e "$sed_rewrite_new_files" \
5017 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5018 | LC_ALL=C sort -u
5019 } > "$tmp"/dirs
5020 { # Rearrange file descriptors. Needed because "while ... done < ..."
5021 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5022 exec 5<&0 < "$tmp"/dirs
5023 while read d; do
5024 if test ! -d "$destdir/$d"; then
5025 if $doit; then
5026 echo "Creating directory $destdir/$d"
5027 mkdir -p "$destdir/$d" || func_fatal_error "failed"
5028 else
5029 echo "Create directory $destdir/$d"
5032 done
5033 exec 0<&5 5<&-
5036 # Copy files or make symbolic links or hard links. Remove obsolete files.
5037 added_files=''
5038 removed_files=''
5039 delimiter=' '
5040 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5041 # representing the files according to the last gnulib-tool invocation.
5042 for f in $old_files; do echo $f; done \
5043 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
5044 | LC_ALL=C sort \
5045 > "$tmp"/old-files
5046 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5047 # representing the files after this gnulib-tool invocation.
5048 for f in $new_files; do echo $f; done \
5049 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
5050 | LC_ALL=C sort \
5051 > "$tmp"/new-files
5052 # First the files that are in old-files, but not in new-files:
5053 sed_take_first_column='s,'"$delimiter"'.*,,'
5054 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
5055 # Remove the file. Do nothing if the user already removed it.
5056 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
5057 if $doit; then
5058 echo "Removing file $g (backup in ${g}~)"
5059 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
5060 else
5061 echo "Remove file $g (backup in ${g}~)"
5063 func_append removed_files "$g$nl"
5065 done
5066 # func_add_or_update handles a file that ought to be present afterwards.
5067 # Uses parameters
5068 # - f the original file name
5069 # - g the rewritten file name
5070 # - already_present nonempty if the file should already exist, empty
5071 # otherwise
5072 func_add_or_update ()
5074 of="$f"
5075 case "$f" in
5076 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5077 esac
5078 func_dest_tmpfilename "$g"
5079 func_lookup_file "$f"
5080 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5081 case "$f" in
5082 *.class | *.mo )
5083 # Don't process binary files with sed.
5086 if test -n "$sed_transform_main_lib_file"; then
5087 case "$of" in
5088 lib/*)
5089 sed -e "$sed_transform_main_lib_file" \
5090 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5092 esac
5094 if test -n "$sed_transform_build_aux_file"; then
5095 case "$of" in
5096 build-aux/*)
5097 sed -e "$sed_transform_build_aux_file" \
5098 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5100 esac
5102 if test -n "$sed_transform_testsrelated_lib_file"; then
5103 case "$of" in
5104 tests=lib/*)
5105 sed -e "$sed_transform_testsrelated_lib_file" \
5106 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5108 esac
5111 esac
5112 if test -f "$destdir/$g"; then
5113 # The file already exists.
5114 func_update_file
5115 else
5116 # Install the file.
5117 # Don't protest if the file should be there but isn't: it happens
5118 # frequently that developers don't put autogenerated files under version control.
5119 func_add_file
5120 func_append added_files "$g$nl"
5122 rm -f "$tmpfile"
5124 # Then the files that are in new-files, but not in old-files:
5125 sed_take_last_column='s,^.*'"$delimiter"',,'
5126 already_present=
5127 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
5128 | sed -e "$sed_take_last_column" \
5129 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
5130 { # Rearrange file descriptors. Needed because "while ... done < ..."
5131 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5132 exec 5<&0 < "$tmp"/added-files
5133 while read g f; do
5134 func_add_or_update
5135 done
5136 exec 0<&5 5<&-
5138 # Then the files that are in new-files and in old-files:
5139 already_present=true
5140 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
5141 | sed -e "$sed_take_last_column" \
5142 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
5143 { # Rearrange file descriptors. Needed because "while ... done < ..."
5144 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5145 exec 5<&0 < "$tmp"/kept-files
5146 while read g f; do
5147 func_add_or_update
5148 done
5149 exec 0<&5 5<&-
5152 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
5153 actioncmd="# gnulib-tool --import"
5155 # Local helper.
5156 func_append_local_dir ()
5158 func_append "$1" " --local-dir=$2"
5160 func_path_foreach "$local_gnulib_path" func_append_local_dir actioncmd %dir%
5162 # Break the action command log into multiple lines.
5163 # Emacs puts some gnulib-tool log lines in its source repository, and
5164 # git send-email rejects patch lines longer than 998 characters.
5165 # Also, config.status uses awk, and the HP-UX 11.00 awk fails if a
5166 # line has length >= 3071; similarly, the IRIX 6.5 awk fails if a
5167 # line has length >= 3072.
5168 func_append_actionarg ()
5170 func_append actioncmd " \\$nl# $1"
5172 func_append_actionarg "--lib=$libname"
5173 func_append_actionarg "--source-base=$sourcebase"
5174 func_append_actionarg "--m4-base=$m4base"
5175 if test -n "$pobase"; then
5176 func_append_actionarg "--po-base=$pobase"
5178 func_append_actionarg "--doc-base=$docbase"
5179 func_append_actionarg "--tests-base=$testsbase"
5180 func_append_actionarg "--aux-dir=$auxdir"
5181 if $inctests; then
5182 func_append_actionarg "--with-tests"
5184 if test -n "$incobsolete"; then
5185 func_append_actionarg "--with-obsolete"
5187 if test -n "$inc_cxx_tests"; then
5188 func_append_actionarg "--with-c++-tests"
5190 if test -n "$inc_longrunning_tests"; then
5191 func_append_actionarg "--with-longrunning-tests"
5193 if test -n "$inc_privileged_tests"; then
5194 func_append_actionarg "--with-privileged-tests"
5196 if test -n "$inc_unportable_tests"; then
5197 func_append_actionarg "--with-unportable-tests"
5199 if test -n "$inc_all_tests"; then
5200 func_append_actionarg "--with-all-tests"
5202 if test -n "$lgpl"; then
5203 if test "$lgpl" = yes; then
5204 func_append_actionarg "--lgpl"
5205 else
5206 func_append_actionarg "--lgpl=$lgpl"
5209 if $gnu_make; then
5210 func_append_actionarg "--gnu-make"
5212 if test -n "$makefile_name"; then
5213 func_append_actionarg "--makefile-name=$makefile_name"
5215 if test "$cond_dependencies" = true; then
5216 func_append_actionarg "--conditional-dependencies"
5217 else
5218 func_append_actionarg "--no-conditional-dependencies"
5220 if test "$libtool" = true; then
5221 func_append_actionarg "--libtool"
5222 else
5223 func_append_actionarg "--no-libtool"
5225 func_append_actionarg "--macro-prefix=$macro_prefix"
5226 if test -n "$po_domain"; then
5227 func_append_actionarg "--po-domain=$po_domain"
5229 if test -n "$witness_c_macro"; then
5230 func_append_actionarg "--witness-c-macro=$witness_c_macro"
5232 if test -n "$vc_files"; then
5233 if test "$vc_files" = true; then
5234 func_append_actionarg "--vc-files"
5235 else
5236 func_append_actionarg "--no-vc-files"
5239 for module in $avoidlist; do
5240 func_append_actionarg "--avoid=$module"
5241 done
5242 for module in $specified_modules; do
5243 func_append_actionarg "$module"
5244 done
5246 # Determine include_guard_prefix.
5247 func_compute_include_guard_prefix
5249 # Default the makefile name to Makefile.am.
5250 if test -n "$makefile_name"; then
5251 makefile_am=$makefile_name
5252 else
5253 makefile_am=Makefile.am
5256 # Create normal Makefile.ams.
5257 for_test=false
5259 # Setup list of Makefile.am edits that are to be performed afterwards.
5260 # Some of these edits apply to files that we will generate; others are
5261 # under the responsibility of the developer.
5262 makefile_am_edits=0
5263 # func_note_Makefile_am_edit dir var value [dotfirst]
5264 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
5265 # ${value}.
5266 # If ${dotfirst} is non-empty, this mention needs to be present after '.'.
5267 # This is a special hack for the SUBDIRS variable, cf.
5268 # <https://www.gnu.org/software/automake/manual/html_node/Subdirectories.html>.
5269 func_note_Makefile_am_edit ()
5271 makefile_am_edits=`expr $makefile_am_edits + 1`
5272 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
5273 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
5274 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
5275 eval makefile_am_edit${makefile_am_edits}_dotfirst=\"\$4\"
5277 if test "$makefile_am" = Makefile.am; then
5278 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
5279 sourcebase_base=`basename "$sourcebase"`
5280 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
5282 if test -n "$pobase"; then
5283 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
5284 pobase_base=`basename "$pobase"`
5285 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
5287 if $inctests; then
5288 if test "$makefile_am" = Makefile.am; then
5289 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
5290 testsbase_base=`basename "$testsbase"`
5291 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base" true
5294 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
5296 # Find the first parent directory of $m4base that contains or will contain
5297 # a Makefile.am.
5298 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
5299 s,//*$,/,'
5300 sed_butlast='s,[^/][^/]*//*$,,'
5301 dir1="${m4base}/"; dir2=""
5302 while test -n "$dir1" \
5303 && ! { test -f "${destdir}/${dir1}Makefile.am" \
5304 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5305 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5306 || { $inctests \
5307 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
5308 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
5309 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
5310 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
5311 done
5312 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
5315 # Create library makefile.
5316 func_dest_tmpfilename $sourcebase/$makefile_am
5317 destfile="$sourcebase/$makefile_am"
5318 modules="$main_modules"
5319 func_emit_lib_Makefile_am > "$tmpfile"
5320 if test -f "$destdir"/$sourcebase/$makefile_am; then
5321 if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
5322 rm -f "$tmpfile"
5323 else
5324 if $doit; then
5325 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5326 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
5327 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5328 else
5329 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5330 rm -f "$tmpfile"
5333 else
5334 if $doit; then
5335 echo "Creating $sourcebase/$makefile_am"
5336 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5337 else
5338 echo "Create $sourcebase/$makefile_am"
5339 rm -f "$tmpfile"
5341 func_append added_files "$sourcebase/$makefile_am$nl"
5344 # Create po/ directory.
5345 if test -n "$pobase"; then
5346 # Create po makefile and auxiliary files.
5347 for file in Makefile.in.in remove-potcdate.sin; do
5348 func_dest_tmpfilename $pobase/$file
5349 func_lookup_file build-aux/po/$file
5350 cat "$lookedup_file" > "$tmpfile"
5351 if test -f "$destdir"/$pobase/$file; then
5352 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
5353 rm -f "$tmpfile"
5354 else
5355 if $doit; then
5356 echo "Updating $pobase/$file (backup in $pobase/$file~)"
5357 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
5358 mv -f "$tmpfile" "$destdir"/$pobase/$file
5359 else
5360 echo "Update $pobase/$file (backup in $pobase/$file~)"
5361 rm -f "$tmpfile"
5364 else
5365 if $doit; then
5366 echo "Creating $pobase/$file"
5367 mv -f "$tmpfile" "$destdir"/$pobase/$file
5368 else
5369 echo "Create $pobase/$file"
5370 rm -f "$tmpfile"
5372 func_append added_files "$pobase/$file$nl"
5374 done
5375 # Create po makefile parameterization, part 1.
5376 func_dest_tmpfilename $pobase/Makevars
5377 func_emit_po_Makevars > "$tmpfile"
5378 if test -f "$destdir"/$pobase/Makevars; then
5379 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
5380 rm -f "$tmpfile"
5381 else
5382 if $doit; then
5383 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
5384 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
5385 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5386 else
5387 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
5388 rm -f "$tmpfile"
5391 else
5392 if $doit; then
5393 echo "Creating $pobase/Makevars"
5394 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5395 else
5396 echo "Create $pobase/Makevars"
5397 rm -f "$tmpfile"
5399 func_append added_files "$pobase/Makevars$nl"
5401 # Create po makefile parameterization, part 2.
5402 func_dest_tmpfilename $pobase/POTFILES.in
5403 func_emit_po_POTFILES_in > "$tmpfile"
5404 if test -f "$destdir"/$pobase/POTFILES.in; then
5405 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5406 rm -f "$tmpfile"
5407 else
5408 if $doit; then
5409 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5410 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5411 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5412 else
5413 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5414 rm -f "$tmpfile"
5417 else
5418 if $doit; then
5419 echo "Creating $pobase/POTFILES.in"
5420 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5421 else
5422 echo "Create $pobase/POTFILES.in"
5423 rm -f "$tmpfile"
5425 func_append added_files "$pobase/POTFILES.in$nl"
5427 # Fetch PO files.
5428 TP_URL="https://translationproject.org/latest/"
5429 if $doit; then
5430 echo "Fetching gnulib PO files from $TP_URL"
5431 (cd "$destdir"/$pobase \
5432 && wget --no-verbose --mirror --level=1 -nd -A.po -P . "${TP_URL}gnulib/"
5434 else
5435 echo "Fetch gnulib PO files from $TP_URL"
5437 # Create po/LINGUAS.
5438 if $doit; then
5439 func_dest_tmpfilename $pobase/LINGUAS
5440 (cd "$destdir"/$pobase \
5441 && { echo '# Set of available languages.'
5442 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5444 ) > "$tmpfile"
5445 if test -f "$destdir"/$pobase/LINGUAS; then
5446 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5447 rm -f "$tmpfile"
5448 else
5449 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5450 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5451 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5453 else
5454 echo "Creating $pobase/LINGUAS"
5455 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5456 func_append added_files "$pobase/LINGUAS$nl"
5458 else
5459 if test -f "$destdir"/$pobase/LINGUAS; then
5460 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5461 else
5462 echo "Create $pobase/LINGUAS"
5467 # func_count_relative_local_gnulib_path
5468 # gl_LOCAL_DIR requires local_gnulib_path to be set relatively to destdir
5469 # Input:
5470 # - local_gnulib_path from --local-dir
5471 # - destdir from --dir
5472 # Output:
5473 # - relative_local_dir path to be stored into gl_LOCAL_DIR
5474 func_count_relative_local_gnulib_path ()
5476 save_IFS=$IFS
5477 IFS=$PATH_SEPARATOR
5478 relative_local_gnulib_path=
5479 for local_dir in $local_gnulib_path
5481 # Store the local_dir relative to destdir.
5482 case "$local_dir" in
5483 "" | /*)
5484 relative_local_dir="$local_dir" ;;
5486 case "$destdir" in
5487 /*) relative_local_dir="$local_dir" ;;
5489 # destdir, local_dir are both relative.
5490 func_relativize "$destdir" "$local_dir"
5491 relative_local_dir="$reldir" ;;
5492 esac ;;
5493 esac
5494 func_path_append relative_local_gnulib_path "$relative_local_dir"
5495 done
5496 IFS=$save_IFS
5499 # Create m4/gnulib-cache.m4.
5500 func_dest_tmpfilename $m4base/gnulib-cache.m4
5502 func_emit_copyright_notice
5503 echo "#"
5504 echo "# This file represents the specification of how gnulib-tool is used."
5505 echo "# It acts as a cache: It is written and read by gnulib-tool."
5506 echo "# In projects that use version control, this file is meant to be put under"
5507 echo "# version control, like the configure.ac and various Makefile.am files."
5508 echo
5509 echo
5510 echo "# Specification in the form of a command-line invocation:"
5511 printf '%s\n' "$actioncmd"
5512 echo
5513 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5514 func_count_relative_local_gnulib_path
5515 echo "gl_LOCAL_DIR([$relative_local_gnulib_path])"
5516 echo "gl_MODULES(["
5517 echo "$specified_modules" | sed -e 's/^/ /g'
5518 echo "])"
5519 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5520 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5521 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5522 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5523 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5524 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5525 echo "gl_AVOID([$avoidlist])"
5526 echo "gl_SOURCE_BASE([$sourcebase])"
5527 echo "gl_M4_BASE([$m4base])"
5528 echo "gl_PO_BASE([$pobase])"
5529 echo "gl_DOC_BASE([$docbase])"
5530 echo "gl_TESTS_BASE([$testsbase])"
5531 if $inctests; then
5532 echo "gl_WITH_TESTS"
5534 echo "gl_LIB([$libname])"
5535 if test -n "$lgpl"; then
5536 if test "$lgpl" = yes; then
5537 echo "gl_LGPL"
5538 else
5539 echo "gl_LGPL([$lgpl])"
5542 echo "gl_MAKEFILE_NAME([$makefile_name])"
5543 if test "$cond_dependencies" = true; then
5544 echo "gl_CONDITIONAL_DEPENDENCIES"
5546 if test "$libtool" = true; then
5547 echo "gl_LIBTOOL"
5549 echo "gl_MACRO_PREFIX([$macro_prefix])"
5550 echo "gl_PO_DOMAIN([$po_domain])"
5551 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5552 if test -n "$vc_files"; then
5553 echo "gl_VC_FILES([$vc_files])"
5555 ) > "$tmpfile"
5556 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5557 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
5558 rm -f "$tmpfile"
5559 else
5560 if $doit; then
5561 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5562 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5563 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5564 else
5565 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5566 if false; then
5567 cat "$tmpfile"
5568 echo
5569 echo "# gnulib-cache.m4 ends here"
5571 rm -f "$tmpfile"
5574 else
5575 if $doit; then
5576 echo "Creating $m4base/gnulib-cache.m4"
5577 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5578 else
5579 echo "Create $m4base/gnulib-cache.m4"
5580 cat "$tmpfile"
5581 rm -f "$tmpfile"
5585 # Create m4/gnulib-comp.m4.
5586 func_dest_tmpfilename $m4base/gnulib-comp.m4
5588 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5589 func_emit_copyright_notice
5590 echo "#"
5591 echo "# This file represents the compiled summary of the specification in"
5592 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5593 echo "# to be invoked from configure.ac."
5594 echo "# In projects that use version control, this file can be treated like"
5595 echo "# other built files."
5596 echo
5597 echo
5598 echo "# This macro should be invoked from $configure_ac, in the section"
5599 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5600 echo "# any checks for libraries, header files, types and library functions."
5601 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5602 echo "["
5603 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5604 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5605 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5606 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5608 func_emit_pre_early_macros : ' ' "$final_modules"
5610 if ! $gnu_make && test -n "$uses_subdirs"; then
5611 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5613 for module in $final_modules; do
5614 func_verify_module
5615 if test -n "$module"; then
5616 echo "# Code from module $module:"
5617 func_get_autoconf_early_snippet "$module"
5619 done \
5620 | sed -e '/^$/d;' -e 's/^/ /'
5621 echo "])"
5622 echo
5623 echo "# This macro should be invoked from $configure_ac, in the section"
5624 echo "# \"Check for header files, types and library functions\"."
5625 echo "AC_DEFUN([${macro_prefix}_INIT],"
5626 echo "["
5627 if test "$libtool" = true; then
5628 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5629 echo " gl_cond_libtool=true"
5630 else
5631 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5632 echo " gl_cond_libtool=false"
5633 echo " gl_libdeps="
5634 echo " gl_ltlibdeps="
5636 if test "$auxdir" != "build-aux"; then
5637 sed_replace_build_aux='
5639 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5640 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5643 else
5644 sed_replace_build_aux="$sed_noop"
5646 echo " gl_m4_base='$m4base'"
5647 func_emit_initmacro_start $macro_prefix
5648 echo " gl_source_base='$sourcebase'"
5649 if test -n "$witness_c_macro"; then
5650 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5652 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false true
5653 if test -n "$witness_c_macro"; then
5654 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5656 echo " # End of code from modules"
5657 func_emit_initmacro_end $macro_prefix
5658 echo " gltests_libdeps="
5659 echo " gltests_ltlibdeps="
5660 func_emit_initmacro_start ${macro_prefix}tests
5661 echo " gl_source_base='$testsbase'"
5662 # Define a tests witness macro that depends on the package.
5663 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5664 # See <https://lists.gnu.org/r/automake/2009-05/msg00145.html>.
5665 echo "changequote(,)dnl"
5666 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"
5667 echo "changequote([, ])dnl"
5668 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5669 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5670 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5671 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true true true
5672 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5673 func_emit_initmacro_end ${macro_prefix}tests
5674 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5675 # created using libtool, because libtool already handles the dependencies.
5676 if test "$libtool" != true; then
5677 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5678 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5679 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5680 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5681 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5683 if $use_libtests; then
5684 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5685 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5687 echo "])"
5688 func_emit_initmacro_done $macro_prefix $sourcebase
5689 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5690 echo
5691 echo "# This macro records the list of files which have been installed by"
5692 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5693 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5694 echo "$files" | sed -e 's,^, ,'
5695 echo "])"
5696 ) > "$tmpfile"
5697 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5698 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
5699 rm -f "$tmpfile"
5700 else
5701 if $doit; then
5702 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5703 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5704 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5705 else
5706 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5707 if false; then
5708 cat "$tmpfile"
5709 echo
5710 echo "# gnulib-comp.m4 ends here"
5712 rm -f "$tmpfile"
5715 else
5716 if $doit; then
5717 echo "Creating $m4base/gnulib-comp.m4"
5718 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5719 else
5720 echo "Create $m4base/gnulib-comp.m4"
5721 cat "$tmpfile"
5722 rm -f "$tmpfile"
5726 if $inctests; then
5727 # Create tests makefile.
5728 func_dest_tmpfilename $testsbase/$makefile_am
5729 destfile="$testsbase/$makefile_am"
5730 modules="$testsrelated_modules"
5731 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5732 if test -f "$destdir"/$testsbase/$makefile_am; then
5733 if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
5734 rm -f "$tmpfile"
5735 else
5736 if $doit; then
5737 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5738 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5739 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5740 else
5741 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5742 rm -f "$tmpfile"
5745 else
5746 if $doit; then
5747 echo "Creating $testsbase/$makefile_am"
5748 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5749 else
5750 echo "Create $testsbase/$makefile_am"
5751 rm -f "$tmpfile"
5753 func_append added_files "$testsbase/$makefile_am$nl"
5757 if test "$vc_files" != false; then
5758 # Update the .cvsignore and .gitignore files.
5759 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5760 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5761 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5762 echo "$m4base/|A|gnulib-comp.m4"
5763 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5764 { # Rearrange file descriptors. Needed because "while ... done < ..."
5765 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5766 exec 5<&0 < "$tmp"/fileset-changes
5767 func_update_ignorelist ()
5769 ignore="$1"
5770 if test "$ignore" = .gitignore; then
5771 # In a .gitignore file, "foo" applies to the current directory and all
5772 # subdirectories, whereas "/foo" applies to the current directory only.
5773 anchor='/'
5774 escaped_anchor='\/'
5775 doubly_escaped_anchor='\\/'
5776 else
5777 anchor=''
5778 escaped_anchor=''
5779 doubly_escaped_anchor=''
5781 if test -f "$destdir/$dir$ignore"; then
5782 if test -n "$dir_added" || test -n "$dir_removed"; then
5783 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5784 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5785 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5786 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5787 > "$tmp"/ignore-removed
5789 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5790 if $doit; then
5791 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5792 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5793 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5794 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5795 } > "$tmp"/sed-ignore-removed
5796 { cat "$destdir/$dir$ignore"~
5797 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5798 } | sed -f "$tmp"/sed-ignore-removed \
5799 > "$destdir/$dir$ignore"
5800 else
5801 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5805 else
5806 if test -n "$dir_added"; then
5807 if $doit; then
5808 echo "Creating $destdir/$dir$ignore"
5810 if test "$ignore" = .cvsignore; then
5811 echo ".deps"
5812 # Automake generates Makefile rules that create .dirstamp files.
5813 echo ".dirstamp"
5815 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5816 } > "$destdir/$dir$ignore"
5817 else
5818 echo "Create $destdir/$dir$ignore"
5823 func_done_dir ()
5825 dir="$1"
5826 dir_added="$2"
5827 dir_removed="$3"
5828 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5829 func_update_ignorelist .cvsignore
5831 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5832 func_update_ignorelist .gitignore
5835 last_dir=
5836 last_dir_added=
5837 last_dir_removed=
5838 while read line; do
5839 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5840 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5841 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5842 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5843 if test "$next_dir" != "$last_dir"; then
5844 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5845 last_dir="$next_dir"
5846 last_dir_added=
5847 last_dir_removed=
5849 case $op in
5850 A) func_append last_dir_added "$file$nl";;
5851 R) func_append last_dir_removed "$file$nl";;
5852 esac
5853 done
5854 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5855 exec 0<&5 5<&-
5859 echo "Finished."
5860 echo
5861 echo "You may need to add #include directives for the following .h files."
5862 # Intersect $specified_modules and $main_modules
5863 # (since $specified_modules is not necessarily of subset of $main_modules
5864 # - some may have been skipped through --avoid, and since the elements of
5865 # $main_modules but not in $specified_modules can go away without explicit
5866 # notice - through changes in the module dependencies).
5867 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5868 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5869 # First the #include <...> directives without #ifs, sorted for convenience,
5870 # then the #include "..." directives without #ifs, sorted for convenience,
5871 # then the #include directives that are surrounded by #ifs. Not sorted.
5872 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5873 include_directive=`func_get_include_directive "$module"`
5874 case "$nl$include_directive" in
5875 *"$nl#if"*)
5876 echo "$include_directive" 1>&5
5879 echo "$include_directive" | grep -v 'include "' 1>&6
5880 echo "$include_directive" | grep 'include "' 1>&7
5882 esac
5883 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5885 LC_ALL=C sort -u "$tmp"/include-angles
5886 LC_ALL=C sort -u "$tmp"/include-quotes
5887 cat "$tmp"/include-if
5888 ) | sed -e '/^$/d' -e 's/^/ /'
5889 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5891 for module in $main_modules; do
5892 func_get_link_directive "$module"
5893 done \
5894 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5895 if test `wc -l < "$tmp"/link` != 0; then
5896 echo
5897 echo "You may need to use the following Makefile variables when linking."
5898 echo "Use them in <program>_LDADD when linking a program, or"
5899 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5900 cat "$tmp"/link
5902 rm -f "$tmp"/link
5904 echo
5905 echo "Don't forget to"
5906 if test "$makefile_am" = Makefile.am; then
5907 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5908 else
5909 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5911 if test -n "$pobase"; then
5912 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5914 if $inctests; then
5915 if test "$makefile_am" = Makefile.am; then
5916 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5917 else
5918 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5921 edit=0
5922 while test $edit != $makefile_am_edits; do
5923 edit=`expr $edit + 1`
5924 eval dir=\"\$makefile_am_edit${edit}_dir\"
5925 eval var=\"\$makefile_am_edit${edit}_var\"
5926 eval val=\"\$makefile_am_edit${edit}_val\"
5927 if test -n "$var"; then
5928 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5930 done
5931 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
5932 position_early_after=AC_PROG_CC_STDC
5933 else
5934 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
5935 position_early_after=AC_PROG_CC_C99
5936 else
5937 position_early_after=AC_PROG_CC
5940 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
5941 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5944 # func_create_testdir testdir modules
5945 # Input:
5946 # - local_gnulib_path from --local-dir
5947 # - modcache true or false, from --cache-modules/--no-cache-modules
5948 # - auxdir directory relative to destdir where to place build aux files
5949 # - inctests true if tests should be included, false otherwise
5950 # - incobsolete true if obsolete modules among dependencies should be
5951 # included, blank otherwise
5952 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5953 # blank otherwise
5954 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5955 # blank otherwise
5956 # - excl_privileged_tests true if tests that require root privileges should be
5957 # excluded, blank otherwise
5958 # - excl_unportable_tests true if tests that fail on some platforms should be
5959 # excluded, blank otherwise
5960 # - single_configure true if a single configure file should be generated,
5961 # false for a separate configure file for the tests
5962 # - avoidlist list of modules to avoid
5963 # - cond_dependencies true if --conditional-dependencies was given, false if
5964 # --no-conditional-dependencies was given, blank otherwise
5965 # - libtool true if --libtool was given, false if --no-libtool was
5966 # given, blank otherwise
5967 # - copymode copy mode for files in general
5968 # - lcopymode copy mode for files from local_gnulib_path
5969 func_create_testdir ()
5971 testdir="$1"
5972 modules="$2"
5973 if test -z "$modules"; then
5974 # All modules together.
5975 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5976 # Except non-recursive-gnulib-prefix-hack, which represents a nonstandard
5977 # way of using Automake.
5978 # Except timevar, which lacks the required file timevar.def.
5979 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5980 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5981 modules=`func_all_modules`
5982 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`
5984 specified_modules="$modules"
5986 # Canonicalize the list of specified modules.
5987 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5989 # Test modules which invoke AC_CONFIG_FILES cannot be used with
5990 # --with-tests --single-configure. Avoid them.
5991 if $inctests && $single_configure; then
5992 avoidlist="$avoidlist havelib-tests"
5995 # Unlike in func_import, here we want to include all kinds of tests for the
5996 # directly specified modules, but not for dependencies.
5997 inc_all_direct_tests=true
5998 inc_all_indirect_tests="$inc_all_tests"
6000 # Check that the license of every module is consistent with the license of
6001 # its dependencies.
6002 saved_inctests="$inctests"
6003 # When computing transitive closures, don't consider $module to depend on
6004 # $module-tests. Need this because tests are implicitly GPL and may depend
6005 # on GPL modules - therefore we don't want a warning in this case.
6006 inctests=false
6007 for requested_module in $specified_modules; do
6008 requested_license=`func_get_license "$requested_module"`
6009 if test "$requested_license" != GPL; then
6010 # Here we use func_modules_transitive_closure, not just
6011 # func_get_dependencies, so that we also detect weird situations like
6012 # an LGPL module which depends on a GPLed build tool module which depends
6013 # on a GPL module.
6014 modules="$requested_module"
6015 func_modules_transitive_closure
6016 for module in $modules; do
6017 license=`func_get_license "$module"`
6018 case "$license" in
6019 'GPLed build tool') ;;
6020 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
6022 case "$requested_license" in
6023 GPLv3+ | GPL)
6024 case "$license" in
6025 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL | GPLv2+ | GPLv3+ | GPL) ;;
6026 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6027 esac
6029 GPLv2+)
6030 case "$license" in
6031 LGPLv2+ | 'LGPLv3+ or GPLv2' | GPLv2+) ;;
6032 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6033 esac
6035 LGPLv3+ | LGPL)
6036 case "$license" in
6037 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
6038 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6039 esac
6041 'LGPLv3+ or GPLv2')
6042 case "$license" in
6043 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
6044 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6045 esac
6047 LGPLv2+)
6048 case "$license" in
6049 LGPLv2+) ;;
6050 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6051 esac
6053 esac
6055 esac
6056 done
6058 done
6059 inctests="$saved_inctests"
6061 # Subdirectory names.
6062 sourcebase=gllib
6063 m4base=glm4
6064 pobase=
6065 docbase=gldoc
6066 testsbase=gltests
6067 macro_prefix=gl
6068 po_domain=
6069 witness_c_macro=
6070 vc_files=
6072 # Determine final module list.
6073 modules="$specified_modules"
6074 func_modules_transitive_closure
6075 if test $verbose -ge 0; then
6076 func_show_module_list
6078 final_modules="$modules"
6080 if $single_configure; then
6081 # Determine main module list and tests-related module list separately.
6082 func_modules_transitive_closure_separately
6085 if $single_configure; then
6086 # Determine whether a $testsbase/libtests.a is needed.
6087 func_determine_use_libtests
6090 # Add the dummy module if needed.
6091 if $single_configure; then
6092 func_modules_add_dummy_separately
6093 else
6094 func_modules_add_dummy
6097 # Note:
6098 # If $single_configure, we use the module lists $main_modules and
6099 # $testsrelated_modules; $modules is merely a temporary variable.
6100 # Whereas if ! $configure, the module list is $modules.
6102 # Show banner notice of every module.
6103 if $single_configure; then
6104 modules="$main_modules"
6105 func_modules_notice
6106 else
6107 func_modules_notice
6110 # Determine final file list.
6111 if $single_configure; then
6112 func_modules_to_filelist_separately
6113 else
6114 func_modules_to_filelist
6115 if test $verbose -ge 0; then
6116 echo "File list:"
6117 echo "$files" | sed -e 's/^/ /'
6120 # Add files for which the copy in gnulib is newer than the one that
6121 # "automake --add-missing --copy" would provide.
6122 files="$files build-aux/config.guess"
6123 files="$files build-aux/config.sub"
6124 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
6126 rewritten='%REWRITTEN%'
6127 sed_rewrite_files="\
6128 s,^build-aux/,$rewritten$auxdir/,
6129 s,^doc/,$rewritten$docbase/,
6130 s,^lib/,$rewritten$sourcebase/,
6131 s,^m4/,$rewritten$m4base/,
6132 s,^tests/,$rewritten$testsbase/,
6133 s,^tests=lib/,$rewritten$testsbase/,
6134 s,^top/,$rewritten,
6135 s,^$rewritten,,"
6137 # Create directories.
6138 for f in $files; do echo $f; done \
6139 | sed -e "$sed_rewrite_files" \
6140 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
6141 | LC_ALL=C sort -u \
6142 > "$tmp"/dirs
6143 { # Rearrange file descriptors. Needed because "while ... done < ..."
6144 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6145 exec 5<&0 < "$tmp"/dirs
6146 while read d; do
6147 mkdir -p "$testdir/$d"
6148 done
6149 exec 0<&5 5<&-
6152 # Copy files or make symbolic links or hard links.
6153 delimiter=' '
6154 for f in $files; do echo $f; done \
6155 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
6156 | LC_ALL=C sort \
6157 > "$tmp"/files
6158 { # Rearrange file descriptors. Needed because "while ... done < ..."
6159 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6160 exec 5<&0 < "$tmp"/files
6161 while read g f; do
6162 case "$f" in
6163 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
6164 esac
6165 func_lookup_file "$f"
6166 if test -n "$lookedup_tmp"; then
6167 cp -p "$lookedup_file" "$testdir/$g"
6168 else
6169 func_should_link
6170 if test "$copyaction" = symlink; then
6171 func_symlink "$lookedup_file" "$testdir/$g"
6172 else
6173 if test "$copyaction" = hardlink; then
6174 func_hardlink "$lookedup_file" "$testdir/$g"
6175 else
6176 cp -p "$lookedup_file" "$testdir/$g"
6180 done
6181 exec 0<&5 5<&-
6184 # Determine include_guard_prefix.
6185 func_compute_include_guard_prefix
6187 # Create Makefile.ams that are for testing.
6188 for_test=true
6190 # No special edits are needed.
6191 makefile_am_edits=0
6193 # Create $sourcebase/Makefile.am.
6194 mkdir -p "$testdir/$sourcebase"
6195 destfile="$sourcebase/Makefile.am"
6196 if $single_configure; then
6197 modules="$main_modules"
6199 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
6200 any_uses_subdirs="$uses_subdirs"
6202 # Create $m4base/Makefile.am.
6203 mkdir -p "$testdir/$m4base"
6204 (echo "## Process this file with automake to produce Makefile.in."
6205 echo
6206 echo "EXTRA_DIST ="
6207 for f in $files; do
6208 case "$f" in
6209 m4/* )
6210 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
6211 esac
6212 done
6213 ) > "$testdir/$m4base/Makefile.am"
6215 subdirs="$sourcebase $m4base"
6216 subdirs_with_configure_ac=""
6218 if false && test -f "$testdir"/$m4base/gettext.m4; then
6219 # Avoid stupid error message from automake:
6220 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
6221 mkdir -p "$testdir/po"
6222 (echo "## Process this file with automake to produce Makefile.in."
6223 ) > "$testdir/po/Makefile.am"
6224 func_append subdirs " po"
6227 if $inctests; then
6228 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
6229 if $single_configure; then
6230 # Create $testsbase/Makefile.am.
6231 destfile="$testsbase/Makefile.am"
6232 modules="$testsrelated_modules"
6233 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
6234 else
6235 # Viewed from the $testsbase subdirectory, $auxdir is different.
6236 saved_auxdir="$auxdir"
6237 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
6238 # Create $testsbase/Makefile.am.
6239 use_libtests=false
6240 destfile="$testsbase/Makefile.am"
6241 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
6242 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
6243 # Create $testsbase/configure.ac.
6244 (echo "# Process this file with autoconf to produce a configure script."
6245 echo "AC_INIT([dummy], [0])"
6246 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6247 echo "AM_INIT_AUTOMAKE"
6248 echo
6249 echo "AC_CONFIG_HEADERS([config.h])"
6250 echo
6251 echo "AC_PROG_CC"
6252 echo "AC_PROG_INSTALL"
6253 echo "AC_PROG_MAKE_SET"
6255 func_emit_pre_early_macros false '' "$modules"
6257 if test -n "$uses_subdirs"; then
6258 echo "AM_PROG_CC_C_O"
6259 echo
6261 for module in $modules; do
6262 func_verify_module
6263 if test -n "$module"; then
6264 case $module in
6265 gnumakefile | maintainer-makefile)
6266 # These modules are meant to be used only in the top-level directory.
6269 func_get_autoconf_early_snippet "$module"
6271 esac
6273 done \
6274 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6275 if test "$libtool" = true; then
6276 echo "LT_INIT([win32-dll])"
6277 echo "LT_LANG([C++])"
6278 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6279 echo "gl_cond_libtool=true"
6280 else
6281 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6282 echo "gl_cond_libtool=false"
6283 echo "gl_libdeps="
6284 echo "gl_ltlibdeps="
6286 # Wrap the set of autoconf snippets into an autoconf macro that is then
6287 # invoked. This is needed because autoconf does not support AC_REQUIRE
6288 # at the top level:
6289 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6290 # but we want the AC_REQUIRE to have its normal meaning (provide one
6291 # expansion of the required macro before the current point, and only one
6292 # expansion total).
6293 echo "AC_DEFUN([gl_INIT], ["
6294 sed_replace_build_aux='
6296 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6297 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6300 echo "gl_m4_base='../$m4base'"
6301 func_emit_initmacro_start $macro_prefix
6302 # We don't have explicit ordering constraints between the various
6303 # autoconf snippets. It's cleanest to put those of the library before
6304 # those of the tests.
6305 echo "gl_source_base='../$sourcebase'"
6306 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module false false false
6307 echo "gl_source_base='.'"
6308 func_emit_autoconf_snippets "$modules" "$modules" func_verify_tests_module false false false
6309 func_emit_initmacro_end $macro_prefix
6310 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6311 # created using libtool, because libtool already handles the dependencies.
6312 if test "$libtool" != true; then
6313 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6314 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6315 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6316 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6317 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6319 echo "])"
6320 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
6321 echo
6322 echo "gl_INIT"
6323 echo
6324 # Usually $testsbase/config.h will be a superset of config.h. Verify this
6325 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
6326 echo "AH_TOP([#include \"../config.h\"])"
6327 echo
6328 echo "AC_CONFIG_FILES([Makefile])"
6329 echo "AC_OUTPUT"
6330 ) > "$testdir/$testsbase/configure.ac"
6331 auxdir="$saved_auxdir"
6332 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
6334 func_append subdirs " $testsbase"
6337 # Create Makefile.am.
6338 (echo "## Process this file with automake to produce Makefile.in."
6339 echo
6340 echo "AUTOMAKE_OPTIONS = 1.11 foreign"
6341 echo
6342 echo "SUBDIRS = $subdirs"
6343 echo
6344 echo "ACLOCAL_AMFLAGS = -I $m4base"
6345 ) > "$testdir/Makefile.am"
6347 # Create configure.ac.
6348 (echo "# Process this file with autoconf to produce a configure script."
6349 echo "AC_INIT([dummy], [0])"
6350 if test "$auxdir" != "."; then
6351 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6353 echo "AM_INIT_AUTOMAKE"
6354 echo
6355 echo "AC_CONFIG_HEADERS([config.h])"
6356 echo
6357 echo "AC_PROG_CC"
6358 echo "AC_PROG_INSTALL"
6359 echo "AC_PROG_MAKE_SET"
6360 echo
6361 echo "# For autobuild."
6362 echo "AC_CANONICAL_BUILD"
6363 echo "AC_CANONICAL_HOST"
6364 echo
6365 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
6366 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
6367 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6368 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6370 func_emit_pre_early_macros false '' "$final_modules"
6372 if test -n "$any_uses_subdirs"; then
6373 echo "AM_PROG_CC_C_O"
6374 echo
6376 for module in $final_modules; do
6377 if $single_configure; then
6378 func_verify_module
6379 else
6380 func_verify_nontests_module
6382 if test -n "$module"; then
6383 func_get_autoconf_early_snippet "$module"
6385 done \
6386 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6387 if test "$libtool" = true; then
6388 echo "LT_INIT([win32-dll])"
6389 echo "LT_LANG([C++])"
6390 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6391 echo "gl_cond_libtool=true"
6392 else
6393 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6394 echo "gl_cond_libtool=false"
6395 echo "gl_libdeps="
6396 echo "gl_ltlibdeps="
6398 # Wrap the set of autoconf snippets into an autoconf macro that is then
6399 # invoked. This is needed because autoconf does not support AC_REQUIRE
6400 # at the top level:
6401 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6402 # but we want the AC_REQUIRE to have its normal meaning (provide one
6403 # expansion of the required macro before the current point, and only one
6404 # expansion total).
6405 echo "AC_DEFUN([gl_INIT], ["
6406 if test "$auxdir" != "build-aux"; then
6407 sed_replace_build_aux='
6409 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6410 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6413 else
6414 sed_replace_build_aux="$sed_noop"
6416 echo "gl_m4_base='$m4base'"
6417 func_emit_initmacro_start $macro_prefix
6418 echo "gl_source_base='$sourcebase'"
6419 if $single_configure; then
6420 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false false
6421 else
6422 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module true false false
6424 func_emit_initmacro_end $macro_prefix
6425 if $single_configure; then
6426 echo " gltests_libdeps="
6427 echo " gltests_ltlibdeps="
6428 func_emit_initmacro_start ${macro_prefix}tests
6429 echo " gl_source_base='$testsbase'"
6430 # Define a tests witness macro.
6431 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
6432 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6433 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6434 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6435 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true false false
6436 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6437 func_emit_initmacro_end ${macro_prefix}tests
6439 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6440 # created using libtool, because libtool already handles the dependencies.
6441 if test "$libtool" != true; then
6442 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6443 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6444 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6445 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6446 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6448 if $single_configure; then
6449 if $use_libtests; then
6450 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6451 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6454 echo "])"
6455 func_emit_initmacro_done $macro_prefix $sourcebase
6456 if $single_configure; then
6457 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6459 echo
6460 echo "gl_INIT"
6461 echo
6462 if test -n "$subdirs_with_configure_ac"; then
6463 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6465 makefiles="Makefile"
6466 for d in $subdirs; do
6467 # For subdirs that have a configure.ac by their own, it's the subdir's
6468 # configure.ac which creates the subdir's Makefile.am, not this one.
6469 case " $subdirs_with_configure_ac " in
6470 *" $d "*) ;;
6471 *) func_append makefiles " $d/Makefile" ;;
6472 esac
6473 done
6474 echo "AC_CONFIG_FILES([$makefiles])"
6475 echo "AC_OUTPUT"
6476 ) > "$testdir/configure.ac"
6478 # Create autogenerated files.
6479 (cd "$testdir"
6480 # Do not use "${AUTORECONF} --force --install", because it may invoke
6481 # autopoint, which brings in older versions of some of our .m4 files.
6482 if test -f $m4base/gettext.m4; then
6483 func_execute_command ${AUTOPOINT} --force || func_exit 1
6484 for f in $m4base/*.m4~; do
6485 if test -f $f; then
6486 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6488 done
6490 if test "$libtool" = true; then
6491 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6493 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6494 if ! test -d build-aux; then
6495 func_execute_command mkdir build-aux || func_exit 1
6497 func_execute_command ${AUTOCONF} || func_exit 1
6498 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6499 func_execute_command ${AUTOHEADER} &&
6500 func_execute_command touch config.h.in ||
6501 func_exit 1
6502 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6503 rm -rf autom4te.cache
6504 ) || func_exit 1
6505 if $inctests && ! $single_configure; then
6506 # Create autogenerated files.
6507 (cd "$testdir/$testsbase" || func_exit 1
6508 # Do not use "${AUTORECONF} --force --install", because it may invoke
6509 # autopoint, which brings in older versions of some of our .m4 files.
6510 if test -f ../$m4base/gettext.m4; then
6511 func_execute_command ${AUTOPOINT} --force || func_exit 1
6512 for f in ../$m4base/*.m4~; do
6513 if test -f $f; then
6514 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6516 done
6518 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6519 if ! test -d ../build-aux; then
6520 func_execute_command mkdir ../build-aux
6522 func_execute_command ${AUTOCONF} || func_exit 1
6523 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6524 func_execute_command ${AUTOHEADER} &&
6525 func_execute_command touch config.h.in ||
6526 func_exit 1
6527 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6528 rm -rf autom4te.cache
6529 ) || func_exit 1
6531 # Need to run configure and make once, to create built files that are to be
6532 # distributed (such as parse-datetime.c).
6533 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6534 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6535 cleaned_files=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6536 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6537 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6538 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6539 # such $(FOO_H) because they don't refer to distributed files.
6540 built_sources=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6541 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6542 | sed -e "$sed_remove_make_variables"`
6543 distributed_built_sources=`for file in $built_sources; do
6544 case "$cleaned_files" in
6545 *" "$file" "*) ;;
6546 *) echo $file ;;
6547 esac;
6548 done`
6549 tests_distributed_built_sources=
6550 if $inctests; then
6551 # Likewise for built files in the $testsbase directory.
6552 tests_cleaned_files=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6553 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6554 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6555 tests_built_sources=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6556 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6557 | sed -e "$sed_remove_make_variables"`
6558 tests_distributed_built_sources=`for file in $tests_built_sources; do
6559 case "$tests_cleaned_files" in
6560 *" "$file" "*) ;;
6561 *) echo $file ;;
6562 esac;
6563 done`
6565 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6566 (cd "$testdir"
6567 ./configure || func_exit 1
6568 if test -n "$distributed_built_sources"; then
6569 cd "$sourcebase"
6570 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6571 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6572 built_sources \
6573 || func_exit 1
6574 cd ..
6576 if test -n "$tests_distributed_built_sources"; then
6577 cd "$testsbase"
6578 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6579 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6580 built_sources \
6581 || func_exit 1
6582 cd ..
6584 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6585 distclean \
6586 || func_exit 1
6587 ) || func_exit 1
6591 # func_create_megatestdir megatestdir allmodules
6592 # Input:
6593 # - local_gnulib_path from --local-dir
6594 # - modcache true or false, from --cache-modules/--no-cache-modules
6595 # - auxdir directory relative to destdir where to place build aux files
6596 func_create_megatestdir ()
6598 megatestdir="$1"
6599 allmodules="$2"
6600 if test -z "$allmodules"; then
6601 allmodules=`func_all_modules`
6604 megasubdirs=
6605 # First, all modules one by one.
6606 for onemodule in $allmodules; do
6607 func_create_testdir "$megatestdir/$onemodule" $onemodule
6608 func_append megasubdirs "$onemodule "
6609 done
6610 # Then, all modules all together.
6611 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6612 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6613 func_create_testdir "$megatestdir/ALL" "$allmodules"
6614 func_append megasubdirs "ALL"
6616 # Create autobuild.
6617 cvsdate=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6618 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6619 | sed -e 's,January,01,' -e 's,Jan,01,' \
6620 -e 's,February,02,' -e 's,Feb,02,' \
6621 -e 's,March,03,' -e 's,Mar,03,' \
6622 -e 's,April,04,' -e 's,Apr,04,' \
6623 -e 's,May,05,' \
6624 -e 's,June,06,' -e 's,Jun,06,' \
6625 -e 's,July,07,' -e 's,Jul,07,' \
6626 -e 's,August,08,' -e 's,Aug,08,' \
6627 -e 's,September,09,' -e 's,Sep,09,' \
6628 -e 's,October,10,' -e 's,Oct,10,' \
6629 -e 's,November,11,' -e 's,Nov,11,' \
6630 -e 's,December,12,' -e 's,Dec,12,' \
6631 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6632 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6633 (echo '#!/bin/sh'
6634 echo "CVSDATE=$cvsdate"
6635 echo ": \${MAKE=make}"
6636 echo "test -d logs || mkdir logs"
6637 echo "for module in $megasubdirs; do"
6638 echo " echo \"Working on module \$module...\""
6639 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6640 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6641 echo " echo"
6642 echo " set -x"
6643 echo " : autobuild project... \$module"
6644 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6645 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6646 echo " : autobuild hostname... \`hostname\`"
6647 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6648 echo " echo rc=\$?"
6649 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6650 echo "done"
6651 ) > "$megatestdir/do-autobuild"
6652 chmod a+x "$megatestdir/do-autobuild"
6654 # Create Makefile.am.
6655 (echo "## Process this file with automake to produce Makefile.in."
6656 echo
6657 echo "AUTOMAKE_OPTIONS = 1.11 foreign"
6658 echo
6659 echo "SUBDIRS = $megasubdirs"
6660 echo
6661 echo "EXTRA_DIST = do-autobuild"
6662 ) > "$megatestdir/Makefile.am"
6664 # Create configure.ac.
6665 (echo "# Process this file with autoconf to produce a configure script."
6666 echo "AC_INIT([dummy], [0])"
6667 if test "$auxdir" != "."; then
6668 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6670 echo "AM_INIT_AUTOMAKE"
6671 echo
6672 echo "AC_PROG_MAKE_SET"
6673 echo
6674 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6675 echo "AC_CONFIG_FILES([Makefile])"
6676 echo "AC_OUTPUT"
6677 ) > "$megatestdir/configure.ac"
6679 # Create autogenerated files.
6680 (cd "$megatestdir"
6681 # Do not use "${AUTORECONF} --install", because autoreconf operates
6682 # recursively, but the subdirectories are already finished, therefore
6683 # calling autoreconf here would only waste lots of CPU time.
6684 func_execute_command ${ACLOCAL} || func_exit 1
6685 func_execute_command mkdir build-aux
6686 func_execute_command ${AUTOCONF} || func_exit 1
6687 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6688 rm -rf autom4te.cache
6689 ) || func_exit 1
6692 case $mode in
6693 "" )
6694 func_fatal_error "no mode specified" ;;
6696 list )
6697 func_all_modules
6700 find )
6701 # sed expression that converts a literal to a basic regular expression.
6702 # Needs to handle . [ \ * ^ $.
6703 sed_literal_to_basic_regex='s/\\/\\\\/g
6704 s/\[/\\[/g
6705 s/\^/\\^/g
6706 s/\([.*$]\)/[\1]/g'
6707 for filename
6709 if test -f "$gnulib_dir/$filename" \
6710 || func_lookup_local_file "$filename"; then
6711 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6712 filename_line_regex='^'"$filename_anywhere_regex"'$'
6713 module_candidates=`
6715 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6716 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$,,'
6718 | func_sanitize_modulelist \
6719 | LC_ALL=C sort -u
6721 for module in $module_candidates; do
6722 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6723 echo $module
6725 done
6726 else
6727 func_warning "file $filename does not exist"
6729 done
6732 import | add-import | remove-import | update )
6734 # Where to import.
6735 if test -z "$destdir"; then
6736 destdir=.
6738 test -d "$destdir" \
6739 || func_fatal_error "destination directory does not exist: $destdir"
6741 # Prefer configure.ac to configure.in.
6742 if test -f "$destdir"/configure.ac; then
6743 configure_ac="$destdir/configure.ac"
6744 else
6745 if test -f "$destdir"/configure.in; then
6746 configure_ac="$destdir/configure.in"
6747 else
6748 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6752 # Analyze configure.ac.
6753 guessed_auxdir="."
6754 guessed_libtool=false
6755 my_sed_traces='
6756 s,#.*$,,
6757 s,^dnl .*$,,
6758 s, dnl .*$,,
6759 /AC_CONFIG_AUX_DIR/ {
6760 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6762 /A[CM]_PROG_LIBTOOL/ {
6763 s,^.*$,guessed_libtool=true,p
6765 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6767 if test -z "$auxdir"; then
6768 auxdir="$guessed_auxdir"
6771 # Determine where to apply func_import.
6772 if test "$mode" = import; then
6773 # Apply func_import to a particular gnulib directory.
6774 # The command line contains the complete specification; don't look at
6775 # the contents of gnulib-cache.m4.
6776 test -n "$supplied_libname" || supplied_libname=true
6777 test -n "$sourcebase" || sourcebase="lib"
6778 test -n "$m4base" || m4base="m4"
6779 test -n "$docbase" || docbase="doc"
6780 test -n "$testsbase" || testsbase="tests"
6781 test -n "$macro_prefix" || macro_prefix="gl"
6782 func_import "$*"
6783 else
6784 if test -n "$m4base"; then
6785 # Apply func_import to a particular gnulib directory.
6786 # Any number of additional modules can be given.
6787 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6788 # First use of gnulib in the given m4base.
6789 test -n "$supplied_libname" || supplied_libname=true
6790 test -n "$sourcebase" || sourcebase="lib"
6791 test -n "$docbase" || docbase="doc"
6792 test -n "$testsbase" || testsbase="tests"
6793 test -n "$macro_prefix" || macro_prefix="gl"
6795 func_import "$*"
6796 else
6797 # Apply func_import to all gnulib directories.
6798 # To get this list of directories, look at Makefile.am. (Not at
6799 # configure, because it may be omitted from version control. Also,
6800 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6801 # too expensive.)
6802 m4dirs=
6803 m4dirs_count=0
6804 if test -f "$destdir"/Makefile.am; then
6805 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6806 m4dir_is_next=
6807 for arg in $aclocal_amflags; do
6808 if test -n "$m4dir_is_next"; then
6809 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6810 case "$arg" in
6811 /*) ;;
6813 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6814 func_append m4dirs " $arg"
6815 m4dirs_count=`expr $m4dirs_count + 1`
6818 esac
6819 m4dir_is_next=
6820 else
6821 if test "X$arg" = "X-I"; then
6822 m4dir_is_next=yes
6823 else
6824 m4dir_is_next=
6827 done
6828 else
6829 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6830 if test -f "$destdir"/aclocal.m4; then
6831 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6832 sedexpr2='s,^[^/]*$,.,'
6833 sedexpr3='s,/[^/]*$,,'
6834 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6835 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6836 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6839 if test $m4dirs_count = 0; then
6840 # First use of gnulib in a package.
6841 # Any number of additional modules can be given.
6842 test -n "$supplied_libname" || supplied_libname=true
6843 test -n "$sourcebase" || sourcebase="lib"
6844 m4base="m4"
6845 test -n "$docbase" || docbase="doc"
6846 test -n "$testsbase" || testsbase="tests"
6847 test -n "$macro_prefix" || macro_prefix="gl"
6848 func_import "$*"
6849 else
6850 if test $m4dirs_count = 1; then
6851 # There's only one use of gnulib here. Assume the user means it.
6852 # Any number of additional modules can be given.
6853 for m4base in $m4dirs; do
6854 func_import "$*"
6855 done
6856 else
6857 # Ambiguous - guess what the user meant.
6858 if test $# = 0; then
6859 # No further arguments. Guess the user wants to update all of them.
6860 for m4base in $m4dirs; do
6861 # Perform func_import in a subshell, so that variable values
6862 # such as
6863 # local_gnulib_path, incobsolete, inc_cxx_tests,
6864 # inc_longrunning_tests, inc_privileged_tests,
6865 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6866 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6867 # makefile_name, libtool, macro_prefix, po_domain,
6868 # witness_c_macro, vc_files
6869 # don't propagate from one directory to another.
6870 (func_import) || func_exit 1
6871 done
6872 else
6873 # Really ambiguous.
6874 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6882 create-testdir )
6883 if test -z "$destdir"; then
6884 func_fatal_error "please specify --dir option"
6886 mkdir "$destdir"
6887 test -d "$destdir" \
6888 || func_fatal_error "could not create destination directory"
6889 test -n "$auxdir" || auxdir="build-aux"
6890 func_create_testdir "$destdir" "$*"
6893 create-megatestdir )
6894 if test -z "$destdir"; then
6895 func_fatal_error "please specify --dir option"
6897 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6898 test -n "$auxdir" || auxdir="build-aux"
6899 func_create_megatestdir "$destdir" "$*"
6902 test )
6903 test -n "$destdir" || destdir=testdir$$
6904 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6905 test -n "$auxdir" || auxdir="build-aux"
6906 func_create_testdir "$destdir" "$*"
6907 cd "$destdir"
6908 mkdir build
6909 cd build
6910 ../configure || func_exit 1
6911 $MAKE || func_exit 1
6912 $MAKE check || func_exit 1
6913 $MAKE distclean || func_exit 1
6914 remaining=`find . -type f -print`
6915 if test -n "$remaining"; then
6916 echo "Remaining files:" $remaining 1>&2
6917 echo "gnulib-tool: *** Stop." 1>&2
6918 func_exit 1
6920 cd ..
6921 cd ..
6922 rm -rf "$destdir"
6925 megatest )
6926 test -n "$destdir" || destdir=testdir$$
6927 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6928 test -n "$auxdir" || auxdir="build-aux"
6929 func_create_megatestdir "$destdir" "$*"
6930 cd "$destdir"
6931 mkdir build
6932 cd build
6933 ../configure
6934 $MAKE
6935 $MAKE check
6936 $MAKE distclean
6937 remaining=`find . -type f -print`
6938 if test -n "$remaining"; then
6939 echo "Remaining files:" $remaining 1>&2
6940 echo "gnulib-tool: *** Stop." 1>&2
6941 func_exit 1
6943 cd ..
6944 cd ..
6945 rm -rf "$destdir"
6948 extract-description )
6949 for module
6951 func_verify_module
6952 if test -n "$module"; then
6953 func_get_description "$module"
6955 done
6958 extract-comment )
6959 for module
6961 func_verify_module
6962 if test -n "$module"; then
6963 func_get_comment "$module"
6965 done
6968 extract-status )
6969 for module
6971 func_verify_module
6972 if test -n "$module"; then
6973 func_get_status "$module"
6975 done
6978 extract-notice )
6979 for module
6981 func_verify_module
6982 if test -n "$module"; then
6983 func_get_notice "$module"
6985 done
6988 extract-applicability )
6989 for module
6991 func_verify_module
6992 if test -n "$module"; then
6993 func_get_applicability "$module"
6995 done
6998 extract-filelist )
6999 for module
7001 func_verify_module
7002 if test -n "$module"; then
7003 func_get_filelist "$module"
7005 done
7008 extract-dependencies )
7009 if test -n "$avoidlist"; then
7010 func_fatal_error "cannot combine --avoid and --extract-dependencies"
7012 for module
7014 func_verify_module
7015 if test -n "$module"; then
7016 func_get_dependencies "$module"
7018 done
7021 extract-autoconf-snippet )
7022 for module
7024 func_verify_module
7025 if test -n "$module"; then
7026 func_get_autoconf_snippet "$module"
7028 done
7031 extract-automake-snippet )
7032 for module
7034 func_verify_module
7035 if test -n "$module"; then
7036 func_get_automake_snippet "$module"
7038 done
7041 extract-include-directive )
7042 for module
7044 func_verify_module
7045 if test -n "$module"; then
7046 func_get_include_directive "$module"
7048 done
7051 extract-link-directive )
7052 for module
7054 func_verify_module
7055 if test -n "$module"; then
7056 func_get_link_directive "$module"
7058 done
7061 extract-license )
7062 for module
7064 func_verify_module
7065 if test -n "$module"; then
7066 func_get_license "$module"
7068 done
7071 extract-maintainer )
7072 for module
7074 func_verify_module
7075 if test -n "$module"; then
7076 func_get_maintainer "$module"
7078 done
7081 extract-tests-module )
7082 for module
7084 func_verify_module
7085 if test -n "$module"; then
7086 func_get_tests_module "$module"
7088 done
7091 copy-file )
7092 # Verify the number of arguments.
7093 if test $# -lt 1 || test $# -gt 2; then
7094 func_fatal_error "invalid number of arguments for --$mode"
7097 # The first argument is the file to be copied.
7098 f="$1"
7099 # Verify the file exists.
7100 func_lookup_file "$f"
7102 # The second argument is the destination; either a directory ot a file.
7103 # It defaults to the current directory.
7104 dest="$2"
7105 test -n "$dest" || dest='.'
7106 test -n "$sourcebase" || sourcebase="lib"
7107 test -n "$m4base" || m4base="m4"
7108 test -n "$docbase" || docbase="doc"
7109 test -n "$testsbase" || testsbase="tests"
7110 test -n "$auxdir" || auxdir="build-aux"
7111 rewritten='%REWRITTEN%'
7112 sed_rewrite_files="\
7113 s,^build-aux/,$rewritten$auxdir/,
7114 s,^doc/,$rewritten$docbase/,
7115 s,^lib/,$rewritten$sourcebase/,
7116 s,^m4/,$rewritten$m4base/,
7117 s,^tests/,$rewritten$testsbase/,
7118 s,^top/,$rewritten,
7119 s,^$rewritten,,"
7120 if test -d "$dest"; then
7121 destdir="$dest"
7122 g=`echo "$f" | sed -e "$sed_rewrite_files"`
7123 else
7124 destdir=`dirname "$dest"`
7125 g=`basename "$dest"`
7128 # Create the directory for destfile.
7129 d=`dirname "$destdir/$g"`
7130 if $doit; then
7131 if test -n "$d" && test ! -d "$d"; then
7132 mkdir -p "$d" || func_fatal_error "failed"
7135 # Copy the file.
7136 func_dest_tmpfilename "$g"
7137 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
7138 already_present=true
7139 if test -f "$destdir/$g"; then
7140 # The file already exists.
7141 func_update_file
7142 else
7143 # Install the file.
7144 # Don't protest if the file should be there but isn't: it happens
7145 # frequently that developers don't put autogenerated files under version
7146 # control.
7147 func_add_file
7149 rm -f "$tmpfile"
7153 func_fatal_error "unknown operation mode --$mode" ;;
7154 esac
7156 if test "$copymode" = hardlink -o "$lcopymode" = hardlink; then
7157 # Setting hard links modifies the ctime of files in the gnulib checkout.
7158 # This disturbs the result of the next "gitk" invocation.
7159 # Workaround: Let git scan the files. This can be done through
7160 # "git update-index --refresh" or "git status" or "git diff".
7161 if test -d "$gnulib_dir"/.git \
7162 && (git --version) >/dev/null 2>/dev/null; then
7163 (cd "$gnulib_dir" && git update-index --refresh >/dev/null)
7167 rm -rf "$tmp"
7168 # Undo the effect of the previous 'trap' command. Some shellology:
7169 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
7170 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
7171 # exit); for the others we need to call 'exit' explicitly. The value of $? is
7172 # 128 + signal number and is set before the trap-registered command is run.
7173 trap '' 0
7174 trap 'func_exit $?' 1 2 3 13 15
7176 exit 0
7178 # Local Variables:
7179 # indent-tabs-mode: nil
7180 # whitespace-check-buffer-indent: nil
7181 # End: