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