mkostemp, mkostemps: Update documentation.
[gnulib.git] / gnulib-tool
blob92bfee4fe085de32e2eff1012fd9254b9637a12a
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,dotfirst}
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 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
3659 if test -n "$var"; then
3660 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3661 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
3662 # The added subdirectory ${val} needs to be mentioned after '.'.
3663 # Since we don't have '.' among SUBDIRS so far, add it now.
3664 val=". ${val}"
3666 echo "${var} += ${val}"
3667 eval "makefile_am_edit${edit}_var="
3670 done
3671 if test -n "$witness_c_macro"; then
3672 cppflags_part1=" -D$witness_c_macro=1"
3673 else
3674 cppflags_part1=
3676 if $for_test; then
3677 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3678 else
3679 cppflags_part2=
3681 if test -z "$makefile_name"; then
3682 echo
3683 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3684 echo "AM_CFLAGS ="
3685 else
3686 if test -n "$cppflags_part1$cppflags_part2"; then
3687 echo
3688 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3691 echo
3692 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3693 || { test -n "$makefile_name" \
3694 && test -f "$sourcebase/Makefile.am" \
3695 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3696 }; then
3697 # One of the snippets or the user's Makefile.am already specifies an
3698 # installation location for the library. Don't confuse automake by saying
3699 # it should not be installed.
3701 else
3702 # By default, the generated library should not be installed.
3703 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3705 echo
3706 echo "${libname}_${libext}_SOURCES ="
3707 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3708 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3709 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3710 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3711 echo "EXTRA_${libname}_${libext}_SOURCES ="
3712 if test "$libtool" = true; then
3713 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3714 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3715 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3716 # the link dependencies of all modules.
3717 for module in $modules; do
3718 func_verify_nontests_module
3719 if test -n "$module"; then
3720 func_get_link_directive "$module"
3722 done \
3723 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3724 | LC_ALL=C sort -u \
3725 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3727 echo
3728 if test -n "$pobase"; then
3729 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3730 echo
3732 cat "$tmp"/allsnippets \
3733 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3734 echo
3735 echo "mostlyclean-local: mostlyclean-generic"
3736 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3737 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3738 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3739 echo " fi; \\"
3740 echo " done; \\"
3741 echo " :"
3742 rm -f "$tmp"/allsnippets
3745 # func_emit_po_Makevars
3746 # emits the contents of po/ makefile parameterization to standard output.
3747 # Input:
3748 # - local_gnulib_path from --local-dir
3749 # - modcache true or false, from --cache-modules/--no-cache-modules
3750 # - sourcebase directory relative to destdir where to place source code
3751 # - pobase directory relative to destdir where to place *.po files
3752 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3753 func_emit_po_Makevars ()
3755 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3756 func_emit_copyright_notice
3757 echo
3758 echo "# Usually the message domain is the same as the package name."
3759 echo "# But here it has a '-gnulib' suffix."
3760 echo "DOMAIN = ${po_domain}-gnulib"
3761 echo
3762 echo "# These two variables depend on the location of this directory."
3763 echo "subdir = ${pobase}"
3764 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3765 echo
3766 cat <<\EOF
3767 # These options get passed to xgettext.
3768 XGETTEXT_OPTIONS = \
3769 --keyword=_ --flag=_:1:pass-c-format \
3770 --keyword=N_ --flag=N_:1:pass-c-format \
3771 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3772 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3773 --flag=error:3:c-format --flag=error_at_line:5:c-format
3775 # This is the copyright holder that gets inserted into the header of the
3776 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3777 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3779 # This is the email address or URL to which the translators shall report
3780 # bugs in the untranslated strings:
3781 # - Strings which are not entire sentences, see the maintainer guidelines
3782 # in the GNU gettext documentation, section 'Preparing Strings'.
3783 # - Strings which use unclear terms or require additional context to be
3784 # understood.
3785 # - Strings which make invalid assumptions about notation of date, time or
3786 # money.
3787 # - Pluralisation problems.
3788 # - Incorrect English spelling.
3789 # - Incorrect formatting.
3790 # It can be your email address, or a mailing list address where translators
3791 # can write to without being subscribed, or the URL of a web page through
3792 # which the translators can contact you.
3793 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3795 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3796 # message catalogs shall be used. It is usually empty.
3797 EXTRA_LOCALE_CATEGORIES =
3799 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3800 # context. Possible values are "yes" and "no". Set this to yes if the
3801 # package uses functions taking also a message context, like pgettext(), or
3802 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3803 USE_MSGCTXT = no
3807 # func_emit_po_POTFILES_in
3808 # emits the file list to be passed to xgettext to standard output.
3809 # Input:
3810 # - local_gnulib_path from --local-dir
3811 # - modcache true or false, from --cache-modules/--no-cache-modules
3812 # - sourcebase directory relative to destdir where to place source code
3813 # - files list of new files
3814 func_emit_po_POTFILES_in ()
3816 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3817 func_emit_copyright_notice
3818 echo
3819 echo "# List of files which contain translatable strings."
3820 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3823 # func_emit_tests_Makefile_am witness_macro
3824 # emits the contents of tests makefile to standard output.
3825 # Input:
3826 # - local_gnulib_path from --local-dir
3827 # - modcache true or false, from --cache-modules/--no-cache-modules
3828 # - modules list of modules, including dependencies
3829 # - libname library name
3830 # - auxdir directory relative to destdir where to place build aux files
3831 # - gnu_make true if --gnu-make was given, false otherwise
3832 # - makefile_name from --makefile-name
3833 # - libtool true if libtool will be used, false or blank otherwise
3834 # - sourcebase relative directory containing lib source code
3835 # - m4base relative directory containing autoconf macros
3836 # - testsbase relative directory containing unit test code
3837 # - macro_prefix prefix of gl_LIBOBJS macros to use
3838 # - witness_c_macro from --witness-c-macro
3839 # - for_test true if creating a package for testing, false otherwise
3840 # - single_configure true if a single configure file should be generated,
3841 # false for a separate configure file for the tests
3842 # - use_libtests true if a libtests.a should be built, false otherwise
3843 # - sed_replace_include_guard_prefix
3844 # sed expression for resolving ${gl_include_guard_prefix}
3845 # - destfile filename relative to destdir of makefile being generated
3846 # Input/Output:
3847 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
3848 # list of edits to be done to Makefile.am variables
3849 # Output:
3850 # - uses_subdirs nonempty if object files in subdirs exist
3851 func_emit_tests_Makefile_am ()
3853 witness_macro="$1"
3854 if test "$libtool" = true; then
3855 libext=la
3856 perhapsLT=LT
3857 sed_eliminate_LDFLAGS="$sed_noop"
3858 else
3859 libext=a
3860 perhapsLT=
3861 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3863 if $for_test; then
3864 # When creating a package for testing: Attempt to provoke failures,
3865 # especially link errors, already during "make" rather than during
3866 # "make check", because "make check" is not possible in a cross-compiling
3867 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3868 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3869 else
3870 sed_transform_check_PROGRAMS="$sed_noop"
3872 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3873 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3874 echo "## Process this file with automake to produce Makefile.in."
3875 func_emit_copyright_notice
3876 echo
3877 uses_subdirs=
3879 for module in $modules; do
3880 if $for_test && ! $single_configure; then
3881 func_verify_tests_module
3882 else
3883 func_verify_module
3885 if test -n "$module"; then
3887 func_get_automake_snippet "$module" |
3888 LC_ALL=C \
3889 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3890 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3891 -e "$sed_eliminate_LDFLAGS" \
3892 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3893 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3894 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3895 -e "$sed_transform_check_PROGRAMS" \
3896 -e "$sed_replace_include_guard_prefix"
3897 if $use_libtests && test "$module" = 'alloca'; then
3898 echo "libtests_a_LIBADD += @ALLOCA@"
3899 echo "libtests_a_DEPENDENCIES += @ALLOCA@"
3901 } > "$tmp"/amsnippet
3902 # Skip the contents if it's entirely empty.
3903 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3904 # Mention long-running tests at the end.
3905 ofd=3
3906 for word in `func_get_status "$module"`; do
3907 if test "$word" = 'longrunning-test'; then
3908 ofd=4
3909 break
3911 done
3912 { echo "## begin gnulib module $module"
3913 if $gnu_make; then
3914 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
3916 echo
3917 cat "$tmp"/amsnippet
3918 if $gnu_make; then
3919 echo "endif"
3921 echo "## end gnulib module $module"
3922 echo
3923 } >&$ofd
3925 rm -f "$tmp"/amsnippet
3926 # Test whether there are some source files in subdirectories.
3927 for f in `func_get_filelist "$module"`; do
3928 case $f in
3929 lib/*/*.c | tests/*/*.c)
3930 uses_subdirs=yes
3931 break
3933 esac
3934 done
3936 done
3937 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3938 # Generate dependencies here, since it eases the debugging of test failures.
3939 # If there are source files in subdirectories, prevent collision of the
3940 # object files (example: hash.c and libxml/hash.c).
3941 subdir_options=
3942 if test -n "$uses_subdirs"; then
3943 subdir_options=' subdir-objects'
3945 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign${subdir_options}"
3946 echo
3947 if $for_test && ! $single_configure; then
3948 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3949 echo
3951 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3952 # variable is needed to avoid an error from automake:
3953 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3954 echo "SUBDIRS = ."
3955 echo "TESTS ="
3956 echo "XFAIL_TESTS ="
3957 echo "TESTS_ENVIRONMENT ="
3958 echo "noinst_PROGRAMS ="
3959 if ! $for_test; then
3960 echo "check_PROGRAMS ="
3962 echo "EXTRA_PROGRAMS ="
3963 echo "noinst_HEADERS ="
3964 echo "noinst_LIBRARIES ="
3965 if $use_libtests; then
3966 if $for_test; then
3967 echo "noinst_LIBRARIES += libtests.a"
3968 else
3969 echo "check_LIBRARIES = libtests.a"
3972 # Automake versions < 1.11.4 create an empty pkgdatadir at
3973 # installation time if you specify pkgdata_DATA to empty.
3974 # See automake bugs #10997 and #11030:
3975 # * https://debbugs.gnu.org/10997
3976 # * https://debbugs.gnu.org/11030
3977 # So we need this workaround.
3978 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3979 echo "pkgdata_DATA ="
3981 echo "EXTRA_DIST ="
3982 echo "BUILT_SOURCES ="
3983 echo "SUFFIXES ="
3984 echo "MOSTLYCLEANFILES = core *.stackdump"
3985 echo "MOSTLYCLEANDIRS ="
3986 echo "CLEANFILES ="
3987 echo "DISTCLEANFILES ="
3988 echo "MAINTAINERCLEANFILES ="
3989 # Execute edits that apply to the Makefile.am being generated.
3990 edit=0
3991 while test $edit != $makefile_am_edits; do
3992 edit=`expr $edit + 1`
3993 eval dir=\"\$makefile_am_edit${edit}_dir\"
3994 eval var=\"\$makefile_am_edit${edit}_var\"
3995 eval val=\"\$makefile_am_edit${edit}_val\"
3996 eval dotfirst=\"\$makefile_am_edit${edit}_dotfirst\"
3997 if test -n "$var"; then
3998 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3999 if test "${var}" = SUBDIRS && test -n "$dotfirst"; then
4000 # The added subdirectory ${val} needs to be mentioned after '.'.
4001 # But we have '.' among SUBDIRS already, so do nothing.
4004 echo "${var} += ${val}"
4005 eval "makefile_am_edit${edit}_var="
4008 done
4009 echo
4010 echo "AM_CPPFLAGS = \\"
4011 if $for_test; then
4012 echo " -DGNULIB_STRICT_CHECKING=1 \\"
4014 if test -n "$witness_c_macro"; then
4015 echo " -D$witness_c_macro=1 \\"
4017 if test -n "${witness_macro}"; then
4018 echo " -D@${witness_macro}@=1 \\"
4020 echo " -I. -I\$(srcdir) \\"
4021 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
4022 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
4023 echo
4024 local_ldadd_before=''
4025 local_ldadd_after=''
4026 if $use_libtests; then
4027 # All test programs need to be linked with libtests.a.
4028 # It needs to be passed to the linker before ${libname}.${libext}, since
4029 # the tests-related modules depend on the main modules.
4030 # It also needs to be passed to the linker after ${libname}.${libext}
4031 # because the latter might contain incomplete modules (such as the 'error'
4032 # module whose dependency to 'progname' is voluntarily omitted).
4033 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
4034 # not matter.
4035 local_ldadd_before=' libtests.a'
4036 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
4038 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
4039 echo
4040 if $use_libtests; then
4041 echo "libtests_a_SOURCES ="
4042 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
4043 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
4044 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
4045 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
4046 echo "EXTRA_libtests_a_SOURCES ="
4047 # The circular dependency in LDADD requires this.
4048 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
4049 echo
4051 # Many test scripts use ${EXEEXT} or ${srcdir}.
4052 # EXEEXT is defined by AC_PROG_CC through autoconf.
4053 # srcdir is defined by autoconf and automake.
4054 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
4055 echo
4056 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
4057 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
4058 echo "# Clean up after Solaris cc."
4059 echo "clean-local:"
4060 echo " rm -rf SunWS_cache"
4061 echo
4062 echo "mostlyclean-local: mostlyclean-generic"
4063 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
4064 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
4065 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
4066 echo " fi; \\"
4067 echo " done; \\"
4068 echo " :"
4069 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
4072 # func_emit_initmacro_start macro_prefix
4073 # emits the first few statements of the gl_INIT macro to standard output.
4074 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4075 func_emit_initmacro_start ()
4077 macro_prefix_arg="$1"
4078 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
4079 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
4080 # LIBOBJS. The purpose is to allow several gnulib instantiations under
4081 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
4082 # flexibility.)
4083 # Furthermore it avoids an automake error like this when a Makefile.am
4084 # that uses pieces of gnulib also uses $(LIBOBJ):
4085 # automatically discovered file `error.c' should not be explicitly mentioned
4086 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
4087 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
4088 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
4089 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
4090 # automatically discovered file `error.c' should not be explicitly mentioned
4091 # We let automake know about the files to be distributed through the
4092 # EXTRA_lib_SOURCES variable.
4093 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
4094 # Create data variables for checking the presence of files that are mentioned
4095 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
4096 # because we want the check to happen when the configure file is created,
4097 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
4098 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
4099 # in which to expect them.
4100 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
4101 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
4102 echo " gl_COMMON"
4105 # func_emit_initmacro_end macro_prefix
4106 # emits the last few statements of the gl_INIT macro to standard output.
4107 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4108 func_emit_initmacro_end ()
4110 macro_prefix_arg="$1"
4111 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
4112 # The check is performed only when autoconf is run from the directory where
4113 # the configure.ac resides; if it is run from a different directory, the
4114 # check is skipped.
4115 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
4116 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
4117 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
4118 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
4119 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
4120 echo " exit 1"
4121 echo " fi"
4122 echo " done])dnl"
4123 echo " m4_if(m4_sysval, [0], [],"
4124 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
4125 echo " ])"
4126 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
4127 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
4128 echo " m4_popdef([AC_LIBSOURCES])"
4129 echo " m4_popdef([AC_REPLACE_FUNCS])"
4130 echo " m4_popdef([AC_LIBOBJ])"
4131 echo " AC_CONFIG_COMMANDS_PRE(["
4132 echo " ${macro_prefix_arg}_libobjs="
4133 echo " ${macro_prefix_arg}_ltlibobjs="
4134 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
4135 echo " # Remove the extension."
4136 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
4137 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
4138 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
4139 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
4140 echo " done"
4141 echo " fi"
4142 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
4143 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
4144 echo " ])"
4147 # func_emit_initmacro_done macro_prefix sourcebase
4148 # emits a few statements after the gl_INIT macro to standard output.
4149 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4150 # - sourcebase directory relative to destdir where to place source code
4151 func_emit_initmacro_done ()
4153 macro_prefix_arg="$1"
4154 sourcebase_arg="$2"
4155 echo
4156 echo "# Like AC_LIBOBJ, except that the module name goes"
4157 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4158 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
4159 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
4160 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
4161 echo "])"
4162 echo
4163 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
4164 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4165 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
4166 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
4167 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
4168 echo "])"
4169 echo
4170 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
4171 echo "# expected is derived from the gnulib-tool parameterization,"
4172 echo "# and alloca is special cased (for the alloca-opt module)."
4173 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
4174 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
4175 echo " m4_foreach([_gl_NAME], [\$1], ["
4176 echo " m4_if(_gl_NAME, [alloca.c], [], ["
4177 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
4178 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
4179 echo " ])"
4180 echo " ])"
4181 echo "])"
4184 # func_emit_autoconf_snippet indentation
4185 # emits the autoconf snippet of a module.
4186 # Input:
4187 # - indentation spaces to prepend on each line
4188 # - local_gnulib_path from --local-dir
4189 # - modcache true or false, from --cache-modules/--no-cache-modules
4190 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4191 # - sed_replace_include_guard_prefix
4192 # sed expression for resolving ${gl_include_guard_prefix}
4193 # - module the module name
4194 # - toplevel true or false. 'false' means a subordinate use of
4195 # gnulib-tool.
4196 # - disable_libtool true or false. It tells whether to disable libtool
4197 # handling even if it has been specified through the
4198 # command line options.
4199 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4200 # invocations.
4201 func_emit_autoconf_snippet ()
4203 indentation="$1"
4204 if { case $module in
4205 gnumakefile | maintainer-makefile)
4206 # These modules are meant to be used only in the top-level directory.
4207 $toplevel ;;
4209 true ;;
4210 esac
4211 }; then
4212 func_get_autoconf_snippet "$module" \
4213 | sed -e '/^$/d;' -e "s/^/$indentation/" \
4214 -e "$sed_replace_build_aux" \
4215 -e "$sed_replace_include_guard_prefix" \
4216 | { if $disable_libtool; then
4217 sed -e 's/\$gl_cond_libtool/false/g' \
4218 -e 's/gl_libdeps/gltests_libdeps/g' \
4219 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4220 else
4224 | { if $disable_gettext; then
4225 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
4226 else
4227 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
4228 # autopoint through at least GNU gettext version 0.18.2.
4229 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
4232 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
4233 echo 'changequote(,)dnl'
4234 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4235 echo 'changequote([, ])dnl'
4236 echo 'AC_SUBST([LTALLOCA])'
4241 # func_emit_autoconf_snippets modules referenceable_modules verifier toplevel disable_libtool disable_gettext
4242 # collects and emit the autoconf snippets of a set of modules.
4243 # Input:
4244 # - local_gnulib_path from --local-dir
4245 # - modcache true or false, from --cache-modules/--no-cache-modules
4246 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4247 # - sed_replace_include_guard_prefix
4248 # sed expression for resolving ${gl_include_guard_prefix}
4249 # - modules the list of modules.
4250 # - referenceable_modules the list of modules which may be referenced as dependencies.
4251 # - verifier one of func_verify_module, func_verify_nontests_module,
4252 # func_verify_tests_module. It selects the subset of
4253 # $modules to consider.
4254 # - toplevel true or false. 'false' means a subordinate use of
4255 # gnulib-tool.
4256 # - disable_libtool true or false. It tells whether to disable libtool
4257 # handling even if it has been specified through the
4258 # command line options.
4259 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4260 # invocations.
4261 func_emit_autoconf_snippets ()
4263 referenceable_modules="$2"
4264 verifier="$3"
4265 toplevel="$4"
4266 disable_libtool="$5"
4267 disable_gettext="$6"
4268 if test "$cond_dependencies" = true; then
4269 for m in $referenceable_modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
4270 # Emit the autoconf code for the unconditional modules.
4271 for module in $1; do
4272 eval $verifier
4273 if test -n "$module"; then
4274 if func_cond_module_p "$module"; then
4276 else
4277 func_emit_autoconf_snippet " "
4280 done
4281 # Initialize the shell variables indicating that the modules are enabled.
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_shellvar_name "$module"
4287 echo " $shellvar=false"
4290 done
4291 # Emit the autoconf code for the conditional modules, each in a separate
4292 # function. This makes it possible to support cycles among conditional
4293 # modules.
4294 for module in $1; do
4295 eval $verifier
4296 if test -n "$module"; then
4297 if func_cond_module_p "$module"; then
4298 func_module_shellfunc_name "$module"
4299 func_module_shellvar_name "$module"
4300 echo " $shellfunc ()"
4301 echo ' {'
4302 echo " if ! \$$shellvar; then"
4303 func_emit_autoconf_snippet " "
4304 echo " $shellvar=true"
4305 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4306 # Intersect $deps with the modules list $1.
4307 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4308 for dep in $deps; do
4309 if func_cond_module_p "$dep"; then
4310 func_module_shellfunc_name "$dep"
4311 func_cond_module_condition "$module" "$dep"
4312 if test "$condition" != true; then
4313 echo " if $condition; then"
4314 echo " $shellfunc"
4315 echo ' fi'
4316 else
4317 echo " $shellfunc"
4319 else
4320 # The autoconf code for $dep has already been emitted above and
4321 # therefore is already executed when this function is run.
4324 done
4325 echo ' fi'
4326 echo ' }'
4329 done
4330 # Emit the dependencies from the unconditional to the conditional modules.
4331 for module in $1; do
4332 eval $verifier
4333 if test -n "$module"; then
4334 if func_cond_module_p "$module"; then
4336 else
4337 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4338 # Intersect $deps with the modules list $1.
4339 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4340 for dep in $deps; do
4341 if func_cond_module_p "$dep"; then
4342 func_module_shellfunc_name "$dep"
4343 func_cond_module_condition "$module" "$dep"
4344 if test "$condition" != true; then
4345 echo " if $condition; then"
4346 echo " $shellfunc"
4347 echo ' fi'
4348 else
4349 echo " $shellfunc"
4351 else
4352 # The autoconf code for $dep has already been emitted above and
4353 # therefore is already executed when this code is run.
4356 done
4359 done
4360 # Define the Automake conditionals.
4361 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4362 for module in $1; do
4363 eval $verifier
4364 if test -n "$module"; then
4365 if func_cond_module_p "$module"; then
4366 func_module_conditional_name "$module"
4367 func_module_shellvar_name "$module"
4368 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4371 done
4372 else
4373 # Ignore the conditions, and enable all modules unconditionally.
4374 for module in $1; do
4375 eval $verifier
4376 if test -n "$module"; then
4377 func_emit_autoconf_snippet " "
4379 done
4383 # func_emit_pre_early_macros require indentation modules
4384 # The require parameter can be ':' (AC_REQUIRE) or 'false' (direct call).
4385 func_emit_pre_early_macros ()
4387 echo
4388 echo "${2}# Pre-early section."
4389 if $1; then
4390 _pre_early_snippet="echo \"${2}AC_REQUIRE([\$_pre_early_macro])\""
4391 else
4392 _pre_early_snippet="echo \"${2}\$_pre_early_macro\""
4395 # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB. Doing
4396 # AC_REQUIRE in configure-ac.early is not early enough.
4397 _pre_early_macro="gl_USE_SYSTEM_EXTENSIONS"
4398 case "${nl}${3}${nl}" in
4399 *${nl}extensions${nl}*) eval "$_pre_early_snippet" ;;
4400 esac
4402 _pre_early_macro="gl_PROG_AR_RANLIB"
4403 eval "$_pre_early_snippet"
4404 echo
4407 # func_reconstruct_cached_dir
4408 # callback for func_reconstruct_cached_local_gnulib_path
4409 # Input:
4410 # - destdir from --dir
4411 # Output:
4412 # - local_gnulib_path restored '--local-dir' path from cache
4413 func_reconstruct_cached_dir ()
4415 cached_dir=$1
4416 if test -n "$cached_dir"; then
4417 case "$destdir" in
4419 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4421 case "$cached_dir" in
4423 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4425 func_relconcat "$destdir" "$cached_dir"
4426 func_path_append local_gnulib_path "$relconcat" ;;
4427 esac ;;
4428 esac
4432 # func_reconstruct_cached_local_gnulib_path
4433 # reconstruct local_gnulib_path from cached_local_gnulib_path to be set
4434 # relatively to $destdir again.
4435 # Input:
4436 # - cached_local_gnulib_path local_gnulib_path stored within gnulib-cache.m4
4437 # - destdir from --dir
4438 # Output:
4439 # - local_gnulib_path restored '--local-dir' path from cache
4440 func_reconstruct_cached_local_gnulib_path ()
4442 func_path_foreach "$cached_local_gnulib_path" func_reconstruct_cached_dir %dir%
4445 # func_import modules
4446 # Uses also the variables
4447 # - mode import or add-import or remove-import or update
4448 # - destdir target directory
4449 # - local_gnulib_path from --local-dir
4450 # - modcache true or false, from --cache-modules/--no-cache-modules
4451 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4452 # - libname library name
4453 # - supplied_libname true if --lib was given, blank otherwise
4454 # - sourcebase directory relative to destdir where to place source code
4455 # - m4base directory relative to destdir where to place *.m4 macros
4456 # - pobase directory relative to destdir where to place *.po files
4457 # - docbase directory relative to destdir where to place doc files
4458 # - testsbase directory relative to destdir where to place unit test code
4459 # - auxdir directory relative to destdir where to place build aux files
4460 # - inctests true if --with-tests was given, false otherwise
4461 # - incobsolete true if --with-obsolete was given, blank otherwise
4462 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4463 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4464 # otherwise
4465 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4466 # otherwise
4467 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4468 # otherwise
4469 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4470 # - avoidlist list of modules to avoid, from --avoid
4471 # - cond_dependencies true if --conditional-dependencies was given, false if
4472 # --no-conditional-dependencies was given, blank otherwise
4473 # - lgpl yes or a number if library's license shall be LGPL,
4474 # blank otherwise
4475 # - makefile_name from --makefile-name
4476 # - libtool true if --libtool was given, false if --no-libtool was
4477 # given, blank otherwise
4478 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4479 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4480 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4481 # - witness_c_macro from --witness-c-macro
4482 # - vc_files true if --vc-files was given, false if --no-vc-files was
4483 # given, blank otherwise
4484 # - autoconf_minversion minimum supported autoconf version
4485 # - doit : if actions shall be executed, false if only to be printed
4486 # - copymode copy mode for files in general
4487 # - lcopymode copy mode for files from local_gnulib_path
4488 # - do_copyrights true if copyright notices in files should be replaced,
4489 # blank otherwise
4490 func_import ()
4492 # Get the cached settings.
4493 # In 'import' mode, we read them only for the purpose of knowing the old
4494 # installed file list, and don't use them as defaults.
4495 cached_local_gnulib_path=
4496 cached_specified_modules=
4497 cached_incobsolete=
4498 cached_inc_cxx_tests=
4499 cached_inc_longrunning_tests=
4500 cached_inc_privileged_tests=
4501 cached_inc_unportable_tests=
4502 cached_inc_all_tests=
4503 cached_avoidlist=
4504 cached_sourcebase=
4505 cached_m4base=
4506 cached_pobase=
4507 cached_docbase=
4508 cached_testsbase=
4509 cached_inctests=
4510 cached_libname=
4511 cached_lgpl=
4512 cached_makefile_name=
4513 cached_cond_dependencies=
4514 cached_libtool=
4515 cached_macro_prefix=
4516 cached_po_domain=
4517 cached_witness_c_macro=
4518 cached_vc_files=
4519 cached_files=
4520 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4521 cached_libtool=false
4522 my_sed_traces='
4523 s,#.*$,,
4524 s,^dnl .*$,,
4525 s, dnl .*$,,
4526 /gl_LOCAL_DIR(/ {
4527 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_path="\1",p
4529 /gl_MODULES(/ {
4532 s/)/)/
4537 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4539 /gl_WITH_OBSOLETE/ {
4540 s,^.*$,cached_incobsolete=true,p
4542 /gl_WITH_CXX_TESTS/ {
4543 s,^.*$,cached_inc_cxx_tests=true,p
4545 /gl_WITH_LONGRUNNING_TESTS/ {
4546 s,^.*$,cached_inc_longrunning_tests=true,p
4548 /gl_WITH_PRIVILEGED_TESTS/ {
4549 s,^.*$,cached_inc_privileged_tests=true,p
4551 /gl_WITH_UNPORTABLE_TESTS/ {
4552 s,^.*$,cached_inc_unportable_tests=true,p
4554 /gl_WITH_ALL_TESTS/ {
4555 s,^.*$,cached_inc_all_tests=true,p
4557 /gl_AVOID(/ {
4558 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4560 /gl_SOURCE_BASE(/ {
4561 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4563 /gl_M4_BASE(/ {
4564 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4566 /gl_PO_BASE(/ {
4567 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4569 /gl_DOC_BASE(/ {
4570 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4572 /gl_TESTS_BASE(/ {
4573 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4575 /gl_WITH_TESTS/ {
4576 s,^.*$,cached_inctests=true,p
4578 /gl_LIB(/ {
4579 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4581 /gl_LGPL(/ {
4582 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4584 /gl_LGPL/ {
4585 s,^.*$,cached_lgpl=yes,p
4587 /gl_MAKEFILE_NAME(/ {
4588 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4590 /gl_CONDITIONAL_DEPENDENCIES/ {
4591 s,^.*$,cached_cond_dependencies=true,p
4593 /gl_LIBTOOL/ {
4594 s,^.*$,cached_libtool=true,p
4596 /gl_MACRO_PREFIX(/ {
4597 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4599 /gl_PO_DOMAIN(/ {
4600 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4602 /gl_WITNESS_C_MACRO(/ {
4603 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4605 /gl_VC_FILES(/ {
4606 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4608 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4609 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4610 my_sed_traces='
4611 s,#.*$,,
4612 s,^dnl .*$,,
4613 s, dnl .*$,,
4614 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4615 s,^.*$,cached_files=",p
4619 s,^\]).*$,",
4621 s,["$`\\],,g
4628 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4632 if test "$mode" = import; then
4633 # In 'import' mode, the new set of specified modules overrides the cached
4634 # set of modules. Ignore the cached settings.
4635 specified_modules="$1"
4636 else
4637 # Merge the cached settings with the specified ones.
4638 # The m4base must be the same as expected from the pathname.
4639 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4640 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4642 # The local_gnulib_path defaults to the cached one. Recall that the cached one
4643 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4644 if test -z "$local_gnulib_path"; then
4645 func_reconstruct_cached_local_gnulib_path
4647 case $mode in
4648 add-import)
4649 # Append the cached and the specified module names. So that
4650 # "gnulib-tool --add-import foo" means to add the module foo.
4651 specified_modules="$cached_specified_modules $1"
4653 remove-import)
4654 # Take the cached module names, minus the specified module names.
4655 specified_modules=
4656 if $have_associative; then
4657 # Use an associative array, for O(N) worst-case run time.
4658 declare -A to_remove
4659 for m in $1; do
4660 eval 'to_remove[$m]=yes'
4661 done
4662 for module in $cached_specified_modules; do
4663 if eval 'test -z "${to_remove[$module]}"'; then
4664 func_append specified_modules "$module "
4666 done
4667 else
4668 # This loop has O(N**2) worst-case run time.
4669 for module in $cached_specified_modules; do
4670 to_remove=
4671 for m in $1; do
4672 if test "$m" = "$module"; then
4673 to_remove=yes
4674 break
4676 done
4677 if test -z "$to_remove"; then
4678 func_append specified_modules "$module "
4680 done
4683 update)
4684 # Take the cached module names. There are no specified module names.
4685 specified_modules="$cached_specified_modules"
4687 esac
4688 # Included obsolete modules among the dependencies if specified either way.
4689 if test -z "$incobsolete"; then
4690 incobsolete="$cached_incobsolete"
4692 # Included special kinds of tests modules among the dependencies if specified
4693 # either way.
4694 if test -z "$inc_cxx_tests"; then
4695 inc_cxx_tests="$cached_inc_cxx_tests"
4697 if test -z "$inc_longrunning_tests"; then
4698 inc_longrunning_tests="$cached_inc_longrunning_tests"
4700 if test -z "$inc_privileged_tests"; then
4701 inc_privileged_tests="$cached_inc_privileged_tests"
4703 if test -z "$inc_unportable_tests"; then
4704 inc_unportable_tests="$cached_inc_unportable_tests"
4706 if test -z "$inc_all_tests"; then
4707 inc_all_tests="$cached_inc_all_tests"
4709 # Append the cached and the specified avoidlist. This is probably better
4710 # than dropping the cached one when --avoid is specified at least once.
4711 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4712 avoidlist=`echo $avoidlist`
4714 # The sourcebase defaults to the cached one.
4715 if test -z "$sourcebase"; then
4716 sourcebase="$cached_sourcebase"
4717 if test -z "$sourcebase"; then
4718 func_fatal_error "missing --source-base option"
4721 # The pobase defaults to the cached one.
4722 if test -z "$pobase"; then
4723 pobase="$cached_pobase"
4725 # The docbase defaults to the cached one.
4726 if test -z "$docbase"; then
4727 docbase="$cached_docbase"
4728 if test -z "$docbase"; then
4729 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."
4732 # The testsbase defaults to the cached one.
4733 if test -z "$testsbase"; then
4734 testsbase="$cached_testsbase"
4735 if test -z "$testsbase"; then
4736 func_fatal_error "missing --tests-base option"
4739 # Require the tests if specified either way.
4740 if ! $inctests; then
4741 inctests="$cached_inctests"
4742 if test -z "$inctests"; then
4743 inctests=false
4746 # The libname defaults to the cached one.
4747 if test -z "$supplied_libname"; then
4748 libname="$cached_libname"
4749 if test -z "$libname"; then
4750 func_fatal_error "missing --lib option"
4753 # Require LGPL if specified either way.
4754 if test -z "$lgpl"; then
4755 lgpl="$cached_lgpl"
4757 # The makefile_name defaults to the cached one.
4758 if test -z "$makefile_name"; then
4759 makefile_name="$cached_makefile_name"
4761 # Use conditional dependencies if specified either way.
4762 if test -z "$cond_dependencies"; then
4763 cond_dependencies="$cached_cond_dependencies"
4765 # Use libtool if specified either way, or if guessed.
4766 if test -z "$libtool"; then
4767 if test -n "$cached_m4base"; then
4768 libtool="$cached_libtool"
4769 else
4770 libtool="$guessed_libtool"
4773 # The macro_prefix defaults to the cached one.
4774 if test -z "$macro_prefix"; then
4775 macro_prefix="$cached_macro_prefix"
4776 if test -z "$macro_prefix"; then
4777 func_fatal_error "missing --macro-prefix option"
4780 # The po_domain defaults to the cached one.
4781 if test -z "$po_domain"; then
4782 po_domain="$cached_po_domain"
4784 # The witness_c_macro defaults to the cached one.
4785 if test -z "$witness_c_macro"; then
4786 witness_c_macro="$cached_witness_c_macro"
4788 # The vc_files defaults to the cached one.
4789 if test -z "$vc_files"; then
4790 vc_files="$cached_vc_files"
4792 # Ensure constraints.
4793 if test "$cond_dependencies" = true && $inctests; then
4794 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4795 func_exit 1
4798 # --without-*-tests options are not supported here.
4799 excl_cxx_tests=
4800 excl_longrunning_tests=
4801 excl_privileged_tests=
4802 excl_unportable_tests=
4804 # Canonicalize the list of specified modules.
4805 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4807 # Include all kinds of tests modules if --with-all-tests was specified.
4808 inc_all_direct_tests="$inc_all_tests"
4809 inc_all_indirect_tests="$inc_all_tests"
4811 # Determine final module list.
4812 modules="$specified_modules"
4813 func_modules_transitive_closure
4814 if test $verbose -ge 0; then
4815 func_show_module_list
4817 final_modules="$modules"
4819 # Determine main module list and tests-related module list separately.
4820 func_modules_transitive_closure_separately
4822 # Determine whether a $testsbase/libtests.a is needed.
4823 func_determine_use_libtests
4825 # Add the dummy module to the main module list or to the tests-related module
4826 # list if needed.
4827 func_modules_add_dummy_separately
4829 # If --lgpl, verify that the licenses of modules are compatible.
4830 if test -n "$lgpl"; then
4831 license_incompatibilities=
4832 for module in $main_modules; do
4833 license=`func_get_license $module`
4834 case $license in
4835 'GPLed build tool') ;;
4836 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4838 case "$lgpl" in
4839 yes | 3)
4840 case $license in
4841 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
4842 *) func_append license_incompatibilities "$module $license$nl" ;;
4843 esac
4845 3orGPLv2)
4846 case $license in
4847 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
4848 *) func_append license_incompatibilities "$module $license$nl" ;;
4849 esac
4852 case $license in
4853 LGPLv2+) ;;
4854 *) func_append license_incompatibilities "$module $license$nl" ;;
4855 esac
4857 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4858 esac
4860 esac
4861 done
4862 if test -n "$license_incompatibilities"; then
4863 # Format the license incompatibilities as a table.
4864 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4865 s,^\(.................................................[^ ]*\) *, \1 ,'
4866 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4867 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4871 # Show banner notice of every module.
4872 modules="$main_modules"
4873 func_modules_notice
4875 # Determine script to apply to imported library files.
4876 sed_transform_lib_file=
4877 for module in $main_modules; do
4878 if test $module = config-h; then
4879 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4880 sed_transform_lib_file=$sed_transform_lib_file'
4881 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4883 break
4885 done
4886 sed_transform_main_lib_file="$sed_transform_lib_file"
4887 if test -n "$do_copyrights"; then
4888 if test -n "$lgpl"; then
4889 # Update license.
4890 case "$lgpl" in
4891 yes | 3)
4892 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4893 s/GNU General/GNU Lesser General/g
4894 s/General Public License/Lesser General Public License/g
4895 s/Lesser Lesser General Public License/Lesser General Public License/g
4898 3orGPLv2)
4899 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4900 /^ *This program is free software/i\
4901 This program is free software: you can redistribute it and\/or\
4902 modify it under the terms of either:\
4904 * the GNU Lesser General Public License as published by the Free\
4905 Software Foundation; either version 3 of the License, or (at your\
4906 option) any later version.\
4910 * the GNU General Public License as published by the Free\
4911 Software Foundation; either version 2 of the License, or (at your\
4912 option) any later version.\
4914 or both in parallel, as here.
4915 /^ *This program is free software/,/^$/d
4919 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4920 s/GNU General/GNU Lesser General/g
4921 s/General Public License/Lesser General Public License/g
4922 s/Lesser Lesser General Public License/Lesser General Public License/g
4924 s/version [23]\([ ,]\)/version 2.1\1/g
4927 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4928 esac
4929 else
4930 # Update license.
4931 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4932 s/GNU Lesser General/GNU General/g
4933 s/Lesser General Public License/General Public License/g
4935 s/GNU Library General/GNU General/g
4936 s/Library General Public License/General Public License/g
4938 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4943 # Determine script to apply to auxiliary files that go into $auxdir/.
4944 sed_transform_build_aux_file=
4945 if test -n "$do_copyrights"; then
4946 # Update license.
4947 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4948 s/GNU Lesser General/GNU General/g
4949 s/Lesser General Public License/General Public License/g
4951 s/GNU Library General/GNU General/g
4952 s/Library General Public License/General Public License/g
4954 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4958 # Determine script to apply to library files that go into $testsbase/.
4959 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4960 if test -n "$do_copyrights"; then
4961 # Update license.
4962 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4963 s/GNU Lesser General/GNU General/g
4964 s/Lesser General Public License/General Public License/g
4966 s/GNU Library General/GNU General/g
4967 s/Library General Public License/General Public License/g
4969 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4973 # Determine the final file lists.
4974 func_modules_to_filelist_separately
4976 test -n "$files" \
4977 || func_fatal_error "refusing to do nothing"
4979 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4980 new_files="$files m4/gnulib-tool.m4"
4981 old_files="$cached_files"
4982 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4983 func_append old_files " m4/gnulib-tool.m4"
4986 rewritten='%REWRITTEN%'
4987 sed_rewrite_old_files="\
4988 s,^build-aux/,$rewritten$auxdir/,
4989 s,^doc/,$rewritten$cached_docbase/,
4990 s,^lib/,$rewritten$cached_sourcebase/,
4991 s,^m4/,$rewritten$cached_m4base/,
4992 s,^tests/,$rewritten$cached_testsbase/,
4993 s,^tests=lib/,$rewritten$cached_testsbase/,
4994 s,^top/,$rewritten,
4995 s,^$rewritten,,"
4996 sed_rewrite_new_files="\
4997 s,^build-aux/,$rewritten$auxdir/,
4998 s,^doc/,$rewritten$docbase/,
4999 s,^lib/,$rewritten$sourcebase/,
5000 s,^m4/,$rewritten$m4base/,
5001 s,^tests/,$rewritten$testsbase/,
5002 s,^tests=lib/,$rewritten$testsbase/,
5003 s,^top/,$rewritten,
5004 s,^$rewritten,,"
5006 # Create directories.
5007 { echo "$sourcebase"
5008 echo "$m4base"
5009 if test -n "$pobase"; then
5010 echo "$pobase"
5012 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
5013 if test -n "$docfiles"; then
5014 echo "$docbase"
5016 if $inctests; then
5017 echo "$testsbase"
5019 echo "$auxdir"
5020 for f in $files; do echo $f; done \
5021 | sed -e "$sed_rewrite_new_files" \
5022 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5023 | LC_ALL=C sort -u
5024 } > "$tmp"/dirs
5025 { # Rearrange file descriptors. Needed because "while ... done < ..."
5026 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5027 exec 5<&0 < "$tmp"/dirs
5028 while read d; do
5029 if test ! -d "$destdir/$d"; then
5030 if $doit; then
5031 echo "Creating directory $destdir/$d"
5032 mkdir -p "$destdir/$d" || func_fatal_error "failed"
5033 else
5034 echo "Create directory $destdir/$d"
5037 done
5038 exec 0<&5 5<&-
5041 # Copy files or make symbolic links or hard links. Remove obsolete files.
5042 added_files=''
5043 removed_files=''
5044 delimiter=' '
5045 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5046 # representing the files according to the last gnulib-tool invocation.
5047 for f in $old_files; do echo $f; done \
5048 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
5049 | LC_ALL=C sort \
5050 > "$tmp"/old-files
5051 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5052 # representing the files after this gnulib-tool invocation.
5053 for f in $new_files; do echo $f; done \
5054 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
5055 | LC_ALL=C sort \
5056 > "$tmp"/new-files
5057 # First the files that are in old-files, but not in new-files:
5058 sed_take_first_column='s,'"$delimiter"'.*,,'
5059 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
5060 # Remove the file. Do nothing if the user already removed it.
5061 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
5062 if $doit; then
5063 echo "Removing file $g (backup in ${g}~)"
5064 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
5065 else
5066 echo "Remove file $g (backup in ${g}~)"
5068 func_append removed_files "$g$nl"
5070 done
5071 # func_add_or_update handles a file that ought to be present afterwards.
5072 # Uses parameters
5073 # - f the original file name
5074 # - g the rewritten file name
5075 # - already_present nonempty if the file should already exist, empty
5076 # otherwise
5077 func_add_or_update ()
5079 of="$f"
5080 case "$f" in
5081 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5082 esac
5083 func_dest_tmpfilename "$g"
5084 func_lookup_file "$f"
5085 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5086 case "$f" in
5087 *.class | *.mo )
5088 # Don't process binary files with sed.
5091 if test -n "$sed_transform_main_lib_file"; then
5092 case "$of" in
5093 lib/*)
5094 sed -e "$sed_transform_main_lib_file" \
5095 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5097 esac
5099 if test -n "$sed_transform_build_aux_file"; then
5100 case "$of" in
5101 build-aux/*)
5102 sed -e "$sed_transform_build_aux_file" \
5103 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5105 esac
5107 if test -n "$sed_transform_testsrelated_lib_file"; then
5108 case "$of" in
5109 tests=lib/*)
5110 sed -e "$sed_transform_testsrelated_lib_file" \
5111 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5113 esac
5116 esac
5117 if test -f "$destdir/$g"; then
5118 # The file already exists.
5119 func_update_file
5120 else
5121 # Install the file.
5122 # Don't protest if the file should be there but isn't: it happens
5123 # frequently that developers don't put autogenerated files under version control.
5124 func_add_file
5125 func_append added_files "$g$nl"
5127 rm -f "$tmpfile"
5129 # Then the files that are in new-files, but not in old-files:
5130 sed_take_last_column='s,^.*'"$delimiter"',,'
5131 already_present=
5132 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
5133 | sed -e "$sed_take_last_column" \
5134 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
5135 { # Rearrange file descriptors. Needed because "while ... done < ..."
5136 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5137 exec 5<&0 < "$tmp"/added-files
5138 while read g f; do
5139 func_add_or_update
5140 done
5141 exec 0<&5 5<&-
5143 # Then the files that are in new-files and in old-files:
5144 already_present=true
5145 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
5146 | sed -e "$sed_take_last_column" \
5147 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
5148 { # Rearrange file descriptors. Needed because "while ... done < ..."
5149 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5150 exec 5<&0 < "$tmp"/kept-files
5151 while read g f; do
5152 func_add_or_update
5153 done
5154 exec 0<&5 5<&-
5157 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
5158 actioncmd="# gnulib-tool --import"
5160 # Local helper.
5161 func_append_local_dir ()
5163 func_append "$1" " --local-dir=$2"
5165 func_path_foreach "$local_gnulib_path" func_append_local_dir actioncmd %dir%
5167 # Break the action command log into multiple lines.
5168 # Emacs puts some gnulib-tool log lines in its source repository, and
5169 # git send-email rejects patch lines longer than 998 characters.
5170 # Also, config.status uses awk, and the HP-UX 11.00 awk fails if a
5171 # line has length >= 3071; similarly, the IRIX 6.5 awk fails if a
5172 # line has length >= 3072.
5173 func_append_actionarg ()
5175 func_append actioncmd " \\$nl# $1"
5177 func_append_actionarg "--lib=$libname"
5178 func_append_actionarg "--source-base=$sourcebase"
5179 func_append_actionarg "--m4-base=$m4base"
5180 if test -n "$pobase"; then
5181 func_append_actionarg "--po-base=$pobase"
5183 func_append_actionarg "--doc-base=$docbase"
5184 func_append_actionarg "--tests-base=$testsbase"
5185 func_append_actionarg "--aux-dir=$auxdir"
5186 if $inctests; then
5187 func_append_actionarg "--with-tests"
5189 if test -n "$incobsolete"; then
5190 func_append_actionarg "--with-obsolete"
5192 if test -n "$inc_cxx_tests"; then
5193 func_append_actionarg "--with-c++-tests"
5195 if test -n "$inc_longrunning_tests"; then
5196 func_append_actionarg "--with-longrunning-tests"
5198 if test -n "$inc_privileged_tests"; then
5199 func_append_actionarg "--with-privileged-tests"
5201 if test -n "$inc_unportable_tests"; then
5202 func_append_actionarg "--with-unportable-tests"
5204 if test -n "$inc_all_tests"; then
5205 func_append_actionarg "--with-all-tests"
5207 if test -n "$lgpl"; then
5208 if test "$lgpl" = yes; then
5209 func_append_actionarg "--lgpl"
5210 else
5211 func_append_actionarg "--lgpl=$lgpl"
5214 if $gnu_make; then
5215 func_append_actionarg "--gnu-make"
5217 if test -n "$makefile_name"; then
5218 func_append_actionarg "--makefile-name=$makefile_name"
5220 if test "$cond_dependencies" = true; then
5221 func_append_actionarg "--conditional-dependencies"
5222 else
5223 func_append_actionarg "--no-conditional-dependencies"
5225 if test "$libtool" = true; then
5226 func_append_actionarg "--libtool"
5227 else
5228 func_append_actionarg "--no-libtool"
5230 func_append_actionarg "--macro-prefix=$macro_prefix"
5231 if test -n "$po_domain"; then
5232 func_append_actionarg "--po-domain=$po_domain"
5234 if test -n "$witness_c_macro"; then
5235 func_append_actionarg "--witness-c-macro=$witness_c_macro"
5237 if test -n "$vc_files"; then
5238 if test "$vc_files" = true; then
5239 func_append_actionarg "--vc-files"
5240 else
5241 func_append_actionarg "--no-vc-files"
5244 for module in $avoidlist; do
5245 func_append_actionarg "--avoid=$module"
5246 done
5247 for module in $specified_modules; do
5248 func_append_actionarg "$module"
5249 done
5251 # Determine include_guard_prefix.
5252 func_compute_include_guard_prefix
5254 # Default the makefile name to Makefile.am.
5255 if test -n "$makefile_name"; then
5256 makefile_am=$makefile_name
5257 else
5258 makefile_am=Makefile.am
5261 # Create normal Makefile.ams.
5262 for_test=false
5264 # Setup list of Makefile.am edits that are to be performed afterwards.
5265 # Some of these edits apply to files that we will generate; others are
5266 # under the responsibility of the developer.
5267 makefile_am_edits=0
5268 # func_note_Makefile_am_edit dir var value [dotfirst]
5269 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
5270 # ${value}.
5271 # If ${dotfirst} is non-empty, this mention needs to be present after '.'.
5272 # This is a special hack for the SUBDIRS variable, cf.
5273 # <https://www.gnu.org/software/automake/manual/html_node/Subdirectories.html>.
5274 func_note_Makefile_am_edit ()
5276 makefile_am_edits=`expr $makefile_am_edits + 1`
5277 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
5278 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
5279 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
5280 eval makefile_am_edit${makefile_am_edits}_dotfirst=\"\$4\"
5282 if test "$makefile_am" = Makefile.am; then
5283 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
5284 sourcebase_base=`basename "$sourcebase"`
5285 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
5287 if test -n "$pobase"; then
5288 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
5289 pobase_base=`basename "$pobase"`
5290 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
5292 if $inctests; then
5293 if test "$makefile_am" = Makefile.am; then
5294 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
5295 testsbase_base=`basename "$testsbase"`
5296 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base" true
5299 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
5301 # Find the first parent directory of $m4base that contains or will contain
5302 # a Makefile.am.
5303 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
5304 s,//*$,/,'
5305 sed_butlast='s,[^/][^/]*//*$,,'
5306 dir1="${m4base}/"; dir2=""
5307 while test -n "$dir1" \
5308 && ! { test -f "${destdir}/${dir1}Makefile.am" \
5309 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5310 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5311 || { $inctests \
5312 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
5313 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
5314 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
5315 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
5316 done
5317 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
5320 # Create library makefile.
5321 func_dest_tmpfilename $sourcebase/$makefile_am
5322 destfile="$sourcebase/$makefile_am"
5323 modules="$main_modules"
5324 func_emit_lib_Makefile_am > "$tmpfile"
5325 if test -f "$destdir"/$sourcebase/$makefile_am; then
5326 if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
5327 rm -f "$tmpfile"
5328 else
5329 if $doit; then
5330 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5331 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
5332 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5333 else
5334 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5335 rm -f "$tmpfile"
5338 else
5339 if $doit; then
5340 echo "Creating $sourcebase/$makefile_am"
5341 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5342 else
5343 echo "Create $sourcebase/$makefile_am"
5344 rm -f "$tmpfile"
5346 func_append added_files "$sourcebase/$makefile_am$nl"
5349 # Create po/ directory.
5350 if test -n "$pobase"; then
5351 # Create po makefile and auxiliary files.
5352 for file in Makefile.in.in remove-potcdate.sin; do
5353 func_dest_tmpfilename $pobase/$file
5354 func_lookup_file build-aux/po/$file
5355 cat "$lookedup_file" > "$tmpfile"
5356 if test -f "$destdir"/$pobase/$file; then
5357 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
5358 rm -f "$tmpfile"
5359 else
5360 if $doit; then
5361 echo "Updating $pobase/$file (backup in $pobase/$file~)"
5362 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
5363 mv -f "$tmpfile" "$destdir"/$pobase/$file
5364 else
5365 echo "Update $pobase/$file (backup in $pobase/$file~)"
5366 rm -f "$tmpfile"
5369 else
5370 if $doit; then
5371 echo "Creating $pobase/$file"
5372 mv -f "$tmpfile" "$destdir"/$pobase/$file
5373 else
5374 echo "Create $pobase/$file"
5375 rm -f "$tmpfile"
5377 func_append added_files "$pobase/$file$nl"
5379 done
5380 # Create po makefile parameterization, part 1.
5381 func_dest_tmpfilename $pobase/Makevars
5382 func_emit_po_Makevars > "$tmpfile"
5383 if test -f "$destdir"/$pobase/Makevars; then
5384 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
5385 rm -f "$tmpfile"
5386 else
5387 if $doit; then
5388 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
5389 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
5390 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5391 else
5392 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
5393 rm -f "$tmpfile"
5396 else
5397 if $doit; then
5398 echo "Creating $pobase/Makevars"
5399 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5400 else
5401 echo "Create $pobase/Makevars"
5402 rm -f "$tmpfile"
5404 func_append added_files "$pobase/Makevars$nl"
5406 # Create po makefile parameterization, part 2.
5407 func_dest_tmpfilename $pobase/POTFILES.in
5408 func_emit_po_POTFILES_in > "$tmpfile"
5409 if test -f "$destdir"/$pobase/POTFILES.in; then
5410 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5411 rm -f "$tmpfile"
5412 else
5413 if $doit; then
5414 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5415 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5416 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5417 else
5418 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5419 rm -f "$tmpfile"
5422 else
5423 if $doit; then
5424 echo "Creating $pobase/POTFILES.in"
5425 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5426 else
5427 echo "Create $pobase/POTFILES.in"
5428 rm -f "$tmpfile"
5430 func_append added_files "$pobase/POTFILES.in$nl"
5432 # Fetch PO files.
5433 TP_URL="https://translationproject.org/latest/"
5434 TP_RSYNC_URI="translationproject.org::tp/latest/"
5435 if $doit; then
5436 echo "Fetching gnulib PO files from $TP_URL"
5437 (cd "$destdir"/$pobase \
5438 && { # Prefer rsync over wget if it is available, since it consumes
5439 # less network bandwidth, due to compression.
5440 if type rsync 2>/dev/null | grep / > /dev/null; then
5441 rsync --delete --include "*.po" --exclude "*" -Lrtz "${TP_RSYNC_URI}gnulib/" . && return
5444 wget --no-verbose --mirror -nd -np -A.po -P . "${TP_URL}gnulib/"
5447 else
5448 echo "Fetch gnulib PO files from $TP_URL"
5450 # Create po/LINGUAS.
5451 if $doit; then
5452 func_dest_tmpfilename $pobase/LINGUAS
5453 (cd "$destdir"/$pobase \
5454 && { echo '# Set of available languages.'
5455 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5457 ) > "$tmpfile"
5458 if test -f "$destdir"/$pobase/LINGUAS; then
5459 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5460 rm -f "$tmpfile"
5461 else
5462 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5463 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5464 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5466 else
5467 echo "Creating $pobase/LINGUAS"
5468 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5469 func_append added_files "$pobase/LINGUAS$nl"
5471 else
5472 if test -f "$destdir"/$pobase/LINGUAS; then
5473 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5474 else
5475 echo "Create $pobase/LINGUAS"
5480 # func_count_relative_local_gnulib_path
5481 # gl_LOCAL_DIR requires local_gnulib_path to be set relatively to destdir
5482 # Input:
5483 # - local_gnulib_path from --local-dir
5484 # - destdir from --dir
5485 # Output:
5486 # - relative_local_dir path to be stored into gl_LOCAL_DIR
5487 func_count_relative_local_gnulib_path ()
5489 save_IFS=$IFS
5490 IFS=$PATH_SEPARATOR
5491 relative_local_gnulib_path=
5492 for local_dir in $local_gnulib_path
5494 # Store the local_dir relative to destdir.
5495 case "$local_dir" in
5496 "" | /*)
5497 relative_local_dir="$local_dir" ;;
5499 case "$destdir" in
5500 /*) relative_local_dir="$local_dir" ;;
5502 # destdir, local_dir are both relative.
5503 func_relativize "$destdir" "$local_dir"
5504 relative_local_dir="$reldir" ;;
5505 esac ;;
5506 esac
5507 func_path_append relative_local_gnulib_path "$relative_local_dir"
5508 done
5509 IFS=$save_IFS
5512 # Create m4/gnulib-cache.m4.
5513 func_dest_tmpfilename $m4base/gnulib-cache.m4
5515 func_emit_copyright_notice
5516 echo "#"
5517 echo "# This file represents the specification of how gnulib-tool is used."
5518 echo "# It acts as a cache: It is written and read by gnulib-tool."
5519 echo "# In projects that use version control, this file is meant to be put under"
5520 echo "# version control, like the configure.ac and various Makefile.am files."
5521 echo
5522 echo
5523 echo "# Specification in the form of a command-line invocation:"
5524 printf '%s\n' "$actioncmd"
5525 echo
5526 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5527 func_count_relative_local_gnulib_path
5528 echo "gl_LOCAL_DIR([$relative_local_gnulib_path])"
5529 echo "gl_MODULES(["
5530 echo "$specified_modules" | sed -e 's/^/ /g'
5531 echo "])"
5532 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5533 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5534 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5535 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5536 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5537 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5538 echo "gl_AVOID([$avoidlist])"
5539 echo "gl_SOURCE_BASE([$sourcebase])"
5540 echo "gl_M4_BASE([$m4base])"
5541 echo "gl_PO_BASE([$pobase])"
5542 echo "gl_DOC_BASE([$docbase])"
5543 echo "gl_TESTS_BASE([$testsbase])"
5544 if $inctests; then
5545 echo "gl_WITH_TESTS"
5547 echo "gl_LIB([$libname])"
5548 if test -n "$lgpl"; then
5549 if test "$lgpl" = yes; then
5550 echo "gl_LGPL"
5551 else
5552 echo "gl_LGPL([$lgpl])"
5555 echo "gl_MAKEFILE_NAME([$makefile_name])"
5556 if test "$cond_dependencies" = true; then
5557 echo "gl_CONDITIONAL_DEPENDENCIES"
5559 if test "$libtool" = true; then
5560 echo "gl_LIBTOOL"
5562 echo "gl_MACRO_PREFIX([$macro_prefix])"
5563 echo "gl_PO_DOMAIN([$po_domain])"
5564 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5565 if test -n "$vc_files"; then
5566 echo "gl_VC_FILES([$vc_files])"
5568 ) > "$tmpfile"
5569 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5570 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
5571 rm -f "$tmpfile"
5572 else
5573 if $doit; then
5574 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5575 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5576 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5577 else
5578 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5579 if false; then
5580 cat "$tmpfile"
5581 echo
5582 echo "# gnulib-cache.m4 ends here"
5584 rm -f "$tmpfile"
5587 else
5588 if $doit; then
5589 echo "Creating $m4base/gnulib-cache.m4"
5590 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5591 else
5592 echo "Create $m4base/gnulib-cache.m4"
5593 cat "$tmpfile"
5594 rm -f "$tmpfile"
5598 # Create m4/gnulib-comp.m4.
5599 func_dest_tmpfilename $m4base/gnulib-comp.m4
5601 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5602 func_emit_copyright_notice
5603 echo "#"
5604 echo "# This file represents the compiled summary of the specification in"
5605 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5606 echo "# to be invoked from configure.ac."
5607 echo "# In projects that use version control, this file can be treated like"
5608 echo "# other built files."
5609 echo
5610 echo
5611 echo "# This macro should be invoked from $configure_ac, in the section"
5612 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5613 echo "# any checks for libraries, header files, types and library functions."
5614 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5615 echo "["
5616 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5617 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5618 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5619 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5621 func_emit_pre_early_macros : ' ' "$final_modules"
5623 if ! $gnu_make && test -n "$uses_subdirs"; then
5624 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5626 for module in $final_modules; do
5627 func_verify_module
5628 if test -n "$module"; then
5629 echo "# Code from module $module:"
5630 func_get_autoconf_early_snippet "$module"
5632 done \
5633 | sed -e '/^$/d;' -e 's/^/ /'
5634 echo "])"
5635 echo
5636 echo "# This macro should be invoked from $configure_ac, in the section"
5637 echo "# \"Check for header files, types and library functions\"."
5638 echo "AC_DEFUN([${macro_prefix}_INIT],"
5639 echo "["
5640 if test "$libtool" = true; then
5641 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5642 echo " gl_cond_libtool=true"
5643 else
5644 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5645 echo " gl_cond_libtool=false"
5646 echo " gl_libdeps="
5647 echo " gl_ltlibdeps="
5649 if test "$auxdir" != "build-aux"; then
5650 sed_replace_build_aux='
5652 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5653 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5656 else
5657 sed_replace_build_aux="$sed_noop"
5659 echo " gl_m4_base='$m4base'"
5660 func_emit_initmacro_start $macro_prefix
5661 echo " gl_source_base='$sourcebase'"
5662 if test -n "$witness_c_macro"; then
5663 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5665 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false true
5666 if test -n "$witness_c_macro"; then
5667 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5669 echo " # End of code from modules"
5670 func_emit_initmacro_end $macro_prefix
5671 echo " gltests_libdeps="
5672 echo " gltests_ltlibdeps="
5673 func_emit_initmacro_start ${macro_prefix}tests
5674 echo " gl_source_base='$testsbase'"
5675 # Define a tests witness macro that depends on the package.
5676 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5677 # See <https://lists.gnu.org/r/automake/2009-05/msg00145.html>.
5678 echo "changequote(,)dnl"
5679 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"
5680 echo "changequote([, ])dnl"
5681 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5682 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5683 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5684 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true true true
5685 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5686 func_emit_initmacro_end ${macro_prefix}tests
5687 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5688 # created using libtool, because libtool already handles the dependencies.
5689 if test "$libtool" != true; then
5690 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5691 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5692 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5693 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5694 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5696 if $use_libtests; then
5697 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5698 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5700 echo "])"
5701 func_emit_initmacro_done $macro_prefix $sourcebase
5702 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5703 echo
5704 echo "# This macro records the list of files which have been installed by"
5705 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5706 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5707 echo "$files" | sed -e 's,^, ,'
5708 echo "])"
5709 ) > "$tmpfile"
5710 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5711 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
5712 rm -f "$tmpfile"
5713 else
5714 if $doit; then
5715 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5716 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5717 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5718 else
5719 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5720 if false; then
5721 cat "$tmpfile"
5722 echo
5723 echo "# gnulib-comp.m4 ends here"
5725 rm -f "$tmpfile"
5728 else
5729 if $doit; then
5730 echo "Creating $m4base/gnulib-comp.m4"
5731 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5732 else
5733 echo "Create $m4base/gnulib-comp.m4"
5734 cat "$tmpfile"
5735 rm -f "$tmpfile"
5739 if $inctests; then
5740 # Create tests makefile.
5741 func_dest_tmpfilename $testsbase/$makefile_am
5742 destfile="$testsbase/$makefile_am"
5743 modules="$testsrelated_modules"
5744 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5745 if test -f "$destdir"/$testsbase/$makefile_am; then
5746 if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
5747 rm -f "$tmpfile"
5748 else
5749 if $doit; then
5750 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5751 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5752 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5753 else
5754 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5755 rm -f "$tmpfile"
5758 else
5759 if $doit; then
5760 echo "Creating $testsbase/$makefile_am"
5761 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5762 else
5763 echo "Create $testsbase/$makefile_am"
5764 rm -f "$tmpfile"
5766 func_append added_files "$testsbase/$makefile_am$nl"
5770 if test "$vc_files" != false; then
5771 # Update the .cvsignore and .gitignore files.
5772 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5773 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5774 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5775 echo "$m4base/|A|gnulib-comp.m4"
5776 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5777 { # Rearrange file descriptors. Needed because "while ... done < ..."
5778 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5779 exec 5<&0 < "$tmp"/fileset-changes
5780 func_update_ignorelist ()
5782 ignore="$1"
5783 if test "$ignore" = .gitignore; then
5784 # In a .gitignore file, "foo" applies to the current directory and all
5785 # subdirectories, whereas "/foo" applies to the current directory only.
5786 anchor='/'
5787 escaped_anchor='\/'
5788 doubly_escaped_anchor='\\/'
5789 else
5790 anchor=''
5791 escaped_anchor=''
5792 doubly_escaped_anchor=''
5794 if test -f "$destdir/$dir$ignore"; then
5795 if test -n "$dir_added" || test -n "$dir_removed"; then
5796 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5797 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5798 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5799 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5800 > "$tmp"/ignore-removed
5802 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5803 if $doit; then
5804 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5805 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5806 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5807 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5808 } > "$tmp"/sed-ignore-removed
5809 { cat "$destdir/$dir$ignore"~
5810 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5811 } | sed -f "$tmp"/sed-ignore-removed \
5812 > "$destdir/$dir$ignore"
5813 else
5814 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5818 else
5819 if test -n "$dir_added"; then
5820 if $doit; then
5821 echo "Creating $destdir/$dir$ignore"
5823 if test "$ignore" = .cvsignore; then
5824 echo ".deps"
5825 # Automake generates Makefile rules that create .dirstamp files.
5826 echo ".dirstamp"
5828 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5829 } > "$destdir/$dir$ignore"
5830 else
5831 echo "Create $destdir/$dir$ignore"
5836 func_done_dir ()
5838 dir="$1"
5839 dir_added="$2"
5840 dir_removed="$3"
5841 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5842 func_update_ignorelist .cvsignore
5844 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5845 func_update_ignorelist .gitignore
5848 last_dir=
5849 last_dir_added=
5850 last_dir_removed=
5851 while read line; do
5852 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5853 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5854 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5855 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5856 if test "$next_dir" != "$last_dir"; then
5857 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5858 last_dir="$next_dir"
5859 last_dir_added=
5860 last_dir_removed=
5862 case $op in
5863 A) func_append last_dir_added "$file$nl";;
5864 R) func_append last_dir_removed "$file$nl";;
5865 esac
5866 done
5867 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5868 exec 0<&5 5<&-
5872 echo "Finished."
5873 echo
5874 echo "You may need to add #include directives for the following .h files."
5875 # Intersect $specified_modules and $main_modules
5876 # (since $specified_modules is not necessarily of subset of $main_modules
5877 # - some may have been skipped through --avoid, and since the elements of
5878 # $main_modules but not in $specified_modules can go away without explicit
5879 # notice - through changes in the module dependencies).
5880 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5881 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5882 # First the #include <...> directives without #ifs, sorted for convenience,
5883 # then the #include "..." directives without #ifs, sorted for convenience,
5884 # then the #include directives that are surrounded by #ifs. Not sorted.
5885 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5886 include_directive=`func_get_include_directive "$module"`
5887 case "$nl$include_directive" in
5888 *"$nl#if"*)
5889 echo "$include_directive" 1>&5
5892 echo "$include_directive" | grep -v 'include "' 1>&6
5893 echo "$include_directive" | grep 'include "' 1>&7
5895 esac
5896 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5898 LC_ALL=C sort -u "$tmp"/include-angles
5899 LC_ALL=C sort -u "$tmp"/include-quotes
5900 cat "$tmp"/include-if
5901 ) | sed -e '/^$/d' -e 's/^/ /'
5902 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5904 for module in $main_modules; do
5905 func_get_link_directive "$module"
5906 done \
5907 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5908 if test `wc -l < "$tmp"/link` != 0; then
5909 echo
5910 echo "You may need to use the following Makefile variables when linking."
5911 echo "Use them in <program>_LDADD when linking a program, or"
5912 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5913 cat "$tmp"/link
5915 rm -f "$tmp"/link
5917 echo
5918 echo "Don't forget to"
5919 if test "$makefile_am" = Makefile.am; then
5920 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5921 else
5922 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5924 if test -n "$pobase"; then
5925 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5927 if $inctests; then
5928 if test "$makefile_am" = Makefile.am; then
5929 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5930 else
5931 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5934 edit=0
5935 while test $edit != $makefile_am_edits; do
5936 edit=`expr $edit + 1`
5937 eval dir=\"\$makefile_am_edit${edit}_dir\"
5938 eval var=\"\$makefile_am_edit${edit}_var\"
5939 eval val=\"\$makefile_am_edit${edit}_val\"
5940 if test -n "$var"; then
5941 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5943 done
5944 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
5945 position_early_after=AC_PROG_CC_STDC
5946 else
5947 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
5948 position_early_after=AC_PROG_CC_C99
5949 else
5950 position_early_after=AC_PROG_CC
5953 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
5954 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5957 # func_create_testdir testdir modules
5958 # Input:
5959 # - local_gnulib_path from --local-dir
5960 # - modcache true or false, from --cache-modules/--no-cache-modules
5961 # - auxdir directory relative to destdir where to place build aux files
5962 # - inctests true if tests should be included, false otherwise
5963 # - incobsolete true if obsolete modules among dependencies should be
5964 # included, blank otherwise
5965 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5966 # blank otherwise
5967 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5968 # blank otherwise
5969 # - excl_privileged_tests true if tests that require root privileges should be
5970 # excluded, blank otherwise
5971 # - excl_unportable_tests true if tests that fail on some platforms should be
5972 # excluded, blank otherwise
5973 # - single_configure true if a single configure file should be generated,
5974 # false for a separate configure file for the tests
5975 # - avoidlist list of modules to avoid
5976 # - cond_dependencies true if --conditional-dependencies was given, false if
5977 # --no-conditional-dependencies was given, blank otherwise
5978 # - libtool true if --libtool was given, false if --no-libtool was
5979 # given, blank otherwise
5980 # - copymode copy mode for files in general
5981 # - lcopymode copy mode for files from local_gnulib_path
5982 func_create_testdir ()
5984 testdir="$1"
5985 modules="$2"
5986 if test -z "$modules"; then
5987 # All modules together.
5988 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5989 # Except non-recursive-gnulib-prefix-hack, which represents a nonstandard
5990 # way of using Automake.
5991 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5992 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5993 modules=`func_all_modules`
5994 modules=`for m in $modules; do case $m in config-h | non-recursive-gnulib-prefix-hack | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5996 specified_modules="$modules"
5998 # Canonicalize the list of specified modules.
5999 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
6001 # Test modules which invoke AC_CONFIG_FILES cannot be used with
6002 # --with-tests --single-configure. Avoid them.
6003 if $inctests && $single_configure; then
6004 avoidlist="$avoidlist havelib-tests"
6007 # Unlike in func_import, here we want to include all kinds of tests for the
6008 # directly specified modules, but not for dependencies.
6009 inc_all_direct_tests=true
6010 inc_all_indirect_tests="$inc_all_tests"
6012 # Check that the license of every module is consistent with the license of
6013 # its dependencies.
6014 saved_inctests="$inctests"
6015 # When computing transitive closures, don't consider $module to depend on
6016 # $module-tests. Need this because tests are implicitly GPL and may depend
6017 # on GPL modules - therefore we don't want a warning in this case.
6018 inctests=false
6019 for requested_module in $specified_modules; do
6020 requested_license=`func_get_license "$requested_module"`
6021 if test "$requested_license" != GPL; then
6022 # Here we use func_modules_transitive_closure, not just
6023 # func_get_dependencies, so that we also detect weird situations like
6024 # an LGPL module which depends on a GPLed build tool module which depends
6025 # on a GPL module.
6026 modules="$requested_module"
6027 func_modules_transitive_closure
6028 for module in $modules; do
6029 license=`func_get_license "$module"`
6030 case "$license" in
6031 'GPLed build tool') ;;
6032 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
6034 case "$requested_license" in
6035 GPLv3+ | GPL)
6036 case "$license" in
6037 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL | GPLv2+ | GPLv3+ | GPL) ;;
6038 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6039 esac
6041 GPLv2+)
6042 case "$license" in
6043 LGPLv2+ | 'LGPLv3+ or GPLv2' | GPLv2+) ;;
6044 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6045 esac
6047 LGPLv3+ | LGPL)
6048 case "$license" in
6049 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
6050 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6051 esac
6053 'LGPLv3+ or GPLv2')
6054 case "$license" in
6055 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
6056 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6057 esac
6059 LGPLv2+)
6060 case "$license" in
6061 LGPLv2+) ;;
6062 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6063 esac
6065 esac
6067 esac
6068 done
6070 done
6071 inctests="$saved_inctests"
6073 # Subdirectory names.
6074 sourcebase=gllib
6075 m4base=glm4
6076 pobase=
6077 docbase=gldoc
6078 testsbase=gltests
6079 macro_prefix=gl
6080 po_domain=
6081 witness_c_macro=
6082 vc_files=
6084 # Determine final module list.
6085 modules="$specified_modules"
6086 func_modules_transitive_closure
6087 if test $verbose -ge 0; then
6088 func_show_module_list
6090 final_modules="$modules"
6092 if $single_configure; then
6093 # Determine main module list and tests-related module list separately.
6094 func_modules_transitive_closure_separately
6097 if $single_configure; then
6098 # Determine whether a $testsbase/libtests.a is needed.
6099 func_determine_use_libtests
6102 # Add the dummy module if needed.
6103 if $single_configure; then
6104 func_modules_add_dummy_separately
6105 else
6106 func_modules_add_dummy
6109 # Note:
6110 # If $single_configure, we use the module lists $main_modules and
6111 # $testsrelated_modules; $modules is merely a temporary variable.
6112 # Whereas if ! $configure, the module list is $modules.
6114 # Show banner notice of every module.
6115 if $single_configure; then
6116 modules="$main_modules"
6117 func_modules_notice
6118 else
6119 func_modules_notice
6122 # Determine final file list.
6123 if $single_configure; then
6124 func_modules_to_filelist_separately
6125 else
6126 func_modules_to_filelist
6127 if test $verbose -ge 0; then
6128 echo "File list:"
6129 echo "$files" | sed -e 's/^/ /'
6132 # Add files for which the copy in gnulib is newer than the one that
6133 # "automake --add-missing --copy" would provide.
6134 files="$files build-aux/config.guess"
6135 files="$files build-aux/config.sub"
6136 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
6138 rewritten='%REWRITTEN%'
6139 sed_rewrite_files="\
6140 s,^build-aux/,$rewritten$auxdir/,
6141 s,^doc/,$rewritten$docbase/,
6142 s,^lib/,$rewritten$sourcebase/,
6143 s,^m4/,$rewritten$m4base/,
6144 s,^tests/,$rewritten$testsbase/,
6145 s,^tests=lib/,$rewritten$testsbase/,
6146 s,^top/,$rewritten,
6147 s,^$rewritten,,"
6149 # Create directories.
6150 for f in $files; do echo $f; done \
6151 | sed -e "$sed_rewrite_files" \
6152 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
6153 | LC_ALL=C sort -u \
6154 > "$tmp"/dirs
6155 { # Rearrange file descriptors. Needed because "while ... done < ..."
6156 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6157 exec 5<&0 < "$tmp"/dirs
6158 while read d; do
6159 mkdir -p "$testdir/$d"
6160 done
6161 exec 0<&5 5<&-
6164 # Copy files or make symbolic links or hard links.
6165 delimiter=' '
6166 for f in $files; do echo $f; done \
6167 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
6168 | LC_ALL=C sort \
6169 > "$tmp"/files
6170 { # Rearrange file descriptors. Needed because "while ... done < ..."
6171 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6172 exec 5<&0 < "$tmp"/files
6173 while read g f; do
6174 case "$f" in
6175 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
6176 esac
6177 func_lookup_file "$f"
6178 if test -n "$lookedup_tmp"; then
6179 cp -p "$lookedup_file" "$testdir/$g"
6180 else
6181 func_should_link
6182 if test "$copyaction" = symlink; then
6183 func_symlink "$lookedup_file" "$testdir/$g"
6184 else
6185 if test "$copyaction" = hardlink; then
6186 func_hardlink "$lookedup_file" "$testdir/$g"
6187 else
6188 cp -p "$lookedup_file" "$testdir/$g"
6192 done
6193 exec 0<&5 5<&-
6196 # Determine include_guard_prefix.
6197 func_compute_include_guard_prefix
6199 # Create Makefile.ams that are for testing.
6200 for_test=true
6202 # No special edits are needed.
6203 makefile_am_edits=0
6205 # Create $sourcebase/Makefile.am.
6206 mkdir -p "$testdir/$sourcebase"
6207 destfile="$sourcebase/Makefile.am"
6208 if $single_configure; then
6209 modules="$main_modules"
6211 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
6212 any_uses_subdirs="$uses_subdirs"
6214 # Create $m4base/Makefile.am.
6215 mkdir -p "$testdir/$m4base"
6216 (echo "## Process this file with automake to produce Makefile.in."
6217 echo
6218 echo "EXTRA_DIST ="
6219 for f in $files; do
6220 case "$f" in
6221 m4/* )
6222 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
6223 esac
6224 done
6225 ) > "$testdir/$m4base/Makefile.am"
6227 subdirs="$sourcebase $m4base"
6228 subdirs_with_configure_ac=""
6230 if false && test -f "$testdir"/$m4base/gettext.m4; then
6231 # Avoid stupid error message from automake:
6232 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
6233 mkdir -p "$testdir/po"
6234 (echo "## Process this file with automake to produce Makefile.in."
6235 ) > "$testdir/po/Makefile.am"
6236 func_append subdirs " po"
6239 if $inctests; then
6240 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
6241 if $single_configure; then
6242 # Create $testsbase/Makefile.am.
6243 destfile="$testsbase/Makefile.am"
6244 modules="$testsrelated_modules"
6245 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
6246 else
6247 # Viewed from the $testsbase subdirectory, $auxdir is different.
6248 saved_auxdir="$auxdir"
6249 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
6250 # Create $testsbase/Makefile.am.
6251 use_libtests=false
6252 destfile="$testsbase/Makefile.am"
6253 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
6254 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
6255 # Create $testsbase/configure.ac.
6256 (echo "# Process this file with autoconf to produce a configure script."
6257 echo "AC_INIT([dummy], [0])"
6258 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6259 echo "AM_INIT_AUTOMAKE"
6260 echo
6261 echo "AC_CONFIG_HEADERS([config.h])"
6262 echo
6263 echo "AC_PROG_CC"
6264 echo "AC_PROG_INSTALL"
6265 echo "AC_PROG_MAKE_SET"
6267 func_emit_pre_early_macros false '' "$modules"
6269 if test -n "$uses_subdirs"; then
6270 echo "AM_PROG_CC_C_O"
6271 echo
6273 for module in $modules; do
6274 func_verify_module
6275 if test -n "$module"; then
6276 case $module in
6277 gnumakefile | maintainer-makefile)
6278 # These modules are meant to be used only in the top-level directory.
6281 func_get_autoconf_early_snippet "$module"
6283 esac
6285 done \
6286 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6287 if test "$libtool" = true; then
6288 echo "LT_INIT([win32-dll])"
6289 echo "LT_LANG([C++])"
6290 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6291 echo "gl_cond_libtool=true"
6292 else
6293 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6294 echo "gl_cond_libtool=false"
6295 echo "gl_libdeps="
6296 echo "gl_ltlibdeps="
6298 # Wrap the set of autoconf snippets into an autoconf macro that is then
6299 # invoked. This is needed because autoconf does not support AC_REQUIRE
6300 # at the top level:
6301 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6302 # but we want the AC_REQUIRE to have its normal meaning (provide one
6303 # expansion of the required macro before the current point, and only one
6304 # expansion total).
6305 echo "AC_DEFUN([gl_INIT], ["
6306 sed_replace_build_aux='
6308 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6309 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6312 echo "gl_m4_base='../$m4base'"
6313 func_emit_initmacro_start $macro_prefix
6314 # We don't have explicit ordering constraints between the various
6315 # autoconf snippets. It's cleanest to put those of the library before
6316 # those of the tests.
6317 echo "gl_source_base='../$sourcebase'"
6318 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module false false false
6319 echo "gl_source_base='.'"
6320 func_emit_autoconf_snippets "$modules" "$modules" func_verify_tests_module false false false
6321 func_emit_initmacro_end $macro_prefix
6322 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6323 # created using libtool, because libtool already handles the dependencies.
6324 if test "$libtool" != true; then
6325 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6326 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6327 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6328 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6329 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6331 echo "])"
6332 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
6333 echo
6334 echo "gl_INIT"
6335 echo
6336 # Usually $testsbase/config.h will be a superset of config.h. Verify this
6337 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
6338 echo "AH_TOP([#include \"../config.h\"])"
6339 echo
6340 echo "AC_CONFIG_FILES([Makefile])"
6341 echo "AC_OUTPUT"
6342 ) > "$testdir/$testsbase/configure.ac"
6343 auxdir="$saved_auxdir"
6344 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
6346 func_append subdirs " $testsbase"
6349 # Create Makefile.am.
6350 (echo "## Process this file with automake to produce Makefile.in."
6351 echo
6352 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
6353 echo
6354 echo "SUBDIRS = $subdirs"
6355 echo
6356 echo "ACLOCAL_AMFLAGS = -I $m4base"
6357 ) > "$testdir/Makefile.am"
6359 # Create configure.ac.
6360 (echo "# Process this file with autoconf to produce a configure script."
6361 echo "AC_INIT([dummy], [0])"
6362 if test "$auxdir" != "."; then
6363 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6365 echo "AM_INIT_AUTOMAKE"
6366 echo
6367 echo "AC_CONFIG_HEADERS([config.h])"
6368 echo
6369 echo "AC_PROG_CC"
6370 echo "AC_PROG_INSTALL"
6371 echo "AC_PROG_MAKE_SET"
6372 echo
6373 echo "# For autobuild."
6374 echo "AC_CANONICAL_BUILD"
6375 echo "AC_CANONICAL_HOST"
6376 echo
6377 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
6378 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
6379 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6380 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6382 func_emit_pre_early_macros false '' "$final_modules"
6384 if test -n "$any_uses_subdirs"; then
6385 echo "AM_PROG_CC_C_O"
6386 echo
6388 for module in $final_modules; do
6389 if $single_configure; then
6390 func_verify_module
6391 else
6392 func_verify_nontests_module
6394 if test -n "$module"; then
6395 func_get_autoconf_early_snippet "$module"
6397 done \
6398 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6399 if test "$libtool" = true; then
6400 echo "LT_INIT([win32-dll])"
6401 echo "LT_LANG([C++])"
6402 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6403 echo "gl_cond_libtool=true"
6404 else
6405 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6406 echo "gl_cond_libtool=false"
6407 echo "gl_libdeps="
6408 echo "gl_ltlibdeps="
6410 # Wrap the set of autoconf snippets into an autoconf macro that is then
6411 # invoked. This is needed because autoconf does not support AC_REQUIRE
6412 # at the top level:
6413 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6414 # but we want the AC_REQUIRE to have its normal meaning (provide one
6415 # expansion of the required macro before the current point, and only one
6416 # expansion total).
6417 echo "AC_DEFUN([gl_INIT], ["
6418 if test "$auxdir" != "build-aux"; then
6419 sed_replace_build_aux='
6421 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6422 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6425 else
6426 sed_replace_build_aux="$sed_noop"
6428 echo "gl_m4_base='$m4base'"
6429 func_emit_initmacro_start $macro_prefix
6430 echo "gl_source_base='$sourcebase'"
6431 if $single_configure; then
6432 func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false false
6433 else
6434 func_emit_autoconf_snippets "$modules" "$modules" func_verify_nontests_module true false false
6436 func_emit_initmacro_end $macro_prefix
6437 if $single_configure; then
6438 echo " gltests_libdeps="
6439 echo " gltests_ltlibdeps="
6440 func_emit_initmacro_start ${macro_prefix}tests
6441 echo " gl_source_base='$testsbase'"
6442 # Define a tests witness macro.
6443 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
6444 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6445 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6446 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6447 func_emit_autoconf_snippets "$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true false false
6448 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6449 func_emit_initmacro_end ${macro_prefix}tests
6451 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6452 # created using libtool, because libtool already handles the dependencies.
6453 if test "$libtool" != true; then
6454 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6455 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6456 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6457 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6458 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6460 if $single_configure; then
6461 if $use_libtests; then
6462 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6463 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6466 echo "])"
6467 func_emit_initmacro_done $macro_prefix $sourcebase
6468 if $single_configure; then
6469 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6471 echo
6472 echo "gl_INIT"
6473 echo
6474 if test -n "$subdirs_with_configure_ac"; then
6475 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6477 makefiles="Makefile"
6478 for d in $subdirs; do
6479 # For subdirs that have a configure.ac by their own, it's the subdir's
6480 # configure.ac which creates the subdir's Makefile.am, not this one.
6481 case " $subdirs_with_configure_ac " in
6482 *" $d "*) ;;
6483 *) func_append makefiles " $d/Makefile" ;;
6484 esac
6485 done
6486 echo "AC_CONFIG_FILES([$makefiles])"
6487 echo "AC_OUTPUT"
6488 ) > "$testdir/configure.ac"
6490 # Create autogenerated files.
6491 (cd "$testdir"
6492 # Do not use "${AUTORECONF} --force --install", because it may invoke
6493 # autopoint, which brings in older versions of some of our .m4 files.
6494 if test -f $m4base/gettext.m4; then
6495 func_execute_command ${AUTOPOINT} --force || func_exit 1
6496 for f in $m4base/*.m4~; do
6497 if test -f $f; then
6498 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6500 done
6502 if test "$libtool" = true; then
6503 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6505 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6506 if ! test -d build-aux; then
6507 func_execute_command mkdir build-aux || func_exit 1
6509 func_execute_command ${AUTOCONF} || func_exit 1
6510 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6511 func_execute_command ${AUTOHEADER} &&
6512 func_execute_command touch config.h.in ||
6513 func_exit 1
6514 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6515 rm -rf autom4te.cache
6516 ) || func_exit 1
6517 if $inctests && ! $single_configure; then
6518 # Create autogenerated files.
6519 (cd "$testdir/$testsbase" || func_exit 1
6520 # Do not use "${AUTORECONF} --force --install", because it may invoke
6521 # autopoint, which brings in older versions of some of our .m4 files.
6522 if test -f ../$m4base/gettext.m4; then
6523 func_execute_command ${AUTOPOINT} --force || func_exit 1
6524 for f in ../$m4base/*.m4~; do
6525 if test -f $f; then
6526 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6528 done
6530 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6531 if ! test -d ../build-aux; then
6532 func_execute_command mkdir ../build-aux
6534 func_execute_command ${AUTOCONF} || func_exit 1
6535 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6536 func_execute_command ${AUTOHEADER} &&
6537 func_execute_command touch config.h.in ||
6538 func_exit 1
6539 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6540 rm -rf autom4te.cache
6541 ) || func_exit 1
6543 # Need to run configure and make once, to create built files that are to be
6544 # distributed (such as parse-datetime.c).
6545 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6546 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6547 cleaned_files=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6548 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6549 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6550 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6551 # such $(FOO_H) because they don't refer to distributed files.
6552 built_sources=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6553 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6554 | sed -e "$sed_remove_make_variables"`
6555 distributed_built_sources=`for file in $built_sources; do
6556 case "$cleaned_files" in
6557 *" "$file" "*) ;;
6558 *) echo $file ;;
6559 esac;
6560 done`
6561 tests_distributed_built_sources=
6562 if $inctests; then
6563 # Likewise for built files in the $testsbase directory.
6564 tests_cleaned_files=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6565 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6566 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6567 tests_built_sources=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6568 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6569 | sed -e "$sed_remove_make_variables"`
6570 tests_distributed_built_sources=`for file in $tests_built_sources; do
6571 case "$tests_cleaned_files" in
6572 *" "$file" "*) ;;
6573 *) echo $file ;;
6574 esac;
6575 done`
6577 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6578 (cd "$testdir"
6579 ./configure || func_exit 1
6580 if test -n "$distributed_built_sources"; then
6581 cd "$sourcebase"
6582 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6583 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6584 built_sources \
6585 || func_exit 1
6586 cd ..
6588 if test -n "$tests_distributed_built_sources"; then
6589 cd "$testsbase"
6590 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6591 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6592 built_sources \
6593 || func_exit 1
6594 cd ..
6596 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6597 distclean \
6598 || func_exit 1
6599 ) || func_exit 1
6603 # func_create_megatestdir megatestdir allmodules
6604 # Input:
6605 # - local_gnulib_path from --local-dir
6606 # - modcache true or false, from --cache-modules/--no-cache-modules
6607 # - auxdir directory relative to destdir where to place build aux files
6608 func_create_megatestdir ()
6610 megatestdir="$1"
6611 allmodules="$2"
6612 if test -z "$allmodules"; then
6613 allmodules=`func_all_modules`
6616 megasubdirs=
6617 # First, all modules one by one.
6618 for onemodule in $allmodules; do
6619 func_create_testdir "$megatestdir/$onemodule" $onemodule
6620 func_append megasubdirs "$onemodule "
6621 done
6622 # Then, all modules all together.
6623 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6624 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6625 func_create_testdir "$megatestdir/ALL" "$allmodules"
6626 func_append megasubdirs "ALL"
6628 # Create autobuild.
6629 cvsdate=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6630 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6631 | sed -e 's,January,01,' -e 's,Jan,01,' \
6632 -e 's,February,02,' -e 's,Feb,02,' \
6633 -e 's,March,03,' -e 's,Mar,03,' \
6634 -e 's,April,04,' -e 's,Apr,04,' \
6635 -e 's,May,05,' \
6636 -e 's,June,06,' -e 's,Jun,06,' \
6637 -e 's,July,07,' -e 's,Jul,07,' \
6638 -e 's,August,08,' -e 's,Aug,08,' \
6639 -e 's,September,09,' -e 's,Sep,09,' \
6640 -e 's,October,10,' -e 's,Oct,10,' \
6641 -e 's,November,11,' -e 's,Nov,11,' \
6642 -e 's,December,12,' -e 's,Dec,12,' \
6643 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6644 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6645 (echo '#!/bin/sh'
6646 echo "CVSDATE=$cvsdate"
6647 echo ": \${MAKE=make}"
6648 echo "test -d logs || mkdir logs"
6649 echo "for module in $megasubdirs; do"
6650 echo " echo \"Working on module \$module...\""
6651 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6652 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6653 echo " echo"
6654 echo " set -x"
6655 echo " : autobuild project... \$module"
6656 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6657 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6658 echo " : autobuild hostname... \`hostname\`"
6659 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6660 echo " echo rc=\$?"
6661 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6662 echo "done"
6663 ) > "$megatestdir/do-autobuild"
6664 chmod a+x "$megatestdir/do-autobuild"
6666 # Create Makefile.am.
6667 (echo "## Process this file with automake to produce Makefile.in."
6668 echo
6669 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
6670 echo
6671 echo "SUBDIRS = $megasubdirs"
6672 echo
6673 echo "EXTRA_DIST = do-autobuild"
6674 ) > "$megatestdir/Makefile.am"
6676 # Create configure.ac.
6677 (echo "# Process this file with autoconf to produce a configure script."
6678 echo "AC_INIT([dummy], [0])"
6679 if test "$auxdir" != "."; then
6680 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6682 echo "AM_INIT_AUTOMAKE"
6683 echo
6684 echo "AC_PROG_MAKE_SET"
6685 echo
6686 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6687 echo "AC_CONFIG_FILES([Makefile])"
6688 echo "AC_OUTPUT"
6689 ) > "$megatestdir/configure.ac"
6691 # Create autogenerated files.
6692 (cd "$megatestdir"
6693 # Do not use "${AUTORECONF} --install", because autoreconf operates
6694 # recursively, but the subdirectories are already finished, therefore
6695 # calling autoreconf here would only waste lots of CPU time.
6696 func_execute_command ${ACLOCAL} || func_exit 1
6697 func_execute_command mkdir build-aux
6698 func_execute_command ${AUTOCONF} || func_exit 1
6699 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6700 rm -rf autom4te.cache
6701 ) || func_exit 1
6704 case $mode in
6705 "" )
6706 func_fatal_error "no mode specified" ;;
6708 list )
6709 func_all_modules
6712 find )
6713 # sed expression that converts a literal to a basic regular expression.
6714 # Needs to handle . [ \ * ^ $.
6715 sed_literal_to_basic_regex='s/\\/\\\\/g
6716 s/\[/\\[/g
6717 s/\^/\\^/g
6718 s/\([.*$]\)/[\1]/g'
6719 for filename
6721 if test -f "$gnulib_dir/$filename" \
6722 || func_lookup_local_file "$filename"; then
6723 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6724 filename_line_regex='^'"$filename_anywhere_regex"'$'
6725 module_candidates=`
6727 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6728 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$,,'
6730 | func_sanitize_modulelist \
6731 | LC_ALL=C sort -u
6733 for module in $module_candidates; do
6734 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6735 echo $module
6737 done
6738 else
6739 func_warning "file $filename does not exist"
6741 done
6744 import | add-import | remove-import | update )
6746 # Where to import.
6747 if test -z "$destdir"; then
6748 destdir=.
6750 test -d "$destdir" \
6751 || func_fatal_error "destination directory does not exist: $destdir"
6753 # Prefer configure.ac to configure.in.
6754 if test -f "$destdir"/configure.ac; then
6755 configure_ac="$destdir/configure.ac"
6756 else
6757 if test -f "$destdir"/configure.in; then
6758 configure_ac="$destdir/configure.in"
6759 else
6760 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6764 # Analyze configure.ac.
6765 guessed_auxdir="."
6766 guessed_libtool=false
6767 my_sed_traces='
6768 s,#.*$,,
6769 s,^dnl .*$,,
6770 s, dnl .*$,,
6771 /AC_CONFIG_AUX_DIR/ {
6772 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6774 /A[CM]_PROG_LIBTOOL/ {
6775 s,^.*$,guessed_libtool=true,p
6777 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6779 if test -z "$auxdir"; then
6780 auxdir="$guessed_auxdir"
6783 # Determine where to apply func_import.
6784 if test "$mode" = import; then
6785 # Apply func_import to a particular gnulib directory.
6786 # The command line contains the complete specification; don't look at
6787 # the contents of gnulib-cache.m4.
6788 test -n "$supplied_libname" || supplied_libname=true
6789 test -n "$sourcebase" || sourcebase="lib"
6790 test -n "$m4base" || m4base="m4"
6791 test -n "$docbase" || docbase="doc"
6792 test -n "$testsbase" || testsbase="tests"
6793 test -n "$macro_prefix" || macro_prefix="gl"
6794 func_import "$*"
6795 else
6796 if test -n "$m4base"; then
6797 # Apply func_import to a particular gnulib directory.
6798 # Any number of additional modules can be given.
6799 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6800 # First use of gnulib in the given m4base.
6801 test -n "$supplied_libname" || supplied_libname=true
6802 test -n "$sourcebase" || sourcebase="lib"
6803 test -n "$docbase" || docbase="doc"
6804 test -n "$testsbase" || testsbase="tests"
6805 test -n "$macro_prefix" || macro_prefix="gl"
6807 func_import "$*"
6808 else
6809 # Apply func_import to all gnulib directories.
6810 # To get this list of directories, look at Makefile.am. (Not at
6811 # configure, because it may be omitted from version control. Also,
6812 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6813 # too expensive.)
6814 m4dirs=
6815 m4dirs_count=0
6816 if test -f "$destdir"/Makefile.am; then
6817 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6818 m4dir_is_next=
6819 for arg in $aclocal_amflags; do
6820 if test -n "$m4dir_is_next"; then
6821 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6822 case "$arg" in
6823 /*) ;;
6825 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6826 func_append m4dirs " $arg"
6827 m4dirs_count=`expr $m4dirs_count + 1`
6830 esac
6831 m4dir_is_next=
6832 else
6833 if test "X$arg" = "X-I"; then
6834 m4dir_is_next=yes
6835 else
6836 m4dir_is_next=
6839 done
6840 else
6841 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6842 if test -f "$destdir"/aclocal.m4; then
6843 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6844 sedexpr2='s,^[^/]*$,.,'
6845 sedexpr3='s,/[^/]*$,,'
6846 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6847 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6848 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6851 if test $m4dirs_count = 0; then
6852 # First use of gnulib in a package.
6853 # Any number of additional modules can be given.
6854 test -n "$supplied_libname" || supplied_libname=true
6855 test -n "$sourcebase" || sourcebase="lib"
6856 m4base="m4"
6857 test -n "$docbase" || docbase="doc"
6858 test -n "$testsbase" || testsbase="tests"
6859 test -n "$macro_prefix" || macro_prefix="gl"
6860 func_import "$*"
6861 else
6862 if test $m4dirs_count = 1; then
6863 # There's only one use of gnulib here. Assume the user means it.
6864 # Any number of additional modules can be given.
6865 for m4base in $m4dirs; do
6866 func_import "$*"
6867 done
6868 else
6869 # Ambiguous - guess what the user meant.
6870 if test $# = 0; then
6871 # No further arguments. Guess the user wants to update all of them.
6872 for m4base in $m4dirs; do
6873 # Perform func_import in a subshell, so that variable values
6874 # such as
6875 # local_gnulib_path, incobsolete, inc_cxx_tests,
6876 # inc_longrunning_tests, inc_privileged_tests,
6877 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6878 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6879 # makefile_name, libtool, macro_prefix, po_domain,
6880 # witness_c_macro, vc_files
6881 # don't propagate from one directory to another.
6882 (func_import) || func_exit 1
6883 done
6884 else
6885 # Really ambiguous.
6886 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6894 create-testdir )
6895 if test -z "$destdir"; then
6896 func_fatal_error "please specify --dir option"
6898 mkdir "$destdir"
6899 test -d "$destdir" \
6900 || func_fatal_error "could not create destination directory"
6901 test -n "$auxdir" || auxdir="build-aux"
6902 func_create_testdir "$destdir" "$*"
6905 create-megatestdir )
6906 if test -z "$destdir"; then
6907 func_fatal_error "please specify --dir option"
6909 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6910 test -n "$auxdir" || auxdir="build-aux"
6911 func_create_megatestdir "$destdir" "$*"
6914 test )
6915 test -n "$destdir" || destdir=testdir$$
6916 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6917 test -n "$auxdir" || auxdir="build-aux"
6918 func_create_testdir "$destdir" "$*"
6919 cd "$destdir"
6920 mkdir build
6921 cd build
6922 ../configure || func_exit 1
6923 $MAKE || func_exit 1
6924 $MAKE check || func_exit 1
6925 $MAKE distclean || func_exit 1
6926 remaining=`find . -type f -print`
6927 if test -n "$remaining"; then
6928 echo "Remaining files:" $remaining 1>&2
6929 echo "gnulib-tool: *** Stop." 1>&2
6930 func_exit 1
6932 cd ..
6933 cd ..
6934 rm -rf "$destdir"
6937 megatest )
6938 test -n "$destdir" || destdir=testdir$$
6939 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6940 test -n "$auxdir" || auxdir="build-aux"
6941 func_create_megatestdir "$destdir" "$*"
6942 cd "$destdir"
6943 mkdir build
6944 cd build
6945 ../configure
6946 $MAKE
6947 $MAKE check
6948 $MAKE distclean
6949 remaining=`find . -type f -print`
6950 if test -n "$remaining"; then
6951 echo "Remaining files:" $remaining 1>&2
6952 echo "gnulib-tool: *** Stop." 1>&2
6953 func_exit 1
6955 cd ..
6956 cd ..
6957 rm -rf "$destdir"
6960 extract-description )
6961 for module
6963 func_verify_module
6964 if test -n "$module"; then
6965 func_get_description "$module"
6967 done
6970 extract-comment )
6971 for module
6973 func_verify_module
6974 if test -n "$module"; then
6975 func_get_comment "$module"
6977 done
6980 extract-status )
6981 for module
6983 func_verify_module
6984 if test -n "$module"; then
6985 func_get_status "$module"
6987 done
6990 extract-notice )
6991 for module
6993 func_verify_module
6994 if test -n "$module"; then
6995 func_get_notice "$module"
6997 done
7000 extract-applicability )
7001 for module
7003 func_verify_module
7004 if test -n "$module"; then
7005 func_get_applicability "$module"
7007 done
7010 extract-filelist )
7011 for module
7013 func_verify_module
7014 if test -n "$module"; then
7015 func_get_filelist "$module"
7017 done
7020 extract-dependencies )
7021 if test -n "$avoidlist"; then
7022 func_fatal_error "cannot combine --avoid and --extract-dependencies"
7024 for module
7026 func_verify_module
7027 if test -n "$module"; then
7028 func_get_dependencies "$module"
7030 done
7033 extract-autoconf-snippet )
7034 for module
7036 func_verify_module
7037 if test -n "$module"; then
7038 func_get_autoconf_snippet "$module"
7040 done
7043 extract-automake-snippet )
7044 for module
7046 func_verify_module
7047 if test -n "$module"; then
7048 func_get_automake_snippet "$module"
7050 done
7053 extract-include-directive )
7054 for module
7056 func_verify_module
7057 if test -n "$module"; then
7058 func_get_include_directive "$module"
7060 done
7063 extract-link-directive )
7064 for module
7066 func_verify_module
7067 if test -n "$module"; then
7068 func_get_link_directive "$module"
7070 done
7073 extract-license )
7074 for module
7076 func_verify_module
7077 if test -n "$module"; then
7078 func_get_license "$module"
7080 done
7083 extract-maintainer )
7084 for module
7086 func_verify_module
7087 if test -n "$module"; then
7088 func_get_maintainer "$module"
7090 done
7093 extract-tests-module )
7094 for module
7096 func_verify_module
7097 if test -n "$module"; then
7098 func_get_tests_module "$module"
7100 done
7103 copy-file )
7104 # Verify the number of arguments.
7105 if test $# -lt 1 || test $# -gt 2; then
7106 func_fatal_error "invalid number of arguments for --$mode"
7109 # The first argument is the file to be copied.
7110 f="$1"
7111 # Verify the file exists.
7112 func_lookup_file "$f"
7114 # The second argument is the destination; either a directory ot a file.
7115 # It defaults to the current directory.
7116 dest="$2"
7117 test -n "$dest" || dest='.'
7118 test -n "$sourcebase" || sourcebase="lib"
7119 test -n "$m4base" || m4base="m4"
7120 test -n "$docbase" || docbase="doc"
7121 test -n "$testsbase" || testsbase="tests"
7122 test -n "$auxdir" || auxdir="build-aux"
7123 rewritten='%REWRITTEN%'
7124 sed_rewrite_files="\
7125 s,^build-aux/,$rewritten$auxdir/,
7126 s,^doc/,$rewritten$docbase/,
7127 s,^lib/,$rewritten$sourcebase/,
7128 s,^m4/,$rewritten$m4base/,
7129 s,^tests/,$rewritten$testsbase/,
7130 s,^top/,$rewritten,
7131 s,^$rewritten,,"
7132 if test -d "$dest"; then
7133 destdir="$dest"
7134 g=`echo "$f" | sed -e "$sed_rewrite_files"`
7135 else
7136 destdir=`dirname "$dest"`
7137 g=`basename "$dest"`
7140 # Create the directory for destfile.
7141 d=`dirname "$destdir/$g"`
7142 if $doit; then
7143 if test -n "$d" && test ! -d "$d"; then
7144 mkdir -p "$d" || func_fatal_error "failed"
7147 # Copy the file.
7148 func_dest_tmpfilename "$g"
7149 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
7150 already_present=true
7151 if test -f "$destdir/$g"; then
7152 # The file already exists.
7153 func_update_file
7154 else
7155 # Install the file.
7156 # Don't protest if the file should be there but isn't: it happens
7157 # frequently that developers don't put autogenerated files under version
7158 # control.
7159 func_add_file
7161 rm -f "$tmpfile"
7165 func_fatal_error "unknown operation mode --$mode" ;;
7166 esac
7168 if test "$copymode" = hardlink -o "$lcopymode" = hardlink; then
7169 # Setting hard links modifies the ctime of files in the gnulib checkout.
7170 # This disturbs the result of the next "gitk" invocation.
7171 # Workaround: Let git scan the files. This can be done through
7172 # "git update-index --refresh" or "git status" or "git diff".
7173 if test -d "$gnulib_dir"/.git \
7174 && (git --version) >/dev/null 2>/dev/null; then
7175 (cd "$gnulib_dir" && git update-index --refresh >/dev/null)
7179 rm -rf "$tmp"
7180 # Undo the effect of the previous 'trap' command. Some shellology:
7181 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
7182 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
7183 # exit); for the others we need to call 'exit' explicitly. The value of $? is
7184 # 128 + signal number and is set before the trap-registered command is run.
7185 trap '' 0
7186 trap 'func_exit $?' 1 2 3 13 15
7188 exit 0
7190 # Local Variables:
7191 # indent-tabs-mode: nil
7192 # whitespace-check-buffer-indent: nil
7193 # End: