fma: Improve code style.
[gnulib.git] / gnulib-tool
blob44cfeb3e03a28e5852b74ea3c721c8c3116f219c
1 #! /bin/sh
3 # Copyright (C) 2002-2019 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
22 progname=$0
23 package=gnulib
24 nl='
26 IFS=" "" $nl"
28 # You can set AUTOCONFPATH to empty if autoconf 2.63 is already in your PATH.
29 AUTOCONFPATH=
30 #case $USER in
31 # bruno )
32 # AUTOCONFBINDIR=/arch/x86-linux/gnu-inst-autoconf/2.63/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
34 # ;;
35 #esac
37 # You can set AUTOMAKEPATH to empty if automake 1.11 is already in your PATH.
38 AUTOMAKEPATH=
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
41 GETTEXTPATH=
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
44 LIBTOOLPATH=
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
74 # You can set MAKE.
75 if test -z "${MAKE}"; then
76 MAKE=make
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <https://lists.gnu.org/r/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
90 *) true;; \
91 esac \
92 ; then
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
109 sed_noop='s,x,x,'
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # AIX 5.3 sed barfs over indented comments.
113 if echo fo | sed -e 's/f/g/
114 # s/o/u/
115 # indented comment
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
117 sed_comments=true
118 else
119 sed_comments=false
122 # func_usage
123 # outputs to stdout the --help usage message.
124 func_usage ()
126 echo "\
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
130 gnulib-tool --add-import [module1 ... moduleN]
131 gnulib-tool --remove-import [module1 ... moduleN]
132 gnulib-tool --update
133 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
134 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
135 gnulib-tool --test --dir=directory module1 ... moduleN
136 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
137 gnulib-tool --extract-description module
138 gnulib-tool --extract-comment module
139 gnulib-tool --extract-status module
140 gnulib-tool --extract-notice module
141 gnulib-tool --extract-applicability module
142 gnulib-tool --extract-filelist module
143 gnulib-tool --extract-dependencies module
144 gnulib-tool --extract-recursive-dependencies module
145 gnulib-tool --extract-autoconf-snippet module
146 gnulib-tool --extract-automake-snippet module
147 gnulib-tool --extract-include-directive module
148 gnulib-tool --extract-link-directive module
149 gnulib-tool --extract-recursive-link-directive module
150 gnulib-tool --extract-license module
151 gnulib-tool --extract-maintainer module
152 gnulib-tool --extract-tests-module module
153 gnulib-tool --copy-file file [destination]
155 Operation modes:
157 --list print the available module names
158 --find find the modules which contain the specified file
159 --import import the given modules into the current package
160 --add-import augment the list of imports from gnulib into the
161 current package, by adding the given modules;
162 if no modules are specified, update the current
163 package from the current gnulib
164 --remove-import reduce the list of imports from gnulib into the
165 current package, by removing the given modules
166 --update update the current package, restore files omitted
167 from version control
168 --create-testdir create a scratch package with the given modules
169 --create-megatestdir create a mega scratch package with the given modules
170 one by one and all together
171 --test test the combination of the given modules
172 (recommended to use CC=\"gcc -Wall\" here)
173 --megatest test the given modules one by one and all together
174 (recommended to use CC=\"gcc -Wall\" here)
175 --extract-description extract the description
176 --extract-comment extract the comment
177 --extract-status extract the status (obsolete etc.)
178 --extract-notice extract the notice or banner
179 --extract-applicability extract the applicability
180 --extract-filelist extract the list of files
181 --extract-dependencies extract the dependencies
182 --extract-recursive-dependencies extract the dependencies of the module
183 and its dependencies, recursively, all
184 together, but without the conditions
185 --extract-autoconf-snippet extract the snippet for configure.ac
186 --extract-automake-snippet extract the snippet for library makefile
187 --extract-include-directive extract the #include directive
188 --extract-link-directive extract the linker directive
189 --extract-recursive-link-directive extract the linker directive of the
190 module and its dependencies,
191 recursively, all together
192 --extract-license report the license terms of the source files
193 under lib/
194 --extract-maintainer report the maintainer(s) inside gnulib
195 --extract-tests-module report the unit test module, if it exists
196 --copy-file copy a file that is not part of any module
197 --help Show this help text.
198 --version Show version and authorship information.
200 General options:
202 --dir=DIRECTORY Specify the target directory.
203 For --import, this specifies where your
204 configure.ac can be found. Defaults to current
205 directory.
206 --local-dir=DIRECTORY Specify a local override directory where to look
207 up files before looking in gnulib's directory.
208 --cache-modules Enable module caching optimization.
209 --no-cache-modules Disable module caching optimization.
210 --verbose Increase verbosity. May be repeated.
211 --quiet Decrease verbosity. May be repeated.
213 Options for --import, --add/remove-import, --update:
215 --dry-run Only print what would have been done.
217 Options for --import, --add/remove-import:
219 --with-tests Include unit tests for the included modules.
221 Options for --create-[mega]testdir, --[mega]test:
223 --without-tests Don't include unit tests for the included modules.
225 Options for --import, --add/remove-import,
226 --create-[mega]testdir, --[mega]test:
228 --with-obsolete Include obsolete modules when they occur among the
229 dependencies. By default, dependencies to obsolete
230 modules are ignored.
231 --with-c++-tests Include even unit tests for C++ interoperability.
232 --without-c++-tests Exclude unit tests for C++ interoperability.
233 --with-longrunning-tests
234 Include even unit tests that are long-runners.
235 --without-longrunning-tests
236 Exclude unit tests that are long-runners.
237 --with-privileged-tests
238 Include even unit tests that require root
239 privileges.
240 --without-privileged-tests
241 Exclude unit tests that require root privileges.
242 --with-unportable-tests
243 Include even unit tests that fail on some platforms.
244 --without-unportable-tests
245 Exclude unit tests that fail on some platforms.
246 --with-all-tests Include all kinds of problematic unit tests.
247 --avoid=MODULE Avoid including the given MODULE. Useful if you
248 have code that provides equivalent functionality.
249 This option can be repeated.
250 --conditional-dependencies
251 Support conditional dependencies (may save configure
252 time and object code).
253 --no-conditional-dependencies
254 Don't use conditional dependencies.
255 --libtool Use libtool rules.
256 --no-libtool Don't use libtool rules.
258 Options for --import, --add/remove-import:
260 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
261 --source-base=DIRECTORY
262 Directory relative to --dir where source code is
263 placed (default \"lib\").
264 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
265 placed (default \"m4\").
266 --po-base=DIRECTORY Directory relative to --dir where *.po files are
267 placed (default \"po\").
268 --doc-base=DIRECTORY Directory relative to --dir where doc files are
269 placed (default \"doc\").
270 --tests-base=DIRECTORY
271 Directory relative to --dir where unit tests are
272 placed (default \"tests\").
273 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
274 tools are placed (default comes from configure.ac).
275 --gnu-make Output for GNU Make instead of for the default
276 Automake
277 --lgpl[=2|=3orGPLv2|=3]
278 Abort if modules aren't available under the LGPL.
279 Also modify license template from GPL to LGPL.
280 The version number of the LGPL can be specified;
281 the default is currently LGPLv3.
282 --makefile-name=NAME Name of makefile in the source-base and tests-base
283 directories (default \"Makefile.am\", or
284 \"Makefile.in\" if --gnu-make).
285 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
286 'gl_INIT'. Default is 'gl'.
287 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
288 the package name. A suffix '-gnulib' is appended.
289 --witness-c-macro=NAME Specify the C macro that is defined when the
290 sources in this directory are compiled or used.
291 --vc-files Update version control related files.
292 --no-vc-files Don't update version control related files
293 (.gitignore and/or .cvsignore).
295 Options for --create-[mega]testdir, --[mega]test:
297 --single-configure Generate a single configure file, not a separate
298 configure file for the tests directory.
300 Options for --import, --add/remove-import, --update,
301 --create-[mega]testdir, --[mega]test:
303 -s, --symbolic, --symlink Make symbolic links instead of copying files.
304 --local-symlink Make symbolic links instead of copying files, only
305 for files from the local override directory.
306 -h, --hardlink Make hard links instead of copying files.
307 --local-hardlink Make hard links instead of copying files, only
308 for files from the local override directory.
310 Options for --import, --add/remove-import, --update:
312 -S, --more-symlinks Make symbolic links instead of copying files, and
313 don't replace copyright notices.
314 -H, --more-hardlinks Make hard links instead of copying files, and
315 don't replace copyright notices.
317 Report bugs to <bug-gnulib@gnu.org>."
320 # func_version
321 # outputs to stdout the --version message.
322 func_version ()
324 func_gnulib_dir
325 if test -d "$gnulib_dir"/.git \
326 && (git --version) >/dev/null 2>/dev/null \
327 && (date --version) >/dev/null 2>/dev/null; then
328 # gnulib checked out from git.
329 sed_extract_first_date='/^Date/{
330 s/^Date:[ ]*//p
333 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
334 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
335 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
336 date=`echo "$date" | sed -e "$sed_year_before_time"`
337 # Use GNU date to compute the time in GMT.
338 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
339 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
340 else
341 # gnulib copy without versioning information.
342 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
343 version=
345 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
346 echo "\
347 gnulib-tool (GNU $package $date)$version
348 Copyright (C) $year Free Software Foundation, Inc.
349 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
350 This is free software: you are free to change and redistribute it.
351 There is NO WARRANTY, to the extent permitted by law.
353 printf "Written by %s, %s, and %s.\n" "Bruno Haible" "Paul Eggert" "Simon Josefsson"
356 # func_emit_copyright_notice
357 # outputs to stdout a header for a generated file.
358 func_emit_copyright_notice ()
360 sed -n -e '/Copyright/ {
363 }' < "$self_abspathname"
364 echo "#"
365 echo "# This file is free software; you can redistribute it and/or modify"
366 echo "# it under the terms of the GNU General Public License as published by"
367 echo "# the Free Software Foundation; either version 3 of the License, or"
368 echo "# (at your option) any later version."
369 echo "#"
370 echo "# This file is distributed in the hope that it will be useful,"
371 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
372 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
373 echo "# GNU General Public License for more details."
374 echo "#"
375 echo "# You should have received a copy of the GNU General Public License"
376 echo "# along with this file. If not, see <https://www.gnu.org/licenses/>."
377 echo "#"
378 echo "# As a special exception to the GNU General Public License,"
379 echo "# this file may be distributed as part of a program that"
380 echo "# contains a configuration script generated by Autoconf, under"
381 echo "# the same distribution terms as the rest of that program."
382 echo "#"
383 echo "# Generated by gnulib-tool."
386 # func_exit STATUS
387 # exits with a given status.
388 # This function needs to be used, rather than 'exit', when a 'trap' handler is
389 # in effect that refers to $?.
390 func_exit ()
392 (exit $1); exit $1
395 # func_gnulib_dir
396 # locates the directory where the gnulib repository lives
397 # Input:
398 # - progname name of this program
399 # Sets variables
400 # - self_abspathname absolute pathname of gnulib-tool
401 # - gnulib_dir absolute pathname of gnulib repository
402 func_gnulib_dir ()
404 case "$progname" in
405 /* | ?:*) self_abspathname="$progname" ;;
406 */*) self_abspathname=`pwd`/"$progname" ;;
408 # Look in $PATH.
409 # Iterate through the elements of $PATH.
410 # We use IFS=: instead of
411 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
412 # because the latter does not work when some PATH element contains spaces.
413 # We use a canonicalized $pathx instead of $PATH, because empty PATH
414 # elements are by definition equivalent to '.', however field splitting
415 # according to IFS=: loses empty fields in many shells:
416 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
417 # beginning, at the end, and in the middle),
418 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
419 # at the beginning and at the end,
420 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
421 # Solaris lose empty fields at the end.
422 # The 'case' statement is an optimization, to avoid evaluating the
423 # explicit canonicalization command when $PATH contains no empty fields.
424 self_abspathname=
425 if test "$PATH_SEPARATOR" = ";"; then
426 # On Windows, programs are searched in "." before $PATH.
427 pathx=".;$PATH"
428 else
429 # On Unix, we have to convert empty PATH elements to ".".
430 pathx="$PATH"
431 case :$PATH: in
432 *::*)
433 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
435 esac
437 save_IFS="$IFS"
438 IFS="$PATH_SEPARATOR"
439 for d in $pathx; do
440 IFS="$save_IFS"
441 test -z "$d" && d=.
442 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
443 self_abspathname="$d/$progname"
444 break
446 done
447 IFS="$save_IFS"
448 if test -z "$self_abspathname"; then
449 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
452 esac
453 while test -h "$self_abspathname"; do
454 # Resolve symbolic link.
455 linkval=`func_readlink "$self_abspathname"`
456 test -n "$linkval" || break
457 case "$linkval" in
458 /* | ?:* ) self_abspathname="$linkval" ;;
459 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
460 esac
461 done
462 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
465 # func_tmpdir
466 # creates a temporary directory.
467 # Input:
468 # - progname name of this program
469 # Sets variable
470 # - tmp pathname of freshly created temporary directory
471 func_tmpdir ()
473 # Use the environment variable TMPDIR, falling back to /tmp. This allows
474 # users to specify a different temporary directory, for example, if their
475 # /tmp is filled up or too small.
476 : ${TMPDIR=/tmp}
478 # Use the mktemp program if available. If not available, hide the error
479 # message.
480 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
481 test -n "$tmp" && test -d "$tmp"
482 } ||
484 # Use a simple mkdir command. It is guaranteed to fail if the directory
485 # already exists. $RANDOM is bash specific and expands to empty in shells
486 # other than bash, ksh and zsh. Its use does not increase security;
487 # rather, it minimizes the probability of failure in a very cluttered /tmp
488 # directory.
489 tmp=$TMPDIR/gl$$-$RANDOM
490 (umask 077 && mkdir "$tmp")
491 } ||
493 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
494 func_exit 1
498 # func_append var value
499 # appends the given value to the shell variable var.
500 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
501 # Use bash's += operator. It reduces complexity of appending repeatedly to
502 # a single variable from O(n^2) to O(n).
503 func_append ()
505 eval "$1+=\"\$2\""
507 fast_func_append=true
508 else
509 func_append ()
511 eval "$1=\"\$$1\$2\""
513 fast_func_append=false
516 # func_remove_prefix var prefix
517 # removes the given prefix from the value of the shell variable var.
518 # var should be the name of a shell variable.
519 # Its value should not contain a newline and not start or end with whitespace.
520 # prefix should not contain the characters "$`\{}[]^|.
521 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
522 func_remove_prefix ()
524 eval "$1=\${$1#\$2}"
526 fast_func_remove_prefix=true
527 else
528 func_remove_prefix ()
530 eval "value=\"\$$1\""
531 prefix="$2"
532 case "$prefix" in
533 *.*)
534 sed_escape_dots='s/\([.]\)/\\\1/g'
535 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
537 esac
538 value=`echo "$value" | sed -e "s|^${prefix}||"`
539 eval "$1=\"\$value\""
541 fast_func_remove_prefix=false
544 # Determine whether we should use ':' or ';' as PATH_SEPARATOR.
545 func_determine_path_separator ()
547 if test "${PATH_SEPARATOR+set}" != set; then
548 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
549 # contains only /bin. Note that ksh looks also at the FPATH variable,
550 # so we have to set that as well for the test.
551 PATH_SEPARATOR=:
552 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
553 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
554 || PATH_SEPARATOR=';'
559 # func_path_prepend pathvar directory
560 # puts directory before pathvar, delimiting directories by PATH_SEPARATOR.
561 # Newly added directory into pathvar has the highest priority.
562 func_path_prepend ()
564 if eval "test -n \"\$$1\""; then
565 eval "$1=\$2\$PATH_SEPARATOR\$$1"
566 else
567 eval "$1=\$2"
571 # func_path_append pathvar directory
572 # Similar to func_path_prepend except that the newest directory has the lowest
573 # priority.
574 func_path_append ()
576 if eval "test -n \"\$$1\""; then
577 func_append "$1" "$PATH_SEPARATOR$2"
578 else
579 eval "$1=\$2"
583 # func_path_foreach_inner
584 # helper for func_path_foreach because we need new 'args' array
585 # Input:
586 # - fpf_dir directory from local_gnulib_path
587 # - fpf_cb callback to be run for fpf_dir
588 func_path_foreach_inner ()
590 set %start% "$@"
591 for _fpf_arg
593 case $_fpf_arg in
594 %start%)
595 set dummy
597 %dir%)
598 set "$@" "$fpf_dir"
601 set "$@" "$_fpf_arg"
603 esac
604 done
605 shift
607 "$fpf_cb" "$@"
610 # func_path_foreach path method args
611 # Execute method for each directory in path. The method will be called
612 # like `method args` while any argument '%dir%' within args will be replaced
613 # with processed directory from path.
614 func_path_foreach ()
616 fpf_save_IFS=$IFS
617 fpf_dirs=$1 ; shift
618 fpf_cb=$1 ; shift
619 fpf_rc=false
621 IFS=$PATH_SEPARATOR
622 for fpf_dir in $fpf_dirs
624 func_path_foreach_inner "$@" && fpf_rc=:
625 done
626 IFS=$fpf_save_IFS
627 $fpf_rc
630 # func_remove_suffix var suffix
631 # removes the given suffix from the value of the shell variable var.
632 # var should be the name of a shell variable.
633 # Its value should not contain a newline and not start or end with whitespace.
634 # suffix should not contain the characters "$`\{}[]^|.
635 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
636 func_remove_suffix ()
638 eval "$1=\${$1%\$2}"
640 fast_func_remove_suffix=true
641 else
642 func_remove_suffix ()
644 eval "value=\"\$$1\""
645 suffix="$2"
646 case "$suffix" in
647 *.*)
648 sed_escape_dots='s/\([.]\)/\\\1/g'
649 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
651 esac
652 value=`echo "$value" | sed -e "s|${suffix}\$||"`
653 eval "$1=\"\$value\""
655 fast_func_remove_suffix=false
658 # func_fatal_error message
659 # outputs to stderr a fatal error message, and terminates the program.
660 # Input:
661 # - progname name of this program
662 func_fatal_error ()
664 echo "$progname: *** $1" 1>&2
665 echo "$progname: *** Stop." 1>&2
666 func_exit 1
669 # func_warning message
670 # Outputs to stderr a warning message,
671 func_warning ()
673 echo "gnulib-tool: warning: $1" 1>&2
676 # func_readlink SYMLINK
677 # outputs the target of the given symlink.
678 if (type readlink) > /dev/null 2>&1; then
679 func_readlink ()
681 # Use the readlink program from GNU coreutils.
682 readlink "$1"
684 else
685 func_readlink ()
687 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
688 # would do the wrong thing if the link target contains " -> ".
689 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
693 # func_relativize DIR1 DIR2
694 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
695 # Input:
696 # - DIR1 relative pathname, relative to the current directory
697 # - DIR2 relative pathname, relative to the current directory
698 # Output:
699 # - reldir relative pathname of DIR2, relative to DIR1
700 func_relativize ()
702 dir0=`pwd`
703 dir1="$1"
704 dir2="$2"
705 sed_first='s,^\([^/]*\)/.*$,\1,'
706 sed_rest='s,^[^/]*/*,,'
707 sed_last='s,^.*/\([^/]*\)$,\1,'
708 sed_butlast='s,/*[^/]*$,,'
709 while test -n "$dir1"; do
710 first=`echo "$dir1" | sed -e "$sed_first"`
711 if test "$first" != "."; then
712 if test "$first" = ".."; then
713 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
714 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
715 else
716 first2=`echo "$dir2" | sed -e "$sed_first"`
717 if test "$first2" = "$first"; then
718 dir2=`echo "$dir2" | sed -e "$sed_rest"`
719 else
720 dir2="../$dir2"
722 dir0="$dir0"/"$first"
725 dir1=`echo "$dir1" | sed -e "$sed_rest"`
726 done
727 reldir="$dir2"
730 # func_relconcat DIR1 DIR2
731 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
732 # Input:
733 # - DIR1 relative pathname, relative to the current directory
734 # - DIR2 relative pathname, relative to DIR1
735 # Output:
736 # - relconcat DIR1/DIR2, relative to the current directory
737 func_relconcat ()
739 dir1="$1"
740 dir2="$2"
741 sed_first='s,^\([^/]*\)/.*$,\1,'
742 sed_rest='s,^[^/]*/*,,'
743 sed_last='s,^.*/\([^/]*\)$,\1,'
744 sed_butlast='s,/*[^/]*$,,'
745 while true; do
746 first=`echo "$dir2" | sed -e "$sed_first"`
747 if test "$first" = "."; then
748 dir2=`echo "$dir2" | sed -e "$sed_rest"`
749 if test -z "$dir2"; then
750 relconcat="$dir1"
751 break
753 else
754 last=`echo "$dir1" | sed -e "$sed_last"`
755 while test "$last" = "."; do
756 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
757 last=`echo "$dir1" | sed -e "$sed_last"`
758 done
759 if test -z "$dir1"; then
760 relconcat="$dir2"
761 break
763 if test "$first" = ".."; then
764 if test "$last" = ".."; then
765 relconcat="$dir1/$dir2"
766 break
768 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
769 dir2=`echo "$dir2" | sed -e "$sed_rest"`
770 if test -z "$dir1"; then
771 relconcat="$dir2"
772 break
774 if test -z "$dir2"; then
775 relconcat="$dir1"
776 break
778 else
779 relconcat="$dir1/$dir2"
780 break
783 done
786 # func_ln_s SRC DEST
787 # Like ln -s, except use cp -p if ln -s fails.
788 func_ln_s ()
790 ln -s "$1" "$2" || {
791 echo "$progname: ln -s failed; falling back on cp -p" >&2
793 case "$1" in
794 /* | ?:*) # SRC is absolute.
795 cp_src="$1" ;;
796 *) # SRC is relative to the directory of DEST.
797 case "$2" in
798 */*) cp_src="${2%/*}/$1" ;;
799 *) cp_src="$1" ;;
800 esac
802 esac
804 cp -p "$cp_src" "$2"
808 # func_symlink_target SRC DEST
809 # Determines LINK_TARGET such that "ln -s LINK_TARGET DEST" will create a
810 # symbolic link DEST that points to SRC.
811 # Output:
812 # - link_target link target, relative to the directory of DEST
813 func_symlink_target ()
815 case "$1" in
816 /* | ?:*)
817 link_target="$1" ;;
818 *) # SRC is relative.
819 case "$2" in
820 /* | ?:*)
821 link_target="`pwd`/$1" ;;
822 *) # DEST is relative too.
823 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
824 test -n "$ln_destdir" || ln_destdir="."
825 func_relativize "$ln_destdir" "$1"
826 link_target="$reldir"
828 esac
830 esac
833 # func_symlink SRC DEST
834 # Like func_ln_s, except that SRC is given relative to the current directory (or
835 # absolute), not given relative to the directory of DEST.
836 func_symlink ()
838 func_symlink_target "$1" "$2"
839 func_ln_s "$link_target" "$2"
842 # func_symlink_if_changed SRC DEST
843 # Like func_symlink, but avoids munging timestamps if the link is correct.
844 # SRC is given relative to the current directory (or absolute).
845 func_symlink_if_changed ()
847 if test $# -ne 2; then
848 echo "usage: func_symlink_if_changed SRC DEST" >&2
850 func_symlink_target "$1" "$2"
851 ln_target=`func_readlink "$2"`
852 if test -h "$2" && test "$link_target" = "$ln_target"; then
854 else
855 rm -f "$2"
856 func_ln_s "$link_target" "$2"
860 # func_hardlink SRC DEST
861 # Like ln, except use cp -p if ln fails.
862 # SRC is given relative to the current directory (or absolute).
863 func_hardlink ()
865 ln "$1" "$2" || {
866 echo "$progname: ln failed; falling back on cp -p" >&2
867 cp -p "$1" "$2"
871 # Ensure an 'echo' command that
872 # 1. does not interpret backslashes and
873 # 2. does not print an error message "broken pipe" when writing into a pipe
874 # with no writers.
876 # Test cases for problem 1:
877 # echo '\n' | wc -l prints 1 when OK, 2 when KO
878 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
879 # Test cases for problem 2:
880 # echo hi | true frequently prints
881 # "bash: echo: write error: Broken pipe"
882 # to standard error in bash 3.2.
884 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
885 # BSD echo interprets '-n' as an option, which is also not desirable).
886 # Nowadays the problem occurs in 4 situations:
887 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
888 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
889 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
890 # - in zsh, when sh-emulation is not set,
891 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
892 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
893 # - in Solaris /bin/sh and OSF/1 /bin/sh.
894 # We try the following workarounds:
895 # - for all: respawn using $CONFIG_SHELL if that is set and works.
896 # - for bash >= 2.04: unset the shell option xpg_echo.
897 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
898 # - for bash < 2.0: define echo to a function that uses cat of a here document.
899 # - for zsh: turn sh-emulation on.
900 # - for ksh: alias echo to 'print -r'.
901 # - for ksh: alias echo to a function that uses cat of a here document.
902 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
903 # the ksh workaround.
904 # - otherwise: respawn using /bin/sh and rely on the workarounds.
905 # When respawning, we pass --no-reexec as first argument, so as to avoid
906 # turning this script into a fork bomb in unlucky situations.
908 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
909 # the 'printf' built-in. See
910 # <https://lists.gnu.org/r/bug-bash/2008-12/msg00050.html>
911 # <https://lists.gnu.org/r/bug-gnulib/2010-02/msg00154.html>
912 # The workaround is: define echo to a function that uses the printf built-in.
913 have_echo=
914 if echo '\t' | grep t > /dev/null; then
915 have_echo=yes # Lucky!
917 # Try the workarounds.
918 # Respawn using $CONFIG_SHELL if that is set and works.
919 if test -z "$have_echo" \
920 && test "X$1" != "X--no-reexec" \
921 && test -n "$CONFIG_SHELL" \
922 && test -f "$CONFIG_SHELL" \
923 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
924 exec $CONFIG_SHELL "$0" --no-reexec "$@"
925 exit 127
927 # For bash >= 2.04: unset the shell option xpg_echo.
928 if test -z "$have_echo" \
929 && test -n "$BASH_VERSION" \
930 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
931 shopt -o xpg_echo
932 have_echo=yes
934 # For bash >= 2.0: define echo to a function that uses the printf built-in.
935 # For bash < 2.0: define echo to a function that uses cat of a here document.
936 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
937 # Also handle problem 2, specific to bash 3.2, here.
938 if { test -z "$have_echo" \
939 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
941 && test -n "$BASH_VERSION"; then \
942 if type printf 2>/dev/null | grep / > /dev/null; then
943 # 'printf' is not a shell built-in.
944 echo ()
946 cat <<EOF
950 else
951 # 'printf' is a shell built-in.
952 echo ()
954 printf '%s\n' "$*"
957 if echo '\t' | grep t > /dev/null; then
958 have_echo=yes
961 # For zsh: turn sh-emulation on.
962 if test -z "$have_echo" \
963 && test -n "$ZSH_VERSION" \
964 && (emulate sh) >/dev/null 2>&1; then
965 emulate sh
967 # For ksh: alias echo to 'print -r'.
968 if test -z "$have_echo" \
969 && (type print) >/dev/null 2>&1; then
970 # A 'print' command exists.
971 if type print 2>/dev/null | grep / > /dev/null; then
973 else
974 # 'print' is a shell built-in.
975 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
976 # 'print' is the ksh shell built-in.
977 alias echo='print -r'
981 if test -z "$have_echo" \
982 && echo '\t' | grep t > /dev/null; then
983 have_echo=yes
985 # For ksh: alias echo to a function that uses cat of a here document.
986 # The ksh manual page says:
987 # "Aliasing is performed when scripts are read, not while they are executed.
988 # Therefore, for an alias to take effect, the alias definition command has
989 # to be executed before the command which references the alias is read."
990 # Because of this, we have to play strange tricks with have_echo, to ensure
991 # that the top-level statement containing the test starts after the 'alias'
992 # command.
993 if test -z "$have_echo"; then
994 bsd_echo ()
996 cat <<EOF
1000 if (alias echo=bsd_echo) 2>/dev/null; then
1001 alias echo=bsd_echo 2>/dev/null
1004 if test -z "$have_echo" \
1005 && echo '\t' | grep t > /dev/null; then
1006 have_echo=yes
1008 if test -z "$have_echo"; then
1009 if (alias echo=bsd_echo) 2>/dev/null; then
1010 unalias echo 2>/dev/null
1013 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
1014 if test -z "$have_echo" \
1015 && test "X$1" != "X--no-reexec" \
1016 && test -f /bin/ksh; then
1017 exec /bin/ksh "$0" --no-reexec "$@"
1018 exit 127
1020 # Otherwise: respawn using /bin/sh.
1021 if test -z "$have_echo" \
1022 && test "X$1" != "X--no-reexec" \
1023 && test -f /bin/sh; then
1024 exec /bin/sh "$0" --no-reexec "$@"
1025 exit 127
1027 if test -z "$have_echo"; then
1028 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
1030 if echo '\t' | grep t > /dev/null; then
1031 : # Works fine now.
1032 else
1033 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
1035 if test "X$1" = "X--no-reexec"; then
1036 shift
1039 # Unset CDPATH. Otherwise, output from 'cd dir' can surprise callers.
1040 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1042 # Determine the path separator early because the following option parsing code
1043 # requires that.
1044 func_determine_path_separator
1046 # Command-line option processing.
1047 # Removes the OPTIONS from the arguments. Sets the variables:
1048 # - mode one of: list, find, import, add-import, remove-import,
1049 # update, create-testdir, create-megatestdir, test, megatest,
1050 # copy-file
1051 # - destdir from --dir
1052 # - local_gnulib_path from --local-dir
1053 # - modcache true or false, from --cache-modules/--no-cache-modules
1054 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1055 # - libname, supplied_libname from --lib
1056 # - sourcebase from --source-base
1057 # - m4base from --m4-base
1058 # - pobase from --po-base
1059 # - docbase from --doc-base
1060 # - testsbase from --tests-base
1061 # - auxdir from --aux-dir
1062 # - inctests true if --with-tests was given, false if --without-tests
1063 # was given, blank otherwise
1064 # - incobsolete true if --with-obsolete was given, blank otherwise
1065 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
1066 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
1067 # otherwise
1068 # - inc_privileged_tests true if --with-privileged-tests was given, blank
1069 # otherwise
1070 # - inc_unportable_tests true if --with-unportable-tests was given, blank
1071 # otherwise
1072 # - inc_all_tests true if --with-all-tests was given, blank otherwise
1073 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
1074 # - excl_longrunning_tests true if --without-longrunning-tests was given,
1075 # blank otherwise
1076 # - excl_privileged_tests true if --without-privileged-tests was given, blank
1077 # otherwise
1078 # - excl_unportable_tests true if --without-unportable-tests was given, blank
1079 # otherwise
1080 # - single_configure true if --single-configure was given, false otherwise
1081 # - avoidlist list of modules to avoid, from --avoid
1082 # - cond_dependencies true if --conditional-dependencies was given, false if
1083 # --no-conditional-dependencies was given, blank otherwise
1084 # - lgpl yes or a number if --lgpl was given, blank otherwise
1085 # - gnu_make true if --gnu-make was given, false otherwise
1086 # - makefile_name from --makefile-name
1087 # - libtool true if --libtool was given, false if --no-libtool was
1088 # given, blank otherwise
1089 # - macro_prefix from --macro-prefix
1090 # - po_domain from --po-domain
1091 # - witness_c_macro from --witness-c-macro
1092 # - vc_files true if --vc-files was given, false if --no-vc-files was
1093 # given, blank otherwise
1094 # - autoconf_minversion minimum supported autoconf version
1095 # - doit : if actions shall be executed, false if only to be printed
1096 # - copymode symlink if --symlink or --more-symlinks was given,
1097 # hardlink if --hardlink or --more-hardlinks was given,
1098 # blank otherwise
1099 # - lcopymode symlink if --local-symlink was given,
1100 # hardlink if --local-hardlink was given,
1101 # blank otherwise
1102 # - do_copyrights blank if --more-symlinks or --more-hardlinks was given,
1103 # true otherwise
1105 mode=
1106 destdir=
1107 local_gnulib_path=
1108 modcache=true
1109 verbose=0
1110 libname=libgnu
1111 supplied_libname=
1112 sourcebase=
1113 m4base=
1114 pobase=
1115 docbase=
1116 testsbase=
1117 auxdir=
1118 inctests=
1119 incobsolete=
1120 inc_cxx_tests=
1121 inc_longrunning_tests=
1122 inc_privileged_tests=
1123 inc_unportable_tests=
1124 inc_all_tests=
1125 excl_cxx_tests=
1126 excl_longrunning_tests=
1127 excl_privileged_tests=
1128 excl_unportable_tests=
1129 single_configure=false
1130 avoidlist=
1131 cond_dependencies=
1132 lgpl=
1133 gnu_make=false
1134 makefile_name=
1135 libtool=
1136 macro_prefix=
1137 po_domain=
1138 witness_c_macro=
1139 vc_files=
1140 doit=:
1141 copymode=
1142 lcopymode=
1143 do_copyrights=true
1145 supplied_opts="$@"
1147 while test $# -gt 0; do
1148 case "$1" in
1149 --list | --lis )
1150 mode=list
1151 shift ;;
1152 --find | --fin | --fi | --f )
1153 mode=find
1154 shift ;;
1155 --import | --impor | --impo | --imp | --im | --i )
1156 mode=import
1157 shift ;;
1158 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1159 mode=add-import
1160 shift ;;
1161 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1162 mode=remove-import
1163 shift ;;
1164 --update | --updat | --upda | --upd | --up | --u )
1165 mode=update
1166 shift ;;
1167 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1168 mode=create-testdir
1169 shift ;;
1170 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1171 mode=create-megatestdir
1172 shift ;;
1173 --test | --tes | --te | --t )
1174 mode=test
1175 shift ;;
1176 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1177 mode=megatest
1178 shift ;;
1179 --extract-* )
1180 mode=`echo "X$1" | sed -e 's/^X--//'`
1181 shift ;;
1182 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1183 mode=copy-file
1184 shift ;;
1185 --dir )
1186 shift
1187 if test $# = 0; then
1188 func_fatal_error "missing argument for --dir"
1190 destdir=$1
1191 shift ;;
1192 --dir=* )
1193 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1194 shift ;;
1195 --local-dir )
1196 shift
1197 if test $# = 0; then
1198 func_fatal_error "missing argument for --local-dir"
1200 func_path_prepend local_gnulib_path "$1"
1201 shift ;;
1202 --local-dir=* )
1203 local_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1204 func_path_prepend local_gnulib_path "$local_dir"
1205 shift ;;
1206 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1207 modcache=true
1208 shift ;;
1209 --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 )
1210 modcache=false
1211 shift ;;
1212 --verbose | --verbos | --verbo | --verb )
1213 verbose=`expr $verbose + 1`
1214 shift ;;
1215 --quiet | --quie | --qui | --qu | --q )
1216 verbose=`expr $verbose - 1`
1217 shift ;;
1218 --lib )
1219 shift
1220 if test $# = 0; then
1221 func_fatal_error "missing argument for --lib"
1223 libname=$1
1224 supplied_libname=true
1225 shift ;;
1226 --lib=* )
1227 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1228 supplied_libname=true
1229 shift ;;
1230 --source-base )
1231 shift
1232 if test $# = 0; then
1233 func_fatal_error "missing argument for --source-base"
1235 sourcebase=$1
1236 shift ;;
1237 --source-base=* )
1238 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1239 shift ;;
1240 --m4-base )
1241 shift
1242 if test $# = 0; then
1243 func_fatal_error "missing argument for --m4-base"
1245 m4base=$1
1246 shift ;;
1247 --m4-base=* )
1248 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1249 shift ;;
1250 --po-base )
1251 shift
1252 if test $# = 0; then
1253 func_fatal_error "missing argument for --po-base"
1255 pobase=$1
1256 shift ;;
1257 --po-base=* )
1258 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1259 shift ;;
1260 --doc-base )
1261 shift
1262 if test $# = 0; then
1263 func_fatal_error "missing argument for --doc-base"
1265 docbase=$1
1266 shift ;;
1267 --doc-base=* )
1268 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1269 shift ;;
1270 --tests-base )
1271 shift
1272 if test $# = 0; then
1273 func_fatal_error "missing argument for --tests-base"
1275 testsbase=$1
1276 shift ;;
1277 --tests-base=* )
1278 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1279 shift ;;
1280 --aux-dir )
1281 shift
1282 if test $# = 0; then
1283 func_fatal_error "missing argument for --aux-dir"
1285 auxdir=$1
1286 shift ;;
1287 --aux-dir=* )
1288 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1289 shift ;;
1290 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1291 inctests=true
1292 shift ;;
1293 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1294 incobsolete=true
1295 shift ;;
1296 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1297 inc_cxx_tests=true
1298 shift ;;
1299 --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)
1300 inc_longrunning_tests=true
1301 shift ;;
1302 --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)
1303 inc_privileged_tests=true
1304 shift ;;
1305 --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)
1306 inc_unportable_tests=true
1307 shift ;;
1308 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1309 inc_all_tests=true
1310 shift ;;
1311 --without-tests | --without-test | --without-tes | --without-te | --without-t)
1312 inctests=false
1313 shift ;;
1314 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1315 excl_cxx_tests=true
1316 shift ;;
1317 --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)
1318 excl_longrunning_tests=true
1319 shift ;;
1320 --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)
1321 excl_privileged_tests=true
1322 shift ;;
1323 --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)
1324 excl_unportable_tests=true
1325 shift ;;
1326 --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)
1327 single_configure=true
1328 shift ;;
1329 --avoid )
1330 shift
1331 if test $# = 0; then
1332 func_fatal_error "missing argument for --avoid"
1334 func_append avoidlist " $1"
1335 shift ;;
1336 --avoid=* )
1337 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1338 func_append avoidlist " $arg"
1339 shift ;;
1340 --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)
1341 cond_dependencies=true
1342 shift ;;
1343 --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)
1344 cond_dependencies=false
1345 shift ;;
1346 --lgpl )
1347 lgpl=yes
1348 shift ;;
1349 --lgpl=* )
1350 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1351 case "$arg" in
1352 2 | 3orGPLv2 | 3) ;;
1353 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1354 esac
1355 lgpl=$arg
1356 shift ;;
1357 --gnu-make )
1358 gnu_make=true
1359 shift ;;
1360 --makefile-name )
1361 shift
1362 if test $# = 0; then
1363 func_fatal_error "missing argument for --makefile-name"
1365 makefile_name="$1"
1366 shift ;;
1367 --makefile-name=* )
1368 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1369 shift ;;
1370 --libtool )
1371 libtool=true
1372 shift ;;
1373 --no-libtool )
1374 libtool=false
1375 shift ;;
1376 --macro-prefix )
1377 shift
1378 if test $# = 0; then
1379 func_fatal_error "missing argument for --macro-prefix"
1381 macro_prefix="$1"
1382 shift ;;
1383 --macro-prefix=* )
1384 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1385 shift ;;
1386 --po-domain )
1387 shift
1388 if test $# = 0; then
1389 func_fatal_error "missing argument for --po-domain"
1391 po_domain="$1"
1392 shift ;;
1393 --po-domain=* )
1394 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1395 shift ;;
1396 --witness-c-macro )
1397 shift
1398 if test $# = 0; then
1399 func_fatal_error "missing argument for --witness-c-macro"
1401 witness_c_macro="$1"
1402 shift ;;
1403 --witness-c-macro=* )
1404 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1405 shift ;;
1406 --vc-files )
1407 vc_files=true
1408 shift ;;
1409 --no-vc-files )
1410 vc_files=false
1411 shift ;;
1412 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1413 # A no-op for backward compatibility.
1414 shift ;;
1415 --dry-run )
1416 doit=false
1417 shift ;;
1418 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1419 copymode=symlink
1420 shift ;;
1421 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1422 lcopymode=symlink
1423 shift ;;
1424 -h | --hardlink | --hardlin | --hardli | --hardl | --hard | --har | --ha )
1425 copymode=hardlink
1426 shift ;;
1427 --local-hardlink | --local-hardlin | --local-hardli | --local-hardl | --local-hard | --local-har | --local-ha | --local-h )
1428 lcopymode=hardlink
1429 shift ;;
1430 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s )
1431 copymode=symlink
1432 do_copyrights=
1433 shift ;;
1434 -H | --more-hardlinks | --more-hardlink | --more-hardlin | --more-hardli | --more-hardl | --more-hard | --more-har | --more-ha | --more-h )
1435 copymode=hardlink
1436 do_copyrights=
1437 shift ;;
1438 --help | --hel | --he )
1439 func_usage
1440 func_exit $? ;;
1441 --version | --versio | --versi | --vers )
1442 func_version
1443 func_exit $? ;;
1444 -- )
1445 # Stop option processing
1446 shift
1447 break ;;
1448 -* )
1449 echo "gnulib-tool: unknown option $1" 1>&2
1450 echo "Try 'gnulib-tool --help' for more information." 1>&2
1451 func_exit 1 ;;
1453 break ;;
1454 esac
1455 done
1457 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1458 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1459 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1460 || test "$single_configure" != false; then
1461 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1462 echo "Try 'gnulib-tool --help' for more information." 1>&2
1463 func_exit 1
1466 if test "$mode" = update; then
1467 if test $# != 0; then
1468 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1469 echo "Try 'gnulib-tool --help' for more information." 1>&2
1470 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1471 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1472 func_exit 1
1474 if test -n "$local_gnulib_path" || test -n "$supplied_libname" \
1475 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1476 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1477 || test -n "$inctests" || test -n "$incobsolete" \
1478 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1479 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1480 || test -n "$inc_all_tests" \
1481 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1482 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1483 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1484 || test -n "$macro_prefix" || test -n "$po_domain" \
1485 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1486 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1487 echo "Try 'gnulib-tool --help' for more information." 1>&2
1488 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1489 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1490 func_exit 1
1493 if test -n "$pobase" && test -z "$po_domain"; then
1494 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1495 echo "Try 'gnulib-tool --help' for more information." 1>&2
1496 func_exit 1
1498 if test -z "$pobase" && test -n "$po_domain"; then
1499 func_warning "--po-domain has no effect without a --po-base option"
1501 case $mode,$gnu_make in
1502 *test*,true)
1503 echo "gnulib-tool: --gnu-make not supported when including tests"
1504 func_exit 1;;
1505 esac
1506 # Canonicalize the inctests variable.
1507 case "$mode" in
1508 import | add-import | remove-import | update)
1509 if test -z "$inctests"; then
1510 inctests=false
1513 create-testdir | create-megatestdir | test | megatest)
1514 if test -z "$inctests"; then
1515 inctests=true
1518 esac
1519 # Now the only possible values of "$inctests" are true and false
1520 # (or blank but then it is irrelevant).
1522 # Determine the minimum supported autoconf version from the project's
1523 # configure.ac.
1524 DEFAULT_AUTOCONF_MINVERSION="2.63"
1525 autoconf_minversion=
1526 configure_ac=
1527 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1528 && test -n "$destdir"; then
1529 if test -f "$destdir"/configure.ac; then
1530 configure_ac="$destdir/configure.ac"
1531 else
1532 if test -f "$destdir"/configure.in; then
1533 configure_ac="$destdir/configure.in"
1536 else
1537 if test -f configure.ac; then
1538 configure_ac="configure.ac"
1539 else
1540 if test -f configure.in; then
1541 configure_ac="configure.in"
1545 if test -n "$configure_ac"; then
1546 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1547 # because when some m4 files are omitted from a version control repository,
1548 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1549 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1550 # autom4te: m4 failed with exit status: 1
1551 prereqs=
1552 my_sed_traces='
1553 s,#.*$,,
1554 s,^dnl .*$,,
1555 s, dnl .*$,,
1556 /AC_PREREQ/ {
1557 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1559 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1560 if test -n "$prereqs"; then
1561 autoconf_minversion=`
1562 for version in $prereqs; do echo $version; done |
1563 LC_ALL=C sort -nru | sed -e 1q
1567 if test -z "$autoconf_minversion"; then
1568 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1570 case "$autoconf_minversion" in
1571 1.* | 2.[0-5]* | 2.6[0-2]*)
1572 func_fatal_error "minimum supported autoconf version is 2.63. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1573 esac
1575 # Remove trailing slashes from the directory names. This is necessary for
1576 # m4base (to avoid an error in func_import) and optional for the others.
1577 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1578 old_local_gnulib_path=$local_gnulib_path
1579 save_IFS=$IFS
1580 IFS=:
1581 local_gnulib_path=
1582 for dir in $old_local_gnulib_path
1584 case "$dir" in
1585 */ ) dir=`echo "$dir" | sed -e "$sed_trimtrailingslashes"` ;;
1586 esac
1587 func_path_append local_gnulib_path "$dir"
1588 done
1589 IFS=$save_IFS
1590 case "$sourcebase" in
1591 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1592 esac
1593 case "$m4base" in
1594 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1595 esac
1596 case "$pobase" in
1597 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1598 esac
1599 case "$docbase" in
1600 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1601 esac
1602 case "$testsbase" in
1603 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1604 esac
1605 case "$auxdir" in
1606 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1607 esac
1610 func_gnulib_dir
1611 func_tmpdir
1612 trap 'exit_status=$?
1613 if test "$signal" != 0; then
1614 echo "caught signal $signal" >&2
1616 rm -rf "$tmp"
1617 exit $exit_status' 0
1618 for signal in 1 2 3 13 15; do
1619 trap '{ signal='$signal'; func_exit 1; }' $signal
1620 done
1621 signal=0
1623 # Note: The 'eval' silences stderr output in dash.
1624 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1625 # Zsh 4 and Bash 4 have associative arrays.
1626 have_associative=true
1627 else
1628 # For other shells, use 'eval' with computed shell variable names.
1629 have_associative=false
1632 # func_lookup_local_file_cb dir file
1633 # return true and set func_lookup_local_file_result if the file 'dir/file'
1634 # exists
1635 func_lookup_local_file_cb ()
1637 test -n "$func_lookup_local_file_result" && return 1 # already found?
1638 test -f "$1/$2" || return 1
1639 func_lookup_local_file_result=$1/$2
1643 # func_lookup_local_file file
1644 # looks up a file in $local_gnulib_path.
1645 # Input:
1646 # - local_gnulib_path from --local-dir
1647 # Output:
1648 # - func_lookup_local_file_result name of the file, valid only when the
1649 # function succeeded.
1650 func_lookup_local_file ()
1652 func_lookup_local_file_result=
1653 func_path_foreach "$local_gnulib_path" func_lookup_local_file_cb %dir% "$1"
1656 # func_lookup_file file
1657 # looks up a file in $local_gnulib_path or $gnulib_dir, or combines it through
1658 # 'patch'.
1659 # Input:
1660 # - local_gnulib_path from --local-dir
1661 # Output:
1662 # - lookedup_file name of the merged (combined) file
1663 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1664 func_lookup_file ()
1666 lkfile="$1"
1667 if func_lookup_local_file "$lkfile"; then
1668 lookedup_file=$func_lookup_local_file_result
1669 lookedup_tmp=
1670 else
1671 if test -f "$gnulib_dir/$lkfile"; then
1672 if func_lookup_local_file "$lkfile.diff"; then
1673 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1674 rm -f "$tmp/$lkbase"
1675 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1676 patch -s "$tmp/$lkbase" < "$func_lookup_local_file_result" >&2 \
1677 || func_fatal_error "patch file $func_lookup_local_file_result didn't apply cleanly"
1678 lookedup_file="$tmp/$lkbase"
1679 lookedup_tmp=true
1680 else
1681 lookedup_file="$gnulib_dir/$lkfile"
1682 lookedup_tmp=
1684 else
1685 func_fatal_error "file $gnulib_dir/$lkfile not found"
1690 # func_sanitize_modulelist
1691 # receives a list of possible module names on standard input, one per line.
1692 # It removes those which are just file names unrelated to modules, and outputs
1693 # the resulting list to standard output, one per line.
1694 func_sanitize_modulelist ()
1696 sed -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1697 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1698 -e '/^README$/d' -e '/\/README$/d' \
1699 -e '/^TEMPLATE$/d' \
1700 -e '/^TEMPLATE-EXTENDED$/d' \
1701 -e '/^TEMPLATE-TESTS$/d' \
1702 -e '/^\..*/d' \
1703 -e '/~$/d'
1707 # func_modules_in_dir dir
1708 # outputs all module files in dir to standard output.
1709 func_modules_in_dir ()
1711 (test -d "$1" && cd "$1" && find modules -type f -print)
1714 # func_all_modules
1715 # Input:
1716 # - local_gnulib_path from --local-dir
1717 func_all_modules ()
1719 # Filter out metainformation files like README, which are not modules.
1720 # Filter out unit test modules; they can be retrieved through
1721 # --extract-tests-module if desired.
1723 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1724 func_path_foreach "$local_gnulib_path" func_modules_in_dir %dir% | sed -e 's,^modules/,,' -e 's,\.diff$,,'
1726 | func_sanitize_modulelist \
1727 | sed -e '/-tests$/d' \
1728 | LC_ALL=C sort -u
1731 # func_exists_local_module dir module
1732 # returns true if module exists in dir
1733 func_exists_local_module ()
1735 test -d "$1/modules" && test -f "$1/modules/$2";
1738 # func_exists_module module
1739 # tests whether a module, given by name, exists
1740 # Input:
1741 # - local_gnulib_path from --local-dir
1742 func_exists_module ()
1744 { test -f "$gnulib_dir/modules/$1" \
1745 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1" ; } \
1746 && test "ChangeLog" != "$1" \
1747 && test "COPYING" != "$1" \
1748 && test "README" != "$1" \
1749 && test "TEMPLATE" != "$1" \
1750 && test "TEMPLATE-EXTENDED" != "$1" \
1751 && test "TEMPLATE-TESTS" != "$1"
1754 # func_verify_module
1755 # verifies a module name
1756 # Input:
1757 # - local_gnulib_path from --local-dir
1758 # - module module name argument
1759 # Output:
1760 # - module unchanged if OK, empty if not OK
1761 # - lookedup_file if OK: name of the merged (combined) module description file
1762 # - lookedup_tmp if OK: true if it is located in the tmp directory, blank otherwise
1763 func_verify_module ()
1765 if func_exists_module "$module"; then
1766 # OK, $module is a correct module name.
1767 # Verify that building the module description with 'patch' succeeds.
1768 func_lookup_file "modules/$module"
1769 else
1770 func_warning "module $module doesn't exist"
1771 module=
1775 # func_verify_nontests_module
1776 # verifies a module name, excluding tests modules
1777 # Input:
1778 # - local_gnulib_path from --local-dir
1779 # - module module name argument
1780 func_verify_nontests_module ()
1782 case "$module" in
1783 *-tests ) module= ;;
1784 * ) func_verify_module ;;
1785 esac
1788 # func_verify_tests_module
1789 # verifies a module name, considering only tests modules
1790 # Input:
1791 # - local_gnulib_path from --local-dir
1792 # - module module name argument
1793 func_verify_tests_module ()
1795 case "$module" in
1796 *-tests ) func_verify_module ;;
1797 * ) module= ;;
1798 esac
1801 # Suffix of a sed expression that extracts a particular field from a
1802 # module description.
1803 # A field starts with a line that contains a keyword, such as 'Description',
1804 # followed by a colon and optional whitespace. All following lines, up to
1805 # the next field (or end of file if there is none) form the contents of the
1806 # field.
1807 # An absent field is equivalent to a field with empty contents.
1808 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1809 sed_extract_prog=':[ ]*$/ {
1812 s/^Description:[ ]*$//
1813 s/^Comment:[ ]*$//
1814 s/^Status:[ ]*$//
1815 s/^Notice:[ ]*$//
1816 s/^Applicability:[ ]*$//
1817 s/^Files:[ ]*$//
1818 s/^Depends-on:[ ]*$//
1819 s/^configure\.ac-early:[ ]*$//
1820 s/^configure\.ac:[ ]*$//
1821 s/^Makefile\.am:[ ]*$//
1822 s/^Include:[ ]*$//
1823 s/^Link:[ ]*$//
1824 s/^License:[ ]*$//
1825 s/^Maintainer:[ ]*$//
1832 # Piece of a sed expression that converts a field header line to a shell
1833 # variable name,
1834 # NOTE: Keep this in sync with sed_extract_prog above!
1835 sed_extract_field_header='
1836 s/^Description:[ ]*$/description/
1837 s/^Comment:[ ]*$/comment/
1838 s/^Status:[ ]*$/status/
1839 s/^Notice:[ ]*$/notice/
1840 s/^Applicability:[ ]*$/applicability/
1841 s/^Files:[ ]*$/files/
1842 s/^Depends-on:[ ]*$/dependson/
1843 s/^configure\.ac-early:[ ]*$/configureac_early/
1844 s/^configure\.ac:[ ]*$/configureac/
1845 s/^Makefile\.am:[ ]*$/makefile/
1846 s/^Include:[ ]*$/include/
1847 s/^Link:[ ]*$/link/
1848 s/^License:[ ]*$/license/
1849 s/^Maintainer:[ ]*$/maintainer/'
1851 if $modcache; then
1853 if $have_associative; then
1855 # Declare the associative arrays.
1856 declare -A modcache_cached
1857 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1858 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1859 eval "$declare_script"
1861 else
1863 # func_cache_var module
1864 # computes the cache variable name corresponding to $module.
1865 # Note: This computation can map different module names to the same
1866 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1867 # to protect against this case.
1868 # Output:
1869 # - cachevar a shell variable name
1870 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1871 # Bash 2.0 and newer, ksh, and zsh support the syntax
1872 # ${param//pattern/replacement}
1873 # as a shorthand for
1874 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1875 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1876 eval 'func_cache_var ()
1878 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1880 else
1881 func_cache_var ()
1883 case $1 in
1884 *[!a-zA-Z0-9_]*)
1885 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1887 cachevar=c_$1 ;;
1888 esac
1894 # func_init_sed_convert_to_cache_statements
1895 # Input:
1896 # - modcachevar_assignment
1897 # Output:
1898 # - sed_convert_to_cache_statements
1899 func_init_sed_convert_to_cache_statements ()
1901 # 'sed' script that turns a module description into shell script
1902 # assignments, suitable to be eval'ed. All active characters are escaped.
1903 # This script turns
1904 # Description:
1905 # Some module's description
1907 # Files:
1908 # lib/file.h
1909 # into:
1910 # modcache_description[$1]=\
1911 # 'Some module'"'"'s description
1913 # modcache_files[$1]=\
1914 # 'lib/file.h'
1915 # or:
1916 # c_MODULE_description_set=set; c_MODULE_description=\
1917 # 'Some module'"'"'s description
1919 # c_MODULE_files_set=set; c_MODULE_files=\
1920 # 'lib/file.h'
1921 # The script consists of two parts:
1922 # 1) Ignore the lines before the first field header.
1923 # 2) A loop, treating non-field-header lines by escaping single quotes
1924 # and adding a closing quote in the last line,
1925 sed_convert_to_cache_statements="
1926 :llla
1927 # Here we have not yet seen a field header.
1929 # See if the current line contains a field header.
1930 t llla1
1931 :llla1
1932 ${sed_extract_field_header}
1933 t lllb
1935 # No field header. Ignore the line.
1937 # Read the next line. Upon EOF, just exit.
1939 b llla
1941 :lllb
1942 # The current line contains a field header.
1944 # Turn it into the beginning of an assignment.
1945 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1947 # Move it to the hold space. Don't print it yet,
1948 # because we want no assignment if the field is empty.
1951 # Read the next line.
1952 # Upon EOF, the field was empty. Print no assignment. Just exit.
1955 # See if the current line contains a field header.
1956 t lllb1
1957 :lllb1
1958 ${sed_extract_field_header}
1959 # If it is, the previous field was empty. Print no assignment.
1960 t lllb
1962 # Not a field header.
1964 # Print the previous line, held in the hold space.
1969 # Transform single quotes.
1970 s/'/'\"'\"'/g
1972 # Prepend a single quote.
1973 s/^/'/
1975 :lllc
1977 # Move it to the hold space.
1980 # Read the next line.
1981 # Upon EOF, branch.
1983 b llle
1987 # See if the current line contains a field header.
1988 t lllc1
1989 :lllc1
1990 ${sed_extract_field_header}
1991 t llld
1993 # Print the previous line, held in the hold space.
1998 # Transform single quotes.
1999 s/'/'\"'\"'/g
2001 b lllc
2003 :llld
2004 # A field header.
2005 # Print the previous line, held in the hold space, with a single quote
2006 # to end the assignment.
2008 s/\$/'/
2012 b lllb
2014 :llle
2015 # EOF seen.
2016 # Print the previous line, held in the hold space, with a single quote
2017 # to end the assignment.
2019 s/\$/'/
2021 # Exit.
2024 if ! $sed_comments; then
2025 # Remove comments.
2026 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
2027 | sed -e 's/^ *//' -e 's/^#.*//'`
2031 if $have_associative; then
2032 # sed_convert_to_cache_statements does not depend on the module.
2033 modcachevar_assignment='modcache_\1[$1]='
2034 func_init_sed_convert_to_cache_statements
2037 # func_cache_lookup_module module
2039 # looks up a module, like 'func_lookup_file modules/$module', and stores all
2040 # of its relevant data in a cache in the memory of the processing shell. If
2041 # already cached, it does not look it up again, thus saving file access time.
2042 # Parameters:
2043 # - module non-empty string
2044 # Output if $have_associative:
2045 # - modcache_cached[$module] set to yes
2046 # - modcache_description[$module] ==
2047 # - modcache_status[$module] \ set to the field's value, minus the
2048 # - ... / final newline,
2049 # - modcache_maintainer[$module] == or unset if the field's value is empty
2050 # Output if ! $have_associative:
2051 # - cachevar a shell variable name
2052 # - ${cachevar}_cached set to $module
2053 # - ${cachevar}_description ==
2054 # - ${cachevar}_status \ set to the field's value, minus the
2055 # - ... / final newline,
2056 # - ${cachevar}_maintainer == or unset if the field's value is empty
2057 # - ${cachevar}_description_set ==
2058 # - ${cachevar}_status_set \ set to non-empty if the field's value
2059 # - ... / is non-empty,
2060 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
2061 func_cache_lookup_module ()
2063 if $have_associative; then
2064 eval 'cached=${modcache_cached[$1]}'
2065 else
2066 func_cache_var "$1"
2067 eval "cached=\"\$${cachevar}_cached\""
2069 if test -z "$cached"; then
2070 # Not found in cache. Look it up on the file system.
2071 func_lookup_file "modules/$1"
2072 if $have_associative; then
2073 eval 'modcache_cached[$1]=yes'
2074 else
2075 eval "${cachevar}_cached=\"\$1\""
2077 if ! $have_associative; then
2078 # sed_convert_to_cache_statements depends on the module.
2079 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
2080 func_init_sed_convert_to_cache_statements
2082 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
2083 eval "$cache_statements"
2084 else
2085 if ! $have_associative; then
2086 if test "$1" != "$cached"; then
2087 func_fatal_error "cache variable collision between $1 and $cached"
2095 # func_get_description module
2096 # Input:
2097 # - local_gnulib_path from --local-dir
2098 # - modcache true or false, from --cache-modules/--no-cache-modules
2099 func_get_description ()
2101 if ! $modcache; then
2102 func_lookup_file "modules/$1"
2103 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
2104 else
2105 func_cache_lookup_module "$1"
2106 # Output the field's value, including the final newline (if any).
2107 if $have_associative; then
2108 if eval 'test -n "${modcache_description[$1]+set}"'; then
2109 eval 'echo "${modcache_description[$1]}"'
2111 else
2112 eval "field_set=\"\$${cachevar}_description_set\""
2113 if test -n "$field_set"; then
2114 eval "field_value=\"\$${cachevar}_description\""
2115 echo "${field_value}"
2121 # func_get_comment module
2122 # Input:
2123 # - local_gnulib_path from --local-dir
2124 # - modcache true or false, from --cache-modules/--no-cache-modules
2125 func_get_comment ()
2127 if ! $modcache; then
2128 func_lookup_file "modules/$1"
2129 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
2130 else
2131 func_cache_lookup_module "$1"
2132 # Output the field's value, including the final newline (if any).
2133 if $have_associative; then
2134 if eval 'test -n "${modcache_comment[$1]+set}"'; then
2135 eval 'echo "${modcache_comment[$1]}"'
2137 else
2138 eval "field_set=\"\$${cachevar}_comment_set\""
2139 if test -n "$field_set"; then
2140 eval "field_value=\"\$${cachevar}_comment\""
2141 echo "${field_value}"
2147 # func_get_status module
2148 # Input:
2149 # - local_gnulib_path from --local-dir
2150 # - modcache true or false, from --cache-modules/--no-cache-modules
2151 func_get_status ()
2153 if ! $modcache; then
2154 func_lookup_file "modules/$1"
2155 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
2156 else
2157 func_cache_lookup_module "$1"
2158 # Output the field's value, including the final newline (if any).
2159 if $have_associative; then
2160 if eval 'test -n "${modcache_status[$1]+set}"'; then
2161 eval 'echo "${modcache_status[$1]}"'
2163 else
2164 eval "field_set=\"\$${cachevar}_status_set\""
2165 if test -n "$field_set"; then
2166 eval "field_value=\"\$${cachevar}_status\""
2167 echo "${field_value}"
2173 # func_get_notice module
2174 # Input:
2175 # - local_gnulib_path from --local-dir
2176 # - modcache true or false, from --cache-modules/--no-cache-modules
2177 func_get_notice ()
2179 if ! $modcache; then
2180 func_lookup_file "modules/$1"
2181 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
2182 else
2183 func_cache_lookup_module "$1"
2184 # Output the field's value, including the final newline (if any).
2185 if $have_associative; then
2186 if eval 'test -n "${modcache_notice[$1]+set}"'; then
2187 eval 'echo "${modcache_notice[$1]}"'
2189 else
2190 eval "field_set=\"\$${cachevar}_notice_set\""
2191 if test -n "$field_set"; then
2192 eval "field_value=\"\$${cachevar}_notice\""
2193 echo "${field_value}"
2199 # func_get_applicability module
2200 # Input:
2201 # - local_gnulib_path from --local-dir
2202 # - modcache true or false, from --cache-modules/--no-cache-modules
2203 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
2204 func_get_applicability ()
2206 if ! $modcache; then
2207 func_lookup_file "modules/$1"
2208 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2209 else
2210 func_cache_lookup_module "$1"
2211 # Get the field's value, without the final newline.
2212 if $have_associative; then
2213 eval 'my_applicability="${modcache_applicability[$1]}"'
2214 else
2215 eval "my_applicability=\"\$${cachevar}_applicability\""
2218 if test -n "$my_applicability"; then
2219 echo $my_applicability
2220 else
2221 # The default is 'main' or 'tests', depending on the module's name.
2222 case $1 in
2223 *-tests) echo "tests";;
2224 *) echo "main";;
2225 esac
2229 # func_get_filelist module
2230 # Input:
2231 # - local_gnulib_path from --local-dir
2232 # - modcache true or false, from --cache-modules/--no-cache-modules
2233 func_get_filelist ()
2235 if ! $modcache; then
2236 func_lookup_file "modules/$1"
2237 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2238 else
2239 func_cache_lookup_module "$1"
2240 # Output the field's value, including the final newline (if any).
2241 if $have_associative; then
2242 if eval 'test -n "${modcache_files[$1]+set}"'; then
2243 eval 'echo "${modcache_files[$1]}"'
2245 else
2246 eval "field_set=\"\$${cachevar}_files_set\""
2247 if test -n "$field_set"; then
2248 eval "field_value=\"\$${cachevar}_files\""
2249 echo "${field_value}"
2253 echo m4/00gnulib.m4
2254 echo m4/gnulib-common.m4
2257 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2258 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2259 # elements starting with prefix and ending with suffix are considered.
2260 # Processing: removed_prefix and removed_suffix are removed from each element,
2261 # added_prefix and added_suffix are added to each element.
2262 # prefix, suffix should not contain shell-special characters.
2263 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2264 # added_prefix, added_suffix should not contain the characters \|&.
2265 func_filter_filelist ()
2267 if test "$2" != "$nl" \
2268 || { $fast_func_append \
2269 && { test -z "$6" || $fast_func_remove_prefix; } \
2270 && { test -z "$7" || $fast_func_remove_suffix; }; \
2271 }; then
2272 ffflist=
2273 for fff in $3; do
2274 # Do not quote possibly-empty parameters in case patterns,
2275 # AIX and HP-UX ksh won't match them if they are empty.
2276 case "$fff" in
2277 $4*$5)
2278 if test -n "$6"; then
2279 func_remove_prefix fff "$6"
2281 if test -n "$7"; then
2282 func_remove_suffix fff "$7"
2284 fff="$8${fff}$9"
2285 if test -z "$ffflist"; then
2286 ffflist="${fff}"
2287 else
2288 func_append ffflist "$2${fff}"
2291 esac
2292 done
2293 else
2294 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2295 ffflist=`for fff in $3; do
2296 case "$fff" in
2297 $4*$5) echo "$fff" ;;
2298 esac
2299 done | sed -e "$sed_fff_filter"`
2301 eval "$1=\"\$ffflist\""
2304 # func_get_dependencies module
2305 # Input:
2306 # - local_gnulib_path from --local-dir
2307 # - modcache true or false, from --cache-modules/--no-cache-modules
2308 func_get_dependencies ()
2310 # ${module}-tests implicitly depends on ${module}, if that module exists.
2311 case "$1" in
2312 *-tests)
2313 fgd1="$1"
2314 func_remove_suffix fgd1 '-tests'
2315 if func_exists_module "$fgd1"; then
2316 echo "$fgd1"
2319 esac
2320 # Then the explicit dependencies listed in the module description.
2321 { if ! $modcache; then
2322 func_lookup_file "modules/$1"
2323 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2324 else
2325 func_cache_lookup_module "$1"
2326 # Output the field's value, including the final newline (if any).
2327 if $have_associative; then
2328 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2329 eval 'echo "${modcache_dependson[$1]}"'
2331 else
2332 eval "field_set=\"\$${cachevar}_dependson_set\""
2333 if test -n "$field_set"; then
2334 eval "field_value=\"\$${cachevar}_dependson\""
2335 echo "${field_value}"
2340 | sed -e '/^#/d'
2343 sed_dependencies_without_conditions='s/ *\[.*//'
2345 # func_get_autoconf_early_snippet module
2346 # Input:
2347 # - local_gnulib_path from --local-dir
2348 # - modcache true or false, from --cache-modules/--no-cache-modules
2349 func_get_autoconf_early_snippet ()
2351 if ! $modcache; then
2352 func_lookup_file "modules/$1"
2353 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2354 else
2355 func_cache_lookup_module "$1"
2356 # Output the field's value, including the final newline (if any).
2357 if $have_associative; then
2358 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2359 eval 'echo "${modcache_configureac_early[$1]}"'
2361 else
2362 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2363 if test -n "$field_set"; then
2364 eval "field_value=\"\$${cachevar}_configureac_early\""
2365 echo "${field_value}"
2371 # func_get_autoconf_snippet module
2372 # Input:
2373 # - local_gnulib_path from --local-dir
2374 # - modcache true or false, from --cache-modules/--no-cache-modules
2375 func_get_autoconf_snippet ()
2377 if ! $modcache; then
2378 func_lookup_file "modules/$1"
2379 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2380 else
2381 func_cache_lookup_module "$1"
2382 # Output the field's value, including the final newline (if any).
2383 if $have_associative; then
2384 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2385 eval 'echo "${modcache_configureac[$1]}"'
2387 else
2388 eval "field_set=\"\$${cachevar}_configureac_set\""
2389 if test -n "$field_set"; then
2390 eval "field_value=\"\$${cachevar}_configureac\""
2391 echo "${field_value}"
2397 # Concatenate lines with trailing slash.
2398 # $1 is an optional filter to restrict the
2399 # concatenation to groups starting with that expression
2400 combine_lines() {
2401 sed -e "/$1.*"'\\$/{
2404 s/\\\n/ /
2405 s/\\$/\\/
2410 # func_get_automake_snippet_conditional module
2411 # returns the part of the Makefile.am snippet that can be put inside Automake
2412 # conditionals.
2413 # Input:
2414 # - local_gnulib_path from --local-dir
2415 # - modcache true or false, from --cache-modules/--no-cache-modules
2416 func_get_automake_snippet_conditional ()
2418 if ! $modcache; then
2419 func_lookup_file "modules/$1"
2420 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2421 else
2422 func_cache_lookup_module "$1"
2423 # Output the field's value, including the final newline (if any).
2424 if $have_associative; then
2425 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2426 eval 'echo "${modcache_makefile[$1]}"'
2428 else
2429 eval "field_set=\"\$${cachevar}_makefile_set\""
2430 if test -n "$field_set"; then
2431 eval "field_value=\"\$${cachevar}_makefile\""
2432 echo "${field_value}"
2438 # func_get_automake_snippet_unconditional module
2439 # returns the part of the Makefile.am snippet that must stay outside of
2440 # Automake conditionals.
2441 # Input:
2442 # - local_gnulib_path from --local-dir
2443 # - modcache true or false, from --cache-modules/--no-cache-modules
2444 func_get_automake_snippet_unconditional ()
2446 case "$1" in
2447 *-tests)
2448 # *-tests module live in tests/, not lib/.
2449 # Synthesize an EXTRA_DIST augmentation.
2450 all_files=`func_get_filelist $1`
2451 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2452 extra_files="$tests_files"
2453 if test -n "$extra_files"; then
2454 echo "EXTRA_DIST +=" $extra_files
2455 echo
2459 # Synthesize an EXTRA_DIST augmentation.
2460 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2461 already_mentioned_files=` \
2462 { if ! $modcache; then
2463 func_lookup_file "modules/$1"
2464 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2465 else
2466 func_cache_lookup_module "$1"
2467 if $have_associative; then
2468 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2469 eval 'echo "${modcache_makefile[$1]}"'
2471 else
2472 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2473 if test -n "$field_set"; then
2474 eval 'field_value="$'"${cachevar}"'_makefile"'
2475 echo "${field_value}"
2480 | combine_lines \
2481 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2482 all_files=`func_get_filelist $1`
2483 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2484 # Remove $already_mentioned_files from $lib_files.
2485 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2486 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2487 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2488 if test -n "$extra_files"; then
2489 echo "EXTRA_DIST +=" $extra_files
2490 echo
2492 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2493 # This is necessary so that automake can generate the right list of
2494 # dependency rules.
2495 # A possible approach would be to use autom4te --trace of the redefined
2496 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2497 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2498 # inside autoconf's built-in macros are not missed).
2499 # But it's simpler and more robust to do it here, based on the file list.
2500 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2501 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2502 # automake will generate a useless dependency; this is harmless.
2503 case "$1" in
2504 relocatable-prog-wrapper) ;;
2505 pt_chown) ;;
2507 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2508 if test -n "$extra_files"; then
2509 echo "EXTRA_lib_SOURCES +=" $extra_files
2510 echo
2513 esac
2514 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2515 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2516 if test -n "$buildaux_files"; then
2517 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2518 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2519 echo
2522 esac
2525 # func_get_automake_snippet module
2526 # Input:
2527 # - local_gnulib_path from --local-dir
2528 # - modcache true or false, from --cache-modules/--no-cache-modules
2529 func_get_automake_snippet ()
2531 func_get_automake_snippet_conditional "$1"
2532 func_get_automake_snippet_unconditional "$1"
2535 # func_get_include_directive module
2536 # Input:
2537 # - local_gnulib_path from --local-dir
2538 # - modcache true or false, from --cache-modules/--no-cache-modules
2539 func_get_include_directive ()
2542 if ! $modcache; then
2543 func_lookup_file "modules/$1"
2544 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2545 else
2546 func_cache_lookup_module "$1"
2547 # Output the field's value, including the final newline (if any).
2548 if $have_associative; then
2549 if eval 'test -n "${modcache_include[$1]+set}"'; then
2550 eval 'echo "${modcache_include[$1]}"'
2552 else
2553 eval "field_set=\"\$${cachevar}_include_set\""
2554 if test -n "$field_set"; then
2555 eval "field_value=\"\$${cachevar}_include\""
2556 echo "${field_value}"
2560 } | sed -e 's/^\(["<]\)/#include \1/'
2563 # func_get_link_directive module
2564 # Input:
2565 # - local_gnulib_path from --local-dir
2566 # - modcache true or false, from --cache-modules/--no-cache-modules
2567 func_get_link_directive ()
2569 if ! $modcache; then
2570 func_lookup_file "modules/$1"
2571 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2572 else
2573 func_cache_lookup_module "$1"
2574 # Output the field's value, including the final newline (if any).
2575 if $have_associative; then
2576 if eval 'test -n "${modcache_link[$1]+set}"'; then
2577 eval 'echo "${modcache_link[$1]}"'
2579 else
2580 eval "field_set=\"\$${cachevar}_link_set\""
2581 if test -n "$field_set"; then
2582 eval "field_value=\"\$${cachevar}_link\""
2583 echo "${field_value}"
2589 # func_get_license_raw module
2590 # Input:
2591 # - local_gnulib_path from --local-dir
2592 # - modcache true or false, from --cache-modules/--no-cache-modules
2593 func_get_license_raw ()
2595 if ! $modcache; then
2596 func_lookup_file "modules/$1"
2597 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2598 else
2599 func_cache_lookup_module "$1"
2600 # Output the field's value, including the final newline (if any).
2601 if $have_associative; then
2602 if eval 'test -n "${modcache_license[$1]+set}"'; then
2603 eval 'echo "${modcache_license[$1]}"'
2605 else
2606 eval "field_set=\"\$${cachevar}_license_set\""
2607 if test -n "$field_set"; then
2608 eval "field_value=\"\$${cachevar}_license\""
2609 echo "${field_value}"
2615 # func_get_license module
2616 # Input:
2617 # - local_gnulib_path from --local-dir
2618 # - modcache true or false, from --cache-modules/--no-cache-modules
2619 func_get_license ()
2621 # Warn if the License field is missing.
2622 case "$1" in
2623 *-tests ) ;;
2625 license=`func_get_license_raw "$1"`
2626 if test -z "$license"; then
2627 func_warning "module $1 lacks a License"
2630 esac
2631 case "$1" in
2632 parse-datetime )
2633 # These modules are under a weaker license only for the purpose of some
2634 # users who hand-edit it and don't use gnulib-tool. For the regular
2635 # gnulib users they are under a stricter license.
2636 echo "GPL"
2640 func_get_license_raw "$1"
2641 # The default is GPL.
2642 echo "GPL"
2643 } | sed -e 's,^ *$,,' | sed -e 1q
2645 esac
2648 # func_get_maintainer module
2649 # Input:
2650 # - local_gnulib_path from --local-dir
2651 # - modcache true or false, from --cache-modules/--no-cache-modules
2652 func_get_maintainer ()
2654 if ! $modcache; then
2655 func_lookup_file "modules/$1"
2656 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2657 else
2658 func_cache_lookup_module "$1"
2659 # Output the field's value, including the final newline (if any).
2660 if $have_associative; then
2661 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2662 eval 'echo "${modcache_maintainer[$1]}"'
2664 else
2665 eval "field_set=\"\$${cachevar}_maintainer_set\""
2666 if test -n "$field_set"; then
2667 eval "field_value=\"\$${cachevar}_maintainer\""
2668 echo "${field_value}"
2674 # func_get_tests_module module
2675 # Input:
2676 # - local_gnulib_path from --local-dir
2677 func_get_tests_module ()
2679 # The naming convention for tests modules is hardwired: ${module}-tests.
2680 if test -f "$gnulib_dir/modules/$1"-tests \
2681 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1-tests"; then
2682 echo "$1"-tests
2686 # func_get_dependencies_recursively module
2687 # Input:
2688 # - local_gnulib_path from --local-dir
2689 # - modcache true or false, from --cache-modules/--no-cache-modules
2690 func_get_dependencies_recursively ()
2692 # In order to process every module only once (for speed), process an "input
2693 # list" of modules, producing an "output list" of modules. During each round,
2694 # more modules can be queued in the input list. Once a module on the input
2695 # list has been processed, it is added to the "handled list", so we can avoid
2696 # to process it again.
2697 handledmodules=
2698 inmodules="$1"
2699 outmodules=
2700 while test -n "$inmodules"; do
2701 inmodules_this_round="$inmodules"
2702 inmodules= # Accumulator, queue for next round
2703 for module in $inmodules_this_round; do
2704 func_verify_module
2705 if test -n "$module"; then
2706 func_append outmodules " $module"
2707 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2708 for dep in $deps; do
2709 func_append inmodules " $dep"
2710 done
2712 done
2713 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2714 # Remove $handledmodules from $inmodules.
2715 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2716 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2717 done
2718 rm -f "$tmp"/queued-modules
2719 for m in $outmodules; do echo $m; done | LC_ALL=C sort -u
2722 # func_get_link_directive_recursively module
2723 # Input:
2724 # - local_gnulib_path from --local-dir
2725 # - modcache true or false, from --cache-modules/--no-cache-modules
2726 func_get_link_directive_recursively ()
2728 # In order to process every module only once (for speed), process an "input
2729 # list" of modules, producing an "output list" of modules. During each round,
2730 # more modules can be queued in the input list. Once a module on the input
2731 # list has been processed, it is added to the "handled list", so we can avoid
2732 # to process it again.
2733 handledmodules=
2734 inmodules="$1"
2735 outmodules=
2736 while test -n "$inmodules"; do
2737 inmodules_this_round="$inmodules"
2738 inmodules= # Accumulator, queue for next round
2739 for module in $inmodules_this_round; do
2740 func_verify_module
2741 if test -n "$module"; then
2742 if grep '^Link:[ ]*$' "$lookedup_file" >/dev/null; then
2743 # The module description has a 'Link:' field. Ignore the dependencies.
2744 func_append outmodules " $module"
2745 else
2746 # The module description has no 'Link:' field. Recurse through the dependencies.
2747 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2748 for dep in $deps; do
2749 func_append inmodules " $dep"
2750 done
2753 done
2754 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2755 # Remove $handledmodules from $inmodules.
2756 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2757 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2758 done
2759 rm -f "$tmp"/queued-modules
2760 for m in $outmodules; do func_get_link_directive "$m"; done | LC_ALL=C sort -u | sed -e '/^$/d'
2763 # func_acceptable module
2764 # tests whether a module is acceptable.
2765 # Input:
2766 # - avoidlist list of modules to avoid
2767 func_acceptable ()
2769 for avoid in $avoidlist; do
2770 if test "$avoid" = "$1"; then
2771 return 1
2773 done
2774 return 0
2777 # sed expression to keep the first 32 characters of each line.
2778 sed_first_32_chars='s/^\(................................\).*/\1/'
2780 # func_module_shellfunc_name module
2781 # computes the shell function name that will contain the m4 macros for the module.
2782 # Input:
2783 # - macro_prefix prefix to use
2784 # Output:
2785 # - shellfunc shell function name
2786 func_module_shellfunc_name ()
2788 case $1 in
2789 *[!a-zA-Z0-9_]*)
2790 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2792 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2793 esac
2796 # func_module_shellvar_name module
2797 # computes the shell variable name the will be set to true once the m4 macros
2798 # for the module have been executed.
2799 # Output:
2800 # - shellvar shell variable name
2801 func_module_shellvar_name ()
2803 case $1 in
2804 *[!a-zA-Z0-9_]*)
2805 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2807 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2808 esac
2811 # func_module_conditional_name module
2812 # computes the automake conditional name for the module.
2813 # Output:
2814 # - conditional name of automake conditional
2815 func_module_conditional_name ()
2817 case $1 in
2818 *[!a-zA-Z0-9_]*)
2819 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2821 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2822 esac
2825 # func_uncond_add_module B
2826 # notes the presence of B as an unconditional module.
2828 # func_conddep_add_module A B cond
2829 # notes the presence of a conditional dependency from module A to module B,
2830 # subject to the condition that A is enabled and cond is true.
2832 # func_cond_module_p B
2833 # tests whether module B is conditional.
2835 # func_cond_module_condition A B
2836 # returns the condition when B should be enabled as a dependency of A, once the
2837 # m4 code for A has been executed.
2838 # Output: - condition
2840 if $have_associative; then
2841 declare -A conddep_isuncond
2842 declare -A conddep_dependers
2843 declare -A conddep_condition
2844 func_uncond_add_module ()
2846 eval 'conddep_isuncond[$1]=true'
2847 eval 'unset conddep_dependers[$1]'
2849 func_conddep_add_module ()
2851 eval 'isuncond="${conddep_isuncond[$2]}"'
2852 if test -z "$isuncond"; then
2853 # No unconditional dependency to B known at this point.
2854 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2855 eval 'conddep_condition[$1---$2]="$3"'
2858 func_cond_module_p ()
2860 eval 'previous_dependers="${conddep_dependers[$1]}"'
2861 test -n "$previous_dependers"
2863 func_cond_module_condition ()
2865 eval 'condition="${conddep_condition[$1---$2]}"'
2867 else
2868 func_uncond_add_module ()
2870 case $1 in
2871 *[!a-zA-Z0-9_]*)
2872 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2874 suffix=$1 ;;
2875 esac
2876 eval 'conddep_isuncond_'"$suffix"'=true'
2877 eval 'unset conddep_dependers_'"$suffix"
2879 func_conddep_add_module ()
2881 case $2 in
2882 *[!a-zA-Z0-9_]*)
2883 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2885 suffix=$2 ;;
2886 esac
2887 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2888 if test -z "$isuncond"; then
2889 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2890 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2891 eval 'conddep_condition_'"$suffix"'="$3"'
2894 func_cond_module_p ()
2896 case $1 in
2897 *[!a-zA-Z0-9_]*)
2898 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2900 suffix=$1 ;;
2901 esac
2902 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2903 test -n "$previous_dependers"
2905 func_cond_module_condition ()
2907 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2908 eval 'condition="${conddep_condition_'"$suffix"'}"'
2912 # func_modules_transitive_closure
2913 # Input:
2914 # - local_gnulib_path from --local-dir
2915 # - gnu_make true if --gnu-make was given, false otherwise
2916 # - modcache true or false, from --cache-modules/--no-cache-modules
2917 # - modules list of specified modules
2918 # - inctests true if tests should be included, false otherwise
2919 # - incobsolete true if obsolete modules among dependencies should be
2920 # included, blank otherwise
2921 # - inc_cxx_tests true if C++ interoperability tests should be included,
2922 # blank otherwise
2923 # - inc_longrunning_tests true if long-runnings tests should be included,
2924 # blank otherwise
2925 # - inc_privileged_tests true if tests that require root privileges should be
2926 # included, blank otherwise
2927 # - inc_unportable_tests true if tests that fail on some platforms should be
2928 # included, blank otherwise
2929 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2930 # the unit tests of the specified modules should be
2931 # included, blank otherwise
2932 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2933 # the unit tests of the dependencies should be
2934 # included, blank otherwise
2935 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2936 # blank otherwise
2937 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2938 # blank otherwise
2939 # - excl_privileged_tests true if tests that require root privileges should be
2940 # excluded, blank otherwise
2941 # - excl_unportable_tests true if tests that fail on some platforms should be
2942 # excluded, blank otherwise
2943 # - avoidlist list of modules to avoid
2944 # - cond_dependencies true if conditional dependencies shall be supported,
2945 # blank otherwise
2946 # - tmp pathname of a temporary directory
2947 # Output:
2948 # - modules list of modules, including dependencies
2949 # - conddep_dependers, conddep_condition information about conditionally
2950 # enabled modules
2951 func_modules_transitive_closure ()
2953 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2954 # In order to process every module only once (for speed), process an "input
2955 # list" of modules, producing an "output list" of modules. During each round,
2956 # more modules can be queued in the input list. Once a module on the input
2957 # list has been processed, it is added to the "handled list", so we can avoid
2958 # to process it again.
2959 handledmodules=
2960 inmodules="$modules"
2961 outmodules=
2962 fmtc_inc_all_tests="$inc_all_direct_tests"
2963 if test "$cond_dependencies" = true; then
2964 for module in $inmodules; do
2965 func_verify_module
2966 if test -n "$module"; then
2967 if func_acceptable $module; then
2968 func_uncond_add_module $module
2971 done
2973 while test -n "$inmodules"; do
2974 inmodules_this_round="$inmodules"
2975 inmodules= # Accumulator, queue for next round
2976 for module in $inmodules_this_round; do
2977 func_verify_module
2978 if test -n "$module"; then
2979 if func_acceptable $module; then
2980 func_append outmodules " $module"
2981 if test "$cond_dependencies" = true; then
2982 if ! $gnu_make \
2983 && func_get_automake_snippet_conditional $module \
2984 | grep '^if ' > /dev/null; then
2985 # A module whose Makefile.am snippet contains a reference to an
2986 # automake conditional. If we were to use it conditionally, we
2987 # would get an error
2988 # configure: error: conditional "..." was never defined.
2989 # because automake 1.11.1 does not handle nested conditionals
2990 # correctly. As a workaround, make the module unconditional.
2991 func_uncond_add_module $module
2993 if func_cond_module_p $module; then
2994 conditional=true
2995 else
2996 conditional=false
2999 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3000 # Duplicate dependencies are harmless, but Jim wants a warning.
3001 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
3002 if test -n "$duplicated_deps"; then
3003 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
3005 if $inctests; then
3006 testsmodule=`func_get_tests_module $module`
3007 if test -n "$testsmodule"; then
3008 deps="$deps $testsmodule"
3011 for dep in $deps; do
3012 # Determine whether to include the dependency or tests module.
3013 inc=true
3014 for word in `func_get_status $dep`; do
3015 case "$word" in
3016 obsolete)
3017 test -n "$incobsolete" \
3018 || inc=false
3020 c++-test)
3021 test -z "$excl_cxx_tests" \
3022 || inc=false
3023 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
3024 || inc=false
3026 longrunning-test)
3027 test -z "$excl_longrunning_tests" \
3028 || inc=false
3029 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
3030 || inc=false
3032 privileged-test)
3033 test -z "$excl_privileged_tests" \
3034 || inc=false
3035 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
3036 || inc=false
3038 unportable-test)
3039 test -z "$excl_unportable_tests" \
3040 || inc=false
3041 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
3042 || inc=false
3044 *-test)
3045 test -n "$fmtc_inc_all_tests" \
3046 || inc=false
3048 esac
3049 done
3050 if $inc && func_acceptable "$dep"; then
3051 func_append inmodules " $dep"
3052 if test "$cond_dependencies" = true; then
3053 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
3054 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
3055 s/^.*$/true/p
3057 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
3058 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
3060 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
3061 if test "$condition" = true; then
3062 condition=
3064 if test -n "$condition"; then
3065 func_conddep_add_module "$module" "$dep" "$condition"
3066 else
3067 if $conditional; then
3068 func_conddep_add_module "$module" "$dep" true
3069 else
3070 func_uncond_add_module "$dep"
3075 done
3078 done
3079 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
3080 # Remove $handledmodules from $inmodules.
3081 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
3082 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
3083 fmtc_inc_all_tests="$inc_all_indirect_tests"
3084 done
3085 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
3086 rm -f "$tmp"/queued-modules
3089 # func_show_module_list
3090 # Input:
3091 # - specified_modules list of specified modules (one per line, sorted)
3092 # - modules complete list of modules (one per line, sorted)
3093 # - tmp pathname of a temporary directory
3094 func_show_module_list ()
3096 if case "$TERM" in
3097 xterm*) test -t 1;;
3098 *) false;;
3099 esac; then
3100 # Assume xterm compatible escape sequences.
3101 bold_on=`printf '\033[1m'`
3102 bold_off=`printf '\033[0m'`
3103 else
3104 bold_on=
3105 bold_off=
3107 echo "Module list with included dependencies (indented):"
3108 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
3109 echo "$modules" | sed -e '/^$/d' \
3110 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
3111 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
3114 # func_modules_transitive_closure_separately
3115 # Determine main module list and tests-related module list separately.
3116 # The main module list is the transitive closure of the specified modules,
3117 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3118 # is specified, it will consist only of LGPLed source.
3119 # The tests-related module list is the transitive closure of the specified
3120 # modules, including tests modules, minus the main module list excluding
3121 # modules of applicability 'all'. Its lib/* sources (brought in through
3122 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3123 # source, even if --lgpl is specified.
3124 # Input:
3125 # - local_gnulib_path from --local-dir
3126 # - modcache true or false, from --cache-modules/--no-cache-modules
3127 # - specified_modules list of specified modules
3128 # - inctests true if tests should be included, false otherwise
3129 # - incobsolete true if obsolete modules among dependencies should be
3130 # included, blank otherwise
3131 # - inc_cxx_tests true if C++ interoperability tests should be included,
3132 # blank otherwise
3133 # - inc_longrunning_tests true if long-runnings tests should be included,
3134 # blank otherwise
3135 # - inc_privileged_tests true if tests that require root privileges should be
3136 # included, blank otherwise
3137 # - inc_unportable_tests true if tests that fail on some platforms should be
3138 # included, blank otherwise
3139 # - inc_all_direct_tests true if all kinds of problematic unit tests among
3140 # the unit tests of the specified modules should be
3141 # included, blank otherwise
3142 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
3143 # the unit tests of the dependencies should be
3144 # included, blank otherwise
3145 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
3146 # blank otherwise
3147 # - excl_longrunning_tests true if long-runnings tests should be excluded,
3148 # blank otherwise
3149 # - excl_privileged_tests true if tests that require root privileges should be
3150 # excluded, blank otherwise
3151 # - excl_unportable_tests true if tests that fail on some platforms should be
3152 # excluded, blank otherwise
3153 # - avoidlist list of modules to avoid
3154 # - cond_dependencies true if conditional dependencies shall be supported,
3155 # blank otherwise
3156 # - tmp pathname of a temporary directory
3157 # Output:
3158 # - main_modules list of modules, including dependencies
3159 # - testsrelated_modules list of tests-related modules, including dependencies
3160 # - conddep_dependers, conddep_condition information about conditionally
3161 # enabled modules
3162 func_modules_transitive_closure_separately ()
3164 # Determine main module list.
3165 saved_inctests="$inctests"
3166 inctests=false
3167 modules="$specified_modules"
3168 func_modules_transitive_closure
3169 main_modules="$modules"
3170 inctests="$saved_inctests"
3171 if test $verbose -ge 1; then
3172 echo "Main module list:"
3173 echo "$main_modules" | sed -e 's/^/ /'
3175 # Determine tests-related module list.
3176 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3177 testsrelated_modules=`for module in $main_modules; do
3178 if test \`func_get_applicability $module\` = main; then
3179 echo $module
3181 done \
3182 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3183 # If testsrelated_modules consists only of modules with applicability 'all',
3184 # set it to empty (because such modules are only helper modules for other modules).
3185 have_nontrivial_testsrelated_modules=
3186 for module in $testsrelated_modules; do
3187 if test `func_get_applicability $module` != all; then
3188 have_nontrivial_testsrelated_modules=yes
3189 break
3191 done
3192 if test -z "$have_nontrivial_testsrelated_modules"; then
3193 testsrelated_modules=
3195 if test $verbose -ge 1; then
3196 echo "Tests-related module list:"
3197 echo "$testsrelated_modules" | sed -e 's/^/ /'
3201 # func_determine_use_libtests
3202 # Determines whether a $testsbase/libtests.a is needed.
3203 # Input:
3204 # - local_gnulib_path from --local-dir
3205 # - modcache true or false, from --cache-modules/--no-cache-modules
3206 # - testsrelated_modules list of tests-related modules, including dependencies
3207 # Output:
3208 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3209 func_determine_use_libtests ()
3211 use_libtests=false
3212 for module in $testsrelated_modules; do
3213 func_verify_nontests_module
3214 if test -n "$module"; then
3215 all_files=`func_get_filelist $module`
3216 # Test whether some file in $all_files lies in lib/.
3217 for f in $all_files; do
3218 case $f in
3219 lib/*)
3220 use_libtests=true
3221 break 2
3223 esac
3224 done
3226 done
3229 # func_modules_add_dummy
3230 # Input:
3231 # - local_gnulib_path from --local-dir
3232 # - modcache true or false, from --cache-modules/--no-cache-modules
3233 # - modules list of modules, including dependencies
3234 # Output:
3235 # - modules list of modules, including 'dummy' if needed
3236 func_modules_add_dummy ()
3238 # Determine whether any module provides a lib_SOURCES augmentation.
3239 have_lib_SOURCES=
3240 for module in $modules; do
3241 func_verify_nontests_module
3242 if test -n "$module"; then
3243 # Extract the value of "lib_SOURCES += ...".
3244 for file in `func_get_automake_snippet "$module" | combine_lines |
3245 sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
3246 # Ignore .h files since they are not compiled.
3247 case "$file" in
3248 *.h) ;;
3250 have_lib_SOURCES=yes
3251 break 2
3253 esac
3254 done
3256 done
3257 # Add the dummy module, to make sure the library will be non-empty.
3258 if test -z "$have_lib_SOURCES"; then
3259 if func_acceptable "dummy"; then
3260 func_append modules " dummy"
3265 # func_modules_add_dummy_separately
3266 # Input:
3267 # - local_gnulib_path from --local-dir
3268 # - modcache true or false, from --cache-modules/--no-cache-modules
3269 # - main_modules list of modules, including dependencies
3270 # - testsrelated_modules list of tests-related modules, including dependencies
3271 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3272 # Output:
3273 # - main_modules list of modules, including 'dummy' if needed
3274 # - testsrelated_modules list of tests-related modules, including 'dummy' if
3275 # needed
3276 func_modules_add_dummy_separately ()
3278 # Add the dummy module to the main module list if needed.
3279 modules="$main_modules"
3280 func_modules_add_dummy
3281 main_modules="$modules"
3283 # Add the dummy module to the tests-related module list if needed.
3284 if $use_libtests; then
3285 modules="$testsrelated_modules"
3286 func_modules_add_dummy
3287 testsrelated_modules="$modules"
3291 # func_modules_notice
3292 # Input:
3293 # - local_gnulib_path from --local-dir
3294 # - modcache true or false, from --cache-modules/--no-cache-modules
3295 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3296 # - modules list of modules, including dependencies
3297 func_modules_notice ()
3299 if test $verbose -ge -1; then
3300 for module in $modules; do
3301 func_verify_module
3302 if test -n "$module"; then
3303 msg=`func_get_notice $module`
3304 if test -n "$msg"; then
3305 echo "Notice from module $module:"
3306 echo "$msg" | sed -e 's/^/ /'
3309 done
3313 # func_modules_to_filelist
3314 # Input:
3315 # - local_gnulib_path from --local-dir
3316 # - modcache true or false, from --cache-modules/--no-cache-modules
3317 # - modules list of modules, including dependencies
3318 # Output:
3319 # - files list of files
3320 func_modules_to_filelist ()
3322 files=
3323 for module in $modules; do
3324 func_verify_module
3325 if test -n "$module"; then
3326 fs=`func_get_filelist $module`
3327 func_append files " $fs"
3329 done
3330 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3333 # func_modules_to_filelist_separately
3334 # Determine the final file lists.
3335 # They must be computed separately, because files in lib/* go into
3336 # $sourcebase/ if they are in the main file list but into $testsbase/
3337 # if they are in the tests-related file list. Furthermore lib/dummy.c
3338 # can be in both.
3339 # Input:
3340 # - local_gnulib_path from --local-dir
3341 # - modcache true or false, from --cache-modules/--no-cache-modules
3342 # - main_modules list of modules, including dependencies
3343 # - testsrelated_modules list of tests-related modules, including dependencies
3344 func_modules_to_filelist_separately ()
3346 # Determine final main file list.
3347 modules="$main_modules"
3348 func_modules_to_filelist
3349 main_files="$files"
3350 # Determine final tests-related file list.
3351 modules="$testsrelated_modules"
3352 func_modules_to_filelist
3353 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3354 # Merge both file lists.
3355 sed_remove_empty_lines='/^$/d'
3356 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3357 if test $verbose -ge 0; then
3358 echo "File list:"
3359 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3360 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3364 # func_compute_include_guard_prefix
3365 # Determine include_guard_prefix.
3366 # Input:
3367 # - macro_prefix prefix of gl_LIBOBJS macros to use
3368 # Output:
3369 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3370 # - sed_replace_include_guard_prefix
3371 # sed expression for resolving ${gl_include_guard_prefix}
3372 func_compute_include_guard_prefix ()
3374 if test "$macro_prefix" = gl; then
3375 include_guard_prefix='GL'
3376 else
3377 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3379 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3382 # func_execute_command command [args...]
3383 # Executes a command.
3384 # Uses also the variables
3385 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3386 func_execute_command ()
3388 if test $verbose -ge 0; then
3389 echo "executing $*"
3390 "$@"
3391 else
3392 # Commands like automake produce output to stderr even when they succeed.
3393 # Turn this output off if the command succeeds.
3394 "$@" > "$tmp"/cmdout 2>&1
3395 cmdret=$?
3396 if test $cmdret = 0; then
3397 rm -f "$tmp"/cmdout
3398 else
3399 echo "executing $*"
3400 cat "$tmp"/cmdout 1>&2
3401 rm -f "$tmp"/cmdout
3402 (exit $cmdret)
3407 # func_dest_tmpfilename file
3408 # determines the name of a temporary file (file is relative to destdir).
3409 # Input:
3410 # - destdir target directory
3411 # - doit : if actions shall be executed, false if only to be printed
3412 # - tmp pathname of a temporary directory
3413 # Sets variable:
3414 # - tmpfile absolute filename of the temporary file
3415 func_dest_tmpfilename ()
3417 if $doit; then
3418 # Put the new contents of $file in a file in the same directory (needed
3419 # to guarantee that an 'mv' to "$destdir/$file" works).
3420 tmpfile="$destdir/$1.tmp"
3421 else
3422 # Put the new contents of $file in a file in a temporary directory
3423 # (because the directory of "$file" might not exist).
3424 tmpfile="$tmp"/`basename "$1"`.tmp
3428 # func_is_local_file lookedup_file file
3429 # check whether file should be instantiated from local gnulib directory
3430 func_is_local_file ()
3432 dname=$1
3433 func_remove_suffix dname "/$2"
3434 func_path_foreach "$local_gnulib_path" test %dir% = "$dname"
3437 # func_should_link
3438 # determines whether the file $f should be copied, symlinked, or hardlinked.
3439 # Input:
3440 # - copymode copy mode for files in general
3441 # - lcopymode copy mode for files from local_gnulib_path
3442 # - f the original file name
3443 # - lookedup_file name of the merged (combined) file
3444 # Sets variable:
3445 # - copyaction copy or symlink or hardlink
3446 func_should_link ()
3448 if test -n "$lcopymode" && func_is_local_file "$lookedup_file" "$f"; then
3449 copyaction="$lcopymode"
3450 else
3451 if test -n "$copymode"; then
3452 copyaction="$copymode"
3453 else
3454 copyaction=copy
3459 # func_add_file
3460 # copies a file from gnulib into the destination directory. The destination
3461 # is known to not exist.
3462 # Input:
3463 # - destdir target directory
3464 # - local_gnulib_path from --local-dir
3465 # - modcache true or false, from --cache-modules/--no-cache-modules
3466 # - f the original file name
3467 # - lookedup_file name of the merged (combined) file
3468 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3469 # - g the rewritten file name
3470 # - tmpfile absolute filename of the temporary file
3471 # - doit : if actions shall be executed, false if only to be printed
3472 # - copymode copy mode for files in general
3473 # - lcopymode copy mode for files from local_gnulib_path
3474 func_add_file ()
3476 if $doit; then
3477 echo "Copying file $g"
3478 func_should_link
3479 if test "$copyaction" = symlink \
3480 && test -z "$lookedup_tmp" \
3481 && cmp -s "$lookedup_file" "$tmpfile"; then
3482 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3483 else
3484 if test "$copyaction" = hardlink \
3485 && test -z "$lookedup_tmp" \
3486 && cmp -s "$lookedup_file" "$tmpfile"; then
3487 func_hardlink "$lookedup_file" "$destdir/$g"
3488 else
3489 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3492 else
3493 echo "Copy file $g"
3497 # func_update_file
3498 # copies a file from gnulib into the destination directory. The destination
3499 # is known to exist.
3500 # Input:
3501 # - destdir target directory
3502 # - local_gnulib_path from --local-dir
3503 # - modcache true or false, from --cache-modules/--no-cache-modules
3504 # - f the original file name
3505 # - lookedup_file name of the merged (combined) file
3506 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3507 # - g the rewritten file name
3508 # - tmpfile absolute filename of the temporary file
3509 # - doit : if actions shall be executed, false if only to be printed
3510 # - copymode copy mode for files in general
3511 # - lcopymode copy mode for files from local_gnulib_path
3512 # - already_present nonempty if the file should already exist, empty otherwise
3513 func_update_file ()
3515 if cmp -s "$destdir/$g" "$tmpfile"; then
3516 : # The file has not changed.
3517 else
3518 # Replace the file.
3519 if $doit; then
3520 if test -n "$already_present"; then
3521 echo "Updating file $g (backup in ${g}~)"
3522 else
3523 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3525 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3526 func_should_link
3527 if test "$copyaction" = symlink \
3528 && test -z "$lookedup_tmp" \
3529 && cmp -s "$lookedup_file" "$tmpfile"; then
3530 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3531 else
3532 if test "$copyaction" = hardlink \
3533 && test -z "$lookedup_tmp" \
3534 && cmp -s "$lookedup_file" "$tmpfile"; then
3535 func_hardlink "$lookedup_file" "$destdir/$g"
3536 else
3537 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3540 else
3541 if test -n "$already_present"; then
3542 echo "Update file $g (backup in ${g}~)"
3543 else
3544 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3550 # func_emit_lib_Makefile_am
3551 # emits the contents of library makefile to standard output.
3552 # Input:
3553 # - local_gnulib_path from --local-dir
3554 # - modcache true or false, from --cache-modules/--no-cache-modules
3555 # - modules list of modules, including dependencies
3556 # - libname library name
3557 # - pobase directory relative to destdir where to place *.po files
3558 # - auxdir directory relative to destdir where to place build aux files
3559 # - gnu_make true if --gnu-make was given, false otherwise
3560 # - makefile_name from --makefile-name
3561 # - libtool true if libtool will be used, false or blank otherwise
3562 # - macro_prefix prefix of gl_LIBOBJS macros to use
3563 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3564 # - witness_c_macro from --witness-c-macro
3565 # - actioncmd (optional) command that will reproduce this invocation
3566 # - for_test true if creating a package for testing, false otherwise
3567 # - sed_replace_include_guard_prefix
3568 # sed expression for resolving ${gl_include_guard_prefix}
3569 # - destfile filename relative to destdir of makefile being generated
3570 # Input/Output:
3571 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
3572 # list of edits to be done to Makefile.am variables
3573 # Output:
3574 # - uses_subdirs nonempty if object files in subdirs exist
3575 func_emit_lib_Makefile_am ()
3578 # When using GNU make, or when creating an includable Makefile.am snippet,
3579 # augment variables with += instead of assigning them.
3580 if $gnu_make || test -n "$makefile_name"; then
3581 assign='+='
3582 else
3583 assign='='
3585 if test "$libtool" = true; then
3586 libext=la
3587 perhapsLT=LT
3588 sed_eliminate_LDFLAGS="$sed_noop"
3589 else
3590 libext=a
3591 perhapsLT=
3592 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3594 if $for_test; then
3595 # When creating a package for testing: Attempt to provoke failures,
3596 # especially link errors, already during "make" rather than during
3597 # "make check", because "make check" is not possible in a cross-compiling
3598 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3599 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3600 else
3601 sed_transform_check_PROGRAMS="$sed_noop"
3603 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3604 $gnu_make ||
3605 echo "## Process this file with automake to produce Makefile.in."
3606 func_emit_copyright_notice
3607 if test -n "$actioncmd"; then
3608 printf '# Reproduce by:\n%s\n' "$actioncmd"
3610 echo
3611 uses_subdirs=
3613 for module in $modules; do
3614 func_verify_nontests_module
3615 if test -n "$module"; then
3617 func_get_automake_snippet_conditional "$module" |
3618 LC_ALL=C \
3619 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3620 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3621 -e "$sed_eliminate_LDFLAGS" \
3622 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3623 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3624 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3625 -e "$sed_transform_check_PROGRAMS" \
3626 -e "$sed_replace_include_guard_prefix"
3627 if test "$module" = 'alloca'; then
3628 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3629 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3631 } | combine_lines "${libname}_${libext}_SOURCES" > "$tmp"/amsnippet1
3633 func_get_automake_snippet_unconditional "$module" |
3634 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3635 } > "$tmp"/amsnippet2
3636 # Skip the contents if it's entirely empty.
3637 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3638 echo "## begin gnulib module $module"
3639 if $gnu_make; then
3640 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
3641 convert_to_gnu_make='s/^if \(.*\)/ifneq (,$(\1))/'
3642 else
3643 convert_to_gnu_make=
3645 echo
3646 if test "$cond_dependencies" = true; then
3647 if func_cond_module_p "$module"; then
3648 func_module_conditional_name "$module"
3649 if $gnu_make; then
3650 echo "ifneq (,\$($conditional))"
3651 else
3652 echo "if $conditional"
3656 sed "$convert_to_gnu_make" "$tmp"/amsnippet1
3657 if test "$cond_dependencies" = true; then
3658 if func_cond_module_p "$module"; then
3659 echo "endif"
3662 sed "$convert_to_gnu_make" "$tmp"/amsnippet2
3663 if $gnu_make; then
3664 echo "endif"
3666 echo "## end gnulib module $module"
3667 echo
3669 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3670 # Test whether there are some source files in subdirectories.
3671 for f in `func_get_filelist "$module"`; do
3672 case $f in
3673 lib/*/*.c)
3674 uses_subdirs=yes
3675 break
3677 esac
3678 done
3680 done
3681 } > "$tmp"/allsnippets
3682 if test -z "$makefile_name"; then
3683 # If there are source files in subdirectories, prevent collision of the
3684 # object files (example: hash.c and libxml/hash.c).
3685 subdir_options=
3686 if test -n "$uses_subdirs"; then
3687 subdir_options=' subdir-objects'
3689 echo "AUTOMAKE_OPTIONS = 1.11 gnits${subdir_options}"
3691 echo
3692 if test -z "$makefile_name"; then
3693 echo "SUBDIRS ="
3694 echo "noinst_HEADERS ="
3695 echo "noinst_LIBRARIES ="
3696 echo "noinst_LTLIBRARIES ="
3697 # Automake versions < 1.11.4 create an empty pkgdatadir at
3698 # installation time if you specify pkgdata_DATA to empty.
3699 # See automake bugs #10997 and #11030:
3700 # * https://debbugs.gnu.org/10997
3701 # * https://debbugs.gnu.org/11030
3702 # So we need this workaround.
3703 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3704 echo "pkgdata_DATA ="
3706 echo "EXTRA_DIST ="
3707 echo "BUILT_SOURCES ="
3708 echo "SUFFIXES ="
3710 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3711 if test -z "$makefile_name"; then
3712 echo "MOSTLYCLEANDIRS ="
3713 echo "CLEANFILES ="
3714 echo "DISTCLEANFILES ="
3715 echo "MAINTAINERCLEANFILES ="
3717 if $gnu_make; then
3718 echo "# Start of GNU Make output."
3720 # Put autoconf output into a temporary file, so that its exit status
3721 # can be checked from the shell. Signal any error by putting a
3722 # syntax error into the output makefile.
3723 ${AUTOCONF} -t 'AC_SUBST:$1 = @$1@' "$configure_ac" \
3724 >"$tmp"/makeout 2>"$tmp"/makeout2 &&
3725 LC_ALL=C sort -u "$tmp"/makeout || {
3726 echo "== gnulib-tool GNU Make output failed as follows =="
3727 sed 's/^/# stderr: /' "$tmp"/makeout2
3729 rm -f "$tmp"/makeout "$tmp"/makeout2
3731 echo "# End of GNU Make output."
3732 else
3733 echo "# No GNU Make output."
3735 # Execute edits that apply to the Makefile.am being generated.
3736 edit=0
3737 while test $edit != $makefile_am_edits; do
3738 edit=`expr $edit + 1`
3739 eval dir=\"\$makefile_am_edit${edit}_dir\"
3740 eval var=\"\$makefile_am_edit${edit}_var\"
3741 eval val=\"\$makefile_am_edit${edit}_val\"
3742 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
3743 if test -n "$var"; then
3744 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3745 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
3746 # The added subdirectory ${val} needs to be mentioned after '.'.
3747 # Since we don't have '.' among SUBDIRS so far, add it now.
3748 val=". ${val}"
3750 echo "${var} += ${val}"
3751 eval "makefile_am_edit${edit}_var="
3754 done
3755 if test -n "$witness_c_macro"; then
3756 cppflags_part1=" -D$witness_c_macro=1"
3757 else
3758 cppflags_part1=
3760 if $for_test; then
3761 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3762 else
3763 cppflags_part2=
3765 if test -z "$makefile_name"; then
3766 echo
3767 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3768 echo "AM_CFLAGS ="
3769 else
3770 if test -n "$cppflags_part1$cppflags_part2"; then
3771 echo
3772 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3775 echo
3776 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3777 || { test -n "$makefile_name" \
3778 && test -f "$sourcebase/Makefile.am" \
3779 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3780 }; then
3781 # One of the snippets or the user's Makefile.am already specifies an
3782 # installation location for the library. Don't confuse automake by saying
3783 # it should not be installed.
3785 else
3786 # By default, the generated library should not be installed.
3787 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3789 echo
3790 echo "${libname}_${libext}_SOURCES ="
3791 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3792 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3793 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3794 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3795 echo "EXTRA_${libname}_${libext}_SOURCES ="
3796 if test "$libtool" = true; then
3797 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3798 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3799 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3800 # the link dependencies of all modules.
3801 for module in $modules; do
3802 func_verify_nontests_module
3803 if test -n "$module"; then
3804 func_get_link_directive "$module"
3806 done \
3807 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3808 | LC_ALL=C sort -u \
3809 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3811 echo
3812 if test -n "$pobase"; then
3813 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3814 echo
3816 cat "$tmp"/allsnippets \
3817 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3818 echo
3819 echo "mostlyclean-local: mostlyclean-generic"
3820 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3821 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3822 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3823 echo " fi; \\"
3824 echo " done; \\"
3825 echo " :"
3826 rm -f "$tmp"/allsnippets
3829 # func_emit_po_Makevars
3830 # emits the contents of po/ makefile parameterization to standard output.
3831 # Input:
3832 # - local_gnulib_path from --local-dir
3833 # - modcache true or false, from --cache-modules/--no-cache-modules
3834 # - sourcebase directory relative to destdir where to place source code
3835 # - pobase directory relative to destdir where to place *.po files
3836 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3837 func_emit_po_Makevars ()
3839 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3840 func_emit_copyright_notice
3841 echo
3842 echo "# Usually the message domain is the same as the package name."
3843 echo "# But here it has a '-gnulib' suffix."
3844 echo "DOMAIN = ${po_domain}-gnulib"
3845 echo
3846 echo "# These two variables depend on the location of this directory."
3847 echo "subdir = ${pobase}"
3848 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3849 echo
3850 cat <<\EOF
3851 # These options get passed to xgettext.
3852 XGETTEXT_OPTIONS = \
3853 --keyword=_ --flag=_:1:pass-c-format \
3854 --keyword=N_ --flag=N_:1:pass-c-format \
3855 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3856 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3857 --flag=error:3:c-format --flag=error_at_line:5:c-format
3859 # This is the copyright holder that gets inserted into the header of the
3860 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3861 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3863 # This is the email address or URL to which the translators shall report
3864 # bugs in the untranslated strings:
3865 # - Strings which are not entire sentences, see the maintainer guidelines
3866 # in the GNU gettext documentation, section 'Preparing Strings'.
3867 # - Strings which use unclear terms or require additional context to be
3868 # understood.
3869 # - Strings which make invalid assumptions about notation of date, time or
3870 # money.
3871 # - Pluralisation problems.
3872 # - Incorrect English spelling.
3873 # - Incorrect formatting.
3874 # It can be your email address, or a mailing list address where translators
3875 # can write to without being subscribed, or the URL of a web page through
3876 # which the translators can contact you.
3877 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3879 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3880 # message catalogs shall be used. It is usually empty.
3881 EXTRA_LOCALE_CATEGORIES =
3883 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3884 # context. Possible values are "yes" and "no". Set this to yes if the
3885 # package uses functions taking also a message context, like pgettext(), or
3886 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3887 USE_MSGCTXT = no
3891 # func_emit_po_POTFILES_in
3892 # emits the file list to be passed to xgettext to standard output.
3893 # Input:
3894 # - local_gnulib_path from --local-dir
3895 # - modcache true or false, from --cache-modules/--no-cache-modules
3896 # - sourcebase directory relative to destdir where to place source code
3897 # - files list of new files
3898 func_emit_po_POTFILES_in ()
3900 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3901 func_emit_copyright_notice
3902 echo
3903 echo "# List of files which contain translatable strings."
3904 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3907 # func_emit_tests_Makefile_am witness_macro
3908 # emits the contents of tests makefile to standard output.
3909 # Input:
3910 # - local_gnulib_path from --local-dir
3911 # - modcache true or false, from --cache-modules/--no-cache-modules
3912 # - modules list of modules, including dependencies
3913 # - libname library name
3914 # - auxdir directory relative to destdir where to place build aux files
3915 # - gnu_make true if --gnu-make was given, false otherwise
3916 # - makefile_name from --makefile-name
3917 # - libtool true if libtool will be used, false or blank otherwise
3918 # - sourcebase relative directory containing lib source code
3919 # - m4base relative directory containing autoconf macros
3920 # - testsbase relative directory containing unit test code
3921 # - macro_prefix prefix of gl_LIBOBJS macros to use
3922 # - witness_c_macro from --witness-c-macro
3923 # - for_test true if creating a package for testing, false otherwise
3924 # - single_configure true if a single configure file should be generated,
3925 # false for a separate configure file for the tests
3926 # - use_libtests true if a libtests.a should be built, false otherwise
3927 # - sed_replace_include_guard_prefix
3928 # sed expression for resolving ${gl_include_guard_prefix}
3929 # - destfile filename relative to destdir of makefile being generated
3930 # Input/Output:
3931 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
3932 # list of edits to be done to Makefile.am variables
3933 # Output:
3934 # - uses_subdirs nonempty if object files in subdirs exist
3935 func_emit_tests_Makefile_am ()
3937 witness_macro="$1"
3938 if test "$libtool" = true; then
3939 libext=la
3940 perhapsLT=LT
3941 sed_eliminate_LDFLAGS="$sed_noop"
3942 else
3943 libext=a
3944 perhapsLT=
3945 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3947 if $for_test; then
3948 # When creating a package for testing: Attempt to provoke failures,
3949 # especially link errors, already during "make" rather than during
3950 # "make check", because "make check" is not possible in a cross-compiling
3951 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3952 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3953 else
3954 sed_transform_check_PROGRAMS="$sed_noop"
3956 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3957 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3958 echo "## Process this file with automake to produce Makefile.in."
3959 func_emit_copyright_notice
3960 echo
3961 uses_subdirs=
3963 for module in $modules; do
3964 if $for_test && ! $single_configure; then
3965 func_verify_tests_module
3966 else
3967 func_verify_module
3969 if test -n "$module"; then
3971 func_get_automake_snippet "$module" |
3972 LC_ALL=C \
3973 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3974 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3975 -e "$sed_eliminate_LDFLAGS" \
3976 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3977 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3978 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3979 -e "$sed_transform_check_PROGRAMS" \
3980 -e "$sed_replace_include_guard_prefix"
3981 if $use_libtests && test "$module" = 'alloca'; then
3982 echo "libtests_a_LIBADD += @ALLOCA@"
3983 echo "libtests_a_DEPENDENCIES += @ALLOCA@"
3985 } > "$tmp"/amsnippet
3986 # Skip the contents if it's entirely empty.
3987 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3988 # Mention long-running tests at the end.
3989 ofd=3
3990 for word in `func_get_status "$module"`; do
3991 if test "$word" = 'longrunning-test'; then
3992 ofd=4
3993 break
3995 done
3996 { echo "## begin gnulib module $module"
3997 if $gnu_make; then
3998 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
4000 echo
4001 cat "$tmp"/amsnippet
4002 if $gnu_make; then
4003 echo "endif"
4005 echo "## end gnulib module $module"
4006 echo
4007 } >&$ofd
4009 rm -f "$tmp"/amsnippet
4010 # Test whether there are some source files in subdirectories.
4011 for f in `func_get_filelist "$module"`; do
4012 case $f in
4013 lib/*/*.c | tests/*/*.c)
4014 uses_subdirs=yes
4015 break
4017 esac
4018 done
4020 done
4021 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
4022 # Generate dependencies here, since it eases the debugging of test failures.
4023 # If there are source files in subdirectories, prevent collision of the
4024 # object files (example: hash.c and libxml/hash.c).
4025 subdir_options=
4026 if test -n "$uses_subdirs"; then
4027 subdir_options=' subdir-objects'
4029 echo "AUTOMAKE_OPTIONS = 1.11 foreign${subdir_options}"
4030 echo
4031 if $for_test && ! $single_configure; then
4032 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
4033 echo
4035 # Nothing is being added to SUBDIRS; nevertheless the existence of this
4036 # variable is needed to avoid an error from automake:
4037 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
4038 echo "SUBDIRS = ."
4039 echo "TESTS ="
4040 echo "XFAIL_TESTS ="
4041 echo "TESTS_ENVIRONMENT ="
4042 echo "noinst_PROGRAMS ="
4043 if ! $for_test; then
4044 echo "check_PROGRAMS ="
4046 echo "EXTRA_PROGRAMS ="
4047 echo "noinst_HEADERS ="
4048 echo "noinst_LIBRARIES ="
4049 if $use_libtests; then
4050 if $for_test; then
4051 echo "noinst_LIBRARIES += libtests.a"
4052 else
4053 echo "check_LIBRARIES = libtests.a"
4056 # Automake versions < 1.11.4 create an empty pkgdatadir at
4057 # installation time if you specify pkgdata_DATA to empty.
4058 # See automake bugs #10997 and #11030:
4059 # * https://debbugs.gnu.org/10997
4060 # * https://debbugs.gnu.org/11030
4061 # So we need this workaround.
4062 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
4063 echo "pkgdata_DATA ="
4065 echo "EXTRA_DIST ="
4066 echo "BUILT_SOURCES ="
4067 echo "SUFFIXES ="
4068 echo "MOSTLYCLEANFILES = core *.stackdump"
4069 echo "MOSTLYCLEANDIRS ="
4070 echo "CLEANFILES ="
4071 echo "DISTCLEANFILES ="
4072 echo "MAINTAINERCLEANFILES ="
4073 # Execute edits that apply to the Makefile.am being generated.
4074 edit=0
4075 while test $edit != $makefile_am_edits; do
4076 edit=`expr $edit + 1`
4077 eval dir=\"\$makefile_am_edit${edit}_dir\"
4078 eval var=\"\$makefile_am_edit${edit}_var\"
4079 eval val=\"\$makefile_am_edit${edit}_val\"
4080 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
4081 if test -n "$var"; then
4082 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
4083 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
4084 # The added subdirectory ${val} needs to be mentioned after '.'.
4085 # But we have '.' among SUBDIRS already, so do nothing.
4088 echo "${var} += ${val}"
4089 eval "makefile_am_edit${edit}_var="
4092 done
4093 echo
4094 echo "AM_CPPFLAGS = \\"
4095 if $for_test; then
4096 echo " -DGNULIB_STRICT_CHECKING=1 \\"
4098 if test -n "$witness_c_macro"; then
4099 echo " -D$witness_c_macro=1 \\"
4101 if test -n "${witness_macro}"; then
4102 echo " -D@${witness_macro}@=1 \\"
4104 echo " -I. -I\$(srcdir) \\"
4105 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
4106 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
4107 echo
4108 local_ldadd_before=''
4109 local_ldadd_after=''
4110 if $use_libtests; then
4111 # All test programs need to be linked with libtests.a.
4112 # It needs to be passed to the linker before ${libname}.${libext}, since
4113 # the tests-related modules depend on the main modules.
4114 # It also needs to be passed to the linker after ${libname}.${libext}
4115 # because the latter might contain incomplete modules (such as the 'error'
4116 # module whose dependency to 'progname' is voluntarily omitted).
4117 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
4118 # not matter.
4119 local_ldadd_before=' libtests.a'
4120 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
4122 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
4123 echo
4124 if $use_libtests; then
4125 echo "libtests_a_SOURCES ="
4126 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
4127 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
4128 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
4129 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
4130 echo "EXTRA_libtests_a_SOURCES ="
4131 # The circular dependency in LDADD requires this.
4132 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
4133 echo
4135 # Many test scripts use ${EXEEXT} or ${srcdir}.
4136 # EXEEXT is defined by AC_PROG_CC through autoconf.
4137 # srcdir is defined by autoconf and automake.
4138 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
4139 echo
4140 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
4141 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
4142 echo "# Clean up after Solaris cc."
4143 echo "clean-local:"
4144 echo " rm -rf SunWS_cache"
4145 echo
4146 echo "mostlyclean-local: mostlyclean-generic"
4147 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
4148 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
4149 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
4150 echo " fi; \\"
4151 echo " done; \\"
4152 echo " :"
4153 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
4156 # func_emit_initmacro_start macro_prefix
4157 # emits the first few statements of the gl_INIT macro to standard output.
4158 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4159 func_emit_initmacro_start ()
4161 macro_prefix_arg="$1"
4162 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
4163 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
4164 # LIBOBJS. The purpose is to allow several gnulib instantiations under
4165 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
4166 # flexibility.)
4167 # Furthermore it avoids an automake error like this when a Makefile.am
4168 # that uses pieces of gnulib also uses $(LIBOBJ):
4169 # automatically discovered file `error.c' should not be explicitly mentioned
4170 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
4171 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
4172 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
4173 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
4174 # automatically discovered file `error.c' should not be explicitly mentioned
4175 # We let automake know about the files to be distributed through the
4176 # EXTRA_lib_SOURCES variable.
4177 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
4178 # Create data variables for checking the presence of files that are mentioned
4179 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
4180 # because we want the check to happen when the configure file is created,
4181 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
4182 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
4183 # in which to expect them.
4184 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
4185 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
4186 echo " gl_COMMON"
4189 # func_emit_initmacro_end macro_prefix
4190 # emits the last few statements of the gl_INIT macro to standard output.
4191 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4192 func_emit_initmacro_end ()
4194 macro_prefix_arg="$1"
4195 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
4196 # The check is performed only when autoconf is run from the directory where
4197 # the configure.ac resides; if it is run from a different directory, the
4198 # check is skipped.
4199 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
4200 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
4201 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
4202 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
4203 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
4204 echo " exit 1"
4205 echo " fi"
4206 echo " done])dnl"
4207 echo " m4_if(m4_sysval, [0], [],"
4208 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
4209 echo " ])"
4210 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
4211 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
4212 echo " m4_popdef([AC_LIBSOURCES])"
4213 echo " m4_popdef([AC_REPLACE_FUNCS])"
4214 echo " m4_popdef([AC_LIBOBJ])"
4215 echo " AC_CONFIG_COMMANDS_PRE(["
4216 echo " ${macro_prefix_arg}_libobjs="
4217 echo " ${macro_prefix_arg}_ltlibobjs="
4218 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
4219 echo " # Remove the extension."
4220 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
4221 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
4222 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
4223 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
4224 echo " done"
4225 echo " fi"
4226 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
4227 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
4228 echo " ])"
4231 # func_emit_initmacro_done macro_prefix sourcebase
4232 # emits a few statements after the gl_INIT macro to standard output.
4233 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4234 # - sourcebase directory relative to destdir where to place source code
4235 func_emit_initmacro_done ()
4237 macro_prefix_arg="$1"
4238 sourcebase_arg="$2"
4239 echo
4240 echo "# Like AC_LIBOBJ, except that the module name goes"
4241 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4242 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
4243 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
4244 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
4245 echo "])"
4246 echo
4247 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
4248 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4249 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
4250 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
4251 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
4252 echo "])"
4253 echo
4254 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
4255 echo "# expected is derived from the gnulib-tool parameterization,"
4256 echo "# and alloca is special cased (for the alloca-opt module)."
4257 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
4258 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
4259 echo " m4_foreach([_gl_NAME], [\$1], ["
4260 echo " m4_if(_gl_NAME, [alloca.c], [], ["
4261 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
4262 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
4263 echo " ])"
4264 echo " ])"
4265 echo "])"
4268 # func_emit_autoconf_snippet indentation
4269 # emits the autoconf snippet of a module.
4270 # Input:
4271 # - indentation spaces to prepend on each line
4272 # - local_gnulib_path from --local-dir
4273 # - modcache true or false, from --cache-modules/--no-cache-modules
4274 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4275 # - sed_replace_include_guard_prefix
4276 # sed expression for resolving ${gl_include_guard_prefix}
4277 # - module the module name
4278 # - toplevel true or false. 'false' means a subordinate use of
4279 # gnulib-tool.
4280 # - disable_libtool true or false. It tells whether to disable libtool
4281 # handling even if it has been specified through the
4282 # command line options.
4283 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4284 # invocations.
4285 func_emit_autoconf_snippet ()
4287 indentation="$1"
4288 if { case $module in
4289 gnumakefile | maintainer-makefile)
4290 # These modules are meant to be used only in the top-level directory.
4291 $toplevel ;;
4293 true ;;
4294 esac
4295 }; then
4296 func_get_autoconf_snippet "$module" \
4297 | sed -e '/^$/d;' -e "s/^/$indentation/" \
4298 -e "$sed_replace_build_aux" \
4299 -e "$sed_replace_include_guard_prefix" \
4300 | { if $disable_libtool; then
4301 sed -e 's/\$gl_cond_libtool/false/g' \
4302 -e 's/gl_libdeps/gltests_libdeps/g' \
4303 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4304 else
4308 | { if $disable_gettext; then
4309 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
4310 else
4311 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
4312 # autopoint through at least GNU gettext version 0.18.2.
4313 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
4316 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
4317 echo 'changequote(,)dnl'
4318 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4319 echo 'changequote([, ])dnl'
4320 echo 'AC_SUBST([LTALLOCA])'
4325 # func_emit_autoconf_snippets modules referenceable_modules verifier toplevel disable_libtool disable_gettext
4326 # collects and emit the autoconf snippets of a set of modules.
4327 # Input:
4328 # - local_gnulib_path from --local-dir
4329 # - modcache true or false, from --cache-modules/--no-cache-modules
4330 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4331 # - sed_replace_include_guard_prefix
4332 # sed expression for resolving ${gl_include_guard_prefix}
4333 # - modules the list of modules.
4334 # - referenceable_modules the list of modules which may be referenced as dependencies.
4335 # - verifier one of func_verify_module, func_verify_nontests_module,
4336 # func_verify_tests_module. It selects the subset of
4337 # $modules to consider.
4338 # - toplevel true or false. 'false' means a subordinate use of
4339 # gnulib-tool.
4340 # - disable_libtool true or false. It tells whether to disable libtool
4341 # handling even if it has been specified through the
4342 # command line options.
4343 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4344 # invocations.
4345 func_emit_autoconf_snippets ()
4347 referenceable_modules="$2"
4348 verifier="$3"
4349 toplevel="$4"
4350 disable_libtool="$5"
4351 disable_gettext="$6"
4352 if test "$cond_dependencies" = true; then
4353 for m in $referenceable_modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
4354 # Emit the autoconf code for the unconditional modules.
4355 for module in $1; do
4356 eval $verifier
4357 if test -n "$module"; then
4358 if func_cond_module_p "$module"; then
4360 else
4361 func_emit_autoconf_snippet " "
4364 done
4365 # Initialize the shell variables indicating that the modules are enabled.
4366 for module in $1; do
4367 eval $verifier
4368 if test -n "$module"; then
4369 if func_cond_module_p "$module"; then
4370 func_module_shellvar_name "$module"
4371 echo " $shellvar=false"
4374 done
4375 # Emit the autoconf code for the conditional modules, each in a separate
4376 # function. This makes it possible to support cycles among conditional
4377 # modules.
4378 for module in $1; do
4379 eval $verifier
4380 if test -n "$module"; then
4381 if func_cond_module_p "$module"; then
4382 func_module_shellfunc_name "$module"
4383 func_module_shellvar_name "$module"
4384 echo " $shellfunc ()"
4385 echo ' {'
4386 echo " if ! \$$shellvar; then"
4387 func_emit_autoconf_snippet " "
4388 echo " $shellvar=true"
4389 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4390 # Intersect $deps with the modules list $1.
4391 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4392 for dep in $deps; do
4393 if func_cond_module_p "$dep"; then
4394 func_module_shellfunc_name "$dep"
4395 func_cond_module_condition "$module" "$dep"
4396 if test "$condition" != true; then
4397 echo " if $condition; then"
4398 echo " $shellfunc"
4399 echo ' fi'
4400 else
4401 echo " $shellfunc"
4403 else
4404 # The autoconf code for $dep has already been emitted above and
4405 # therefore is already executed when this function is run.
4408 done
4409 echo ' fi'
4410 echo ' }'
4413 done
4414 # Emit the dependencies from the unconditional to the conditional modules.
4415 for module in $1; do
4416 eval $verifier
4417 if test -n "$module"; then
4418 if func_cond_module_p "$module"; then
4420 else
4421 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4422 # Intersect $deps with the modules list $1.
4423 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4424 for dep in $deps; do
4425 if func_cond_module_p "$dep"; then
4426 func_module_shellfunc_name "$dep"
4427 func_cond_module_condition "$module" "$dep"
4428 if test "$condition" != true; then
4429 echo " if $condition; then"
4430 echo " $shellfunc"
4431 echo ' fi'
4432 else
4433 echo " $shellfunc"
4435 else
4436 # The autoconf code for $dep has already been emitted above and
4437 # therefore is already executed when this code is run.
4440 done
4443 done
4444 # Define the Automake conditionals.
4445 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4446 for module in $1; do
4447 eval $verifier
4448 if test -n "$module"; then
4449 if func_cond_module_p "$module"; then
4450 func_module_conditional_name "$module"
4451 func_module_shellvar_name "$module"
4452 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4455 done
4456 else
4457 # Ignore the conditions, and enable all modules unconditionally.
4458 for module in $1; do
4459 eval $verifier
4460 if test -n "$module"; then
4461 func_emit_autoconf_snippet " "
4463 done
4467 # func_emit_pre_early_macros require indentation modules
4468 # The require parameter can be ':' (AC_REQUIRE) or 'false' (direct call).
4469 func_emit_pre_early_macros ()
4471 echo
4472 echo "${2}# Pre-early section."
4473 if $1; then
4474 _pre_early_snippet="echo \"${2}AC_REQUIRE([\$_pre_early_macro])\""
4475 else
4476 _pre_early_snippet="echo \"${2}\$_pre_early_macro\""
4479 # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB. Doing
4480 # AC_REQUIRE in configure-ac.early is not early enough.
4481 _pre_early_macro="gl_USE_SYSTEM_EXTENSIONS"
4482 case "${nl}${3}${nl}" in
4483 *${nl}extensions${nl}*) eval "$_pre_early_snippet" ;;
4484 esac
4486 _pre_early_macro="gl_PROG_AR_RANLIB"
4487 eval "$_pre_early_snippet"
4488 echo
4491 # func_reconstruct_cached_dir
4492 # callback for func_reconstruct_cached_local_gnulib_path
4493 # Input:
4494 # - destdir from --dir
4495 # Output:
4496 # - local_gnulib_path restored '--local-dir' path from cache
4497 func_reconstruct_cached_dir ()
4499 cached_dir=$1
4500 if test -n "$cached_dir"; then
4501 case "$destdir" in
4503 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4505 case "$cached_dir" in
4507 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4509 func_relconcat "$destdir" "$cached_dir"
4510 func_path_append local_gnulib_path "$relconcat" ;;
4511 esac ;;
4512 esac
4516 # func_reconstruct_cached_local_gnulib_path
4517 # reconstruct local_gnulib_path from cached_local_gnulib_path to be set
4518 # relatively to $destdir again.
4519 # Input:
4520 # - cached_local_gnulib_path local_gnulib_path stored within gnulib-cache.m4
4521 # - destdir from --dir
4522 # Output:
4523 # - local_gnulib_path restored '--local-dir' path from cache
4524 func_reconstruct_cached_local_gnulib_path ()
4526 func_path_foreach "$cached_local_gnulib_path" func_reconstruct_cached_dir %dir%
4529 # func_import modules
4530 # Uses also the variables
4531 # - mode import or add-import or remove-import or update
4532 # - destdir target directory
4533 # - local_gnulib_path from --local-dir
4534 # - modcache true or false, from --cache-modules/--no-cache-modules
4535 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4536 # - libname library name
4537 # - supplied_libname true if --lib was given, blank otherwise
4538 # - sourcebase directory relative to destdir where to place source code
4539 # - m4base directory relative to destdir where to place *.m4 macros
4540 # - pobase directory relative to destdir where to place *.po files
4541 # - docbase directory relative to destdir where to place doc files
4542 # - testsbase directory relative to destdir where to place unit test code
4543 # - auxdir directory relative to destdir where to place build aux files
4544 # - inctests true if --with-tests was given, false otherwise
4545 # - incobsolete true if --with-obsolete was given, blank otherwise
4546 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4547 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4548 # otherwise
4549 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4550 # otherwise
4551 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4552 # otherwise
4553 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4554 # - avoidlist list of modules to avoid, from --avoid
4555 # - cond_dependencies true if --conditional-dependencies was given, false if
4556 # --no-conditional-dependencies was given, blank otherwise
4557 # - lgpl yes or a number if library's license shall be LGPL,
4558 # blank otherwise
4559 # - makefile_name from --makefile-name
4560 # - libtool true if --libtool was given, false if --no-libtool was
4561 # given, blank otherwise
4562 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4563 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4564 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4565 # - witness_c_macro from --witness-c-macro
4566 # - vc_files true if --vc-files was given, false if --no-vc-files was
4567 # given, blank otherwise
4568 # - autoconf_minversion minimum supported autoconf version
4569 # - doit : if actions shall be executed, false if only to be printed
4570 # - copymode copy mode for files in general
4571 # - lcopymode copy mode for files from local_gnulib_path
4572 # - do_copyrights true if copyright notices in files should be replaced,
4573 # blank otherwise
4574 func_import ()
4576 # Get the cached settings.
4577 # In 'import' mode, we read them only for the purpose of knowing the old
4578 # installed file list, and don't use them as defaults.
4579 cached_local_gnulib_path=
4580 cached_specified_modules=
4581 cached_incobsolete=
4582 cached_inc_cxx_tests=
4583 cached_inc_longrunning_tests=
4584 cached_inc_privileged_tests=
4585 cached_inc_unportable_tests=
4586 cached_inc_all_tests=
4587 cached_avoidlist=
4588 cached_sourcebase=
4589 cached_m4base=
4590 cached_pobase=
4591 cached_docbase=
4592 cached_testsbase=
4593 cached_inctests=
4594 cached_libname=
4595 cached_lgpl=
4596 cached_makefile_name=
4597 cached_cond_dependencies=
4598 cached_libtool=
4599 cached_macro_prefix=
4600 cached_po_domain=
4601 cached_witness_c_macro=
4602 cached_vc_files=
4603 cached_files=
4604 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4605 cached_libtool=false
4606 my_sed_traces='
4607 s,#.*$,,
4608 s,^dnl .*$,,
4609 s, dnl .*$,,
4610 /gl_LOCAL_DIR(/ {
4611 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_path="\1",p
4613 /gl_MODULES(/ {
4616 s/)/)/
4621 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4623 /gl_WITH_OBSOLETE/ {
4624 s,^.*$,cached_incobsolete=true,p
4626 /gl_WITH_CXX_TESTS/ {
4627 s,^.*$,cached_inc_cxx_tests=true,p
4629 /gl_WITH_LONGRUNNING_TESTS/ {
4630 s,^.*$,cached_inc_longrunning_tests=true,p
4632 /gl_WITH_PRIVILEGED_TESTS/ {
4633 s,^.*$,cached_inc_privileged_tests=true,p
4635 /gl_WITH_UNPORTABLE_TESTS/ {
4636 s,^.*$,cached_inc_unportable_tests=true,p
4638 /gl_WITH_ALL_TESTS/ {
4639 s,^.*$,cached_inc_all_tests=true,p
4641 /gl_AVOID(/ {
4642 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4644 /gl_SOURCE_BASE(/ {
4645 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4647 /gl_M4_BASE(/ {
4648 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4650 /gl_PO_BASE(/ {
4651 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4653 /gl_DOC_BASE(/ {
4654 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4656 /gl_TESTS_BASE(/ {
4657 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4659 /gl_WITH_TESTS/ {
4660 s,^.*$,cached_inctests=true,p
4662 /gl_LIB(/ {
4663 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4665 /gl_LGPL(/ {
4666 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4668 /gl_LGPL/ {
4669 s,^.*$,cached_lgpl=yes,p
4671 /gl_MAKEFILE_NAME(/ {
4672 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4674 /gl_CONDITIONAL_DEPENDENCIES/ {
4675 s,^.*$,cached_cond_dependencies=true,p
4677 /gl_LIBTOOL/ {
4678 s,^.*$,cached_libtool=true,p
4680 /gl_MACRO_PREFIX(/ {
4681 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4683 /gl_PO_DOMAIN(/ {
4684 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4686 /gl_WITNESS_C_MACRO(/ {
4687 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4689 /gl_VC_FILES(/ {
4690 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4692 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4693 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4694 my_sed_traces='
4695 s,#.*$,,
4696 s,^dnl .*$,,
4697 s, dnl .*$,,
4698 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4699 s,^.*$,cached_files=",p
4703 s,^\]).*$,",
4705 s,["$`\\],,g
4712 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4716 if test "$mode" = import; then
4717 # In 'import' mode, the new set of specified modules overrides the cached
4718 # set of modules. Ignore the cached settings.
4719 specified_modules="$1"
4720 else
4721 # Merge the cached settings with the specified ones.
4722 # The m4base must be the same as expected from the pathname.
4723 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4724 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4726 # The local_gnulib_path defaults to the cached one. Recall that the cached one
4727 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4728 if test -z "$local_gnulib_path"; then
4729 func_reconstruct_cached_local_gnulib_path
4731 case $mode in
4732 add-import)
4733 # Append the cached and the specified module names. So that
4734 # "gnulib-tool --add-import foo" means to add the module foo.
4735 specified_modules="$cached_specified_modules $1"
4737 remove-import)
4738 # Take the cached module names, minus the specified module names.
4739 specified_modules=
4740 if $have_associative; then
4741 # Use an associative array, for O(N) worst-case run time.
4742 declare -A to_remove
4743 for m in $1; do
4744 eval 'to_remove[$m]=yes'
4745 done
4746 for module in $cached_specified_modules; do
4747 if eval 'test -z "${to_remove[$module]}"'; then
4748 func_append specified_modules "$module "
4750 done
4751 else
4752 # This loop has O(N**2) worst-case run time.
4753 for module in $cached_specified_modules; do
4754 to_remove=
4755 for m in $1; do
4756 if test "$m" = "$module"; then
4757 to_remove=yes
4758 break
4760 done
4761 if test -z "$to_remove"; then
4762 func_append specified_modules "$module "
4764 done
4767 update)
4768 # Take the cached module names. There are no specified module names.
4769 specified_modules="$cached_specified_modules"
4771 esac
4772 # Included obsolete modules among the dependencies if specified either way.
4773 if test -z "$incobsolete"; then
4774 incobsolete="$cached_incobsolete"
4776 # Included special kinds of tests modules among the dependencies if specified
4777 # either way.
4778 if test -z "$inc_cxx_tests"; then
4779 inc_cxx_tests="$cached_inc_cxx_tests"
4781 if test -z "$inc_longrunning_tests"; then
4782 inc_longrunning_tests="$cached_inc_longrunning_tests"
4784 if test -z "$inc_privileged_tests"; then
4785 inc_privileged_tests="$cached_inc_privileged_tests"
4787 if test -z "$inc_unportable_tests"; then
4788 inc_unportable_tests="$cached_inc_unportable_tests"
4790 if test -z "$inc_all_tests"; then
4791 inc_all_tests="$cached_inc_all_tests"
4793 # Append the cached and the specified avoidlist. This is probably better
4794 # than dropping the cached one when --avoid is specified at least once.
4795 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4796 avoidlist=`echo $avoidlist`
4798 # The sourcebase defaults to the cached one.
4799 if test -z "$sourcebase"; then
4800 sourcebase="$cached_sourcebase"
4801 if test -z "$sourcebase"; then
4802 func_fatal_error "missing --source-base option"
4805 # The pobase defaults to the cached one.
4806 if test -z "$pobase"; then
4807 pobase="$cached_pobase"
4809 # The docbase defaults to the cached one.
4810 if test -z "$docbase"; then
4811 docbase="$cached_docbase"
4812 if test -z "$docbase"; then
4813 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."
4816 # The testsbase defaults to the cached one.
4817 if test -z "$testsbase"; then
4818 testsbase="$cached_testsbase"
4819 if test -z "$testsbase"; then
4820 func_fatal_error "missing --tests-base option"
4823 # Require the tests if specified either way.
4824 if ! $inctests; then
4825 inctests="$cached_inctests"
4826 if test -z "$inctests"; then
4827 inctests=false
4830 # The libname defaults to the cached one.
4831 if test -z "$supplied_libname"; then
4832 libname="$cached_libname"
4833 if test -z "$libname"; then
4834 func_fatal_error "missing --lib option"
4837 # Require LGPL if specified either way.
4838 if test -z "$lgpl"; then
4839 lgpl="$cached_lgpl"
4841 # The makefile_name defaults to the cached one.
4842 if test -z "$makefile_name"; then
4843 makefile_name="$cached_makefile_name"
4845 # Use conditional dependencies if specified either way.
4846 if test -z "$cond_dependencies"; then
4847 cond_dependencies="$cached_cond_dependencies"
4849 # Use libtool if specified either way, or if guessed.
4850 if test -z "$libtool"; then
4851 if test -n "$cached_m4base"; then
4852 libtool="$cached_libtool"
4853 else
4854 libtool="$guessed_libtool"
4857 # The macro_prefix defaults to the cached one.
4858 if test -z "$macro_prefix"; then
4859 macro_prefix="$cached_macro_prefix"
4860 if test -z "$macro_prefix"; then
4861 func_fatal_error "missing --macro-prefix option"
4864 # The po_domain defaults to the cached one.
4865 if test -z "$po_domain"; then
4866 po_domain="$cached_po_domain"
4868 # The witness_c_macro defaults to the cached one.
4869 if test -z "$witness_c_macro"; then
4870 witness_c_macro="$cached_witness_c_macro"
4872 # The vc_files defaults to the cached one.
4873 if test -z "$vc_files"; then
4874 vc_files="$cached_vc_files"
4876 # Ensure constraints.
4877 if test "$cond_dependencies" = true && $inctests; then
4878 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4879 func_exit 1
4882 # --without-*-tests options are not supported here.
4883 excl_cxx_tests=
4884 excl_longrunning_tests=
4885 excl_privileged_tests=
4886 excl_unportable_tests=
4888 # Canonicalize the list of specified modules.
4889 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4891 # Include all kinds of tests modules if --with-all-tests was specified.
4892 inc_all_direct_tests="$inc_all_tests"
4893 inc_all_indirect_tests="$inc_all_tests"
4895 # Determine final module list.
4896 modules="$specified_modules"
4897 func_modules_transitive_closure
4898 if test $verbose -ge 0; then
4899 func_show_module_list
4901 final_modules="$modules"
4903 # Determine main module list and tests-related module list separately.
4904 func_modules_transitive_closure_separately
4906 # Determine whether a $testsbase/libtests.a is needed.
4907 func_determine_use_libtests
4909 # Add the dummy module to the main module list or to the tests-related module
4910 # list if needed.
4911 func_modules_add_dummy_separately
4913 # If --lgpl, verify that the licenses of modules are compatible.
4914 if test -n "$lgpl"; then
4915 license_incompatibilities=
4916 for module in $main_modules; do
4917 license=`func_get_license $module`
4918 case $license in
4919 'GPLed build tool') ;;
4920 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4922 case "$lgpl" in
4923 yes | 3)
4924 case $license in
4925 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
4926 *) func_append license_incompatibilities "$module $license$nl" ;;
4927 esac
4929 3orGPLv2)
4930 case $license in
4931 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
4932 *) func_append license_incompatibilities "$module $license$nl" ;;
4933 esac
4936 case $license in
4937 LGPLv2+) ;;
4938 *) func_append license_incompatibilities "$module $license$nl" ;;
4939 esac
4941 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4942 esac
4944 esac
4945 done
4946 if test -n "$license_incompatibilities"; then
4947 # Format the license incompatibilities as a table.
4948 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4949 s,^\(.................................................[^ ]*\) *, \1 ,'
4950 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4951 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4955 # Show banner notice of every module.
4956 modules="$main_modules"
4957 func_modules_notice
4959 # Determine script to apply to imported library files.
4960 sed_transform_lib_file=
4961 for module in $main_modules; do
4962 if test $module = config-h; then
4963 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4964 sed_transform_lib_file=$sed_transform_lib_file'
4965 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4967 break
4969 done
4970 sed_transform_main_lib_file="$sed_transform_lib_file"
4971 if test -n "$do_copyrights"; then
4972 if test -n "$lgpl"; then
4973 # Update license.
4974 case "$lgpl" in
4975 yes | 3)
4976 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4977 s/GNU General/GNU Lesser General/g
4978 s/General Public License/Lesser General Public License/g
4979 s/Lesser Lesser General Public License/Lesser General Public License/g
4982 3orGPLv2)
4983 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4984 /^ *This program is free software/i\
4985 This program is free software: you can redistribute it and\/or\
4986 modify it under the terms of either:\
4988 * the GNU Lesser General Public License as published by the Free\
4989 Software Foundation; either version 3 of the License, or (at your\
4990 option) any later version.\
4994 * the GNU General Public License as published by the Free\
4995 Software Foundation; either version 2 of the License, or (at your\
4996 option) any later version.\
4998 or both in parallel, as here.
4999 /^ *This program is free software/,/^$/d
5003 sed_transform_main_lib_file=$sed_transform_main_lib_file'
5004 s/GNU General/GNU Lesser General/g
5005 s/General Public License/Lesser General Public License/g
5006 s/Lesser Lesser General Public License/Lesser General Public License/g
5008 s/version [23]\([ ,]\)/version 2.1\1/g
5011 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
5012 esac
5013 else
5014 # Update license.
5015 sed_transform_main_lib_file=$sed_transform_main_lib_file'
5016 s/GNU Lesser General/GNU General/g
5017 s/Lesser General Public License/General Public License/g
5019 s/GNU Library General/GNU General/g
5020 s/Library General Public License/General Public License/g
5022 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
5027 # Determine script to apply to auxiliary files that go into $auxdir/.
5028 sed_transform_build_aux_file=
5029 if test -n "$do_copyrights"; then
5030 # Update license.
5031 sed_transform_build_aux_file=$sed_transform_build_aux_file'
5032 s/GNU Lesser General/GNU General/g
5033 s/Lesser General Public License/General Public License/g
5035 s/GNU Library General/GNU General/g
5036 s/Library General Public License/General Public License/g
5038 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
5042 # Determine script to apply to library files that go into $testsbase/.
5043 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
5044 if test -n "$do_copyrights"; then
5045 # Update license.
5046 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
5047 s/GNU Lesser General/GNU General/g
5048 s/Lesser General Public License/General Public License/g
5050 s/GNU Library General/GNU General/g
5051 s/Library General Public License/General Public License/g
5053 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
5057 # Determine the final file lists.
5058 func_modules_to_filelist_separately
5060 test -n "$files" \
5061 || func_fatal_error "refusing to do nothing"
5063 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
5064 new_files="$files m4/gnulib-tool.m4"
5065 old_files="$cached_files"
5066 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
5067 func_append old_files " m4/gnulib-tool.m4"
5070 rewritten='%REWRITTEN%'
5071 sed_rewrite_old_files="\
5072 s,^build-aux/,$rewritten$auxdir/,
5073 s,^doc/,$rewritten$cached_docbase/,
5074 s,^lib/,$rewritten$cached_sourcebase/,
5075 s,^m4/,$rewritten$cached_m4base/,
5076 s,^tests/,$rewritten$cached_testsbase/,
5077 s,^tests=lib/,$rewritten$cached_testsbase/,
5078 s,^top/,$rewritten,
5079 s,^$rewritten,,"
5080 sed_rewrite_new_files="\
5081 s,^build-aux/,$rewritten$auxdir/,
5082 s,^doc/,$rewritten$docbase/,
5083 s,^lib/,$rewritten$sourcebase/,
5084 s,^m4/,$rewritten$m4base/,
5085 s,^tests/,$rewritten$testsbase/,
5086 s,^tests=lib/,$rewritten$testsbase/,
5087 s,^top/,$rewritten,
5088 s,^$rewritten,,"
5090 # Create directories.
5091 { echo "$sourcebase"
5092 echo "$m4base"
5093 if test -n "$pobase"; then
5094 echo "$pobase"
5096 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
5097 if test -n "$docfiles"; then
5098 echo "$docbase"
5100 if $inctests; then
5101 echo "$testsbase"
5103 echo "$auxdir"
5104 for f in $files; do echo $f; done \
5105 | sed -e "$sed_rewrite_new_files" \
5106 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5107 | LC_ALL=C sort -u
5108 } > "$tmp"/dirs
5109 { # Rearrange file descriptors. Needed because "while ... done < ..."
5110 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5111 exec 5<&0 < "$tmp"/dirs
5112 while read d; do
5113 if test ! -d "$destdir/$d"; then
5114 if $doit; then
5115 echo "Creating directory $destdir/$d"
5116 mkdir -p "$destdir/$d" || func_fatal_error "failed"
5117 else
5118 echo "Create directory $destdir/$d"
5121 done
5122 exec 0<&5 5<&-
5125 # Copy files or make symbolic links or hard links. Remove obsolete files.
5126 added_files=''
5127 removed_files=''
5128 delimiter=' '
5129 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5130 # representing the files according to the last gnulib-tool invocation.
5131 for f in $old_files; do echo $f; done \
5132 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
5133 | LC_ALL=C sort \
5134 > "$tmp"/old-files
5135 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5136 # representing the files after this gnulib-tool invocation.
5137 for f in $new_files; do echo $f; done \
5138 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
5139 | LC_ALL=C sort \
5140 > "$tmp"/new-files
5141 # First the files that are in old-files, but not in new-files:
5142 sed_take_first_column='s,'"$delimiter"'.*,,'
5143 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
5144 # Remove the file. Do nothing if the user already removed it.
5145 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
5146 if $doit; then
5147 echo "Removing file $g (backup in ${g}~)"
5148 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
5149 else
5150 echo "Remove file $g (backup in ${g}~)"
5152 func_append removed_files "$g$nl"
5154 done
5155 # func_add_or_update handles a file that ought to be present afterwards.
5156 # Uses parameters
5157 # - f the original file name
5158 # - g the rewritten file name
5159 # - already_present nonempty if the file should already exist, empty
5160 # otherwise
5161 func_add_or_update ()
5163 of="$f"
5164 case "$f" in
5165 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5166 esac
5167 func_dest_tmpfilename "$g"
5168 func_lookup_file "$f"
5169 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5170 case "$f" in
5171 *.class | *.mo )
5172 # Don't process binary files with sed.
5175 if test -n "$sed_transform_main_lib_file"; then
5176 case "$of" in
5177 lib/*)
5178 sed -e "$sed_transform_main_lib_file" \
5179 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5181 esac
5183 if test -n "$sed_transform_build_aux_file"; then
5184 case "$of" in
5185 build-aux/*)
5186 sed -e "$sed_transform_build_aux_file" \
5187 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5189 esac
5191 if test -n "$sed_transform_testsrelated_lib_file"; then
5192 case "$of" in
5193 tests=lib/*)
5194 sed -e "$sed_transform_testsrelated_lib_file" \
5195 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5197 esac
5200 esac
5201 if test -f "$destdir/$g"; then
5202 # The file already exists.
5203 func_update_file
5204 else
5205 # Install the file.
5206 # Don't protest if the file should be there but isn't: it happens
5207 # frequently that developers don't put autogenerated files under version control.
5208 func_add_file
5209 func_append added_files "$g$nl"
5211 rm -f "$tmpfile"
5213 # Then the files that are in new-files, but not in old-files:
5214 sed_take_last_column='s,^.*'"$delimiter"',,'
5215 already_present=
5216 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
5217 | sed -e "$sed_take_last_column" \
5218 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
5219 { # Rearrange file descriptors. Needed because "while ... done < ..."
5220 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5221 exec 5<&0 < "$tmp"/added-files
5222 while read g f; do
5223 func_add_or_update
5224 done
5225 exec 0<&5 5<&-
5227 # Then the files that are in new-files and in old-files:
5228 already_present=true
5229 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
5230 | sed -e "$sed_take_last_column" \
5231 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
5232 { # Rearrange file descriptors. Needed because "while ... done < ..."
5233 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5234 exec 5<&0 < "$tmp"/kept-files
5235 while read g f; do
5236 func_add_or_update
5237 done
5238 exec 0<&5 5<&-
5241 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
5242 actioncmd="# gnulib-tool --import"
5244 # Local helper.
5245 func_append_local_dir ()
5247 func_append "$1" " --local-dir=$2"
5249 func_path_foreach "$local_gnulib_path" func_append_local_dir actioncmd %dir%
5251 # Break the action command log into multiple lines.
5252 # Emacs puts some gnulib-tool log lines in its source repository, and
5253 # git send-email rejects patch lines longer than 998 characters.
5254 # Also, config.status uses awk, and the HP-UX 11.00 awk fails if a
5255 # line has length >= 3071; similarly, the IRIX 6.5 awk fails if a
5256 # line has length >= 3072.
5257 func_append_actionarg ()
5259 func_append actioncmd " \\$nl# $1"
5261 func_append_actionarg "--lib=$libname"
5262 func_append_actionarg "--source-base=$sourcebase"
5263 func_append_actionarg "--m4-base=$m4base"
5264 if test -n "$pobase"; then
5265 func_append_actionarg "--po-base=$pobase"
5267 func_append_actionarg "--doc-base=$docbase"
5268 func_append_actionarg "--tests-base=$testsbase"
5269 func_append_actionarg "--aux-dir=$auxdir"
5270 if $inctests; then
5271 func_append_actionarg "--with-tests"
5273 if test -n "$incobsolete"; then
5274 func_append_actionarg "--with-obsolete"
5276 if test -n "$inc_cxx_tests"; then
5277 func_append_actionarg "--with-c++-tests"
5279 if test -n "$inc_longrunning_tests"; then
5280 func_append_actionarg "--with-longrunning-tests"
5282 if test -n "$inc_privileged_tests"; then
5283 func_append_actionarg "--with-privileged-tests"
5285 if test -n "$inc_unportable_tests"; then
5286 func_append_actionarg "--with-unportable-tests"
5288 if test -n "$inc_all_tests"; then
5289 func_append_actionarg "--with-all-tests"
5291 if test -n "$lgpl"; then
5292 if test "$lgpl" = yes; then
5293 func_append_actionarg "--lgpl"
5294 else
5295 func_append_actionarg "--lgpl=$lgpl"
5298 if $gnu_make; then
5299 func_append_actionarg "--gnu-make"
5301 if test -n "$makefile_name"; then
5302 func_append_actionarg "--makefile-name=$makefile_name"
5304 if test "$cond_dependencies" = true; then
5305 func_append_actionarg "--conditional-dependencies"
5306 else
5307 func_append_actionarg "--no-conditional-dependencies"
5309 if test "$libtool" = true; then
5310 func_append_actionarg "--libtool"
5311 else
5312 func_append_actionarg "--no-libtool"
5314 func_append_actionarg "--macro-prefix=$macro_prefix"
5315 if test -n "$po_domain"; then
5316 func_append_actionarg "--po-domain=$po_domain"
5318 if test -n "$witness_c_macro"; then
5319 func_append_actionarg "--witness-c-macro=$witness_c_macro"
5321 if test -n "$vc_files"; then
5322 if test "$vc_files" = true; then
5323 func_append_actionarg "--vc-files"
5324 else
5325 func_append_actionarg "--no-vc-files"
5328 for module in $avoidlist; do
5329 func_append_actionarg "--avoid=$module"
5330 done
5331 for module in $specified_modules; do
5332 func_append_actionarg "$module"
5333 done
5335 # Determine include_guard_prefix.
5336 func_compute_include_guard_prefix
5338 # Default the makefile name to Makefile.am.
5339 if test -n "$makefile_name"; then
5340 makefile_am=$makefile_name
5341 else
5342 makefile_am=Makefile.am
5345 # Create normal Makefile.ams.
5346 for_test=false
5348 # Setup list of Makefile.am edits that are to be performed afterwards.
5349 # Some of these edits apply to files that we will generate; others are
5350 # under the responsibility of the developer.
5351 makefile_am_edits=0
5352 # func_note_Makefile_am_edit dir var value [dotfirst]
5353 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
5354 # ${value}.
5355 # If ${dotfirst} is non-empty, this mention needs to be present after '.'.
5356 # This is a special hack for the SUBDIRS variable, cf.
5357 # <https://www.gnu.org/software/automake/manual/html_node/Subdirectories.html>.
5358 func_note_Makefile_am_edit ()
5360 makefile_am_edits=`expr $makefile_am_edits + 1`
5361 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
5362 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
5363 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
5364 eval makefile_am_edit${makefile_am_edits}_dotfirst=\"\$4\"
5366 if test "$makefile_am" = Makefile.am; then
5367 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
5368 sourcebase_base=`basename "$sourcebase"`
5369 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
5371 if test -n "$pobase"; then
5372 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
5373 pobase_base=`basename "$pobase"`
5374 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
5376 if $inctests; then
5377 if test "$makefile_am" = Makefile.am; then
5378 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
5379 testsbase_base=`basename "$testsbase"`
5380 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base" true
5383 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
5385 # Find the first parent directory of $m4base that contains or will contain
5386 # a Makefile.am.
5387 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
5388 s,//*$,/,'
5389 sed_butlast='s,[^/][^/]*//*$,,'
5390 dir1="${m4base}/"; dir2=""
5391 while test -n "$dir1" \
5392 && ! { test -f "${destdir}/${dir1}Makefile.am" \
5393 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5394 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5395 || { $inctests \
5396 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
5397 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
5398 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
5399 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
5400 done
5401 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
5404 # Create library makefile.
5405 func_dest_tmpfilename $sourcebase/$makefile_am
5406 destfile="$sourcebase/$makefile_am"
5407 modules="$main_modules"
5408 func_emit_lib_Makefile_am > "$tmpfile"
5409 if test -f "$destdir"/$sourcebase/$makefile_am; then
5410 if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
5411 rm -f "$tmpfile"
5412 else
5413 if $doit; then
5414 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5415 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
5416 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5417 else
5418 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5419 rm -f "$tmpfile"
5422 else
5423 if $doit; then
5424 echo "Creating $sourcebase/$makefile_am"
5425 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5426 else
5427 echo "Create $sourcebase/$makefile_am"
5428 rm -f "$tmpfile"
5430 func_append added_files "$sourcebase/$makefile_am$nl"
5433 # Create po/ directory.
5434 if test -n "$pobase"; then
5435 # Create po makefile and auxiliary files.
5436 for file in Makefile.in.in remove-potcdate.sin; do
5437 func_dest_tmpfilename $pobase/$file
5438 func_lookup_file build-aux/po/$file
5439 cat "$lookedup_file" > "$tmpfile"
5440 if test -f "$destdir"/$pobase/$file; then
5441 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
5442 rm -f "$tmpfile"
5443 else
5444 if $doit; then
5445 echo "Updating $pobase/$file (backup in $pobase/$file~)"
5446 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
5447 mv -f "$tmpfile" "$destdir"/$pobase/$file
5448 else
5449 echo "Update $pobase/$file (backup in $pobase/$file~)"
5450 rm -f "$tmpfile"
5453 else
5454 if $doit; then
5455 echo "Creating $pobase/$file"
5456 mv -f "$tmpfile" "$destdir"/$pobase/$file
5457 else
5458 echo "Create $pobase/$file"
5459 rm -f "$tmpfile"
5461 func_append added_files "$pobase/$file$nl"
5463 done
5464 # Create po makefile parameterization, part 1.
5465 func_dest_tmpfilename $pobase/Makevars
5466 func_emit_po_Makevars > "$tmpfile"
5467 if test -f "$destdir"/$pobase/Makevars; then
5468 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
5469 rm -f "$tmpfile"
5470 else
5471 if $doit; then
5472 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
5473 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
5474 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5475 else
5476 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
5477 rm -f "$tmpfile"
5480 else
5481 if $doit; then
5482 echo "Creating $pobase/Makevars"
5483 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5484 else
5485 echo "Create $pobase/Makevars"
5486 rm -f "$tmpfile"
5488 func_append added_files "$pobase/Makevars$nl"
5490 # Create po makefile parameterization, part 2.
5491 func_dest_tmpfilename $pobase/POTFILES.in
5492 func_emit_po_POTFILES_in > "$tmpfile"
5493 if test -f "$destdir"/$pobase/POTFILES.in; then
5494 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5495 rm -f "$tmpfile"
5496 else
5497 if $doit; then
5498 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5499 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5500 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5501 else
5502 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5503 rm -f "$tmpfile"
5506 else
5507 if $doit; then
5508 echo "Creating $pobase/POTFILES.in"
5509 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5510 else
5511 echo "Create $pobase/POTFILES.in"
5512 rm -f "$tmpfile"
5514 func_append added_files "$pobase/POTFILES.in$nl"
5516 # Fetch PO files.
5517 TP_URL="https://translationproject.org/latest/"
5518 if $doit; then
5519 echo "Fetching gnulib PO files from $TP_URL"
5520 (cd "$destdir"/$pobase \
5521 && wget --no-verbose --mirror --level=1 -nd -A.po -P . "${TP_URL}gnulib/"
5523 else
5524 echo "Fetch gnulib PO files from $TP_URL"
5526 # Create po/LINGUAS.
5527 if $doit; then
5528 func_dest_tmpfilename $pobase/LINGUAS
5529 (cd "$destdir"/$pobase \
5530 && { echo '# Set of available languages.'
5531 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5533 ) > "$tmpfile"
5534 if test -f "$destdir"/$pobase/LINGUAS; then
5535 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5536 rm -f "$tmpfile"
5537 else
5538 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5539 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5540 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5542 else
5543 echo "Creating $pobase/LINGUAS"
5544 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5545 func_append added_files "$pobase/LINGUAS$nl"
5547 else
5548 if test -f "$destdir"/$pobase/LINGUAS; then
5549 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5550 else
5551 echo "Create $pobase/LINGUAS"
5556 # func_count_relative_local_gnulib_path
5557 # gl_LOCAL_DIR requires local_gnulib_path to be set relatively to destdir
5558 # Input:
5559 # - local_gnulib_path from --local-dir
5560 # - destdir from --dir
5561 # Output:
5562 # - relative_local_dir path to be stored into gl_LOCAL_DIR
5563 func_count_relative_local_gnulib_path ()
5565 save_IFS=$IFS
5566 IFS=$PATH_SEPARATOR
5567 relative_local_gnulib_path=
5568 for local_dir in $local_gnulib_path
5570 # Store the local_dir relative to destdir.
5571 case "$local_dir" in
5572 "" | /*)
5573 relative_local_dir="$local_dir" ;;
5575 case "$destdir" in
5576 /*) relative_local_dir="$local_dir" ;;
5578 # destdir, local_dir are both relative.
5579 func_relativize "$destdir" "$local_dir"
5580 relative_local_dir="$reldir" ;;
5581 esac ;;
5582 esac
5583 func_path_append relative_local_gnulib_path "$relative_local_dir"
5584 done
5585 IFS=$save_IFS
5588 # Create m4/gnulib-cache.m4.
5589 func_dest_tmpfilename $m4base/gnulib-cache.m4
5591 func_emit_copyright_notice
5592 echo "#"
5593 echo "# This file represents the specification of how gnulib-tool is used."
5594 echo "# It acts as a cache: It is written and read by gnulib-tool."
5595 echo "# In projects that use version control, this file is meant to be put under"
5596 echo "# version control, like the configure.ac and various Makefile.am files."
5597 echo
5598 echo
5599 echo "# Specification in the form of a command-line invocation:"
5600 printf '%s\n' "$actioncmd"
5601 echo
5602 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5603 func_count_relative_local_gnulib_path
5604 echo "gl_LOCAL_DIR([$relative_local_gnulib_path])"
5605 echo "gl_MODULES(["
5606 echo "$specified_modules" | sed -e 's/^/ /g'
5607 echo "])"
5608 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5609 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5610 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5611 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5612 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5613 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5614 echo "gl_AVOID([$avoidlist])"
5615 echo "gl_SOURCE_BASE([$sourcebase])"
5616 echo "gl_M4_BASE([$m4base])"
5617 echo "gl_PO_BASE([$pobase])"
5618 echo "gl_DOC_BASE([$docbase])"
5619 echo "gl_TESTS_BASE([$testsbase])"
5620 if $inctests; then
5621 echo "gl_WITH_TESTS"
5623 echo "gl_LIB([$libname])"
5624 if test -n "$lgpl"; then
5625 if test "$lgpl" = yes; then
5626 echo "gl_LGPL"
5627 else
5628 echo "gl_LGPL([$lgpl])"
5631 echo "gl_MAKEFILE_NAME([$makefile_name])"
5632 if test "$cond_dependencies" = true; then
5633 echo "gl_CONDITIONAL_DEPENDENCIES"
5635 if test "$libtool" = true; then
5636 echo "gl_LIBTOOL"
5638 echo "gl_MACRO_PREFIX([$macro_prefix])"
5639 echo "gl_PO_DOMAIN([$po_domain])"
5640 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5641 if test -n "$vc_files"; then
5642 echo "gl_VC_FILES([$vc_files])"
5644 ) > "$tmpfile"
5645 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5646 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
5647 rm -f "$tmpfile"
5648 else
5649 if $doit; then
5650 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5651 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5652 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5653 else
5654 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5655 if false; then
5656 cat "$tmpfile"
5657 echo
5658 echo "# gnulib-cache.m4 ends here"
5660 rm -f "$tmpfile"
5663 else
5664 if $doit; then
5665 echo "Creating $m4base/gnulib-cache.m4"
5666 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5667 else
5668 echo "Create $m4base/gnulib-cache.m4"
5669 cat "$tmpfile"
5670 rm -f "$tmpfile"
5674 # Create m4/gnulib-comp.m4.
5675 func_dest_tmpfilename $m4base/gnulib-comp.m4
5677 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5678 func_emit_copyright_notice
5679 echo "#"
5680 echo "# This file represents the compiled summary of the specification in"
5681 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5682 echo "# to be invoked from configure.ac."
5683 echo "# In projects that use version control, this file can be treated like"
5684 echo "# other built files."
5685 echo
5686 echo
5687 echo "# This macro should be invoked from $configure_ac, in the section"
5688 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5689 echo "# any checks for libraries, header files, types and library functions."
5690 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5691 echo "["
5692 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5693 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5694 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5695 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5697 func_emit_pre_early_macros : ' ' "$final_modules"
5699 if ! $gnu_make && test -n "$uses_subdirs"; then
5700 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5702 for module in $final_modules; do
5703 func_verify_module
5704 if test -n "$module"; then
5705 echo "# Code from module $module:"
5706 func_get_autoconf_early_snippet "$module"
5708 done \
5709 | sed -e '/^$/d;' -e 's/^/ /'
5710 echo "])"
5711 echo
5712 echo "# This macro should be invoked from $configure_ac, in the section"
5713 echo "# \"Check for header files, types and library functions\"."
5714 echo "AC_DEFUN([${macro_prefix}_INIT],"
5715 echo "["
5716 if test "$libtool" = true; then
5717 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5718 echo " gl_cond_libtool=true"
5719 else
5720 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5721 echo " gl_cond_libtool=false"
5722 echo " gl_libdeps="
5723 echo " gl_ltlibdeps="
5725 if test "$auxdir" != "build-aux"; then
5726 sed_replace_build_aux='
5728 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5729 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5732 else
5733 sed_replace_build_aux="$sed_noop"
5735 echo " gl_m4_base='$m4base'"
5736 func_emit_initmacro_start $macro_prefix
5737 echo " gl_source_base='$sourcebase'"
5738 if test -n "$witness_c_macro"; then
5739 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5741 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false true
5742 if test -n "$witness_c_macro"; then
5743 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5745 echo " # End of code from modules"
5746 func_emit_initmacro_end $macro_prefix
5747 echo " gltests_libdeps="
5748 echo " gltests_ltlibdeps="
5749 func_emit_initmacro_start ${macro_prefix}tests
5750 echo " gl_source_base='$testsbase'"
5751 # Define a tests witness macro that depends on the package.
5752 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5753 # See <https://lists.gnu.org/r/automake/2009-05/msg00145.html>.
5754 echo "changequote(,)dnl"
5755 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"
5756 echo "changequote([, ])dnl"
5757 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5758 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5759 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5760 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true true true
5761 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5762 func_emit_initmacro_end ${macro_prefix}tests
5763 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5764 # created using libtool, because libtool already handles the dependencies.
5765 if test "$libtool" != true; then
5766 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5767 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5768 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5769 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5770 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5772 if $use_libtests; then
5773 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5774 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5776 echo "])"
5777 func_emit_initmacro_done $macro_prefix $sourcebase
5778 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5779 echo
5780 echo "# This macro records the list of files which have been installed by"
5781 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5782 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5783 echo "$files" | sed -e 's,^, ,'
5784 echo "])"
5785 ) > "$tmpfile"
5786 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5787 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
5788 rm -f "$tmpfile"
5789 else
5790 if $doit; then
5791 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5792 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5793 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5794 else
5795 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5796 if false; then
5797 cat "$tmpfile"
5798 echo
5799 echo "# gnulib-comp.m4 ends here"
5801 rm -f "$tmpfile"
5804 else
5805 if $doit; then
5806 echo "Creating $m4base/gnulib-comp.m4"
5807 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5808 else
5809 echo "Create $m4base/gnulib-comp.m4"
5810 cat "$tmpfile"
5811 rm -f "$tmpfile"
5815 if $inctests; then
5816 # Create tests makefile.
5817 func_dest_tmpfilename $testsbase/$makefile_am
5818 destfile="$testsbase/$makefile_am"
5819 modules="$testsrelated_modules"
5820 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5821 if test -f "$destdir"/$testsbase/$makefile_am; then
5822 if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
5823 rm -f "$tmpfile"
5824 else
5825 if $doit; then
5826 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5827 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5828 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5829 else
5830 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5831 rm -f "$tmpfile"
5834 else
5835 if $doit; then
5836 echo "Creating $testsbase/$makefile_am"
5837 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5838 else
5839 echo "Create $testsbase/$makefile_am"
5840 rm -f "$tmpfile"
5842 func_append added_files "$testsbase/$makefile_am$nl"
5846 if test "$vc_files" != false; then
5847 # Update the .cvsignore and .gitignore files.
5848 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5849 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5850 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5851 echo "$m4base/|A|gnulib-comp.m4"
5852 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5853 { # Rearrange file descriptors. Needed because "while ... done < ..."
5854 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5855 exec 5<&0 < "$tmp"/fileset-changes
5856 func_update_ignorelist ()
5858 ignore="$1"
5859 if test "$ignore" = .gitignore; then
5860 # In a .gitignore file, "foo" applies to the current directory and all
5861 # subdirectories, whereas "/foo" applies to the current directory only.
5862 anchor='/'
5863 escaped_anchor='\/'
5864 doubly_escaped_anchor='\\/'
5865 else
5866 anchor=''
5867 escaped_anchor=''
5868 doubly_escaped_anchor=''
5870 if test -f "$destdir/$dir$ignore"; then
5871 if test -n "$dir_added" || test -n "$dir_removed"; then
5872 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5873 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5874 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5875 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5876 > "$tmp"/ignore-removed
5878 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5879 if $doit; then
5880 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5881 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5882 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5883 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5884 } > "$tmp"/sed-ignore-removed
5885 { cat "$destdir/$dir$ignore"~
5886 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5887 } | sed -f "$tmp"/sed-ignore-removed \
5888 > "$destdir/$dir$ignore"
5889 else
5890 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5894 else
5895 if test -n "$dir_added"; then
5896 if $doit; then
5897 echo "Creating $destdir/$dir$ignore"
5899 if test "$ignore" = .cvsignore; then
5900 echo ".deps"
5901 # Automake generates Makefile rules that create .dirstamp files.
5902 echo ".dirstamp"
5904 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5905 } > "$destdir/$dir$ignore"
5906 else
5907 echo "Create $destdir/$dir$ignore"
5912 func_done_dir ()
5914 dir="$1"
5915 dir_added="$2"
5916 dir_removed="$3"
5917 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5918 func_update_ignorelist .cvsignore
5920 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5921 func_update_ignorelist .gitignore
5924 last_dir=
5925 last_dir_added=
5926 last_dir_removed=
5927 while read line; do
5928 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5929 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5930 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5931 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5932 if test "$next_dir" != "$last_dir"; then
5933 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5934 last_dir="$next_dir"
5935 last_dir_added=
5936 last_dir_removed=
5938 case $op in
5939 A) func_append last_dir_added "$file$nl";;
5940 R) func_append last_dir_removed "$file$nl";;
5941 esac
5942 done
5943 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5944 exec 0<&5 5<&-
5948 echo "Finished."
5949 echo
5950 echo "You may need to add #include directives for the following .h files."
5951 # Intersect $specified_modules and $main_modules
5952 # (since $specified_modules is not necessarily of subset of $main_modules
5953 # - some may have been skipped through --avoid, and since the elements of
5954 # $main_modules but not in $specified_modules can go away without explicit
5955 # notice - through changes in the module dependencies).
5956 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5957 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5958 # First the #include <...> directives without #ifs, sorted for convenience,
5959 # then the #include "..." directives without #ifs, sorted for convenience,
5960 # then the #include directives that are surrounded by #ifs. Not sorted.
5961 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5962 include_directive=`func_get_include_directive "$module"`
5963 case "$nl$include_directive" in
5964 *"$nl#if"*)
5965 echo "$include_directive" 1>&5
5968 echo "$include_directive" | grep -v 'include "' 1>&6
5969 echo "$include_directive" | grep 'include "' 1>&7
5971 esac
5972 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5974 LC_ALL=C sort -u "$tmp"/include-angles
5975 LC_ALL=C sort -u "$tmp"/include-quotes
5976 cat "$tmp"/include-if
5977 ) | sed -e '/^$/d' -e 's/^/ /'
5978 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5980 for module in $main_modules; do
5981 func_get_link_directive "$module"
5982 done \
5983 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5984 if test `wc -l < "$tmp"/link` != 0; then
5985 echo
5986 echo "You may need to use the following Makefile variables when linking."
5987 echo "Use them in <program>_LDADD when linking a program, or"
5988 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5989 cat "$tmp"/link
5991 rm -f "$tmp"/link
5993 echo
5994 echo "Don't forget to"
5995 if test "$makefile_am" = Makefile.am; then
5996 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5997 else
5998 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
6000 if test -n "$pobase"; then
6001 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
6003 if $inctests; then
6004 if test "$makefile_am" = Makefile.am; then
6005 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
6006 else
6007 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
6010 edit=0
6011 while test $edit != $makefile_am_edits; do
6012 edit=`expr $edit + 1`
6013 eval dir=\"\$makefile_am_edit${edit}_dir\"
6014 eval var=\"\$makefile_am_edit${edit}_var\"
6015 eval val=\"\$makefile_am_edit${edit}_val\"
6016 if test -n "$var"; then
6017 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
6019 done
6020 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
6021 position_early_after=AC_PROG_CC_STDC
6022 else
6023 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
6024 position_early_after=AC_PROG_CC_C99
6025 else
6026 position_early_after=AC_PROG_CC
6029 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
6030 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
6033 # func_create_testdir testdir modules
6034 # Input:
6035 # - local_gnulib_path from --local-dir
6036 # - modcache true or false, from --cache-modules/--no-cache-modules
6037 # - auxdir directory relative to destdir where to place build aux files
6038 # - inctests true if tests should be included, false otherwise
6039 # - incobsolete true if obsolete modules among dependencies should be
6040 # included, blank otherwise
6041 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
6042 # blank otherwise
6043 # - excl_longrunning_tests true if long-runnings tests should be excluded,
6044 # blank otherwise
6045 # - excl_privileged_tests true if tests that require root privileges should be
6046 # excluded, blank otherwise
6047 # - excl_unportable_tests true if tests that fail on some platforms should be
6048 # excluded, blank otherwise
6049 # - single_configure true if a single configure file should be generated,
6050 # false for a separate configure file for the tests
6051 # - avoidlist list of modules to avoid
6052 # - cond_dependencies true if --conditional-dependencies was given, false if
6053 # --no-conditional-dependencies was given, blank otherwise
6054 # - libtool true if --libtool was given, false if --no-libtool was
6055 # given, blank otherwise
6056 # - copymode copy mode for files in general
6057 # - lcopymode copy mode for files from local_gnulib_path
6058 func_create_testdir ()
6060 testdir="$1"
6061 modules="$2"
6062 if test -z "$modules"; then
6063 # All modules together.
6064 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6065 # Except non-recursive-gnulib-prefix-hack, which represents a nonstandard
6066 # way of using Automake.
6067 # Except timevar, which lacks the required file timevar.def.
6068 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
6069 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
6070 modules=`func_all_modules`
6071 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`
6073 specified_modules="$modules"
6075 # Canonicalize the list of specified modules.
6076 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
6078 # Test modules which invoke AC_CONFIG_FILES cannot be used with
6079 # --with-tests --single-configure. Avoid them.
6080 if $inctests && $single_configure; then
6081 avoidlist="$avoidlist havelib-tests"
6084 # Unlike in func_import, here we want to include all kinds of tests for the
6085 # directly specified modules, but not for dependencies.
6086 inc_all_direct_tests=true
6087 inc_all_indirect_tests="$inc_all_tests"
6089 # Check that the license of every module is consistent with the license of
6090 # its dependencies.
6091 saved_inctests="$inctests"
6092 # When computing transitive closures, don't consider $module to depend on
6093 # $module-tests. Need this because tests are implicitly GPL and may depend
6094 # on GPL modules - therefore we don't want a warning in this case.
6095 inctests=false
6096 for requested_module in $specified_modules; do
6097 requested_license=`func_get_license "$requested_module"`
6098 if test "$requested_license" != GPL; then
6099 # Here we use func_modules_transitive_closure, not just
6100 # func_get_dependencies, so that we also detect weird situations like
6101 # an LGPL module which depends on a GPLed build tool module which depends
6102 # on a GPL module.
6103 modules="$requested_module"
6104 func_modules_transitive_closure
6105 for module in $modules; do
6106 license=`func_get_license "$module"`
6107 case "$license" in
6108 'GPLed build tool') ;;
6109 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
6111 case "$requested_license" in
6112 GPLv3+ | GPL)
6113 case "$license" in
6114 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL | GPLv2+ | GPLv3+ | GPL) ;;
6115 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6116 esac
6118 GPLv2+)
6119 case "$license" in
6120 LGPLv2+ | 'LGPLv3+ or GPLv2' | GPLv2+) ;;
6121 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6122 esac
6124 LGPLv3+ | LGPL)
6125 case "$license" in
6126 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
6127 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6128 esac
6130 'LGPLv3+ or GPLv2')
6131 case "$license" in
6132 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
6133 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6134 esac
6136 LGPLv2+)
6137 case "$license" in
6138 LGPLv2+) ;;
6139 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6140 esac
6142 esac
6144 esac
6145 done
6147 done
6148 inctests="$saved_inctests"
6150 # Subdirectory names.
6151 sourcebase=gllib
6152 m4base=glm4
6153 pobase=
6154 docbase=gldoc
6155 testsbase=gltests
6156 macro_prefix=gl
6157 po_domain=
6158 witness_c_macro=
6159 vc_files=
6161 # Determine final module list.
6162 modules="$specified_modules"
6163 func_modules_transitive_closure
6164 if test $verbose -ge 0; then
6165 func_show_module_list
6167 final_modules="$modules"
6169 if $single_configure; then
6170 # Determine main module list and tests-related module list separately.
6171 func_modules_transitive_closure_separately
6174 if $single_configure; then
6175 # Determine whether a $testsbase/libtests.a is needed.
6176 func_determine_use_libtests
6179 # Add the dummy module if needed.
6180 if $single_configure; then
6181 func_modules_add_dummy_separately
6182 else
6183 func_modules_add_dummy
6186 # Note:
6187 # If $single_configure, we use the module lists $main_modules and
6188 # $testsrelated_modules; $modules is merely a temporary variable.
6189 # Whereas if ! $configure, the module list is $modules.
6191 # Show banner notice of every module.
6192 if $single_configure; then
6193 modules="$main_modules"
6194 func_modules_notice
6195 else
6196 func_modules_notice
6199 # Determine final file list.
6200 if $single_configure; then
6201 func_modules_to_filelist_separately
6202 else
6203 func_modules_to_filelist
6204 if test $verbose -ge 0; then
6205 echo "File list:"
6206 echo "$files" | sed -e 's/^/ /'
6209 # Add files for which the copy in gnulib is newer than the one that
6210 # "automake --add-missing --copy" would provide.
6211 files="$files build-aux/config.guess"
6212 files="$files build-aux/config.sub"
6213 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
6215 rewritten='%REWRITTEN%'
6216 sed_rewrite_files="\
6217 s,^build-aux/,$rewritten$auxdir/,
6218 s,^doc/,$rewritten$docbase/,
6219 s,^lib/,$rewritten$sourcebase/,
6220 s,^m4/,$rewritten$m4base/,
6221 s,^tests/,$rewritten$testsbase/,
6222 s,^tests=lib/,$rewritten$testsbase/,
6223 s,^top/,$rewritten,
6224 s,^$rewritten,,"
6226 # Create directories.
6227 for f in $files; do echo $f; done \
6228 | sed -e "$sed_rewrite_files" \
6229 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
6230 | LC_ALL=C sort -u \
6231 > "$tmp"/dirs
6232 { # Rearrange file descriptors. Needed because "while ... done < ..."
6233 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6234 exec 5<&0 < "$tmp"/dirs
6235 while read d; do
6236 mkdir -p "$testdir/$d"
6237 done
6238 exec 0<&5 5<&-
6241 # Copy files or make symbolic links or hard links.
6242 delimiter=' '
6243 for f in $files; do echo $f; done \
6244 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
6245 | LC_ALL=C sort \
6246 > "$tmp"/files
6247 { # Rearrange file descriptors. Needed because "while ... done < ..."
6248 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6249 exec 5<&0 < "$tmp"/files
6250 while read g f; do
6251 case "$f" in
6252 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
6253 esac
6254 func_lookup_file "$f"
6255 if test -n "$lookedup_tmp"; then
6256 cp -p "$lookedup_file" "$testdir/$g"
6257 else
6258 func_should_link
6259 if test "$copyaction" = symlink; then
6260 func_symlink "$lookedup_file" "$testdir/$g"
6261 else
6262 if test "$copyaction" = hardlink; then
6263 func_hardlink "$lookedup_file" "$testdir/$g"
6264 else
6265 cp -p "$lookedup_file" "$testdir/$g"
6269 done
6270 exec 0<&5 5<&-
6273 # Determine include_guard_prefix.
6274 func_compute_include_guard_prefix
6276 # Create Makefile.ams that are for testing.
6277 for_test=true
6279 # No special edits are needed.
6280 makefile_am_edits=0
6282 # Create $sourcebase/Makefile.am.
6283 mkdir -p "$testdir/$sourcebase"
6284 destfile="$sourcebase/Makefile.am"
6285 if $single_configure; then
6286 modules="$main_modules"
6288 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
6289 any_uses_subdirs="$uses_subdirs"
6291 # Create $m4base/Makefile.am.
6292 mkdir -p "$testdir/$m4base"
6293 (echo "## Process this file with automake to produce Makefile.in."
6294 echo
6295 echo "EXTRA_DIST ="
6296 for f in $files; do
6297 case "$f" in
6298 m4/* )
6299 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
6300 esac
6301 done
6302 ) > "$testdir/$m4base/Makefile.am"
6304 subdirs="$sourcebase $m4base"
6305 subdirs_with_configure_ac=""
6307 if false && test -f "$testdir"/$m4base/gettext.m4; then
6308 # Avoid stupid error message from automake:
6309 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
6310 mkdir -p "$testdir/po"
6311 (echo "## Process this file with automake to produce Makefile.in."
6312 ) > "$testdir/po/Makefile.am"
6313 func_append subdirs " po"
6316 if $inctests; then
6317 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
6318 if $single_configure; then
6319 # Create $testsbase/Makefile.am.
6320 destfile="$testsbase/Makefile.am"
6321 modules="$testsrelated_modules"
6322 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
6323 else
6324 # Viewed from the $testsbase subdirectory, $auxdir is different.
6325 saved_auxdir="$auxdir"
6326 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
6327 # Create $testsbase/Makefile.am.
6328 use_libtests=false
6329 destfile="$testsbase/Makefile.am"
6330 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
6331 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
6332 # Create $testsbase/configure.ac.
6333 (echo "# Process this file with autoconf to produce a configure script."
6334 echo "AC_INIT([dummy], [0])"
6335 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6336 echo "AM_INIT_AUTOMAKE"
6337 echo
6338 echo "AC_CONFIG_HEADERS([config.h])"
6339 echo
6340 echo "AC_PROG_CC"
6341 echo "AC_PROG_INSTALL"
6342 echo "AC_PROG_MAKE_SET"
6344 func_emit_pre_early_macros false '' "$modules"
6346 if test -n "$uses_subdirs"; then
6347 echo "AM_PROG_CC_C_O"
6348 echo
6350 for module in $modules; do
6351 func_verify_module
6352 if test -n "$module"; then
6353 case $module in
6354 gnumakefile | maintainer-makefile)
6355 # These modules are meant to be used only in the top-level directory.
6358 func_get_autoconf_early_snippet "$module"
6360 esac
6362 done \
6363 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6364 if test "$libtool" = true; then
6365 echo "LT_INIT([win32-dll])"
6366 echo "LT_LANG([C++])"
6367 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6368 echo "gl_cond_libtool=true"
6369 else
6370 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6371 echo "gl_cond_libtool=false"
6372 echo "gl_libdeps="
6373 echo "gl_ltlibdeps="
6375 # Wrap the set of autoconf snippets into an autoconf macro that is then
6376 # invoked. This is needed because autoconf does not support AC_REQUIRE
6377 # at the top level:
6378 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6379 # but we want the AC_REQUIRE to have its normal meaning (provide one
6380 # expansion of the required macro before the current point, and only one
6381 # expansion total).
6382 echo "AC_DEFUN([gl_INIT], ["
6383 sed_replace_build_aux='
6385 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6386 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6389 echo "gl_m4_base='../$m4base'"
6390 func_emit_initmacro_start $macro_prefix
6391 # We don't have explicit ordering constraints between the various
6392 # autoconf snippets. It's cleanest to put those of the library before
6393 # those of the tests.
6394 echo "gl_source_base='../$sourcebase'"
6395 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module false false false
6396 echo "gl_source_base='.'"
6397 func_emit_autoconf_snippets "$modules" "$modules" func_verify_tests_module false false false
6398 func_emit_initmacro_end $macro_prefix
6399 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6400 # created using libtool, because libtool already handles the dependencies.
6401 if test "$libtool" != true; then
6402 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6403 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6404 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6405 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6406 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6408 echo "])"
6409 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
6410 echo
6411 echo "gl_INIT"
6412 echo
6413 # Usually $testsbase/config.h will be a superset of config.h. Verify this
6414 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
6415 echo "AH_TOP([#include \"../config.h\"])"
6416 echo
6417 echo "AC_CONFIG_FILES([Makefile])"
6418 echo "AC_OUTPUT"
6419 ) > "$testdir/$testsbase/configure.ac"
6420 auxdir="$saved_auxdir"
6421 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
6423 func_append subdirs " $testsbase"
6426 # Create Makefile.am.
6427 (echo "## Process this file with automake to produce Makefile.in."
6428 echo
6429 echo "AUTOMAKE_OPTIONS = 1.11 foreign"
6430 echo
6431 echo "SUBDIRS = $subdirs"
6432 echo
6433 echo "ACLOCAL_AMFLAGS = -I $m4base"
6434 ) > "$testdir/Makefile.am"
6436 # Create configure.ac.
6437 (echo "# Process this file with autoconf to produce a configure script."
6438 echo "AC_INIT([dummy], [0])"
6439 if test "$auxdir" != "."; then
6440 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6442 echo "AM_INIT_AUTOMAKE"
6443 echo
6444 echo "AC_CONFIG_HEADERS([config.h])"
6445 echo
6446 echo "AC_PROG_CC"
6447 echo "AC_PROG_INSTALL"
6448 echo "AC_PROG_MAKE_SET"
6449 echo
6450 echo "# For autobuild."
6451 echo "AC_CANONICAL_BUILD"
6452 echo "AC_CANONICAL_HOST"
6453 echo
6454 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
6455 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
6456 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6457 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6459 func_emit_pre_early_macros false '' "$final_modules"
6461 if test -n "$any_uses_subdirs"; then
6462 echo "AM_PROG_CC_C_O"
6463 echo
6465 for module in $final_modules; do
6466 if $single_configure; then
6467 func_verify_module
6468 else
6469 func_verify_nontests_module
6471 if test -n "$module"; then
6472 func_get_autoconf_early_snippet "$module"
6474 done \
6475 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6476 if test "$libtool" = true; then
6477 echo "LT_INIT([win32-dll])"
6478 echo "LT_LANG([C++])"
6479 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6480 echo "gl_cond_libtool=true"
6481 else
6482 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6483 echo "gl_cond_libtool=false"
6484 echo "gl_libdeps="
6485 echo "gl_ltlibdeps="
6487 # Wrap the set of autoconf snippets into an autoconf macro that is then
6488 # invoked. This is needed because autoconf does not support AC_REQUIRE
6489 # at the top level:
6490 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6491 # but we want the AC_REQUIRE to have its normal meaning (provide one
6492 # expansion of the required macro before the current point, and only one
6493 # expansion total).
6494 echo "AC_DEFUN([gl_INIT], ["
6495 if test "$auxdir" != "build-aux"; then
6496 sed_replace_build_aux='
6498 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6499 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6502 else
6503 sed_replace_build_aux="$sed_noop"
6505 echo "gl_m4_base='$m4base'"
6506 func_emit_initmacro_start $macro_prefix
6507 echo "gl_source_base='$sourcebase'"
6508 if $single_configure; then
6509 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false false
6510 else
6511 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module true false false
6513 func_emit_initmacro_end $macro_prefix
6514 if $single_configure; then
6515 echo " gltests_libdeps="
6516 echo " gltests_ltlibdeps="
6517 func_emit_initmacro_start ${macro_prefix}tests
6518 echo " gl_source_base='$testsbase'"
6519 # Define a tests witness macro.
6520 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
6521 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6522 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6523 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6524 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true false false
6525 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6526 func_emit_initmacro_end ${macro_prefix}tests
6528 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6529 # created using libtool, because libtool already handles the dependencies.
6530 if test "$libtool" != true; then
6531 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6532 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6533 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6534 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6535 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6537 if $single_configure; then
6538 if $use_libtests; then
6539 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6540 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6543 echo "])"
6544 func_emit_initmacro_done $macro_prefix $sourcebase
6545 if $single_configure; then
6546 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6548 echo
6549 echo "gl_INIT"
6550 echo
6551 if test -n "$subdirs_with_configure_ac"; then
6552 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6554 makefiles="Makefile"
6555 for d in $subdirs; do
6556 # For subdirs that have a configure.ac by their own, it's the subdir's
6557 # configure.ac which creates the subdir's Makefile.am, not this one.
6558 case " $subdirs_with_configure_ac " in
6559 *" $d "*) ;;
6560 *) func_append makefiles " $d/Makefile" ;;
6561 esac
6562 done
6563 echo "AC_CONFIG_FILES([$makefiles])"
6564 echo "AC_OUTPUT"
6565 ) > "$testdir/configure.ac"
6567 # Create autogenerated files.
6568 (cd "$testdir"
6569 # Do not use "${AUTORECONF} --force --install", because it may invoke
6570 # autopoint, which brings in older versions of some of our .m4 files.
6571 if test -f $m4base/gettext.m4; then
6572 func_execute_command ${AUTOPOINT} --force || func_exit 1
6573 for f in $m4base/*.m4~; do
6574 if test -f $f; then
6575 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6577 done
6579 if test "$libtool" = true; then
6580 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6582 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6583 if ! test -d build-aux; then
6584 func_execute_command mkdir build-aux || func_exit 1
6586 func_execute_command ${AUTOCONF} || func_exit 1
6587 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6588 func_execute_command ${AUTOHEADER} &&
6589 func_execute_command touch config.h.in ||
6590 func_exit 1
6591 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6592 rm -rf autom4te.cache
6593 ) || func_exit 1
6594 if $inctests && ! $single_configure; then
6595 # Create autogenerated files.
6596 (cd "$testdir/$testsbase" || func_exit 1
6597 # Do not use "${AUTORECONF} --force --install", because it may invoke
6598 # autopoint, which brings in older versions of some of our .m4 files.
6599 if test -f ../$m4base/gettext.m4; then
6600 func_execute_command ${AUTOPOINT} --force || func_exit 1
6601 for f in ../$m4base/*.m4~; do
6602 if test -f $f; then
6603 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6605 done
6607 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6608 if ! test -d ../build-aux; then
6609 func_execute_command mkdir ../build-aux
6611 func_execute_command ${AUTOCONF} || func_exit 1
6612 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6613 func_execute_command ${AUTOHEADER} &&
6614 func_execute_command touch config.h.in ||
6615 func_exit 1
6616 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6617 rm -rf autom4te.cache
6618 ) || func_exit 1
6620 # Need to run configure and make once, to create built files that are to be
6621 # distributed (such as parse-datetime.c).
6622 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6623 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6624 cleaned_files=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6625 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6626 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6627 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6628 # such $(FOO_H) because they don't refer to distributed files.
6629 built_sources=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6630 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6631 | sed -e "$sed_remove_make_variables"`
6632 distributed_built_sources=`for file in $built_sources; do
6633 case "$cleaned_files" in
6634 *" "$file" "*) ;;
6635 *) echo $file ;;
6636 esac;
6637 done`
6638 tests_distributed_built_sources=
6639 if $inctests; then
6640 # Likewise for built files in the $testsbase directory.
6641 tests_cleaned_files=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6642 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6643 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6644 tests_built_sources=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6645 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6646 | sed -e "$sed_remove_make_variables"`
6647 tests_distributed_built_sources=`for file in $tests_built_sources; do
6648 case "$tests_cleaned_files" in
6649 *" "$file" "*) ;;
6650 *) echo $file ;;
6651 esac;
6652 done`
6654 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6655 (cd "$testdir"
6656 ./configure || func_exit 1
6657 if test -n "$distributed_built_sources"; then
6658 cd "$sourcebase"
6659 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6660 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6661 built_sources \
6662 || func_exit 1
6663 cd ..
6665 if test -n "$tests_distributed_built_sources"; then
6666 cd "$testsbase"
6667 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6668 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6669 built_sources \
6670 || func_exit 1
6671 cd ..
6673 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6674 distclean \
6675 || func_exit 1
6676 ) || func_exit 1
6678 (cd "$testdir"
6679 if test -f build-aux/test-driver; then
6680 patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver.diff || func_exit 1
6682 ) || func_exit 1
6685 # func_create_megatestdir megatestdir allmodules
6686 # Input:
6687 # - local_gnulib_path from --local-dir
6688 # - modcache true or false, from --cache-modules/--no-cache-modules
6689 # - auxdir directory relative to destdir where to place build aux files
6690 func_create_megatestdir ()
6692 megatestdir="$1"
6693 allmodules="$2"
6694 if test -z "$allmodules"; then
6695 allmodules=`func_all_modules`
6698 megasubdirs=
6699 # First, all modules one by one.
6700 for onemodule in $allmodules; do
6701 func_create_testdir "$megatestdir/$onemodule" $onemodule
6702 func_append megasubdirs "$onemodule "
6703 done
6704 # Then, all modules all together.
6705 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6706 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6707 func_create_testdir "$megatestdir/ALL" "$allmodules"
6708 func_append megasubdirs "ALL"
6710 # Create autobuild.
6711 cvsdate=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6712 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6713 | sed -e 's,January,01,' -e 's,Jan,01,' \
6714 -e 's,February,02,' -e 's,Feb,02,' \
6715 -e 's,March,03,' -e 's,Mar,03,' \
6716 -e 's,April,04,' -e 's,Apr,04,' \
6717 -e 's,May,05,' \
6718 -e 's,June,06,' -e 's,Jun,06,' \
6719 -e 's,July,07,' -e 's,Jul,07,' \
6720 -e 's,August,08,' -e 's,Aug,08,' \
6721 -e 's,September,09,' -e 's,Sep,09,' \
6722 -e 's,October,10,' -e 's,Oct,10,' \
6723 -e 's,November,11,' -e 's,Nov,11,' \
6724 -e 's,December,12,' -e 's,Dec,12,' \
6725 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6726 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6727 (echo '#!/bin/sh'
6728 echo "CVSDATE=$cvsdate"
6729 echo ": \${MAKE=make}"
6730 echo "test -d logs || mkdir logs"
6731 echo "for module in $megasubdirs; do"
6732 echo " echo \"Working on module \$module...\""
6733 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6734 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6735 echo " echo"
6736 echo " set -x"
6737 echo " : autobuild project... \$module"
6738 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6739 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6740 echo " : autobuild hostname... \`hostname\`"
6741 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6742 echo " echo rc=\$?"
6743 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6744 echo "done"
6745 ) > "$megatestdir/do-autobuild"
6746 chmod a+x "$megatestdir/do-autobuild"
6748 # Create Makefile.am.
6749 (echo "## Process this file with automake to produce Makefile.in."
6750 echo
6751 echo "AUTOMAKE_OPTIONS = 1.11 foreign"
6752 echo
6753 echo "SUBDIRS = $megasubdirs"
6754 echo
6755 echo "EXTRA_DIST = do-autobuild"
6756 ) > "$megatestdir/Makefile.am"
6758 # Create configure.ac.
6759 (echo "# Process this file with autoconf to produce a configure script."
6760 echo "AC_INIT([dummy], [0])"
6761 if test "$auxdir" != "."; then
6762 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6764 echo "AM_INIT_AUTOMAKE"
6765 echo
6766 echo "AC_PROG_MAKE_SET"
6767 echo
6768 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6769 echo "AC_CONFIG_FILES([Makefile])"
6770 echo "AC_OUTPUT"
6771 ) > "$megatestdir/configure.ac"
6773 # Create autogenerated files.
6774 (cd "$megatestdir"
6775 # Do not use "${AUTORECONF} --install", because autoreconf operates
6776 # recursively, but the subdirectories are already finished, therefore
6777 # calling autoreconf here would only waste lots of CPU time.
6778 func_execute_command ${ACLOCAL} || func_exit 1
6779 func_execute_command mkdir build-aux
6780 func_execute_command ${AUTOCONF} || func_exit 1
6781 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6782 rm -rf autom4te.cache
6783 if test -f build-aux/test-driver; then
6784 patch build-aux/test-driver < "$gnulib_dir"/build-aux/test-driver.diff || func_exit 1
6786 ) || func_exit 1
6789 case $mode in
6790 "" )
6791 func_fatal_error "no mode specified" ;;
6793 list )
6794 func_all_modules
6797 find )
6798 # sed expression that converts a literal to a basic regular expression.
6799 # Needs to handle . [ \ * ^ $.
6800 sed_literal_to_basic_regex='s/\\/\\\\/g
6801 s/\[/\\[/g
6802 s/\^/\\^/g
6803 s/\([.*$]\)/[\1]/g'
6804 for filename
6806 if test -f "$gnulib_dir/$filename" \
6807 || func_lookup_local_file "$filename"; then
6808 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6809 filename_line_regex='^'"$filename_anywhere_regex"'$'
6810 module_candidates=`
6812 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6813 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$,,'
6815 | func_sanitize_modulelist \
6816 | LC_ALL=C sort -u
6818 for module in $module_candidates; do
6819 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6820 echo $module
6822 done
6823 else
6824 func_warning "file $filename does not exist"
6826 done
6829 import | add-import | remove-import | update )
6831 # Where to import.
6832 if test -z "$destdir"; then
6833 destdir=.
6835 test -d "$destdir" \
6836 || func_fatal_error "destination directory does not exist: $destdir"
6838 # Prefer configure.ac to configure.in.
6839 if test -f "$destdir"/configure.ac; then
6840 configure_ac="$destdir/configure.ac"
6841 else
6842 if test -f "$destdir"/configure.in; then
6843 configure_ac="$destdir/configure.in"
6844 else
6845 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6849 # Analyze configure.ac.
6850 guessed_auxdir="."
6851 guessed_libtool=false
6852 my_sed_traces='
6853 s,#.*$,,
6854 s,^dnl .*$,,
6855 s, dnl .*$,,
6856 /AC_CONFIG_AUX_DIR/ {
6857 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6859 /A[CM]_PROG_LIBTOOL/ {
6860 s,^.*$,guessed_libtool=true,p
6862 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6864 if test -z "$auxdir"; then
6865 auxdir="$guessed_auxdir"
6868 # Determine where to apply func_import.
6869 if test "$mode" = import; then
6870 # Apply func_import to a particular gnulib directory.
6871 # The command line contains the complete specification; don't look at
6872 # the contents of gnulib-cache.m4.
6873 test -n "$supplied_libname" || supplied_libname=true
6874 test -n "$sourcebase" || sourcebase="lib"
6875 test -n "$m4base" || m4base="m4"
6876 test -n "$docbase" || docbase="doc"
6877 test -n "$testsbase" || testsbase="tests"
6878 test -n "$macro_prefix" || macro_prefix="gl"
6879 func_import "$*"
6880 else
6881 if test -n "$m4base"; then
6882 # Apply func_import to a particular gnulib directory.
6883 # Any number of additional modules can be given.
6884 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6885 # First use of gnulib in the given m4base.
6886 test -n "$supplied_libname" || supplied_libname=true
6887 test -n "$sourcebase" || sourcebase="lib"
6888 test -n "$docbase" || docbase="doc"
6889 test -n "$testsbase" || testsbase="tests"
6890 test -n "$macro_prefix" || macro_prefix="gl"
6892 func_import "$*"
6893 else
6894 # Apply func_import to all gnulib directories.
6895 # To get this list of directories, look at Makefile.am. (Not at
6896 # configure, because it may be omitted from version control. Also,
6897 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6898 # too expensive.)
6899 m4dirs=
6900 m4dirs_count=0
6901 if test -f "$destdir"/Makefile.am; then
6902 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6903 m4dir_is_next=
6904 for arg in $aclocal_amflags; do
6905 if test -n "$m4dir_is_next"; then
6906 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6907 case "$arg" in
6908 /*) ;;
6910 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6911 func_append m4dirs " $arg"
6912 m4dirs_count=`expr $m4dirs_count + 1`
6915 esac
6916 m4dir_is_next=
6917 else
6918 if test "X$arg" = "X-I"; then
6919 m4dir_is_next=yes
6920 else
6921 m4dir_is_next=
6924 done
6925 else
6926 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6927 if test -f "$destdir"/aclocal.m4; then
6928 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6929 sedexpr2='s,^[^/]*$,.,'
6930 sedexpr3='s,/[^/]*$,,'
6931 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6932 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6933 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6936 if test $m4dirs_count = 0; then
6937 # First use of gnulib in a package.
6938 # Any number of additional modules can be given.
6939 test -n "$supplied_libname" || supplied_libname=true
6940 test -n "$sourcebase" || sourcebase="lib"
6941 m4base="m4"
6942 test -n "$docbase" || docbase="doc"
6943 test -n "$testsbase" || testsbase="tests"
6944 test -n "$macro_prefix" || macro_prefix="gl"
6945 func_import "$*"
6946 else
6947 if test $m4dirs_count = 1; then
6948 # There's only one use of gnulib here. Assume the user means it.
6949 # Any number of additional modules can be given.
6950 for m4base in $m4dirs; do
6951 func_import "$*"
6952 done
6953 else
6954 # Ambiguous - guess what the user meant.
6955 if test $# = 0; then
6956 # No further arguments. Guess the user wants to update all of them.
6957 for m4base in $m4dirs; do
6958 # Perform func_import in a subshell, so that variable values
6959 # such as
6960 # local_gnulib_path, incobsolete, inc_cxx_tests,
6961 # inc_longrunning_tests, inc_privileged_tests,
6962 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6963 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6964 # makefile_name, libtool, macro_prefix, po_domain,
6965 # witness_c_macro, vc_files
6966 # don't propagate from one directory to another.
6967 (func_import) || func_exit 1
6968 done
6969 else
6970 # Really ambiguous.
6971 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6979 create-testdir )
6980 if test -z "$destdir"; then
6981 func_fatal_error "please specify --dir option"
6983 mkdir "$destdir"
6984 test -d "$destdir" \
6985 || func_fatal_error "could not create destination directory"
6986 test -n "$auxdir" || auxdir="build-aux"
6987 func_create_testdir "$destdir" "$*"
6990 create-megatestdir )
6991 if test -z "$destdir"; then
6992 func_fatal_error "please specify --dir option"
6994 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6995 test -n "$auxdir" || auxdir="build-aux"
6996 func_create_megatestdir "$destdir" "$*"
6999 test )
7000 test -n "$destdir" || destdir=testdir$$
7001 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7002 test -n "$auxdir" || auxdir="build-aux"
7003 func_create_testdir "$destdir" "$*"
7004 cd "$destdir"
7005 mkdir build
7006 cd build
7007 ../configure || func_exit 1
7008 $MAKE || func_exit 1
7009 $MAKE check || func_exit 1
7010 $MAKE distclean || func_exit 1
7011 remaining=`find . -type f -print`
7012 if test -n "$remaining"; then
7013 echo "Remaining files:" $remaining 1>&2
7014 echo "gnulib-tool: *** Stop." 1>&2
7015 func_exit 1
7017 cd ..
7018 cd ..
7019 rm -rf "$destdir"
7022 megatest )
7023 test -n "$destdir" || destdir=testdir$$
7024 mkdir "$destdir" || func_fatal_error "could not create destination directory"
7025 test -n "$auxdir" || auxdir="build-aux"
7026 func_create_megatestdir "$destdir" "$*"
7027 cd "$destdir"
7028 mkdir build
7029 cd build
7030 ../configure
7031 $MAKE
7032 $MAKE check
7033 $MAKE distclean
7034 remaining=`find . -type f -print`
7035 if test -n "$remaining"; then
7036 echo "Remaining files:" $remaining 1>&2
7037 echo "gnulib-tool: *** Stop." 1>&2
7038 func_exit 1
7040 cd ..
7041 cd ..
7042 rm -rf "$destdir"
7045 extract-description )
7046 for module
7048 func_verify_module
7049 if test -n "$module"; then
7050 func_get_description "$module"
7052 done
7055 extract-comment )
7056 for module
7058 func_verify_module
7059 if test -n "$module"; then
7060 func_get_comment "$module"
7062 done
7065 extract-status )
7066 for module
7068 func_verify_module
7069 if test -n "$module"; then
7070 func_get_status "$module"
7072 done
7075 extract-notice )
7076 for module
7078 func_verify_module
7079 if test -n "$module"; then
7080 func_get_notice "$module"
7082 done
7085 extract-applicability )
7086 for module
7088 func_verify_module
7089 if test -n "$module"; then
7090 func_get_applicability "$module"
7092 done
7095 extract-filelist )
7096 for module
7098 func_verify_module
7099 if test -n "$module"; then
7100 func_get_filelist "$module"
7102 done
7105 extract-dependencies )
7106 if test -n "$avoidlist"; then
7107 func_fatal_error "cannot combine --avoid and --extract-dependencies"
7109 for module
7111 func_verify_module
7112 if test -n "$module"; then
7113 func_get_dependencies "$module"
7115 done
7118 extract-recursive-dependencies )
7119 if test -n "$avoidlist"; then
7120 func_fatal_error "cannot combine --avoid and --extract-recursive-dependencies"
7122 for module
7124 func_verify_module
7125 if test -n "$module"; then
7126 func_get_dependencies_recursively "$module"
7128 done
7131 extract-autoconf-snippet )
7132 for module
7134 func_verify_module
7135 if test -n "$module"; then
7136 func_get_autoconf_snippet "$module"
7138 done
7141 extract-automake-snippet )
7142 for module
7144 func_verify_module
7145 if test -n "$module"; then
7146 func_get_automake_snippet "$module"
7148 done
7151 extract-include-directive )
7152 for module
7154 func_verify_module
7155 if test -n "$module"; then
7156 func_get_include_directive "$module"
7158 done
7161 extract-link-directive )
7162 for module
7164 func_verify_module
7165 if test -n "$module"; then
7166 func_get_link_directive "$module"
7168 done
7171 extract-recursive-link-directive )
7172 if test -n "$avoidlist"; then
7173 func_fatal_error "cannot combine --avoid and --extract-recursive-link-directive"
7175 for module
7177 func_verify_module
7178 if test -n "$module"; then
7179 func_get_link_directive_recursively "$module"
7181 done
7184 extract-license )
7185 for module
7187 func_verify_module
7188 if test -n "$module"; then
7189 func_get_license "$module"
7191 done
7194 extract-maintainer )
7195 for module
7197 func_verify_module
7198 if test -n "$module"; then
7199 func_get_maintainer "$module"
7201 done
7204 extract-tests-module )
7205 for module
7207 func_verify_module
7208 if test -n "$module"; then
7209 func_get_tests_module "$module"
7211 done
7214 copy-file )
7215 # Verify the number of arguments.
7216 if test $# -lt 1 || test $# -gt 2; then
7217 func_fatal_error "invalid number of arguments for --$mode"
7220 # The first argument is the file to be copied.
7221 f="$1"
7222 # Verify the file exists.
7223 func_lookup_file "$f"
7225 # The second argument is the destination; either a directory ot a file.
7226 # It defaults to the current directory.
7227 dest="$2"
7228 test -n "$dest" || dest='.'
7229 test -n "$sourcebase" || sourcebase="lib"
7230 test -n "$m4base" || m4base="m4"
7231 test -n "$docbase" || docbase="doc"
7232 test -n "$testsbase" || testsbase="tests"
7233 test -n "$auxdir" || auxdir="build-aux"
7234 rewritten='%REWRITTEN%'
7235 sed_rewrite_files="\
7236 s,^build-aux/,$rewritten$auxdir/,
7237 s,^doc/,$rewritten$docbase/,
7238 s,^lib/,$rewritten$sourcebase/,
7239 s,^m4/,$rewritten$m4base/,
7240 s,^tests/,$rewritten$testsbase/,
7241 s,^top/,$rewritten,
7242 s,^$rewritten,,"
7243 if test -d "$dest"; then
7244 destdir="$dest"
7245 g=`echo "$f" | sed -e "$sed_rewrite_files"`
7246 else
7247 destdir=`dirname "$dest"`
7248 g=`basename "$dest"`
7251 # Create the directory for destfile.
7252 d=`dirname "$destdir/$g"`
7253 if $doit; then
7254 if test -n "$d" && test ! -d "$d"; then
7255 mkdir -p "$d" || func_fatal_error "failed"
7258 # Copy the file.
7259 func_dest_tmpfilename "$g"
7260 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
7261 already_present=true
7262 if test -f "$destdir/$g"; then
7263 # The file already exists.
7264 func_update_file
7265 else
7266 # Install the file.
7267 # Don't protest if the file should be there but isn't: it happens
7268 # frequently that developers don't put autogenerated files under version
7269 # control.
7270 func_add_file
7272 rm -f "$tmpfile"
7276 func_fatal_error "unknown operation mode --$mode" ;;
7277 esac
7279 if test "$copymode" = hardlink -o "$lcopymode" = hardlink; then
7280 # Setting hard links modifies the ctime of files in the gnulib checkout.
7281 # This disturbs the result of the next "gitk" invocation.
7282 # Workaround: Let git scan the files. This can be done through
7283 # "git update-index --refresh" or "git status" or "git diff".
7284 if test -d "$gnulib_dir"/.git \
7285 && (git --version) >/dev/null 2>/dev/null; then
7286 (cd "$gnulib_dir" && git update-index --refresh >/dev/null)
7290 rm -rf "$tmp"
7291 # Undo the effect of the previous 'trap' command. Some shellology:
7292 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
7293 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
7294 # exit); for the others we need to call 'exit' explicitly. The value of $? is
7295 # 128 + signal number and is set before the trap-registered command is run.
7296 trap '' 0
7297 trap 'func_exit $?' 1 2 3 13 15
7299 exit 0
7301 # Local Variables:
7302 # indent-tabs-mode: nil
7303 # whitespace-check-buffer-indent: nil
7304 # End: