3 # Copyright (C) 2002-2024 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 # CODING STYLE for this file:
23 # * Indentation: Indent by 2 spaces. Indent case clauses by 2 spaces as well.
24 # * Shell variable references: Use double-quote around shell variable
25 # references always (except when word splitting is explicitly desired),
26 # even when you know the double-quote are not needed. This style tends to
27 # avoid undesired word splitting caused by omitted double-quotes (the
28 # number one mistake in shell scripts).
29 # When the referenced variable can only have a finite number of possible
30 # values and these values are all simple words (e.g. true and false), it's
31 # OK to omit the double-quotes.
33 # - Use backquotes like in `command`, not $(command).
34 # - Don't use `command` inside double-quotes. Instead assign the result of
35 # `command` to a variable, and use the value of the variable afterwards.
37 # - All functions that don't emulate a program or shell built-in have a name
38 # that starts with 'func_'.
39 # - Document the implicit and explicit arguments of all functions, as well
40 # as their output variables and side effects.
41 # * Use test condition instead of [ condition ].
42 # * Minimize the use of eval; when you need it, make sure the string to be
43 # evaluated has a very simple syntactic structure.
51 # You can set AUTOCONFPATH to empty if autoconf 2.64 is already in your PATH.
55 # AUTOCONFBINDIR=/arch/x86-linux/gnu-inst-autoconf/2.64/bin
56 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
60 # You can set AUTOMAKEPATH to empty if automake 1.11 is already in your PATH.
63 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
66 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
69 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
70 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
71 if test -z "${AUTOCONF}" ||
test -n "${AUTOCONFPATH}"; then
72 AUTOCONF
="${AUTOCONFPATH}autoconf"
74 if test -z "${AUTOHEADER}" ||
test -n "${AUTOCONFPATH}"; then
75 AUTOHEADER
="${AUTOCONFPATH}autoheader"
77 if test -z "${ACLOCAL}" ||
test -n "${AUTOMAKEPATH}"; then
78 ACLOCAL
="${AUTOMAKEPATH}aclocal"
80 if test -z "${AUTOMAKE}" ||
test -n "${AUTOMAKEPATH}"; then
81 AUTOMAKE
="${AUTOMAKEPATH}automake"
83 if test -z "${AUTORECONF}" ||
test -n "${AUTOCONFPATH}"; then
84 AUTORECONF
="${AUTOCONFPATH}autoreconf"
87 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
88 if test -z "${AUTOPOINT}" ||
test -n "${GETTEXTPATH}"; then
89 AUTOPOINT
="${GETTEXTPATH}autopoint"
92 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
93 if test -z "${LIBTOOLIZE}" ||
test -n "${LIBTOOLPATH}"; then
94 LIBTOOLIZE
="${LIBTOOLPATH}libtoolize"
98 if test -z "${MAKE}"; then
102 # When using GNU sed, turn off as many GNU extensions as possible,
103 # to minimize the risk of accidentally using non-portable features.
104 # However, do this only for gnulib-tool itself, not for the code that
105 # gnulib-tool generates, since we don't want "sed --posix" to leak
106 # into makefiles. And do it only for sed versions 4.2 or newer,
107 # because "sed --posix" is buggy in GNU sed 4.1.5, see
108 # <https://lists.gnu.org/r/bug-gnulib/2009-02/msg00225.html>.
109 if (alias) > /dev
/null
2>&1 \
110 && echo |
sed --posix -e d
>/dev
/null
2>&1 \
111 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
112 [1-3]* |
4.
[01]*) false
;; \
116 # Define sed as an alias.
117 # It is not always possible to use aliases. Aliases are guaranteed to work
118 # if the executing shell is bash and either it is invoked as /bin/sh or
119 # is a version >= 2.0, supporting shopt. This is the common case.
120 # Two other approaches (use of a variable $sed or of a function func_sed
121 # instead of an alias) require massive, fragile code changes.
122 # An other approach (use of function sed) requires `which sed` - but
123 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
124 if test -n "$BASH_VERSION"; then
125 shopt -s expand_aliases
>/dev
/null
2>&1
127 alias sed='sed --posix'
130 # sed_noop is a sed expression that does nothing.
131 # An empty expression does not work with the native 'sed' on AIX 6.1.
134 # sed_comments is true or false, depending whether 'sed' supports comments.
135 # AIX 5.3 sed barfs over indented comments.
136 if echo fo |
sed -e 's/f/g/
139 s/o/e/' 2>/dev
/null |
grep ge
> /dev
/null
; then
146 # outputs to stdout the --help usage message.
150 Usage: gnulib-tool --list
151 gnulib-tool --find filename
152 gnulib-tool --import [module1 ... moduleN]
153 gnulib-tool --add-import [module1 ... moduleN]
154 gnulib-tool --remove-import [module1 ... moduleN]
156 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
157 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
158 gnulib-tool --test --dir=directory [module1 ... moduleN]
159 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
160 gnulib-tool --extract-description module
161 gnulib-tool --extract-comment module
162 gnulib-tool --extract-status module
163 gnulib-tool --extract-notice module
164 gnulib-tool --extract-applicability module
165 gnulib-tool --extract-filelist module
166 gnulib-tool --extract-dependencies module
167 gnulib-tool --extract-recursive-dependencies module
168 gnulib-tool --extract-autoconf-snippet module
169 gnulib-tool --extract-automake-snippet module
170 gnulib-tool --extract-include-directive module
171 gnulib-tool --extract-link-directive module
172 gnulib-tool --extract-recursive-link-directive module
173 gnulib-tool --extract-license module
174 gnulib-tool --extract-maintainer module
175 gnulib-tool --extract-tests-module module
176 gnulib-tool --copy-file file [destination]
180 --list print the available module names
181 --find find the modules which contain the specified file
182 --import import the given modules into the current package
183 --add-import augment the list of imports from gnulib into the
184 current package, by adding the given modules;
185 if no modules are specified, update the current
186 package from the current gnulib
187 --remove-import reduce the list of imports from gnulib into the
188 current package, by removing the given modules
189 --update update the current package, restore files omitted
191 --create-testdir create a scratch package with the given modules
192 --create-megatestdir create a mega scratch package with the given modules
193 one by one and all together
194 --test test the combination of the given modules
195 (recommended to use CC=\"gcc -Wall\" here)
196 --megatest test the given modules one by one and all together
197 (recommended to use CC=\"gcc -Wall\" here)
198 --extract-description extract the description
199 --extract-comment extract the comment
200 --extract-status extract the status (obsolete etc.)
201 --extract-notice extract the notice or banner
202 --extract-applicability extract the applicability
203 --extract-filelist extract the list of files
204 --extract-dependencies extract the dependencies
205 --extract-recursive-dependencies extract the dependencies of the module
206 and its dependencies, recursively, all
207 together, but without the conditions
208 --extract-autoconf-snippet extract the snippet for configure.ac
209 --extract-automake-snippet extract the snippet for library makefile
210 --extract-include-directive extract the #include directive
211 --extract-link-directive extract the linker directive
212 --extract-recursive-link-directive extract the linker directive of the
213 module and its dependencies,
214 recursively, all together
215 --extract-license report the license terms of the source files
217 --extract-maintainer report the maintainer(s) inside gnulib
218 --extract-tests-module report the unit test module, if it exists
219 --copy-file copy a file that is not part of any module
220 --help Show this help text.
221 --version Show version and authorship information.
225 --dir=DIRECTORY Specify the target directory.
226 For --import, this specifies where your
227 configure.ac can be found. Defaults to current
229 --local-dir=DIRECTORY Specify a local override directory where to look
230 up files before looking in gnulib's directory.
231 --cache-modules Enable module caching optimization.
232 --no-cache-modules Disable module caching optimization.
233 --verbose Increase verbosity. May be repeated.
234 --quiet Decrease verbosity. May be repeated.
236 Options for --import, --add/remove-import, --update:
238 --dry-run Only print what would have been done.
240 Options for --import, --add/remove-import:
242 --with-tests Include unit tests for the included modules.
244 Options for --create-[mega]testdir, --[mega]test:
246 --without-tests Don't include unit tests for the included modules.
248 Options for --import, --add/remove-import,
249 --create-[mega]testdir, --[mega]test:
251 --with-obsolete Include obsolete modules when they occur among the
252 dependencies. By default, dependencies to obsolete
254 --with-c++-tests Include even unit tests for C++ interoperability.
255 --without-c++-tests Exclude unit tests for C++ interoperability.
256 --with-longrunning-tests
257 Include even unit tests that are long-runners.
258 --without-longrunning-tests
259 Exclude unit tests that are long-runners.
260 --with-privileged-tests
261 Include even unit tests that require root
263 --without-privileged-tests
264 Exclude unit tests that require root privileges.
265 --with-unportable-tests
266 Include even unit tests that fail on some platforms.
267 --without-unportable-tests
268 Exclude unit tests that fail on some platforms.
269 --with-all-tests Include all kinds of problematic unit tests.
270 --avoid=MODULE Avoid including the given MODULE. Useful if you
271 have code that provides equivalent functionality.
272 This option can be repeated.
273 --conditional-dependencies
274 Support conditional dependencies (may save configure
275 time and object code).
276 --no-conditional-dependencies
277 Don't use conditional dependencies.
278 --libtool Use libtool rules.
279 --no-libtool Don't use libtool rules.
281 Options for --import, --add/remove-import:
283 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
284 --source-base=DIRECTORY
285 Directory relative to --dir where source code is
286 placed (default \"lib\").
287 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
288 placed (default \"m4\").
289 --po-base=DIRECTORY Directory relative to --dir where *.po files are
290 placed (default \"po\").
291 --doc-base=DIRECTORY Directory relative to --dir where doc files are
292 placed (default \"doc\").
293 --tests-base=DIRECTORY
294 Directory relative to --dir where unit tests are
295 placed (default \"tests\").
296 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
297 tools are placed (default comes from configure.ac).
298 --gnu-make Output for GNU Make instead of for the default
300 --lgpl[=2|=3orGPLv2|=3]
301 Abort if modules aren't available under the LGPL.
302 Also modify license template from GPL to LGPL.
303 The version number of the LGPL can be specified;
304 the default is currently LGPLv3.
305 --makefile-name=NAME Name of makefile in the source-base and tests-base
306 directories (default \"Makefile.am\", or
307 \"Makefile.in\" if --gnu-make).
308 --tests-makefile-name=NAME
309 Name of makefile in the tests-base directory
310 (default as specified through --makefile-name).
311 --automake-subdir Specify that the makefile in the source-base
312 directory be generated in such a way that it can
313 be 'include'd from the toplevel Makefile.am.
314 --automake-subdir-tests
315 Likewise, but for the tests directory.
316 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
317 'gl_INIT'. Default is 'gl'.
318 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
319 the package name. A suffix '-gnulib' is appended.
320 --witness-c-macro=NAME Specify the C macro that is defined when the
321 sources in this directory are compiled or used.
322 --vc-files Update version control related files.
323 --no-vc-files Don't update version control related files
324 (.gitignore and/or .cvsignore).
326 Options for --create-[mega]testdir, --[mega]test:
328 --single-configure Generate a single configure file, not a separate
329 configure file for the tests directory.
331 Options for --import, --add/remove-import, --update,
332 --create-[mega]testdir, --[mega]test:
334 -s, --symbolic, --symlink Make symbolic links instead of copying files.
335 --local-symlink Make symbolic links instead of copying files, only
336 for files from the local override directory.
337 -h, --hardlink Make hard links instead of copying files.
338 --local-hardlink Make hard links instead of copying files, only
339 for files from the local override directory.
341 Options for --import, --add/remove-import, --update:
343 -S, --more-symlinks Deprecated; equivalent to --symlink.
344 -H, --more-hardlinks Deprecated; equivalent to --hardlink.
346 Report bugs to <bug-gnulib@gnu.org>."
350 # outputs to stdout the --version message.
354 if test -d "$gnulib_dir"/.git \
355 && (git
--version) >/dev
/null
2>/dev
/null \
356 && (date --version) >/dev
/null
2>/dev
/null
; then
357 # gnulib checked out from git.
358 sed_extract_first_date
='/^Date/{
362 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
363 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
364 sed_year_before_time
='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
365 date=`echo "$date" | sed -e "$sed_year_before_time"`
366 # Use GNU date to compute the time in GMT.
367 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
368 version
=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
370 # gnulib copy without versioning information.
371 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
374 year
=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
376 gnulib-tool (GNU $package $date)$version
377 Copyright (C) $year Free Software Foundation, Inc.
378 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
379 This is free software: you are free to change and redistribute it.
380 There is NO WARRANTY, to the extent permitted by law.
382 printf "Written by %s, %s, and %s.\n" "Bruno Haible" "Paul Eggert" "Simon Josefsson"
385 # func_emit_copyright_notice
386 # outputs to stdout a header for a generated file.
387 func_emit_copyright_notice
()
389 sed -n -e '/Copyright/ {
392 }' < "$self_abspathname"
394 echo "# This file is free software; you can redistribute it and/or modify"
395 echo "# it under the terms of the GNU General Public License as published by"
396 echo "# the Free Software Foundation, either version 3 of the License, or"
397 echo "# (at your option) any later version."
399 echo "# This file is distributed in the hope that it will be useful,"
400 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
401 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
402 echo "# GNU General Public License for more details."
404 echo "# You should have received a copy of the GNU General Public License"
405 echo "# along with this file. If not, see <https://www.gnu.org/licenses/>."
407 echo "# As a special exception to the GNU General Public License,"
408 echo "# this file may be distributed as part of a program that"
409 echo "# contains a configuration script generated by Autoconf, under"
410 echo "# the same distribution terms as the rest of that program."
412 echo "# Generated by gnulib-tool."
416 # exits with a given status.
417 # This function needs to be used, rather than 'exit', when a 'trap' handler is
418 # in effect that refers to $?.
425 # locates the directory where the gnulib repository lives
427 # - progname name of this program
429 # - self_abspathname absolute pathname of gnulib-tool
430 # - gnulib_dir absolute pathname of gnulib repository
434 /* | ?
:*) self_abspathname
="$progname" ;;
435 */*) self_abspathname
=`pwd`/"$progname" ;;
438 # Iterate through the elements of $PATH.
439 # We use IFS=: instead of
440 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
441 # because the latter does not work when some PATH element contains spaces.
442 # We use a canonicalized $pathx instead of $PATH, because empty PATH
443 # elements are by definition equivalent to '.', however field splitting
444 # according to IFS=: loses empty fields in many shells:
445 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
446 # beginning, at the end, and in the middle),
447 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
448 # at the beginning and at the end,
449 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
450 # Solaris lose empty fields at the end.
451 # The 'case' statement is an optimization, to avoid evaluating the
452 # explicit canonicalization command when $PATH contains no empty fields.
454 if test "$PATH_SEPARATOR" = ";"; then
455 # On Windows, programs are searched in "." before $PATH.
458 # On Unix, we have to convert empty PATH elements to ".".
462 pathx
=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
467 IFS
="$PATH_SEPARATOR"
471 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
472 self_abspathname
="$d/$progname"
477 if test -z "$self_abspathname"; then
478 func_fatal_error
"could not locate the gnulib-tool program - how did you invoke it?"
482 while test -h "$self_abspathname"; do
483 # Resolve symbolic link.
484 linkval
=`func_readlink "$self_abspathname"`
485 test -n "$linkval" ||
break
487 /* | ?
:* ) self_abspathname
="$linkval" ;;
488 * ) self_abspathname
=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
491 gnulib_dir
=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
495 # creates a temporary directory.
497 # - progname name of this program
499 # - tmp pathname of freshly created temporary directory
502 # Use the environment variable TMPDIR, falling back to /tmp. This allows
503 # users to specify a different temporary directory, for example, if their
504 # /tmp is filled up or too small.
507 # Use the mktemp program if available. If not available, hide the error
509 tmp
=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
510 test -n "$tmp" && test -d "$tmp"
513 # Use a simple mkdir command. It is guaranteed to fail if the directory
514 # already exists. $RANDOM is bash specific and expands to empty in shells
515 # other than bash, ksh and zsh. Its use does not increase security;
516 # rather, it minimizes the probability of failure in a very cluttered /tmp
518 tmp
=$TMPDIR/gl$$
-$RANDOM
519 (umask 077 && mkdir
"$tmp")
522 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
527 # func_append var value
528 # appends the given value to the shell variable var.
529 if ( foo
=bar
; foo
+=baz
&& test "$foo" = barbaz
) >/dev
/null
2>&1; then
530 # Use bash's += operator. It reduces complexity of appending repeatedly to
531 # a single variable from O(n^2) to O(n).
536 fast_func_append
=true
540 eval "$1=\"\$$1\$2\""
542 fast_func_append
=false
545 # func_remove_prefix var prefix
546 # removes the given prefix from the value of the shell variable var.
547 # var should be the name of a shell variable.
548 # Its value should not contain a newline and not start or end with whitespace.
549 # prefix should not contain the characters "$`\{}[]^|.
550 if ( foo
=bar
; eval 'test "${foo#b}" = ar' ) >/dev
/null
2>&1; then
551 func_remove_prefix
()
555 fast_func_remove_prefix
=true
557 func_remove_prefix
()
559 eval "value=\"\$$1\""
563 sed_escape_dots
='s/\([.]\)/\\\1/g'
564 prefix
=`echo "$prefix" | sed -e "$sed_escape_dots"`
567 value
=`echo "$value" | sed -e "s|^${prefix}||"`
568 eval "$1=\"\$value\""
570 fast_func_remove_prefix
=false
573 # Determine whether we should use ':' or ';' as PATH_SEPARATOR.
574 func_determine_path_separator
()
576 if test "${PATH_SEPARATOR+set}" != set; then
577 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
578 # contains only /bin. Note that ksh looks also at the FPATH variable,
579 # so we have to set that as well for the test.
581 (PATH
='/bin;/bin'; FPATH
=$PATH; sh
-c :) >/dev
/null
2>&1 \
582 && { (PATH
='/bin:/bin'; FPATH
=$PATH; sh
-c :) >/dev
/null
2>&1 \
583 || PATH_SEPARATOR
=';'
588 # func_path_append pathvar directory
589 # appends directory to pathvar, delimiting directories by PATH_SEPARATOR.
592 if eval "test -n \"\$$1\""; then
593 func_append
"$1" "$PATH_SEPARATOR$2"
599 # func_path_foreach_inner
600 # helper for func_path_foreach because we need new 'args' array
602 # - fpf_dir directory from local_gnulib_path
603 # - fpf_cb callback to be run for fpf_dir
604 func_path_foreach_inner
()
626 # func_path_foreach path method args
627 # Execute method for each directory in path. The method will be called
628 # like `method args` while any argument '%dir%' within args will be replaced
629 # with processed directory from path.
637 IFS
="$PATH_SEPARATOR"
638 for fpf_dir
in $fpf_dirs
641 func_path_foreach_inner
"$@" && fpf_rc
=:
647 # func_remove_suffix var suffix
648 # removes the given suffix from the value of the shell variable var.
649 # var should be the name of a shell variable.
650 # Its value should not contain a newline and not start or end with whitespace.
651 # suffix should not contain the characters "$`\{}[]^|.
652 if ( foo
=bar
; eval 'test "${foo%r}" = ba' ) >/dev
/null
2>&1; then
653 func_remove_suffix
()
657 fast_func_remove_suffix
=true
659 func_remove_suffix
()
661 eval "value=\"\$$1\""
665 sed_escape_dots
='s/\([.]\)/\\\1/g'
666 suffix
=`echo "$suffix" | sed -e "$sed_escape_dots"`
669 value
=`echo "$value" | sed -e "s|${suffix}\$||"`
670 eval "$1=\"\$value\""
672 fast_func_remove_suffix
=false
675 # func_fatal_error message
676 # outputs to stderr a fatal error message, and terminates the program.
678 # - progname name of this program
681 echo "$progname: *** $1" 1>&2
682 echo "$progname: *** Stop." 1>&2
686 # func_warning message
687 # Outputs to stderr a warning message,
690 echo "gnulib-tool: warning: $1" 1>&2
693 # func_readlink SYMLINK
694 # outputs the target of the given symlink.
695 if (type readlink
) > /dev
/null
2>&1; then
698 # Use the readlink program from GNU coreutils.
704 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
705 # would do the wrong thing if the link target contains " -> ".
706 LC_ALL
=C
ls -l "$1" |
sed -e 's, -> ,#%%#,' |
sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
710 # func_relativize DIR1 DIR2
711 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
713 # - DIR1 relative pathname, relative to the current directory
714 # - DIR2 relative pathname, relative to the current directory
716 # - reldir relative pathname of DIR2, relative to DIR1
722 sed_first
='s,^\([^/]*\)/.*$,\1,'
723 sed_rest
='s,^[^/]*/*,,'
724 sed_last
='s,^.*/\([^/]*\)$,\1,'
725 sed_butlast
='s,/*[^/]*$,,'
726 while test -n "$dir1"; do
727 first
=`echo "$dir1" | sed -e "$sed_first"`
728 if test "$first" != "."; then
729 if test "$first" = ".."; then
730 dir2
=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
731 dir0
=`echo "$dir0" | sed -e "$sed_butlast"`
733 first2
=`echo "$dir2" | sed -e "$sed_first"`
734 if test "$first2" = "$first"; then
735 dir2
=`echo "$dir2" | sed -e "$sed_rest"`
739 dir0
="$dir0"/"$first"
742 dir1
=`echo "$dir1" | sed -e "$sed_rest"`
747 # func_relconcat DIR1 DIR2
748 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
750 # - DIR1 relative pathname, relative to the current directory
751 # - DIR2 relative pathname, relative to DIR1
753 # - relconcat DIR1/DIR2, relative to the current directory
758 sed_first
='s,^\([^/]*\)/.*$,\1,'
759 sed_rest
='s,^[^/]*/*,,'
760 sed_last
='s,^.*/\([^/]*\)$,\1,'
761 sed_butlast
='s,/*[^/]*$,,'
763 first
=`echo "$dir2" | sed -e "$sed_first"`
764 if test "$first" = "."; then
765 dir2
=`echo "$dir2" | sed -e "$sed_rest"`
766 if test -z "$dir2"; then
771 last
=`echo "$dir1" | sed -e "$sed_last"`
772 while test "$last" = "."; do
773 dir1
=`echo "$dir1" | sed -e "$sed_butlast"`
774 last
=`echo "$dir1" | sed -e "$sed_last"`
776 if test -z "$dir1"; then
780 if test "$first" = ".."; then
781 if test "$last" = ".."; then
782 relconcat
="$dir1/$dir2"
785 dir1
=`echo "$dir1" | sed -e "$sed_butlast"`
786 dir2
=`echo "$dir2" | sed -e "$sed_rest"`
787 if test -z "$dir1"; then
791 if test -z "$dir2"; then
796 relconcat
="$dir1/$dir2"
803 # func_ensure_writable DEST
804 # Ensures the file DEST is writable.
805 func_ensure_writable
()
807 test -w "$1" ||
chmod u
+w
"$1"
811 # Like ln -s, except use cp -p if ln -s fails.
815 echo "$progname: ln -s failed; falling back on cp -p" >&2
818 /* | ?
:*) # SRC is absolute.
820 *) # SRC is relative to the directory of DEST.
822 */*) cp_src
="${2%/*}/$1" ;;
829 func_ensure_writable
"$2"
833 # func_symlink_target SRC DEST
834 # Determines LINK_TARGET such that "ln -s LINK_TARGET DEST" will create a
835 # symbolic link DEST that points to SRC.
837 # - link_target link target, relative to the directory of DEST
838 func_symlink_target
()
843 *) # SRC is relative.
846 link_target
="`pwd`/$1" ;;
847 *) # DEST is relative too.
848 ln_destdir
=`echo "$2" | sed -e 's,[^/]*$,,'`
849 test -n "$ln_destdir" || ln_destdir
="."
850 func_relativize
"$ln_destdir" "$1"
851 link_target
="$reldir"
858 # func_symlink SRC DEST
859 # Like func_ln_s, except that SRC is given relative to the current directory (or
860 # absolute), not given relative to the directory of DEST.
863 func_symlink_target
"$1" "$2"
864 func_ln_s
"$link_target" "$2"
867 # func_symlink_if_changed SRC DEST
868 # Like func_symlink, but avoids munging timestamps if the link is correct.
869 # SRC is given relative to the current directory (or absolute).
870 func_symlink_if_changed
()
872 if test $# -ne 2; then
873 echo "usage: func_symlink_if_changed SRC DEST" >&2
875 func_symlink_target
"$1" "$2"
876 ln_target
=`func_readlink "$2"`
877 if test -h "$2" && test "$link_target" = "$ln_target"; then
881 func_ln_s
"$link_target" "$2"
885 # func_hardlink SRC DEST
886 # Like ln, except use cp -p if ln fails.
887 # SRC is given relative to the current directory (or absolute).
891 echo "$progname: ln failed; falling back on cp -p" >&2
893 func_ensure_writable
"$2"
897 # Ensure an 'echo' command that
898 # 1. does not interpret backslashes and
899 # 2. does not print an error message "broken pipe" when writing into a pipe
902 # Test cases for problem 1:
903 # echo '\n' | wc -l prints 1 when OK, 2 when KO
904 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
905 # Test cases for problem 2:
906 # echo hi | true frequently prints
907 # "bash: echo: write error: Broken pipe"
908 # to standard error in bash 3.2.
910 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
911 # BSD echo interprets '-n' as an option, which is also not desirable).
912 # Nowadays the problem occurs in 4 situations:
913 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
914 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
915 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
916 # - in zsh, when sh-emulation is not set,
917 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
918 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
919 # - in Solaris /bin/sh and OSF/1 /bin/sh.
920 # We try the following workarounds:
921 # - for all: respawn using $CONFIG_SHELL if that is set and works.
922 # - for bash >= 2.04: unset the shell option xpg_echo.
923 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
924 # - for bash < 2.0: define echo to a function that uses cat of a here document.
925 # - for zsh: turn sh-emulation on.
926 # - for ksh: alias echo to 'print -r'.
927 # - for ksh: alias echo to a function that uses cat of a here document.
928 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
929 # the ksh workaround.
930 # - otherwise: respawn using /bin/sh and rely on the workarounds.
931 # When respawning, we pass --no-reexec as first argument, so as to avoid
932 # turning this script into a fork bomb in unlucky situations.
934 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
935 # the 'printf' built-in. See
936 # <https://lists.gnu.org/r/bug-bash/2008-12/msg00050.html>
937 # <https://lists.gnu.org/r/bug-gnulib/2010-02/msg00154.html>
938 # The workaround is: define echo to a function that uses the printf built-in.
940 if echo '\t' |
grep t
> /dev
/null
; then
941 have_echo
=yes # Lucky!
943 # Try the workarounds.
944 # Respawn using $CONFIG_SHELL if that is set and works.
945 if test -z "$have_echo" \
946 && test "X$1" != "X--no-reexec" \
947 && test -n "$CONFIG_SHELL" \
948 && test -f "$CONFIG_SHELL" \
949 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
950 exec $CONFIG_SHELL "$0" --no-reexec "$@"
953 # For bash >= 2.04: unset the shell option xpg_echo.
954 if test -z "$have_echo" \
955 && test -n "$BASH_VERSION" \
956 && (shopt -o xpg_echo
; echo '\t' |
grep t
> /dev
/null
) 2>/dev
/null
; then
960 # For bash >= 2.0: define echo to a function that uses the printf built-in.
961 # For bash < 2.0: define echo to a function that uses cat of a here document.
962 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
963 # Also handle problem 2, specific to bash 3.2, here.
964 if { test -z "$have_echo" \
965 ||
case "$BASH_VERSION" in 3.2*) true
;; *) false
;; esac; \
967 && test -n "$BASH_VERSION"; then \
968 if type printf 2>/dev
/null |
grep / > /dev
/null
; then
969 # 'printf' is not a shell built-in.
977 # 'printf' is a shell built-in.
983 if echo '\t' |
grep t
> /dev
/null
; then
987 # For zsh: turn sh-emulation on.
988 if test -z "$have_echo" \
989 && test -n "$ZSH_VERSION" \
990 && (emulate sh
) >/dev
/null
2>&1; then
993 # For ksh: alias echo to 'print -r'.
994 if test -z "$have_echo" \
995 && (type print
) >/dev
/null
2>&1; then
996 # A 'print' command exists.
997 if type print
2>/dev
/null |
grep / > /dev
/null
; then
1000 # 'print' is a shell built-in.
1001 if (print
-r '\told' |
grep told
> /dev
/null
) 2>/dev
/null
; then
1002 # 'print' is the ksh shell built-in.
1003 alias echo='print -r'
1007 if test -z "$have_echo" \
1008 && echo '\t' |
grep t
> /dev
/null
; then
1011 # For ksh: alias echo to a function that uses cat of a here document.
1012 # The ksh manual page says:
1013 # "Aliasing is performed when scripts are read, not while they are executed.
1014 # Therefore, for an alias to take effect, the alias definition command has
1015 # to be executed before the command which references the alias is read."
1016 # Because of this, we have to play strange tricks with have_echo, to ensure
1017 # that the top-level statement containing the test starts after the 'alias'
1019 if test -z "$have_echo"; then
1026 if (alias echo=bsd_echo
) 2>/dev
/null
; then
1027 alias echo=bsd_echo
2>/dev
/null
1030 if test -z "$have_echo" \
1031 && echo '\t' |
grep t
> /dev
/null
; then
1034 if test -z "$have_echo"; then
1035 if (alias echo=bsd_echo
) 2>/dev
/null
; then
1036 unalias echo 2>/dev
/null
1039 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
1040 if test -z "$have_echo" \
1041 && test "X$1" != "X--no-reexec" \
1042 && test -f /bin
/ksh
; then
1043 exec /bin
/ksh
"$0" --no-reexec "$@"
1046 # Otherwise: respawn using /bin/sh.
1047 if test -z "$have_echo" \
1048 && test "X$1" != "X--no-reexec" \
1049 && test -f /bin
/sh
; then
1050 exec /bin
/sh
"$0" --no-reexec "$@"
1053 if test -z "$have_echo"; then
1054 func_fatal_error
"Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
1056 if echo '\t' |
grep t
> /dev
/null
; then
1059 func_fatal_error
"Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
1061 if test "X$1" = "X--no-reexec"; then
1067 trap 'exit_status=$?
1068 if test "$signal" != EXIT; then
1069 echo "caught signal SIG$signal" >&2
1072 exit $exit_status' EXIT
1073 for signal
in HUP INT QUIT PIPE TERM
; do
1074 trap '{ signal='$signal'; func_exit 1; }' $signal
1078 # The 'join' program does not exist on all platforms, and
1079 # on macOS 12.6, FreeBSD 14.0, NetBSD 9.3 it is buggy, see
1080 # <https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=232405>.
1081 # In these cases, bail out. Otherwise, we can use it.
1082 if (type join) >/dev
/null
2>&1; then
1083 echo a
> "$tmp"/join-input-1
1084 { echo; echo a
; } > "$tmp"/join-input-2
1085 if LC_ALL
=C
join "$tmp"/join-input-1
"$tmp"/join-input-2 |
grep a
>/dev
/null \
1086 && LC_ALL
=C
join "$tmp"/join-input-2
"$tmp"/join-input-1 |
grep a
>/dev
/null
; then
1089 echo "$progname: 'join' program is buggy. Consider installing GNU coreutils." >&2
1093 echo "$progname: 'join' program not found. Consider installing GNU coreutils." >&2
1097 # Unset CDPATH. Otherwise, output from 'cd dir' can surprise callers.
1098 (unset CDPATH
) >/dev
/null
2>&1 && unset CDPATH
1100 # Determine the path separator early because the following option parsing code
1102 func_determine_path_separator
1104 # Command-line option processing.
1105 # Removes the OPTIONS from the arguments. Sets the variables:
1106 # - mode one of: list, find, import, add-import, remove-import,
1107 # update, create-testdir, create-megatestdir, test, megatest,
1109 # - destdir from --dir
1110 # - local_gnulib_path from --local-dir, highest priority dir comes first
1111 # - modcache true or false, from --cache-modules/--no-cache-modules
1112 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1113 # - libname, supplied_libname from --lib
1114 # - sourcebase from --source-base
1115 # - m4base from --m4-base
1116 # - pobase from --po-base
1117 # - docbase from --doc-base
1118 # - testsbase from --tests-base
1119 # - auxdir from --aux-dir
1120 # - inctests true if --with-tests was given, false if --without-tests
1121 # was given, blank otherwise
1122 # - incobsolete true if --with-obsolete was given, blank otherwise
1123 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
1124 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
1126 # - inc_privileged_tests true if --with-privileged-tests was given, blank
1128 # - inc_unportable_tests true if --with-unportable-tests was given, blank
1130 # - inc_all_tests true if --with-all-tests was given, blank otherwise
1131 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
1132 # - excl_longrunning_tests true if --without-longrunning-tests was given,
1134 # - excl_privileged_tests true if --without-privileged-tests was given, blank
1136 # - excl_unportable_tests true if --without-unportable-tests was given, blank
1138 # - single_configure true if --single-configure was given, false otherwise
1139 # - avoidlist list of modules to avoid, from --avoid
1140 # - cond_dependencies true if --conditional-dependencies was given, false if
1141 # --no-conditional-dependencies was given, blank otherwise
1142 # - lgpl yes or a number if --lgpl was given, blank otherwise
1143 # - gnu_make true if --gnu-make was given, false otherwise
1144 # - makefile_name from --makefile-name
1145 # - tests_makefile_name from --tests-makefile-name
1146 # - automake_subdir true if --automake-subdir was given, false otherwise
1147 # - automake_subdir_tests true if --automake-subdir-tests was given, false otherwise
1148 # - libtool true if --libtool was given, false if --no-libtool was
1149 # given, blank otherwise
1150 # - macro_prefix from --macro-prefix
1151 # - po_domain from --po-domain
1152 # - witness_c_macro from --witness-c-macro
1153 # - vc_files true if --vc-files was given, false if --no-vc-files was
1154 # given, blank otherwise
1155 # - autoconf_minversion minimum supported autoconf version
1156 # - doit : if actions shall be executed, false if only to be printed
1157 # - copymode symlink if --symlink or --more-symlinks was given,
1158 # hardlink if --hardlink or --more-hardlinks was given,
1160 # - lcopymode symlink if --local-symlink was given,
1161 # hardlink if --local-hardlink was given,
1180 inc_longrunning_tests
=
1181 inc_privileged_tests
=
1182 inc_unportable_tests
=
1185 excl_longrunning_tests
=
1186 excl_privileged_tests
=
1187 excl_unportable_tests
=
1188 single_configure
=false
1194 tests_makefile_name
=
1195 automake_subdir
=false
1196 automake_subdir_tests
=false
1206 while test $# -gt 0; do
1211 --find |
--fin |
--fi |
--f )
1214 --import |
--impor |
--impo |
--imp |
--im |
--i )
1217 --add-import |
--add-impor |
--add-impo |
--add-imp |
--add-im |
--add-i |
--add- |
--add |
--ad )
1220 --remove-import |
--remove-impor |
--remove-impo |
--remove-imp |
--remove-im |
--remove-i |
--remove- |
--remove |
--remov |
--remo |
--rem |
--re |
--r )
1223 --update |
--updat |
--upda |
--upd |
--up |
--u )
1226 --create-testdir |
--create-testdi |
--create-testd |
--create-test |
--create-tes |
--create-te |
--create-t )
1229 --create-megatestdir |
--create-megatestdi |
--create-megatestd |
--create-megatest |
--create-megates |
--create-megate |
--create-megat |
--create-mega |
--create-meg |
--create-me |
--create-m )
1230 mode
=create-megatestdir
1232 --test |
--tes |
--te |
--t )
1235 --megatest |
--megates |
--megate |
--megat |
--mega |
--meg |
--me |
--m )
1239 mode
=`echo "X$1" | sed -e 's/^X--//'`
1241 --copy-file |
--copy-fil |
--copy-fi |
--copy-f |
--copy- |
--copy |
--cop )
1246 if test $# = 0; then
1247 func_fatal_error
"missing argument for --dir"
1252 destdir
=`echo "X$1" | sed -e 's/^X--dir=//'`
1256 if test $# = 0; then
1257 func_fatal_error
"missing argument for --local-dir"
1259 func_path_append local_gnulib_path
"$1"
1262 local_dir
=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1263 func_path_append local_gnulib_path
"$local_dir"
1265 --cache-modules |
--cache-module |
--cache-modul |
--cache-modu |
--cache-mod |
--cache-mo |
--cache-m |
--cache- |
--cache |
--cach |
--cac |
--ca )
1268 --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 )
1271 --verbose |
--verbos |
--verbo |
--verb )
1272 verbose
=`expr $verbose + 1`
1274 --quiet |
--quie |
--qui |
--qu |
--q )
1275 verbose
=`expr $verbose - 1`
1279 if test $# = 0; then
1280 func_fatal_error
"missing argument for --lib"
1283 supplied_libname
=true
1286 libname
=`echo "X$1" | sed -e 's/^X--lib=//'`
1287 supplied_libname
=true
1291 if test $# = 0; then
1292 func_fatal_error
"missing argument for --source-base"
1297 sourcebase
=`echo "X$1" | sed -e 's/^X--source-base=//'`
1301 if test $# = 0; then
1302 func_fatal_error
"missing argument for --m4-base"
1307 m4base
=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1311 if test $# = 0; then
1312 func_fatal_error
"missing argument for --po-base"
1317 pobase
=`echo "X$1" | sed -e 's/^X--po-base=//'`
1321 if test $# = 0; then
1322 func_fatal_error
"missing argument for --doc-base"
1327 docbase
=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1331 if test $# = 0; then
1332 func_fatal_error
"missing argument for --tests-base"
1337 testsbase
=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1341 if test $# = 0; then
1342 func_fatal_error
"missing argument for --aux-dir"
1347 auxdir
=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1349 --with-tests |
--with-test |
--with-tes |
--with-te |
--with-t)
1352 --with-obsolete |
--with-obsolet |
--with-obsole |
--with-obsol |
--with-obso |
--with-obs |
--with-ob |
--with-o)
1355 --with-c++-tests |
--with-c++-test |
--with-c++-tes |
--with-c++-te |
--with-c++-t |
--with-c++- |
--with-c++ |
--with-c+ |
--with-c)
1358 --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)
1359 inc_longrunning_tests
=true
1361 --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)
1362 inc_privileged_tests
=true
1364 --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)
1365 inc_unportable_tests
=true
1367 --with-all-tests |
--with-all-test |
--with-all-tes |
--with-all-te |
--with-all-t |
--with-all- |
--with-all |
--with-al |
--with-a)
1370 --without-tests |
--without-test |
--without-tes |
--without-te |
--without-t)
1373 --without-c++-tests |
--without-c++-test |
--without-c++-tes |
--without-c++-te |
--without-c++-t |
--without-c++- |
--without-c++ |
--without-c+ |
--without-c)
1376 --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)
1377 excl_longrunning_tests
=true
1379 --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)
1380 excl_privileged_tests
=true
1382 --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)
1383 excl_unportable_tests
=true
1385 --single-configure |
--single-configur |
--single-configu |
--single-config |
--single-confi |
--single-conf |
--single-con |
--single-co |
--single-c |
--single- |
--single |
--singl |
--sing |
--sin |
--si)
1386 single_configure
=true
1390 if test $# = 0; then
1391 func_fatal_error
"missing argument for --avoid"
1393 func_append avoidlist
" $1"
1396 arg
=`echo "X$1" | sed -e 's/^X--avoid=//'`
1397 func_append avoidlist
" $arg"
1399 --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)
1400 cond_dependencies
=true
1402 --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)
1403 cond_dependencies
=false
1409 arg
=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1411 2 |
3orGPLv2 |
3) ;;
1412 *) func_fatal_error
"invalid LGPL version number for --lgpl" ;;
1421 if test $# = 0; then
1422 func_fatal_error
"missing argument for --makefile-name"
1427 makefile_name
=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1429 --tests-makefile-name )
1431 if test $# = 0; then
1432 func_fatal_error
"missing argument for --tests-makefile-name"
1434 tests_makefile_name
="$1"
1436 --tests-makefile-name=* )
1437 tests_makefile_name
=`echo "X$1" | sed -e 's/^X--tests-makefile-name=//'`
1440 automake_subdir
=true
1442 --automake-subdir-tests )
1443 automake_subdir_tests
=true
1453 if test $# = 0; then
1454 func_fatal_error
"missing argument for --macro-prefix"
1459 macro_prefix
=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1463 if test $# = 0; then
1464 func_fatal_error
"missing argument for --po-domain"
1469 po_domain
=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1473 if test $# = 0; then
1474 func_fatal_error
"missing argument for --witness-c-macro"
1476 witness_c_macro
="$1"
1478 --witness-c-macro=* )
1479 witness_c_macro
=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1487 --no-changelog |
--no-changelo |
--no-changel |
--no-change |
--no-chang |
--no-chan |
--no-cha |
--no-ch )
1488 # A no-op for backward compatibility.
1493 -s |
--symbolic |
--symboli |
--symbol |
--symbo |
--symb |
--symlink |
--symlin |
--symli |
--syml |
--sym |
--sy )
1496 --local-symlink |
--local-symlin |
--local-symli |
--local-syml |
--local-sym |
--local-sy |
--local-s )
1499 -h |
--hardlink |
--hardlin |
--hardli |
--hardl |
--hard |
--har |
--ha )
1502 --local-hardlink |
--local-hardlin |
--local-hardli |
--local-hardl |
--local-hard |
--local-har |
--local-ha |
--local-h )
1505 -S |
--more-symlinks |
--more-symlink |
--more-symlin |
--more-symli |
--more-syml |
--more-sym |
--more-sy |
--more-s )
1508 -H |
--more-hardlinks |
--more-hardlink |
--more-hardlin |
--more-hardli |
--more-hardl |
--more-hard |
--more-har |
--more-ha |
--more-h )
1511 --help |
--hel |
--he )
1514 --version |
--versio |
--versi |
--vers )
1518 # Stop option processing
1522 echo "gnulib-tool: unknown option $1" 1>&2
1523 echo "Try 'gnulib-tool --help' for more information." 1>&2
1530 if case "$mode" in import | add-import | remove-import
) true
;; *) false
;; esac; then
1531 if test -n "$excl_cxx_tests" ||
test -n "$excl_longrunning_tests" \
1532 ||
test -n "$excl_privileged_tests" ||
test -n "$excl_unportable_tests" \
1533 ||
test "$single_configure" != false
; then
1534 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1535 echo "Try 'gnulib-tool --help' for more information." 1>&2
1539 if test "$mode" = update
; then
1540 if test $# != 0; then
1541 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1542 echo "Try 'gnulib-tool --help' for more information." 1>&2
1543 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1544 echo "you need to use 'gnulib-tool --import' - at your own risk!" 1>&2
1547 if test -n "$local_gnulib_path" ||
test -n "$supplied_libname" \
1548 ||
test -n "$sourcebase" ||
test -n "$m4base" ||
test -n "$pobase" \
1549 ||
test -n "$docbase" ||
test -n "$testsbase" ||
test -n "$auxdir" \
1550 ||
test -n "$inctests" ||
test -n "$incobsolete" \
1551 ||
test -n "$inc_cxx_tests" ||
test -n "$inc_longrunning_tests" \
1552 ||
test -n "$inc_privileged_tests" ||
test -n "$inc_unportable_tests" \
1553 ||
test -n "$inc_all_tests" \
1554 ||
test -n "$excl_cxx_tests" ||
test -n "$excl_longrunning_tests" \
1555 ||
test -n "$excl_privileged_tests" ||
test -n "$excl_unportable_tests" \
1556 ||
test -n "$avoidlist" ||
test -n "$lgpl" ||
test -n "$makefile_name" \
1557 ||
test -n "$tests_makefile_name" ||
test "$automake_subdir" != false \
1558 ||
test "$automake_subdir_tests" != false \
1559 ||
test -n "$macro_prefix" ||
test -n "$po_domain" \
1560 ||
test -n "$witness_c_macro" ||
test -n "$vc_files"; then
1561 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1562 echo "Try 'gnulib-tool --help' for more information." 1>&2
1563 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1564 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1568 if test -n "$pobase" && test -z "$po_domain"; then
1569 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1570 echo "Try 'gnulib-tool --help' for more information." 1>&2
1573 if test -z "$pobase" && test -n "$po_domain"; then
1574 func_warning
"--po-domain has no effect without a --po-base option"
1576 case $mode,$gnu_make in
1578 echo "gnulib-tool: --gnu-make not supported when including tests"
1581 # Canonicalize the inctests variable.
1583 import | add-import | remove-import | update
)
1584 if test -z "$inctests"; then
1588 create-testdir | create-megatestdir |
test | megatest
)
1589 if test -z "$inctests"; then
1594 # Now the only possible values of "$inctests" are true and false
1595 # (or blank but then it is irrelevant).
1597 # Determine the minimum supported autoconf version from the project's
1599 DEFAULT_AUTOCONF_MINVERSION
="2.64"
1600 autoconf_minversion
=
1602 if case "$mode" in import | add-import | remove-import | update
) true
;; *) false
;; esac \
1603 && test -n "$destdir"; then
1604 if test -f "$destdir"/configure.ac
; then
1605 configure_ac
="$destdir/configure.ac"
1607 if test -f "$destdir"/configure.
in; then
1608 configure_ac
="$destdir/configure.in"
1612 if test -f configure.ac
; then
1613 configure_ac
="configure.ac"
1615 if test -f configure.
in; then
1616 configure_ac
="configure.in"
1620 if test -n "$configure_ac"; then
1621 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1622 # because when some m4 files are omitted from a version control repository,
1623 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1624 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1625 # autom4te: m4 failed with exit status: 1
1631 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1633 prereqs
=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1634 if test -n "$prereqs"; then
1635 autoconf_minversion
=`
1636 for version in $prereqs; do echo $version; done |
1637 LC_ALL=C sort -nru | sed -e 1q
1641 if test -z "$autoconf_minversion"; then
1642 autoconf_minversion
=$DEFAULT_AUTOCONF_MINVERSION
1644 case "$autoconf_minversion" in
1645 1.
* |
2.
[0-5]* |
2.6[0-3]*)
1646 func_fatal_error
"minimum supported autoconf version is 2.64. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1649 # Determine whether --automake-subdir/--automake-subdir-tests are supported.
1650 if $automake_subdir ||
$automake_subdir_tests; then
1651 found_subdir_objects
=false
1652 if test -n "$configure_ac"; then
1657 /AM_INIT_AUTOMAKE/ {
1658 s,^.*AM_INIT_AUTOMAKE([[ ]*\([^])]*\).*$,\1,p
1660 automake_options
=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1661 for option
in $automake_options; do
1663 subdir-objects
) found_subdir_objects
=true
;;
1667 if test -f "${destdir:-.}"/Makefile.am
; then
1668 automake_options
=`sed -n -e 's/^AUTOMAKE_OPTIONS[ ]*=\(.*\)$/\1/p' "${destdir:-.}"/Makefile.am`
1669 for option
in $automake_options; do
1671 subdir-objects
) found_subdir_objects
=true
;;
1675 if ! $found_subdir_objects; then
1676 func_fatal_error
"Option --automake-subdir/--automake-subdir-tests are only supported if the definition of AUTOMAKE_OPTIONS in Makefile.am contains 'subdir-objects'."
1680 # Remove trailing slashes from the directory names. This is necessary for
1681 # m4base (to avoid an error in func_import) and optional for the others.
1682 sed_trimtrailingslashes
='s,\([^/]\)//*$,\1,'
1683 old_local_gnulib_path
="$local_gnulib_path"
1687 for dir
in $old_local_gnulib_path
1691 */ ) dir
=`echo "$dir" | sed -e "$sed_trimtrailingslashes"` ;;
1693 func_path_append local_gnulib_path
"$dir"
1696 case "$sourcebase" in
1697 */ ) sourcebase
=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1700 */ ) m4base
=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1703 */ ) pobase
=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1706 */ ) docbase
=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1708 case "$testsbase" in
1709 */ ) testsbase
=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1712 */ ) auxdir
=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1716 # Note: The 'eval' silences stderr output in dash.
1717 if (declare -A x
&& { x
[f
/2]='foo'; x
[f
/3]='bar'; eval test '${x[f/2]}' = foo
; }) 2>/dev
/null
; then
1718 # Zsh 4 and Bash 4 have associative arrays.
1719 have_associative
=true
1721 # For other shells, use 'eval' with computed shell variable names.
1722 have_associative
=false
1725 # func_lookup_local_file_cb dir file
1726 # returns true and sets func_lookup_local_file_result if the file $dir/$file
1728 func_lookup_local_file_cb
()
1730 test -n "$func_lookup_local_file_result" && return 1 # already found?
1731 test -f "$1/$2" ||
return 1
1732 func_lookup_local_file_result
=$1/$2
1736 # func_lookup_local_file file
1737 # looks up a file in $local_gnulib_path.
1739 # - local_gnulib_path from --local-dir
1741 # - func_lookup_local_file_result name of the file, valid only when the
1742 # function succeeded.
1743 func_lookup_local_file
()
1745 func_lookup_local_file_result
=
1746 func_path_foreach
"$local_gnulib_path" func_lookup_local_file_cb
%dir
% "$1"
1749 # func_lookup_file_cb dir
1750 # does one step in processing the $local_gnulib_path, looking for $dir/$lkfile
1751 # and $dir/$lkfile.diff.
1752 func_lookup_file_cb
()
1754 # If we found the file already in a --local-dir of higher priority, nothing
1756 if test -z "$lookedup_file"; then
1757 # Otherwise, look for $dir/$lkfile and $dir/$lkfile.diff.
1758 if test -f "$1/$lkfile"; then
1759 lookedup_file
="$1/$lkfile"
1761 if test -f "$1/$lkfile.diff"; then
1762 lkpatches
="$1/$lkfile.diff${lkpatches:+$PATH_SEPARATOR$lkpatches}"
1768 # func_lookup_file file
1769 # looks up a file in $local_gnulib_path or $gnulib_dir, or combines it through
1772 # - local_gnulib_path from --local-dir
1774 # - lookedup_file name of the merged (combined) file
1775 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1779 # Each element in $local_gnulib_path is a directory whose contents overrides
1780 # or amends the result of the lookup in the rest of $local_gnulib_path and
1781 # $gnulib_dir. So, the first element of $local_gnulib_path is the highest
1785 func_path_foreach
"$local_gnulib_path" func_lookup_file_cb
%dir
%
1786 # Treat $gnulib_dir like a lowest-priority --local-dir, except that here we
1787 # don't look for .diff files.
1788 if test -z "$lookedup_file"; then
1789 if test -f "$gnulib_dir/$lkfile"; then
1790 lookedup_file
="$gnulib_dir/$lkfile"
1792 func_fatal_error
"file $gnulib_dir/$lkfile not found"
1795 # Now apply the patches, from lowest-priority to highest-priority.
1797 if test -n "$lkpatches"; then
1798 lkbase
=`echo "$lkfile" | sed -e 's,^.*/,,'`
1799 rm -f "$tmp/$lkbase"
1800 cp "$lookedup_file" "$tmp/$lkbase"
1801 func_ensure_writable
"$tmp/$lkbase"
1803 IFS
="$PATH_SEPARATOR"
1804 for patchfile
in $lkpatches; do
1806 patch -s "$tmp/$lkbase" < "$patchfile" >&2 \
1807 || func_fatal_error
"patch file $patchfile didn't apply cleanly"
1810 lookedup_file
="$tmp/$lkbase"
1815 # func_sanitize_modulelist
1816 # receives a list of possible module names on standard input, one per line.
1817 # It removes those which are just file names unrelated to modules, and outputs
1818 # the resulting list to standard output, one per line.
1819 func_sanitize_modulelist
()
1821 sed -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1822 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1823 -e '/^README$/d' -e '/\/README$/d' \
1824 -e '/^TEMPLATE$/d' \
1825 -e '/^TEMPLATE-EXTENDED$/d' \
1826 -e '/^TEMPLATE-TESTS$/d' \
1834 # func_modules_in_dir dir
1835 # outputs all module files in dir to standard output.
1836 func_modules_in_dir
()
1838 (test -d "$1" && cd "$1" && find modules
-type f
-print)
1843 # - local_gnulib_path from --local-dir
1846 # Filter out metainformation files like README, which are not modules.
1847 # Filter out unit test modules; they can be retrieved through
1848 # --extract-tests-module if desired.
1850 (cd "$gnulib_dir" && find modules
-type f
-print |
sed -e 's,^modules/,,')
1851 func_path_foreach
"$local_gnulib_path" func_modules_in_dir
%dir
% |
sed -e 's,^modules/,,' -e 's,\.diff$,,'
1853 | func_sanitize_modulelist \
1854 |
sed -e '/-tests$/d' \
1858 # func_exists_local_module dir module
1859 # returns true if module exists in dir
1860 func_exists_local_module
()
1862 test -d "$1/modules" && test -f "$1/modules/$2";
1865 # func_exists_module module
1866 # tests whether a module, given by name, exists
1868 # - local_gnulib_path from --local-dir
1869 func_exists_module
()
1871 { test -f "$gnulib_dir/modules/$1" \
1872 || func_path_foreach
"$local_gnulib_path" func_exists_local_module
%dir
% "$1" ; } \
1873 && test "ChangeLog" != "$1" \
1874 && test "COPYING" != "$1" \
1875 && test "README" != "$1" \
1876 && test "TEMPLATE" != "$1" \
1877 && test "TEMPLATE-EXTENDED" != "$1" \
1878 && test "TEMPLATE-TESTS" != "$1"
1881 # func_verify_module
1882 # verifies a module name
1884 # - local_gnulib_path from --local-dir
1885 # - module module name argument
1887 # - module unchanged if OK, empty if not OK
1888 # - lookedup_file if OK: name of the merged (combined) module description file
1889 # - lookedup_tmp if OK: true if it is located in the tmp directory, blank otherwise
1890 func_verify_module
()
1892 if func_exists_module
"$module"; then
1893 # OK, $module is a correct module name.
1894 # Verify that building the module description with 'patch' succeeds.
1895 func_lookup_file
"modules/$module"
1897 func_warning
"module $module doesn't exist"
1902 # func_verify_nontests_module
1903 # verifies a module name, excluding tests modules
1905 # - local_gnulib_path from --local-dir
1906 # - module module name argument
1907 func_verify_nontests_module
()
1910 *-tests ) module
= ;;
1911 * ) func_verify_module
;;
1915 # Suffix of a sed expression that extracts a particular field from a
1916 # module description.
1917 # A field starts with a line that contains a keyword, such as 'Description',
1918 # followed by a colon and optional whitespace. All following lines, up to
1919 # the next field (or end of file if there is none) form the contents of the
1921 # An absent field is equivalent to a field with empty contents.
1922 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1923 sed_extract_prog
=':[ ]*$/ {
1926 s/^Description:[ ]*$//
1930 s/^Applicability:[ ]*$//
1932 s/^Depends-on:[ ]*$//
1933 s/^configure\.ac-early:[ ]*$//
1934 s/^configure\.ac:[ ]*$//
1935 s/^Makefile\.am:[ ]*$//
1939 s/^Maintainer:[ ]*$//
1946 # Piece of a sed expression that converts a field header line to a shell
1948 # NOTE: Keep this in sync with sed_extract_prog above!
1949 sed_extract_field_header
='
1950 s/^Description:[ ]*$/description/
1951 s/^Comment:[ ]*$/comment/
1952 s/^Status:[ ]*$/status/
1953 s/^Notice:[ ]*$/notice/
1954 s/^Applicability:[ ]*$/applicability/
1955 s/^Files:[ ]*$/files/
1956 s/^Depends-on:[ ]*$/dependson/
1957 s/^configure\.ac-early:[ ]*$/configureac_early/
1958 s/^configure\.ac:[ ]*$/configureac/
1959 s/^Makefile\.am:[ ]*$/makefile/
1960 s/^Include:[ ]*$/include/
1962 s/^License:[ ]*$/license/
1963 s/^Maintainer:[ ]*$/maintainer/'
1967 if $have_associative; then
1969 # Declare the associative arrays.
1970 declare -A modcache_cached
1971 sed_to_declare_statement
='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1972 declare_script
=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1973 eval "$declare_script"
1977 # func_cache_var module
1978 # computes the cache variable name corresponding to $module.
1979 # Note: This computation can map different module names to the same
1980 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1981 # to protect against this case.
1983 # - cachevar a shell variable name
1984 if (f
=foo
; eval echo '${f//o/e}') < /dev
/null
2>/dev
/null |
grep fee
>/dev
/null
; then
1985 # Bash 2.0 and newer, ksh, and zsh support the syntax
1986 # ${param//pattern/replacement}
1987 # as a shorthand for
1988 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1989 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1990 eval 'func_cache_var ()
1992 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1999 cachevar
=c_
`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
2008 # func_init_sed_convert_to_cache_statements
2010 # - modcachevar_assignment
2012 # - sed_convert_to_cache_statements
2013 func_init_sed_convert_to_cache_statements
()
2015 # 'sed' script that turns a module description into shell script
2016 # assignments, suitable to be eval'ed. All active characters are escaped.
2019 # Some module's description
2024 # modcache_description[$1]=\
2025 # 'Some module'"'"'s description
2027 # modcache_files[$1]=\
2030 # c_MODULE_description_set=set; c_MODULE_description=\
2031 # 'Some module'"'"'s description
2033 # c_MODULE_files_set=set; c_MODULE_files=\
2035 # The script consists of two parts:
2036 # 1) Ignore the lines before the first field header.
2037 # 2) A loop, treating non-field-header lines by escaping single quotes
2038 # and adding a closing quote in the last line,
2039 sed_convert_to_cache_statements
="
2041 # Here we have not yet seen a field header.
2043 # See if the current line contains a field header.
2046 ${sed_extract_field_header}
2049 # No field header. Ignore the line.
2051 # Read the next line. Upon EOF, just exit.
2056 # The current line contains a field header.
2058 # Turn it into the beginning of an assignment.
2059 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
2061 # Move it to the hold space. Don't print it yet,
2062 # because we want no assignment if the field is empty.
2065 # Read the next line.
2066 # Upon EOF, the field was empty. Print no assignment. Just exit.
2069 # See if the current line contains a field header.
2072 ${sed_extract_field_header}
2073 # If it is, the previous field was empty. Print no assignment.
2076 # Not a field header.
2078 # Print the previous line, held in the hold space.
2083 # Transform single quotes.
2086 # Prepend a single quote.
2091 # Move it to the hold space.
2094 # Read the next line.
2101 # See if the current line contains a field header.
2104 ${sed_extract_field_header}
2107 # Print the previous line, held in the hold space.
2112 # Transform single quotes.
2119 # Print the previous line, held in the hold space, with a single quote
2120 # to end the assignment.
2130 # Print the previous line, held in the hold space, with a single quote
2131 # to end the assignment.
2138 if ! $sed_comments; then
2140 sed_convert_to_cache_statements
=`echo "$sed_convert_to_cache_statements" \
2141 | sed -e 's/^ *//' -e 's/^#.*//'`
2145 if $have_associative; then
2146 # sed_convert_to_cache_statements does not depend on the module.
2147 modcachevar_assignment
='modcache_\1[$1]='
2148 func_init_sed_convert_to_cache_statements
2151 # func_cache_lookup_module module
2153 # looks up a module, like 'func_lookup_file modules/$module', and stores all
2154 # of its relevant data in a cache in the memory of the processing shell. If
2155 # already cached, it does not look it up again, thus saving file access time.
2157 # - module non-empty string
2158 # Output if $have_associative:
2159 # - modcache_cached[$module] set to yes
2160 # - modcache_description[$module] ==
2161 # - modcache_status[$module] \ set to the field's value, minus the
2162 # - ... / final newline,
2163 # - modcache_maintainer[$module] == or unset if the field's value is empty
2164 # Output if ! $have_associative:
2165 # - cachevar a shell variable name
2166 # - ${cachevar}_cached set to $module
2167 # - ${cachevar}_description ==
2168 # - ${cachevar}_status \ set to the field's value, minus the
2169 # - ... / final newline,
2170 # - ${cachevar}_maintainer == or unset if the field's value is empty
2171 # - ${cachevar}_description_set ==
2172 # - ${cachevar}_status_set \ set to non-empty if the field's value
2173 # - ... / is non-empty,
2174 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
2175 func_cache_lookup_module
()
2177 if $have_associative; then
2178 eval 'cached=${modcache_cached[$1]}'
2181 eval "cached=\"\$${cachevar}_cached\""
2183 if test -z "$cached"; then
2184 # Not found in cache. Look it up on the file system.
2185 func_lookup_file
"modules/$1"
2186 if $have_associative; then
2187 eval 'modcache_cached[$1]=yes'
2189 eval "${cachevar}_cached=\"\$1\""
2191 if ! $have_associative; then
2192 # sed_convert_to_cache_statements depends on the module.
2193 modcachevar_assignment
="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
2194 func_init_sed_convert_to_cache_statements
2196 cache_statements
=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
2197 eval "$cache_statements"
2199 if ! $have_associative; then
2200 if test "$1" != "$cached"; then
2201 func_fatal_error
"cache variable collision between $1 and $cached"
2209 # func_get_description module
2211 # - local_gnulib_path from --local-dir
2212 # - modcache true or false, from --cache-modules/--no-cache-modules
2213 func_get_description
()
2215 if ! $modcache; then
2216 func_lookup_file
"modules/$1"
2217 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
2219 func_cache_lookup_module
"$1"
2220 # Output the field's value, including the final newline (if any).
2221 if $have_associative; then
2222 if eval 'test -n "${modcache_description[$1]+set}"'; then
2223 eval 'echo "${modcache_description[$1]}"'
2226 eval "field_set=\"\$${cachevar}_description_set\""
2227 if test -n "$field_set"; then
2228 eval "field_value=\"\$${cachevar}_description\""
2229 echo "${field_value}"
2235 # func_get_comment module
2237 # - local_gnulib_path from --local-dir
2238 # - modcache true or false, from --cache-modules/--no-cache-modules
2241 if ! $modcache; then
2242 func_lookup_file
"modules/$1"
2243 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
2245 func_cache_lookup_module
"$1"
2246 # Output the field's value, including the final newline (if any).
2247 if $have_associative; then
2248 if eval 'test -n "${modcache_comment[$1]+set}"'; then
2249 eval 'echo "${modcache_comment[$1]}"'
2252 eval "field_set=\"\$${cachevar}_comment_set\""
2253 if test -n "$field_set"; then
2254 eval "field_value=\"\$${cachevar}_comment\""
2255 echo "${field_value}"
2261 # func_get_status module
2263 # - local_gnulib_path from --local-dir
2264 # - modcache true or false, from --cache-modules/--no-cache-modules
2267 if ! $modcache; then
2268 func_lookup_file
"modules/$1"
2269 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
2271 func_cache_lookup_module
"$1"
2272 # Output the field's value, including the final newline (if any).
2273 if $have_associative; then
2274 if eval 'test -n "${modcache_status[$1]+set}"'; then
2275 eval 'echo "${modcache_status[$1]}"'
2278 eval "field_set=\"\$${cachevar}_status_set\""
2279 if test -n "$field_set"; then
2280 eval "field_value=\"\$${cachevar}_status\""
2281 echo "${field_value}"
2287 # func_get_notice module
2289 # - local_gnulib_path from --local-dir
2290 # - modcache true or false, from --cache-modules/--no-cache-modules
2293 if ! $modcache; then
2294 func_lookup_file
"modules/$1"
2295 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
2297 func_cache_lookup_module
"$1"
2298 # Output the field's value, including the final newline (if any).
2299 if $have_associative; then
2300 if eval 'test -n "${modcache_notice[$1]+set}"'; then
2301 eval 'echo "${modcache_notice[$1]}"'
2304 eval "field_set=\"\$${cachevar}_notice_set\""
2305 if test -n "$field_set"; then
2306 eval "field_value=\"\$${cachevar}_notice\""
2307 echo "${field_value}"
2313 # func_get_applicability module
2315 # - local_gnulib_path from --local-dir
2316 # - modcache true or false, from --cache-modules/--no-cache-modules
2317 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
2318 func_get_applicability
()
2320 if ! $modcache; then
2321 func_lookup_file
"modules/$1"
2322 my_applicability
=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2324 func_cache_lookup_module
"$1"
2325 # Get the field's value, without the final newline.
2326 if $have_associative; then
2327 eval 'my_applicability="${modcache_applicability[$1]}"'
2329 eval "my_applicability=\"\$${cachevar}_applicability\""
2332 if test -n "$my_applicability"; then
2333 echo $my_applicability
2335 # The default is 'main' or 'tests', depending on the module's name.
2337 *-tests) echo "tests";;
2343 # func_get_filelist module
2345 # - local_gnulib_path from --local-dir
2346 # - modcache true or false, from --cache-modules/--no-cache-modules
2347 func_get_filelist
()
2349 if ! $modcache; then
2350 func_lookup_file
"modules/$1"
2351 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2353 func_cache_lookup_module
"$1"
2354 # Output the field's value, including the final newline (if any).
2355 if $have_associative; then
2356 if eval 'test -n "${modcache_files[$1]+set}"'; then
2357 eval 'echo "${modcache_files[$1]}"'
2360 eval "field_set=\"\$${cachevar}_files_set\""
2361 if test -n "$field_set"; then
2362 eval "field_value=\"\$${cachevar}_files\""
2363 echo "${field_value}"
2369 echo m
4/gnulib-common.
m4
2372 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2373 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2374 # elements starting with prefix and ending with suffix are considered.
2375 # Processing: removed_prefix and removed_suffix are removed from each element,
2376 # added_prefix and added_suffix are added to each element.
2377 # prefix, suffix should not contain shell-special characters.
2378 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2379 # added_prefix, added_suffix should not contain the characters \|&.
2380 func_filter_filelist
()
2382 if test "$2" != "$nl" \
2383 ||
{ $fast_func_append \
2384 && { test -z "$6" ||
$fast_func_remove_prefix; } \
2385 && { test -z "$7" ||
$fast_func_remove_suffix; }; \
2389 # Do not quote possibly-empty parameters in case patterns,
2390 # AIX and HP-UX ksh won't match them if they are empty.
2393 if test -n "$6"; then
2394 func_remove_prefix fff
"$6"
2396 if test -n "$7"; then
2397 func_remove_suffix fff
"$7"
2400 if test -z "$ffflist"; then
2403 func_append ffflist
"$2${fff}"
2409 sed_fff_filter
="s|^$6\(.*\)$7\$|$8\\1$9|"
2410 ffflist
=`for fff in $3; do
2412 $4*$5) echo "$fff" ;;
2414 done | sed -e "$sed_fff_filter"`
2416 eval "$1=\"\$ffflist\""
2419 # func_get_dependencies module
2421 # - local_gnulib_path from --local-dir
2422 # - modcache true or false, from --cache-modules/--no-cache-modules
2423 func_get_dependencies
()
2425 # ${module}-tests implicitly depends on ${module}, if that module exists.
2429 func_remove_suffix fgd1
'-tests'
2430 if func_exists_module
"$fgd1"; then
2435 # Then the explicit dependencies listed in the module description.
2436 { if ! $modcache; then
2437 func_lookup_file
"modules/$1"
2438 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2440 func_cache_lookup_module
"$1"
2441 # Output the field's value, including the final newline (if any).
2442 if $have_associative; then
2443 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2444 eval 'echo "${modcache_dependson[$1]}"'
2447 eval "field_set=\"\$${cachevar}_dependson_set\""
2448 if test -n "$field_set"; then
2449 eval "field_value=\"\$${cachevar}_dependson\""
2450 echo "${field_value}"
2458 sed_dependencies_without_conditions
='s/ *\[.*//'
2460 # func_get_autoconf_early_snippet module
2462 # - local_gnulib_path from --local-dir
2463 # - modcache true or false, from --cache-modules/--no-cache-modules
2464 func_get_autoconf_early_snippet
()
2466 if ! $modcache; then
2467 func_lookup_file
"modules/$1"
2468 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2470 func_cache_lookup_module
"$1"
2471 # Output the field's value, including the final newline (if any).
2472 if $have_associative; then
2473 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2474 eval 'echo "${modcache_configureac_early[$1]}"'
2477 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2478 if test -n "$field_set"; then
2479 eval "field_value=\"\$${cachevar}_configureac_early\""
2480 echo "${field_value}"
2486 # func_get_autoconf_snippet module
2488 # - local_gnulib_path from --local-dir
2489 # - modcache true or false, from --cache-modules/--no-cache-modules
2490 func_get_autoconf_snippet
()
2492 if ! $modcache; then
2493 func_lookup_file
"modules/$1"
2494 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2496 func_cache_lookup_module
"$1"
2497 # Output the field's value, including the final newline (if any).
2498 if $have_associative; then
2499 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2500 eval 'echo "${modcache_configureac[$1]}"'
2503 eval "field_set=\"\$${cachevar}_configureac_set\""
2504 if test -n "$field_set"; then
2505 eval "field_value=\"\$${cachevar}_configureac\""
2506 echo "${field_value}"
2512 # Concatenate lines with trailing slash.
2513 # $1 is an optional filter to restrict the
2514 # concatenation to groups starting with that expression
2516 sed -e "/$1.*"'\\$/{
2525 # func_get_automake_snippet_conditional module
2526 # returns the part of the Makefile.am snippet that can be put inside Automake
2529 # - local_gnulib_path from --local-dir
2530 # - modcache true or false, from --cache-modules/--no-cache-modules
2531 func_get_automake_snippet_conditional
()
2533 if ! $modcache; then
2534 func_lookup_file
"modules/$1"
2535 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
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_makefile[$1]+set}"'; then
2541 eval 'echo "${modcache_makefile[$1]}"'
2544 eval "field_set=\"\$${cachevar}_makefile_set\""
2545 if test -n "$field_set"; then
2546 eval "field_value=\"\$${cachevar}_makefile\""
2547 echo "${field_value}"
2553 # func_get_automake_snippet_unconditional module
2554 # returns the part of the Makefile.am snippet that must stay outside of
2555 # Automake conditionals.
2557 # - local_gnulib_path from --local-dir
2558 # - modcache true or false, from --cache-modules/--no-cache-modules
2559 func_get_automake_snippet_unconditional
()
2563 # *-tests module live in tests/, not lib/.
2564 # Synthesize an EXTRA_DIST augmentation.
2565 all_files
=`func_get_filelist $1`
2566 func_filter_filelist tests_files
" " "$all_files" 'tests/' '' 'tests/' ''
2567 extra_files
="$tests_files"
2568 if test -n "$extra_files"; then
2569 echo "EXTRA_DIST +=" $extra_files
2574 # Synthesize an EXTRA_DIST augmentation.
2575 sed_extract_mentioned_files
='s/^lib_SOURCES[ ]*+=[ ]*//p'
2576 already_mentioned_files
=` \
2577 { if ! $modcache; then
2578 func_lookup_file "modules/$1"
2579 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2581 func_cache_lookup_module "$1"
2582 if $have_associative; then
2583 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2584 eval 'echo "${modcache_makefile[$1]}"'
2587 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2588 if test -n "$field_set"; then
2589 eval 'field_value="$'"${cachevar}"'_makefile"'
2590 echo "${field_value}"
2596 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2597 all_files
=`func_get_filelist $1`
2598 func_filter_filelist lib_files
"$nl" "$all_files" 'lib/' '' 'lib/' ''
2599 # Remove $already_mentioned_files from $lib_files.
2600 echo "$lib_files" | LC_ALL
=C
sort -u > "$tmp"/lib-files
2601 extra_files
=`for f in $already_mentioned_files; do echo $f; done \
2602 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2603 if test -n "$extra_files"; then
2604 echo "EXTRA_DIST +=" $extra_files
2607 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2608 # This is necessary so that automake can generate the right list of
2610 # A possible approach would be to use autom4te --trace of the redefined
2611 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2612 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2613 # inside autoconf's built-in macros are not missed).
2614 # But it's simpler and more robust to do it here, based on the file list.
2615 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2616 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2617 # automake will generate a useless dependency; this is harmless.
2619 relocatable-prog-wrapper
) ;;
2622 func_filter_filelist extra_files
"$nl" "$extra_files" '' '.c' '' ''
2623 if test -n "$extra_files"; then
2624 echo "EXTRA_lib_SOURCES +=" $extra_files
2629 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2630 func_filter_filelist buildaux_files
"$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2631 if test -n "$buildaux_files"; then
2632 sed_prepend_auxdir
='s,^,$(top_srcdir)/'"$auxdir"'/,'
2633 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2640 # func_get_automake_snippet module
2642 # - local_gnulib_path from --local-dir
2643 # - modcache true or false, from --cache-modules/--no-cache-modules
2644 func_get_automake_snippet
()
2646 func_get_automake_snippet_conditional
"$1"
2647 func_get_automake_snippet_unconditional
"$1"
2650 # func_get_include_directive module
2652 # - local_gnulib_path from --local-dir
2653 # - modcache true or false, from --cache-modules/--no-cache-modules
2654 func_get_include_directive
()
2657 if ! $modcache; then
2658 func_lookup_file
"modules/$1"
2659 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2661 func_cache_lookup_module
"$1"
2662 # Output the field's value, including the final newline (if any).
2663 if $have_associative; then
2664 if eval 'test -n "${modcache_include[$1]+set}"'; then
2665 eval 'echo "${modcache_include[$1]}"'
2668 eval "field_set=\"\$${cachevar}_include_set\""
2669 if test -n "$field_set"; then
2670 eval "field_value=\"\$${cachevar}_include\""
2671 echo "${field_value}"
2675 } |
sed -e 's/^\(["<]\)/#include \1/'
2678 # func_get_link_directive module
2680 # - local_gnulib_path from --local-dir
2681 # - modcache true or false, from --cache-modules/--no-cache-modules
2682 func_get_link_directive
()
2684 if ! $modcache; then
2685 func_lookup_file
"modules/$1"
2686 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2688 func_cache_lookup_module
"$1"
2689 # Output the field's value, including the final newline (if any).
2690 if $have_associative; then
2691 if eval 'test -n "${modcache_link[$1]+set}"'; then
2692 eval 'echo "${modcache_link[$1]}"'
2695 eval "field_set=\"\$${cachevar}_link_set\""
2696 if test -n "$field_set"; then
2697 eval "field_value=\"\$${cachevar}_link\""
2698 echo "${field_value}"
2704 # func_get_license_raw module
2706 # - local_gnulib_path from --local-dir
2707 # - modcache true or false, from --cache-modules/--no-cache-modules
2708 func_get_license_raw
()
2710 if ! $modcache; then
2711 func_lookup_file
"modules/$1"
2712 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2714 func_cache_lookup_module
"$1"
2715 # Output the field's value, including the final newline (if any).
2716 if $have_associative; then
2717 if eval 'test -n "${modcache_license[$1]+set}"'; then
2718 eval 'echo "${modcache_license[$1]}"'
2721 eval "field_set=\"\$${cachevar}_license_set\""
2722 if test -n "$field_set"; then
2723 eval "field_value=\"\$${cachevar}_license\""
2724 echo "${field_value}"
2730 # func_get_license module
2732 # - local_gnulib_path from --local-dir
2733 # - modcache true or false, from --cache-modules/--no-cache-modules
2736 # Warn if the License field is missing.
2740 license
=`func_get_license_raw "$1"`
2741 if test -z "$license"; then
2742 func_warning
"module $1 lacks a License"
2748 # These modules are under a weaker license only for the purpose of some
2749 # users who hand-edit it and don't use gnulib-tool. For the regular
2750 # gnulib users they are under a stricter license.
2755 func_get_license_raw
"$1"
2756 # The default is GPL.
2758 } |
sed -e 's,^ *$,,' |
sed -e 1q
2763 # func_get_maintainer module
2765 # - local_gnulib_path from --local-dir
2766 # - modcache true or false, from --cache-modules/--no-cache-modules
2767 func_get_maintainer
()
2769 if ! $modcache; then
2770 func_lookup_file
"modules/$1"
2771 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2773 func_cache_lookup_module
"$1"
2774 # Output the field's value, including the final newline (if any).
2775 if $have_associative; then
2776 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2777 eval 'echo "${modcache_maintainer[$1]}"'
2780 eval "field_set=\"\$${cachevar}_maintainer_set\""
2781 if test -n "$field_set"; then
2782 eval "field_value=\"\$${cachevar}_maintainer\""
2783 echo "${field_value}"
2789 # func_get_tests_module module
2791 # - local_gnulib_path from --local-dir
2792 func_get_tests_module
()
2794 # The naming convention for tests modules is hardwired: ${module}-tests.
2795 if test -f "$gnulib_dir/modules/$1"-tests \
2796 || func_path_foreach
"$local_gnulib_path" func_exists_local_module
%dir
% "$1-tests"; then
2801 # func_verify_tests_module
2802 # verifies a module name, considering only tests modules and modules with
2803 # applicability 'all'.
2805 # - local_gnulib_path from --local-dir
2806 # - modcache true or false, from --cache-modules/--no-cache-modules
2807 # - module module name argument
2808 func_verify_tests_module
()
2811 if test -n "$module"; then
2812 if test `func_get_applicability $module` = main
; then
2818 # func_repeat_module_in_tests
2819 # tests whether, when the tests have their own configure.ac script, a given
2820 # module should be repeated in the tests, although it was already among the main
2823 # - module module name argument
2824 func_repeat_module_in_tests
()
2827 libtextstyle-optional
)
2828 # This module is special because it relies on a gl_LIBTEXTSTYLE_OPTIONAL
2829 # invocation that it does not itself do or require. Therefore if the
2830 # tests contain such an invocation, the module - as part of tests -
2831 # will produce different AC_SUBSTed variable values than the same module
2832 # - as part of the main configure.ac -.
2839 # func_get_dependencies_recursively module
2841 # - local_gnulib_path from --local-dir
2842 # - modcache true or false, from --cache-modules/--no-cache-modules
2843 func_get_dependencies_recursively
()
2845 # In order to process every module only once (for speed), process an "input
2846 # list" of modules, producing an "output list" of modules. During each round,
2847 # more modules can be queued in the input list. Once a module on the input
2848 # list has been processed, it is added to the "handled list", so we can avoid
2849 # to process it again.
2853 while test -n "$inmodules"; do
2854 inmodules_this_round
="$inmodules"
2855 inmodules
= # Accumulator, queue for next round
2856 for module
in $inmodules_this_round; do
2858 if test -n "$module"; then
2859 func_append outmodules
" $module"
2860 deps
=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2861 for dep
in $deps; do
2862 func_append inmodules
" $dep"
2866 handledmodules
=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2867 # Remove $handledmodules from $inmodules.
2868 for m
in $inmodules; do echo $m; done | LC_ALL
=C
sort -u > "$tmp"/queued-modules
2869 inmodules
=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2871 rm -f "$tmp"/queued-modules
2872 for m
in $outmodules; do echo $m; done | LC_ALL
=C
sort -u
2875 # func_get_link_directive_recursively module
2877 # - local_gnulib_path from --local-dir
2878 # - modcache true or false, from --cache-modules/--no-cache-modules
2879 func_get_link_directive_recursively
()
2881 # In order to process every module only once (for speed), process an "input
2882 # list" of modules, producing an "output list" of modules. During each round,
2883 # more modules can be queued in the input list. Once a module on the input
2884 # list has been processed, it is added to the "handled list", so we can avoid
2885 # to process it again.
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
2894 if test -n "$module"; then
2895 if grep '^Link:[ ]*$' "$lookedup_file" >/dev
/null
; then
2896 # The module description has a 'Link:' field. Ignore the dependencies.
2897 func_append outmodules
" $module"
2899 # The module description has no 'Link:' field. Recurse through the dependencies.
2900 deps
=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2901 for dep
in $deps; do
2902 func_append inmodules
" $dep"
2907 handledmodules
=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2908 # Remove $handledmodules from $inmodules.
2909 for m
in $inmodules; do echo $m; done | LC_ALL
=C
sort -u > "$tmp"/queued-modules
2910 inmodules
=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2912 rm -f "$tmp"/queued-modules
2913 for m
in $outmodules; do func_get_link_directive
"$m"; done | LC_ALL
=C
sort -u |
sed -e '/^$/d'
2916 # func_acceptable module
2917 # tests whether a module is acceptable.
2919 # - avoidlist list of modules to avoid
2922 for avoid
in $avoidlist; do
2923 if test "$avoid" = "$1"; then
2930 # sed expression to keep the first 32 characters of each line.
2931 sed_first_32_chars
='s/^\(................................\).*/\1/'
2933 # func_module_shellfunc_name module
2934 # computes the shell function name that will contain the m4 macros for the module.
2936 # - macro_prefix prefix to use
2938 # - shellfunc shell function name
2939 func_module_shellfunc_name
()
2943 shellfunc
=func_
${macro_prefix}_gnulib_m4code_
`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2945 shellfunc
=func_
${macro_prefix}_gnulib_m4code_
$1 ;;
2949 # func_module_shellvar_name module
2950 # computes the shell variable name the will be set to true once the m4 macros
2951 # for the module have been executed.
2953 # - shellvar shell variable name
2954 func_module_shellvar_name
()
2958 shellvar
=${macro_prefix}_gnulib_enabled_
`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2960 shellvar
=${macro_prefix}_gnulib_enabled_
$1 ;;
2964 # func_module_conditional_name module
2965 # computes the automake conditional name for the module.
2967 # - conditional name of automake conditional
2968 func_module_conditional_name
()
2972 conditional
=${macro_prefix}_GNULIB_ENABLED_
`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2974 conditional
=${macro_prefix}_GNULIB_ENABLED_
$1 ;;
2978 # func_uncond_add_module B
2979 # notes the presence of B as an unconditional module.
2981 # func_conddep_add_module A B cond
2982 # notes the presence of a conditional dependency from module A to module B,
2983 # subject to the condition that A is enabled and cond is true.
2985 # func_cond_module_p B
2986 # tests whether module B is conditional.
2988 # func_cond_module_condition A B
2989 # returns the condition when B should be enabled as a dependency of A, once the
2990 # m4 code for A has been executed.
2991 # Output: - condition
2993 if $have_associative; then
2994 declare -A conddep_isuncond
2995 declare -A conddep_dependers
2996 declare -A conddep_condition
2997 func_uncond_add_module
()
2999 eval 'conddep_isuncond[$1]=true'
3000 eval 'unset conddep_dependers[$1]'
3002 func_conddep_add_module
()
3004 eval 'isuncond="${conddep_isuncond[$2]}"'
3005 if test -z "$isuncond"; then
3006 # No unconditional dependency to B known at this point.
3007 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
3008 eval 'conddep_condition[$1---$2]="$3"'
3011 func_cond_module_p
()
3013 eval 'previous_dependers="${conddep_dependers[$1]}"'
3014 test -n "$previous_dependers"
3016 func_cond_module_condition
()
3018 eval 'condition="${conddep_condition[$1---$2]}"'
3021 func_uncond_add_module
()
3025 suffix
=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
3029 eval 'conddep_isuncond_'"$suffix"'=true'
3030 eval 'unset conddep_dependers_'"$suffix"
3032 func_conddep_add_module
()
3036 suffix
=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
3040 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
3041 if test -z "$isuncond"; then
3042 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
3043 suffix
=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
3044 eval 'conddep_condition_'"$suffix"'="$3"'
3047 func_cond_module_p
()
3051 suffix
=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
3055 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
3056 test -n "$previous_dependers"
3058 func_cond_module_condition
()
3060 suffix
=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
3061 eval 'condition="${conddep_condition_'"$suffix"'}"'
3065 # func_modules_transitive_closure
3067 # - local_gnulib_path from --local-dir
3068 # - gnu_make true if --gnu-make was given, false otherwise
3069 # - modcache true or false, from --cache-modules/--no-cache-modules
3070 # - modules list of specified modules
3071 # - inctests true if tests should be included, false otherwise
3072 # - incobsolete true if obsolete modules among dependencies should be
3073 # included, blank otherwise
3074 # - inc_cxx_tests true if C++ interoperability tests should be included,
3076 # - inc_longrunning_tests true if long-runnings tests should be included,
3078 # - inc_privileged_tests true if tests that require root privileges should be
3079 # included, blank otherwise
3080 # - inc_unportable_tests true if tests that fail on some platforms should be
3081 # included, blank otherwise
3082 # - inc_all_direct_tests true if all kinds of problematic unit tests among
3083 # the unit tests of the specified modules should be
3084 # included, blank otherwise
3085 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
3086 # the unit tests of the dependencies should be
3087 # included, blank otherwise
3088 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
3090 # - excl_longrunning_tests true if long-runnings tests should be excluded,
3092 # - excl_privileged_tests true if tests that require root privileges should be
3093 # excluded, blank otherwise
3094 # - excl_unportable_tests true if tests that fail on some platforms should be
3095 # excluded, blank otherwise
3096 # - avoidlist list of modules to avoid
3097 # - cond_dependencies true if conditional dependencies shall be supported,
3099 # - tmp pathname of a temporary directory
3101 # - modules list of modules, including dependencies
3102 # - conddep_dependers, conddep_condition information about conditionally
3104 func_modules_transitive_closure
()
3106 sed_escape_dependency
='s|\([/.]\)|\\\1|g'
3107 # In order to process every module only once (for speed), process an "input
3108 # list" of modules, producing an "output list" of modules. During each round,
3109 # more modules can be queued in the input list. Once a module on the input
3110 # list has been processed, it is added to the "handled list", so we can avoid
3111 # to process it again.
3113 inmodules
="$modules"
3115 fmtc_inc_all_tests
="$inc_all_direct_tests"
3116 if test "$cond_dependencies" = true
; then
3117 for module
in $inmodules; do
3119 if test -n "$module"; then
3120 if func_acceptable
$module; then
3121 func_uncond_add_module
$module
3126 while test -n "$inmodules"; do
3127 inmodules_this_round
="$inmodules"
3128 inmodules
= # Accumulator, queue for next round
3129 for module
in $inmodules_this_round; do
3131 if test -n "$module"; then
3132 if func_acceptable
$module; then
3133 func_append outmodules
" $module"
3134 if test "$cond_dependencies" = true
; then
3135 if func_cond_module_p
$module; then
3141 deps
=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3142 # Duplicate dependencies are harmless, but Jim wants a warning.
3143 duplicated_deps
=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
3144 if test -n "$duplicated_deps"; then
3145 func_warning
"module $module has duplicated dependencies: "`echo $duplicated_deps`
3148 testsmodule
=`func_get_tests_module $module`
3149 if test -n "$testsmodule"; then
3150 deps
="$deps $testsmodule"
3153 for dep
in $deps; do
3154 # Determine whether to include the dependency or tests module.
3156 for word
in `func_get_status $dep`; do
3159 test -n "$incobsolete" \
3163 test -z "$excl_cxx_tests" \
3165 test -n "$fmtc_inc_all_tests" ||
test -n "$inc_cxx_tests" \
3169 test -z "$excl_longrunning_tests" \
3171 test -n "$fmtc_inc_all_tests" ||
test -n "$inc_longrunning_tests" \
3175 test -z "$excl_privileged_tests" \
3177 test -n "$fmtc_inc_all_tests" ||
test -n "$inc_privileged_tests" \
3181 test -z "$excl_unportable_tests" \
3183 test -n "$fmtc_inc_all_tests" ||
test -n "$inc_unportable_tests" \
3187 test -n "$fmtc_inc_all_tests" \
3192 if $inc && func_acceptable
"$dep"; then
3193 func_append inmodules
" $dep"
3194 if test "$cond_dependencies" = true
; then
3195 escaped_dep
=`echo "$dep" | sed -e "$sed_escape_dependency"`
3196 sed_extract_condition1
='/^ *'"$escaped_dep"' *$/{
3199 sed_extract_condition2
='/^ *'"$escaped_dep"' *\[.*] *$/{
3200 s/^ *'"$escaped_dep"' *\[\(.*\)] *$/\1/p
3202 condition
=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
3203 if test "$condition" = true
; then
3206 if test -n "$condition"; then
3207 func_conddep_add_module
"$module" "$dep" "$condition"
3209 if $conditional; then
3210 func_conddep_add_module
"$module" "$dep" true
3212 func_uncond_add_module
"$dep"
3221 handledmodules
=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
3222 # Remove $handledmodules from $inmodules.
3223 for m
in $inmodules; do echo $m; done | LC_ALL
=C
sort -u > "$tmp"/queued-modules
3224 inmodules
=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
3225 fmtc_inc_all_tests
="$inc_all_indirect_tests"
3227 modules
=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
3228 rm -f "$tmp"/queued-modules
3231 # func_show_module_list
3233 # - specified_modules list of specified modules (one per line, sorted)
3234 # - modules complete list of modules (one per line, sorted)
3235 # - tmp pathname of a temporary directory
3236 func_show_module_list
()
3242 # Assume xterm compatible escape sequences.
3243 bold_on
=`printf '\033[1m'`
3244 bold_off
=`printf '\033[0m'`
3249 echo "Module list with included dependencies (indented):"
3250 echo "$specified_modules" |
sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
3251 echo "$modules" |
sed -e '/^$/d' \
3252 | LC_ALL
=C
join -t '|' -a2 "$tmp"/specified-modules
- \
3253 |
sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
3256 # func_modules_transitive_closure_separately
3257 # Determine main module list and tests-related module list separately.
3258 # The main module list is the transitive closure of the specified modules,
3259 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3260 # is specified, it will consist only of LGPLed source.
3261 # The tests-related module list is the transitive closure of the specified
3262 # modules, including tests modules, minus the main module list excluding
3263 # modules of applicability 'all'. Its lib/* sources (brought in through
3264 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3265 # source, even if --lgpl is specified.
3267 # - local_gnulib_path from --local-dir
3268 # - modcache true or false, from --cache-modules/--no-cache-modules
3269 # - specified_modules list of specified modules
3270 # - inctests true if tests should be included, false otherwise
3271 # - incobsolete true if obsolete modules among dependencies should be
3272 # included, blank otherwise
3273 # - inc_cxx_tests true if C++ interoperability tests should be included,
3275 # - inc_longrunning_tests true if long-runnings tests should be included,
3277 # - inc_privileged_tests true if tests that require root privileges should be
3278 # included, blank otherwise
3279 # - inc_unportable_tests true if tests that fail on some platforms should be
3280 # included, blank otherwise
3281 # - inc_all_direct_tests true if all kinds of problematic unit tests among
3282 # the unit tests of the specified modules should be
3283 # included, blank otherwise
3284 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
3285 # the unit tests of the dependencies should be
3286 # included, blank otherwise
3287 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
3289 # - excl_longrunning_tests true if long-runnings tests should be excluded,
3291 # - excl_privileged_tests true if tests that require root privileges should be
3292 # excluded, blank otherwise
3293 # - excl_unportable_tests true if tests that fail on some platforms should be
3294 # excluded, blank otherwise
3295 # - avoidlist list of modules to avoid
3296 # - cond_dependencies true if conditional dependencies shall be supported,
3298 # - tmp pathname of a temporary directory
3300 # - main_modules list of modules, including dependencies
3301 # - testsrelated_modules list of tests-related modules, including dependencies
3302 # - conddep_dependers, conddep_condition information about conditionally
3304 func_modules_transitive_closure_separately
()
3306 # Determine main module list.
3307 saved_inctests
="$inctests"
3309 modules
="$specified_modules"
3310 func_modules_transitive_closure
3311 main_modules
="$modules"
3312 inctests
="$saved_inctests"
3313 if test $verbose -ge 1; then
3314 echo "Main module list:"
3315 echo "$main_modules" |
sed -e 's/^/ /'
3317 # Determine tests-related module list.
3318 echo "$final_modules" | LC_ALL
=C
sort -u > "$tmp"/final-modules
3319 testsrelated_modules
=`for module in $main_modules; do
3320 if test \`func_get_applicability
$module\
` = main; then
3324 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3325 # If testsrelated_modules consists only of modules with applicability 'all',
3326 # set it to empty (because such modules are only helper modules for other modules).
3327 have_nontrivial_testsrelated_modules
=
3328 for module
in $testsrelated_modules; do
3329 if test `func_get_applicability $module` != all
; then
3330 have_nontrivial_testsrelated_modules
=yes
3334 if test -z "$have_nontrivial_testsrelated_modules"; then
3335 testsrelated_modules
=
3337 if test $verbose -ge 1; then
3338 echo "Tests-related module list:"
3339 echo "$testsrelated_modules" |
sed -e 's/^/ /'
3343 # func_determine_use_libtests
3344 # Determines whether a $testsbase/libtests.a is needed.
3346 # - local_gnulib_path from --local-dir
3347 # - modcache true or false, from --cache-modules/--no-cache-modules
3348 # - testsrelated_modules list of tests-related modules, including dependencies
3350 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3351 func_determine_use_libtests
()
3354 for module
in $testsrelated_modules; do
3355 func_verify_nontests_module
3356 if test -n "$module"; then
3357 all_files
=`func_get_filelist $module`
3358 # Test whether some file in $all_files lies in lib/.
3359 for f
in $all_files; do
3371 # func_remove_if_blocks
3372 # removes if...endif blocks from an automake snippet.
3373 func_remove_if_blocks
()
3386 # func_modules_add_dummy
3388 # - local_gnulib_path from --local-dir
3389 # - modcache true or false, from --cache-modules/--no-cache-modules
3390 # - modules list of modules, including dependencies
3392 # - modules list of modules, including 'dummy' if needed
3393 func_modules_add_dummy
()
3395 # Determine whether any module provides a lib_SOURCES augmentation.
3397 for module
in $modules; do
3398 func_verify_nontests_module
3399 if test -n "$module"; then
3400 if test "$cond_dependencies" = true
&& func_cond_module_p
$module; then
3401 # Ignore conditional modules, since they are not guaranteed to
3402 # contribute to lib_SOURCES.
3405 # Extract the value of unconditional "lib_SOURCES += ..." augmentations.
3406 for file in `func_get_automake_snippet "$module" | combine_lines |
3407 func_remove_if_blocks |
3408 sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
3409 # Ignore .h files since they are not compiled.
3413 have_lib_SOURCES
=yes
3421 # Add the dummy module, to make sure the library will be non-empty.
3422 if test -z "$have_lib_SOURCES"; then
3423 if func_acceptable
"dummy"; then
3424 func_append modules
" dummy"
3429 # func_modules_add_dummy_separately
3431 # - local_gnulib_path from --local-dir
3432 # - modcache true or false, from --cache-modules/--no-cache-modules
3433 # - main_modules list of modules, including dependencies
3434 # - testsrelated_modules list of tests-related modules, including dependencies
3435 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3437 # - main_modules list of modules, including 'dummy' if needed
3438 # - testsrelated_modules list of tests-related modules, including 'dummy' if
3440 func_modules_add_dummy_separately
()
3442 # Add the dummy module to the main module list if needed.
3443 modules
="$main_modules"
3444 func_modules_add_dummy
3445 main_modules
="$modules"
3447 # Add the dummy module to the tests-related module list if needed.
3448 if $use_libtests; then
3449 modules
="$testsrelated_modules"
3450 func_modules_add_dummy
3451 testsrelated_modules
="$modules"
3455 # func_modules_notice
3457 # - local_gnulib_path from --local-dir
3458 # - modcache true or false, from --cache-modules/--no-cache-modules
3459 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3460 # - modules list of modules, including dependencies
3461 func_modules_notice
()
3463 if test $verbose -ge -1; then
3464 for module
in $modules; do
3466 if test -n "$module"; then
3467 msg
=`func_get_notice $module`
3468 if test -n "$msg"; then
3469 echo "Notice from module $module:"
3470 echo "$msg" |
sed -e 's/^/ /'
3477 # func_modules_to_filelist
3479 # - local_gnulib_path from --local-dir
3480 # - modcache true or false, from --cache-modules/--no-cache-modules
3481 # - modules list of modules, including dependencies
3483 # - files list of files
3484 func_modules_to_filelist
()
3487 for module
in $modules; do
3489 if test -n "$module"; then
3490 fs
=`func_get_filelist $module`
3491 func_append files
" $fs"
3494 files
=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3497 # func_modules_to_filelist_separately
3498 # Determine the final file lists.
3499 # They must be computed separately, because files in lib/* go into
3500 # $sourcebase/ if they are in the main file list but into $testsbase/
3501 # if they are in the tests-related file list. Furthermore lib/dummy.c
3504 # - local_gnulib_path from --local-dir
3505 # - modcache true or false, from --cache-modules/--no-cache-modules
3506 # - main_modules list of modules, including dependencies
3507 # - testsrelated_modules list of tests-related modules, including dependencies
3508 func_modules_to_filelist_separately
()
3510 # Determine final main file list.
3511 modules
="$main_modules"
3512 func_modules_to_filelist
3514 # Determine final tests-related file list.
3515 modules
="$testsrelated_modules"
3516 func_modules_to_filelist
3517 testsrelated_files
=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3518 # Merge both file lists.
3519 sed_remove_empty_lines
='/^$/d'
3520 files
=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3521 if test $verbose -ge 0; then
3523 sed_prettyprint_files
='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3524 echo "$files" |
sed -e "$sed_prettyprint_files" -e 's/^/ /'
3528 # func_compute_include_guard_prefix
3529 # Determine include_guard_prefix and module_indicator_prefix.
3531 # - macro_prefix prefix of gl_LIBOBJS macros to use
3533 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3534 # - sed_replace_include_guard_prefix
3535 # sed expression for resolving ${gl_include_guard_prefix}
3536 # - module_indicator_prefix prefix of GNULIB_<modulename> variables to use
3537 func_compute_include_guard_prefix
()
3539 if test "$macro_prefix" = gl
; then
3540 include_guard_prefix
='GL'
3542 include_guard_prefix
='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3544 sed_replace_include_guard_prefix
='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3545 module_indicator_prefix
="${include_guard_prefix}"
3548 # func_execute_command command [args...]
3549 # Executes a command.
3550 # Uses also the variables
3551 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3552 func_execute_command
()
3554 if test $verbose -ge 0; then
3558 # Commands like automake produce output to stderr even when they succeed.
3559 # Turn this output off if the command succeeds.
3560 "$@" > "$tmp"/cmdout
2>&1
3562 if test $cmdret = 0; then
3566 cat "$tmp"/cmdout
1>&2
3573 # func_dest_tmpfilename file
3574 # determines the name of a temporary file (file is relative to destdir).
3576 # - destdir target directory
3577 # - doit : if actions shall be executed, false if only to be printed
3578 # - tmp pathname of a temporary directory
3580 # - tmpfile absolute filename of the temporary file
3581 func_dest_tmpfilename
()
3584 # Put the new contents of $file in a file in the same directory (needed
3585 # to guarantee that an 'mv' to "$destdir/$file" works).
3586 tmpfile
="$destdir/$1.tmp"
3588 # Put the new contents of $file in a file in a temporary directory
3589 # (because the directory of "$file" might not exist).
3590 tmpfile
="$tmp"/`basename "$1"`.tmp
3594 # func_is_local_file lookedup_file file
3595 # check whether file should be instantiated from local gnulib directory
3596 func_is_local_file
()
3599 func_remove_suffix dname
"/$2"
3600 func_path_foreach
"$local_gnulib_path" test %dir
% = "$dname"
3604 # determines whether the file $f should be copied, symlinked, or hardlinked.
3606 # - copymode copy mode for files in general
3607 # - lcopymode copy mode for files from local_gnulib_path
3608 # - f the original file name
3609 # - lookedup_file name of the merged (combined) file
3611 # - copyaction copy or symlink or hardlink
3614 if test -n "$lcopymode" && func_is_local_file
"$lookedup_file" "$f"; then
3615 copyaction
="$lcopymode"
3617 if test -n "$copymode"; then
3618 copyaction
="$copymode"
3626 # copies a file from gnulib into the destination directory. The destination
3627 # is known to not exist.
3629 # - destdir target directory
3630 # - local_gnulib_path from --local-dir
3631 # - modcache true or false, from --cache-modules/--no-cache-modules
3632 # - f the original file name
3633 # - lookedup_file name of the merged (combined) file
3634 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3635 # - g the rewritten file name
3636 # - tmpfile absolute filename of the temporary file
3637 # - doit : if actions shall be executed, false if only to be printed
3638 # - copymode copy mode for files in general
3639 # - lcopymode copy mode for files from local_gnulib_path
3643 echo "Copying file $g"
3645 if test "$copyaction" = symlink \
3646 && test -z "$lookedup_tmp" \
3647 && cmp -s "$lookedup_file" "$tmpfile"; then
3648 func_symlink_if_changed
"$lookedup_file" "$destdir/$g"
3650 if test "$copyaction" = hardlink \
3651 && test -z "$lookedup_tmp" \
3652 && cmp -s "$lookedup_file" "$tmpfile"; then
3653 func_hardlink
"$lookedup_file" "$destdir/$g"
3655 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error
"failed"
3664 # copies a file from gnulib into the destination directory. The destination
3665 # is known to exist.
3667 # - destdir target directory
3668 # - local_gnulib_path from --local-dir
3669 # - modcache true or false, from --cache-modules/--no-cache-modules
3670 # - f the original file name
3671 # - lookedup_file name of the merged (combined) file
3672 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3673 # - g the rewritten file name
3674 # - tmpfile absolute filename of the temporary file
3675 # - doit : if actions shall be executed, false if only to be printed
3676 # - copymode copy mode for files in general
3677 # - lcopymode copy mode for files from local_gnulib_path
3678 # - already_present nonempty if the file should already exist, empty otherwise
3681 if cmp -s "$destdir/$g" "$tmpfile"; then
3682 : # The file has not changed.
3686 if test -n "$already_present"; then
3687 echo "Updating file $g (backup in ${g}~)"
3689 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3691 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error
"failed"
3693 if test "$copyaction" = symlink \
3694 && test -z "$lookedup_tmp" \
3695 && cmp -s "$lookedup_file" "$tmpfile"; then
3696 func_symlink_if_changed
"$lookedup_file" "$destdir/$g"
3698 if test "$copyaction" = hardlink \
3699 && test -z "$lookedup_tmp" \
3700 && cmp -s "$lookedup_file" "$tmpfile"; then
3701 func_hardlink
"$lookedup_file" "$destdir/$g"
3703 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error
"failed"
3707 if test -n "$already_present"; then
3708 echo "Update file $g (backup in ${g}~)"
3710 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3716 # func_emit_lib_Makefile_am
3717 # emits the contents of library makefile to standard output.
3719 # - local_gnulib_path from --local-dir
3720 # - modcache true or false, from --cache-modules/--no-cache-modules
3721 # - modules list of modules, including dependencies
3722 # - libname library name
3723 # - pobase directory relative to destdir where to place *.po files
3724 # - auxdir directory relative to destdir where to place build aux files
3725 # - gnu_make true if --gnu-make was given, false otherwise
3726 # - makefile_name from --makefile-name
3727 # - automake_subdir true if --automake-subdir was given, false otherwise
3728 # - libtool true if libtool will be used, false or blank otherwise
3729 # - macro_prefix prefix of gl_LIBOBJS macros to use
3730 # - module_indicator_prefix prefix of GNULIB_<modulename> variables to use
3731 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3732 # - witness_c_macro from --witness-c-macro
3733 # - actioncmd (optional) command that will reproduce this invocation
3734 # - for_test true if creating a package for testing, false otherwise
3735 # - sed_replace_include_guard_prefix
3736 # sed expression for resolving ${gl_include_guard_prefix}
3737 # - destfile filename relative to destdir of makefile being generated
3739 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
3740 # list of edits to be done to Makefile.am variables
3742 # - uses_subdirs nonempty if object files in subdirs exist
3743 func_emit_lib_Makefile_am
()
3745 # When using GNU make, or when creating an includable Makefile.am snippet,
3746 # augment variables with += instead of assigning them.
3747 if $gnu_make ||
test -n "$makefile_name"; then
3752 if test "$libtool" = true
; then
3755 sed_eliminate_LDFLAGS
="$sed_noop"
3759 sed_eliminate_LDFLAGS
='/^lib_LDFLAGS[ ]*+=/d'
3761 # Replace NMD, so as to remove redundant "$(MKDIR_P) '.'" invocations.
3762 # The logic is similar to how we define gl_source_base_prefix.
3763 if $automake_subdir; then
3764 sed_eliminate_NMD
='s/@NMD@//;/@!NMD@/d'
3766 sed_eliminate_NMD
='/@NMD@/d;s/@!NMD@//'
3769 # When creating a package for testing: Attempt to provoke failures,
3770 # especially link errors, already during "make" rather than during
3771 # "make check", because "make check" is not possible in a cross-compiling
3772 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3773 sed_transform_check_PROGRAMS
='s,check_PROGRAMS,noinst_PROGRAMS,g'
3775 sed_transform_check_PROGRAMS
="$sed_noop"
3777 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3778 if ! $gnu_make; then
3779 echo "## Process this file with automake to produce Makefile.in."
3781 func_emit_copyright_notice
3782 if test -n "$actioncmd"; then
3783 printf '# Reproduce by:\n%s\n' "$actioncmd"
3788 for module
in $modules; do
3789 func_verify_nontests_module
3790 if test -n "$module"; then
3792 func_get_automake_snippet_conditional
"$module" |
3794 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3795 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3796 -e "$sed_eliminate_LDFLAGS" \
3797 -e "$sed_eliminate_NMD" \
3798 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3799 -e 's,\$(GNULIB_,$('"${module_indicator_prefix}"'_GNULIB_,' \
3800 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3801 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3802 -e "$sed_transform_check_PROGRAMS" \
3803 -e "$sed_replace_include_guard_prefix"
3804 if test "$module" = 'alloca'; then
3805 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3806 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3808 } | combine_lines
"${libname}_${libext}_SOURCES" > "$tmp"/amsnippet1
3810 func_get_automake_snippet_unconditional
"$module" |
3812 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3813 -e 's,\$(GNULIB_,$('"${module_indicator_prefix}"'_GNULIB_,'
3814 } > "$tmp"/amsnippet2
3815 # Skip the contents if it's entirely empty.
3816 if grep '[^ ]' "$tmp"/amsnippet1
"$tmp"/amsnippet2
> /dev
/null
; then
3817 echo "## begin gnulib module $module"
3819 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
3820 convert_to_gnu_make_1
='s/^if \(.*\)/ifneq (,$(\1_CONDITION))/'
3821 convert_to_gnu_make_2
='s|%reldir%/||g'
3822 convert_to_gnu_make_3
='s|%reldir%|.|g'
3825 if test "$cond_dependencies" = true
; then
3826 if func_cond_module_p
"$module"; then
3827 func_module_conditional_name
"$module"
3829 echo "ifneq (,\$(${conditional}_CONDITION))"
3831 echo "if $conditional"
3836 sed -e "$convert_to_gnu_make_1" \
3837 -e "$convert_to_gnu_make_2" \
3838 -e "$convert_to_gnu_make_3" \
3841 cat "$tmp"/amsnippet1
3843 if test "$cond_dependencies" = true
; then
3844 if func_cond_module_p
"$module"; then
3849 sed -e "$convert_to_gnu_make_1" \
3850 -e "$convert_to_gnu_make_2" \
3851 -e "$convert_to_gnu_make_3" \
3854 cat "$tmp"/amsnippet2
3859 echo "## end gnulib module $module"
3862 rm -f "$tmp"/amsnippet1
"$tmp"/amsnippet2
3863 # Test whether there are some source files in subdirectories.
3864 for f
in `func_get_filelist "$module"`; do
3874 } > "$tmp"/allsnippets
3875 if test -z "$makefile_name"; then
3876 # If there are source files in subdirectories, prevent collision of the
3877 # object files (example: hash.c and libxml/hash.c).
3879 if test -n "$uses_subdirs"; then
3880 subdir_options
=' subdir-objects'
3882 echo "AUTOMAKE_OPTIONS = 1.14 gnits${subdir_options}"
3885 if test -z "$makefile_name"; then
3887 echo "noinst_HEADERS ="
3888 echo "noinst_LIBRARIES ="
3889 echo "noinst_LTLIBRARIES ="
3890 # Automake versions < 1.11.4 create an empty pkgdatadir at
3891 # installation time if you specify pkgdata_DATA to empty.
3892 # See automake bugs #10997 and #11030:
3893 # * https://debbugs.gnu.org/10997
3894 # * https://debbugs.gnu.org/11030
3895 # So we need this workaround.
3896 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets
> /dev
/null
; then
3897 echo "pkgdata_DATA ="
3900 echo "BUILT_SOURCES ="
3903 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3904 if test -z "$makefile_name"; then
3905 echo "MOSTLYCLEANDIRS ="
3907 echo "DISTCLEANFILES ="
3908 echo "MAINTAINERCLEANFILES ="
3911 echo "# Start of GNU Make output."
3913 # Put autoconf output into a temporary file, so that its exit status
3914 # can be checked from the shell. Signal any error by putting a
3915 # syntax error into the output makefile.
3916 ${AUTOCONF} -t 'AC_SUBST:$1 = @$1@' "$configure_ac" \
3917 >"$tmp"/makeout
2>"$tmp"/makeout2
&&
3918 LC_ALL
=C
sort -u "$tmp"/makeout ||
{
3919 echo "== gnulib-tool GNU Make output failed as follows =="
3920 sed 's/^/# stderr: /' "$tmp"/makeout2
3922 rm -f "$tmp"/makeout
"$tmp"/makeout2
3924 echo "# End of GNU Make output."
3926 echo "# No GNU Make output."
3928 # Execute edits that apply to the Makefile.am being generated.
3930 while test $edit != $makefile_am_edits; do
3931 edit
=`expr $edit + 1`
3932 eval dir
=\"\
$makefile_am_edit${edit}_dir
\"
3933 eval var
=\"\
$makefile_am_edit${edit}_var
\"
3934 eval val
=\"\
$makefile_am_edit${edit}_val
\"
3935 eval dotfirst
=\"\
$makefile_am_edit${edit}_dotfirst
\"
3936 if test -n "$var"; then
3937 if test "${dir}Makefile.am" = "$destfile" ||
test "./${dir}Makefile.am" = "$destfile"; then
3938 if test "${var}" = SUBDIRS
&& test -n "$dotfirst"; then
3939 # The added subdirectory ${val} needs to be mentioned after '.'.
3940 # Since we don't have '.' among SUBDIRS so far, add it now.
3943 echo "${var} += ${val}"
3944 eval "makefile_am_edit${edit}_var="
3948 if test -n "$witness_c_macro"; then
3949 cppflags_part1
=" -D$witness_c_macro=1"
3954 cppflags_part2
=" -DGNULIB_STRICT_CHECKING=1"
3958 if test -z "$makefile_name"; then
3960 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3963 if test -n "$cppflags_part1$cppflags_part2"; then
3965 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3969 if LC_ALL
=C
grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets
> /dev
/null \
3970 ||
{ test -n "$makefile_name" \
3971 && test -f "$sourcebase/Makefile.am" \
3972 && LC_ALL
=C
grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev
/null
; \
3974 # One of the snippets or the user's Makefile.am already specifies an
3975 # installation location for the library. Don't confuse automake by saying
3976 # it should not be installed.
3979 # By default, the generated library should not be installed.
3980 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3983 echo "${libname}_${libext}_SOURCES ="
3984 if ! $for_test; then
3985 echo "${libname}_${libext}_CFLAGS = \$(AM_CFLAGS) \$(GL_CFLAG_GNULIB_WARNINGS)"
3987 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3988 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3989 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3990 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3991 echo "EXTRA_${libname}_${libext}_SOURCES ="
3992 if test "$libtool" = true
; then
3993 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3994 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3995 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3996 # the link dependencies of all modules.
3997 for module
in $modules; do
3998 func_verify_nontests_module
3999 if test -n "$module"; then
4000 func_get_link_directive
"$module"
4003 | LC_ALL
=C
sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
4004 | LC_ALL
=C
sort -u \
4005 | LC_ALL
=C
sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
4008 if test -n "$pobase"; then
4009 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
4012 cat "$tmp"/allsnippets \
4013 |
sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
4015 echo "mostlyclean-local: mostlyclean-generic"
4016 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
4017 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
4018 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
4022 # Emit rules to erase .Po and .Plo files for AC_LIBOBJ invocations.
4023 # Extend the 'distclean' rule.
4024 echo "distclean-local: distclean-gnulib-libobjs"
4025 echo "distclean-gnulib-libobjs:"
4026 echo " -rm -f @${macro_prefix}_LIBOBJDEPS@"
4027 # Extend the 'maintainer-clean' rule.
4028 echo "maintainer-clean-local: distclean-gnulib-libobjs"
4029 rm -f "$tmp"/allsnippets
4032 # func_emit_po_Makevars
4033 # emits the contents of po/ makefile parameterization to standard output.
4035 # - local_gnulib_path from --local-dir
4036 # - modcache true or false, from --cache-modules/--no-cache-modules
4037 # - sourcebase directory relative to destdir where to place source code
4038 # - pobase directory relative to destdir where to place *.po files
4039 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4040 func_emit_po_Makevars
()
4042 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
4043 func_emit_copyright_notice
4045 echo "# Usually the message domain is the same as the package name."
4046 echo "# But here it has a '-gnulib' suffix."
4047 echo "DOMAIN = ${po_domain}-gnulib"
4049 echo "# These two variables depend on the location of this directory."
4050 echo "subdir = ${pobase}"
4051 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
4054 # These options get passed to xgettext.
4055 XGETTEXT_OPTIONS
= \
4056 --keyword=_
--flag=_
:1:pass-c-format \
4057 --keyword=N_
--flag=N_
:1:pass-c-format \
4058 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
4059 --keyword='proper_name_lite:1,"This is a proper name. See the gettext manual, section Names."' \
4060 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
4061 --flag=error
:3:c-format
--flag=error_at_line
:5:c-format
4063 # This is the copyright holder that gets inserted into the header of the
4064 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
4065 COPYRIGHT_HOLDER
= Free Software Foundation
, Inc.
4067 # This is the email address or URL to which the translators shall report
4068 # bugs in the untranslated strings:
4069 # - Strings which are not entire sentences, see the maintainer guidelines
4070 # in the GNU gettext documentation, section 'Preparing Strings'.
4071 # - Strings which use unclear terms or require additional context to be
4073 # - Strings which make invalid assumptions about notation of date, time or
4075 # - Pluralisation problems.
4076 # - Incorrect English spelling.
4077 # - Incorrect formatting.
4078 # It can be your email address, or a mailing list address where translators
4079 # can write to without being subscribed, or the URL of a web page through
4080 # which the translators can contact you.
4081 MSGID_BUGS_ADDRESS
= bug-gnulib@gnu.org
4083 # This is the list of locale categories, beyond LC_MESSAGES, for which the
4084 # message catalogs shall be used. It is usually empty.
4085 EXTRA_LOCALE_CATEGORIES
=
4087 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
4088 # context. Possible values are "yes" and "no". Set this to yes if the
4089 # package uses functions taking also a message context, like pgettext(), or
4090 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
4095 # func_emit_po_POTFILES_in
4096 # emits the file list to be passed to xgettext to standard output.
4098 # - local_gnulib_path from --local-dir
4099 # - modcache true or false, from --cache-modules/--no-cache-modules
4100 # - sourcebase directory relative to destdir where to place source code
4101 # - files list of new files
4102 func_emit_po_POTFILES_in
()
4104 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
4105 func_emit_copyright_notice
4107 echo "# List of files which contain translatable strings."
4108 echo "$files" |
sed -n -e "s,^lib/,$sourcebase/,p"
4111 # func_emit_tests_Makefile_am witness_macro
4112 # emits the contents of tests makefile to standard output.
4114 # - local_gnulib_path from --local-dir
4115 # - modcache true or false, from --cache-modules/--no-cache-modules
4116 # - modules list of modules, including dependencies
4117 # - libname library name
4118 # - auxdir directory relative to destdir where to place build aux files
4119 # - gnu_make true if --gnu-make was given, false otherwise
4120 # - makefile_name from --makefile-name
4121 # - tests_makefile_name from --tests-makefile-name
4122 # - libtool true if libtool will be used, false or blank otherwise
4123 # - sourcebase relative directory containing lib source code
4124 # - m4base relative directory containing autoconf macros
4125 # - testsbase relative directory containing unit test code
4126 # - macro_prefix prefix of gl_LIBOBJS macros to use
4127 # - module_indicator_prefix prefix of GNULIB_<modulename> variables to use
4128 # - witness_c_macro from --witness-c-macro
4129 # - for_test true if creating a package for testing, false otherwise
4130 # - single_configure true if a single configure file should be generated,
4131 # false for a separate configure file for the tests
4132 # - use_libtests true if a libtests.a should be built, false otherwise
4133 # - sed_replace_include_guard_prefix
4134 # sed expression for resolving ${gl_include_guard_prefix}
4135 # - destfile filename relative to destdir of makefile being generated
4137 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val,dotfirst}
4138 # list of edits to be done to Makefile.am variables
4140 # - uses_subdirs nonempty if object files in subdirs exist
4141 func_emit_tests_Makefile_am
()
4144 if test "$libtool" = true
; then
4147 sed_eliminate_LDFLAGS
="$sed_noop"
4151 sed_eliminate_LDFLAGS
='/^lib_LDFLAGS[ ]*+=/d'
4153 # Replace NMD, so as to remove redundant "$(MKDIR_P) '.'" invocations.
4154 # The logic is similar to how we define gl_source_base_prefix.
4155 sed_eliminate_NMD
='/@NMD@/d;s/@!NMD@//'
4157 # When creating a package for testing: Attempt to provoke failures,
4158 # especially link errors, already during "make" rather than during
4159 # "make check", because "make check" is not possible in a cross-compiling
4160 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
4161 sed_transform_check_PROGRAMS
='s,check_PROGRAMS,noinst_PROGRAMS,g'
4163 sed_transform_check_PROGRAMS
="$sed_noop"
4165 testsbase_inverse
=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
4166 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
4167 echo "## Process this file with automake to produce Makefile.in."
4168 func_emit_copyright_notice
4172 for module
in $modules; do
4173 if $for_test && ! $single_configure; then
4174 if `func_repeat_module_in_tests`; then
4177 func_verify_tests_module
4182 if test -n "$module"; then
4184 func_get_automake_snippet_conditional
"$module" |
4186 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
4187 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
4188 -e "$sed_eliminate_LDFLAGS" \
4189 -e "$sed_eliminate_NMD" \
4190 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
4191 -e 's,\$(GNULIB_,$('"${module_indicator_prefix}"'_GNULIB_,' \
4192 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
4193 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
4194 -e "$sed_transform_check_PROGRAMS" \
4195 -e "$sed_replace_include_guard_prefix"
4196 if $use_libtests && test "$module" = 'alloca'; then
4197 echo "libtests_a_LIBADD += @ALLOCA@"
4198 echo "libtests_a_DEPENDENCIES += @ALLOCA@"
4200 } | combine_lines
"libtests_a_SOURCES" > "$tmp"/amsnippet1
4202 func_get_automake_snippet_unconditional
"$module" |
4204 sed -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
4205 -e 's,\$(GNULIB_,$('"${module_indicator_prefix}"'_GNULIB_,'
4206 } > "$tmp"/amsnippet2
4207 # Skip the contents if it's entirely empty.
4208 if grep '[^ ]' "$tmp"/amsnippet1
"$tmp"/amsnippet2
> /dev
/null
; then
4209 # Mention long-running tests at the end.
4211 for word
in `func_get_status "$module"`; do
4212 if test "$word" = 'longrunning-test'; then
4217 { echo "## begin gnulib module $module"
4219 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
4220 convert_to_gnu_make_1
='s/^if \(.*\)/ifneq (,$(\1_CONDITION))/'
4221 convert_to_gnu_make_2
='s|%reldir%/||g'
4222 convert_to_gnu_make_3
='s|%reldir%|.|g'
4225 if test "$cond_dependencies" = true
; then
4226 if func_cond_module_p
"$module"; then
4227 func_module_conditional_name
"$module"
4229 echo "ifneq (,\$(${conditional}_CONDITION))"
4231 echo "if $conditional"
4236 sed -e "$convert_to_gnu_make_1" \
4237 -e "$convert_to_gnu_make_2" \
4238 -e "$convert_to_gnu_make_3" \
4241 cat "$tmp"/amsnippet1
4243 if test "$cond_dependencies" = true
; then
4244 if func_cond_module_p
"$module"; then
4249 sed -e "$convert_to_gnu_make_1" \
4250 -e "$convert_to_gnu_make_2" \
4251 -e "$convert_to_gnu_make_3" \
4254 cat "$tmp"/amsnippet2
4259 echo "## end gnulib module $module"
4263 rm -f "$tmp"/amsnippet1
"$tmp"/amsnippet2
4264 # Test whether there are some source files in subdirectories.
4265 for f
in `func_get_filelist "$module"`; do
4267 lib
/*/*.c |
tests
/*/*.c
)
4275 } 3> "$tmp"/main_snippets
4> "$tmp"/longrunning_snippets
4276 # Generate dependencies here, since it eases the debugging of test failures.
4277 # If there are source files in subdirectories, prevent collision of the
4278 # object files (example: hash.c and libxml/hash.c).
4280 if test -n "$uses_subdirs"; then
4281 subdir_options
=' subdir-objects'
4283 echo "AUTOMAKE_OPTIONS = 1.14 foreign${subdir_options}"
4285 if $for_test && ! $single_configure; then
4286 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
4289 # Nothing is being added to SUBDIRS; nevertheless the existence of this
4290 # variable is needed to avoid an error from automake:
4291 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
4294 echo "XFAIL_TESTS ="
4295 echo "TESTS_ENVIRONMENT ="
4296 echo "noinst_PROGRAMS ="
4297 if ! $for_test; then
4298 echo "check_PROGRAMS ="
4300 echo "EXTRA_PROGRAMS ="
4301 echo "noinst_HEADERS ="
4302 echo "noinst_LIBRARIES ="
4303 if $use_libtests; then
4305 echo "noinst_LIBRARIES += libtests.a"
4307 echo "check_LIBRARIES = libtests.a"
4310 # Automake versions < 1.11.4 create an empty pkgdatadir at
4311 # installation time if you specify pkgdata_DATA to empty.
4312 # See automake bugs #10997 and #11030:
4313 # * https://debbugs.gnu.org/10997
4314 # * https://debbugs.gnu.org/11030
4315 # So we need this workaround.
4316 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets
"$tmp"/longrunning_snippets
> /dev
/null
; then
4317 echo "pkgdata_DATA ="
4320 echo "BUILT_SOURCES ="
4322 echo "MOSTLYCLEANFILES = core *.stackdump"
4323 echo "MOSTLYCLEANDIRS ="
4325 echo "DISTCLEANFILES ="
4326 echo "MAINTAINERCLEANFILES ="
4327 # Execute edits that apply to the Makefile.am being generated.
4329 while test $edit != $makefile_am_edits; do
4330 edit
=`expr $edit + 1`
4331 eval dir
=\"\
$makefile_am_edit${edit}_dir
\"
4332 eval var
=\"\
$makefile_am_edit${edit}_var
\"
4333 eval val
=\"\
$makefile_am_edit${edit}_val
\"
4334 eval dotfirst
=\"\
$makefile_am_edit${edit}_dotfirst
\"
4335 if test -n "$var"; then
4336 if test "${dir}Makefile.am" = "$destfile" ||
test "./${dir}Makefile.am" = "$destfile"; then
4337 if test "${var}" = SUBDIRS
&& test -n "$dotfirst"; then
4338 # The added subdirectory ${val} needs to be mentioned after '.'.
4339 # But we have '.' among SUBDIRS already, so do nothing.
4342 echo "${var} += ${val}"
4343 eval "makefile_am_edit${edit}_var="
4348 # Insert a '-Wno-error' option in the compilation commands emitted by
4349 # Automake, between $(AM_CPPFLAGS) and before the reference to @CFLAGS@.
4351 # 1) Because parts of the Gnulib tests exercise corner cases (invalid
4352 # arguments, endless recursions, etc.) that a compiler may warn about,
4353 # even with just the normal '-Wall' option.
4354 # 2) Because every package maintainer has their preferred set of warnings
4355 # that they may want to enforce in the main source code of their package.
4356 # But Gnulib tests are maintained in Gnulib and don't end up in binaries
4357 # that that package installs; therefore it does not make sense for
4358 # package maintainers to enforce the absence of warnings on these tests.
4359 # Why before @CFLAGS@?
4360 # - Because "the user is always right": If a user adds '-Werror' to their
4361 # CFLAGS, they have asked for errors, they will get errors. But they have
4362 # no right to complain about these errors, because Gnulib does not support
4364 cflags_for_gnulib_code
=
4365 if ! $for_test; then
4366 # Enable or disable warnings as suitable for the Gnulib coding style.
4367 cflags_for_gnulib_code
=" \$(GL_CFLAG_GNULIB_WARNINGS)"
4369 echo "CFLAGS = @GL_CFLAG_ALLOW_WARNINGS@${cflags_for_gnulib_code} @CFLAGS@"
4370 echo "CXXFLAGS = @GL_CXXFLAG_ALLOW_WARNINGS@ @CXXFLAGS@"
4372 echo "AM_CPPFLAGS = \\"
4374 echo " -DGNULIB_STRICT_CHECKING=1 \\"
4376 if test -n "$witness_c_macro"; then
4377 echo " -D$witness_c_macro=1 \\"
4379 if test -n "${witness_macro}"; then
4380 echo " -D@${witness_macro}@=1 \\"
4382 echo " -I. -I\$(srcdir) \\"
4383 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
4384 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
4386 if $use_libtests; then
4387 # All test programs need to be linked with libtests.a.
4388 # It needs to be passed to the linker before ${libname}.${libext}, since
4389 # the tests-related modules depend on the main modules.
4390 # It also needs to be passed to the linker after ${libname}.${libext}
4391 # because the latter might contain incomplete modules (such as the
4392 # 'version-etc' module whose dependency to 'version-etc-fsf' is voluntarily
4394 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
4396 echo "LDADD = libtests.a ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext} libtests.a ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext} libtests.a \$(LIBTESTS_LIBDEPS)"
4398 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
4401 if $use_libtests; then
4402 echo "libtests_a_SOURCES ="
4403 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
4404 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
4405 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
4406 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
4407 echo "EXTRA_libtests_a_SOURCES ="
4408 # The circular dependency in LDADD requires this.
4409 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
4412 # Many test scripts use ${EXEEXT} or ${srcdir}.
4413 # EXEEXT is defined by AC_PROG_CC through autoconf.
4414 # srcdir is defined by autoconf and automake.
4415 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
4417 cat "$tmp"/main_snippets
"$tmp"/longrunning_snippets \
4418 |
sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
4419 # Arrange to print a message before compiling the files in this directory.
4420 echo "all: all-notice"
4422 echo " @echo '## ---------------------------------------------------- ##'"
4423 echo " @echo '## ------------------- Gnulib tests ------------------- ##'"
4424 echo " @echo '## You can ignore compiler warnings in this directory. ##'"
4425 echo " @echo '## ---------------------------------------------------- ##'"
4427 # Arrange to print a message before executing the tests in this directory.
4428 echo "check-am: check-notice"
4429 echo "check-notice:"
4430 echo " @echo '## ---------------------------------------------------------------------- ##'"
4431 echo " @echo '## ---------------------------- Gnulib tests ---------------------------- ##'"
4432 echo " @echo '## Please report test failures in this directory to <bug-gnulib@gnu.org>. ##'"
4433 echo " @echo '## ---------------------------------------------------------------------- ##'"
4435 echo "# Clean up after Solaris cc."
4437 echo " rm -rf SunWS_cache"
4439 echo "mostlyclean-local: mostlyclean-generic"
4440 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
4441 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
4442 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
4446 rm -f "$tmp"/main_snippets
"$tmp"/longrunning_snippets
4449 # func_emit_initmacro_start macro_prefix gentests
4450 # emits the first few statements of the gl_INIT macro to standard output.
4451 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4452 # - gentests true if a tests Makefile.am is being generated,
4454 # - module_indicator_prefix prefix of GNULIB_<modulename> variables to use
4455 func_emit_initmacro_start
()
4457 macro_prefix_arg
="$1"
4458 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
4459 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
4460 # LIBOBJS. The purpose is to allow several gnulib instantiations under
4461 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
4463 # Furthermore it avoids an automake error like this when a Makefile.am
4464 # that uses pieces of gnulib also uses $(LIBOBJ):
4465 # automatically discovered file `error.c' should not be explicitly mentioned
4466 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
4467 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
4468 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
4469 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
4470 # automatically discovered file `error.c' should not be explicitly mentioned
4471 # We let automake know about the files to be distributed through the
4472 # EXTRA_lib_SOURCES variable.
4473 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
4474 # Create data variables for checking the presence of files that are mentioned
4475 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
4476 # because we want the check to happen when the configure file is created,
4477 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
4478 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
4479 # in which to expect them.
4480 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
4481 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
4482 # Scope for m4 macros.
4483 echo " m4_pushdef([GL_MACRO_PREFIX], [${macro_prefix_arg}])"
4484 # Scope the GNULIB_<modulename> variables.
4485 echo " m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [${module_indicator_prefix}])"
4488 echo " AC_REQUIRE([gl_CC_ALLOW_WARNINGS])"
4489 echo " AC_REQUIRE([gl_CXX_ALLOW_WARNINGS])"
4493 # func_emit_initmacro_end macro_prefix gentests
4494 # emits the last few statements of the gl_INIT macro to standard output.
4495 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4496 # - gentests true if a tests Makefile.am is being generated,
4498 # - automake_subdir true if --automake-subdir was given, false otherwise
4499 # - libtool true if --libtool was given, false if --no-libtool was
4500 # given, blank otherwise
4501 func_emit_initmacro_end
()
4503 macro_prefix_arg
="$1"
4504 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
4505 # The check is performed only when autoconf is run from the directory where
4506 # the configure.ac resides; if it is run from a different directory, the
4508 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
4509 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
4510 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
4511 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
4512 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
4516 echo " m4_if(m4_sysval, [0], [],"
4517 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
4519 echo " m4_popdef([GL_MODULE_INDICATOR_PREFIX])"
4520 echo " m4_popdef([GL_MACRO_PREFIX])"
4521 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
4522 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
4523 echo " m4_popdef([AC_LIBSOURCES])"
4524 echo " m4_popdef([AC_REPLACE_FUNCS])"
4525 echo " m4_popdef([AC_LIBOBJ])"
4526 echo " AC_CONFIG_COMMANDS_PRE(["
4527 echo " ${macro_prefix_arg}_libobjs="
4528 echo " ${macro_prefix_arg}_ltlibobjs="
4529 echo " ${macro_prefix_arg}_libobjdeps="
4530 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
4531 echo " # Remove the extension."
4532 echo "changequote(,)dnl"
4533 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
4534 echo " sed_dirname1='s,//*,/,g'"
4535 echo " sed_dirname2='s,\\(.\\)/\$,\\1,'"
4536 echo " sed_dirname3='s,^[^/]*\$,.,'"
4537 echo " sed_dirname4='s,\\(.\\)/[^/]*\$,\\1,'"
4538 echo " sed_basename1='s,.*/,,'"
4539 echo "changequote([, ])dnl"
4540 if $automake_subdir && ! "$2" && test -n "$sourcebase" && test "$sourcebase" != '.'; then
4541 subdir
="$sourcebase/"
4542 elif $automake_subdir_tests && "$2" && test -n "$testsbase" && test "$testsbase" != '.'; then
4543 subdir
="$testsbase/"
4547 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
4548 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs ${subdir}\$i.\$ac_objext\""
4549 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs ${subdir}\$i.lo\""
4550 echo " i_dir=\`echo \"\$i\" | sed -e \"\$sed_dirname1\" -e \"\$sed_dirname2\" -e \"\$sed_dirname3\" -e \"\$sed_dirname4\"\`"
4551 echo " i_base=\`echo \"\$i\" | sed -e \"\$sed_basename1\"\`"
4552 if test "$libtool" = true
; then
4553 echo " ${macro_prefix_arg}_libobjdeps=\"\$${macro_prefix_arg}_libobjdeps ${subdir}\$i_dir/\\\$(DEPDIR)/\$i_base.Plo\""
4555 echo " ${macro_prefix_arg}_libobjdeps=\"\$${macro_prefix_arg}_libobjdeps ${subdir}\$i_dir/\\\$(DEPDIR)/\$i_base.Po\""
4559 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
4560 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
4561 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJDEPS], [\$${macro_prefix_arg}_libobjdeps])"
4565 # func_emit_initmacro_done macro_prefix sourcebase
4566 # emits a few statements after the gl_INIT macro to standard output.
4567 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4568 # - sourcebase directory relative to destdir where to place source code
4569 func_emit_initmacro_done
()
4571 macro_prefix_arg
="$1"
4574 echo "# Like AC_LIBOBJ, except that the module name goes"
4575 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4576 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
4577 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
4578 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
4581 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
4582 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4583 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
4584 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
4585 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
4588 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
4589 echo "# expected is derived from the gnulib-tool parameterization,"
4590 echo "# and alloca is special cased (for the alloca-opt module)."
4591 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
4592 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
4593 echo " m4_foreach([_gl_NAME], [\$1], ["
4594 echo " m4_if(_gl_NAME, [alloca.c], [], ["
4595 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
4596 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
4602 # func_emit_shellvars_init gentests base
4603 # emits some shell variable assignments to standard output.
4604 # - gentests true if a tests Makefile.am is being generated,
4606 # - base base directory, relative to the top-level directory
4607 # - automake_subdir true if --automake-subdir was given, false otherwise
4608 # - automake_subdir_tests true if --automake-subdir-tests was given, false otherwise
4609 func_emit_shellvars_init
()
4611 # Define the base directory, relative to the top-level directory.
4612 echo " gl_source_base='$2'"
4613 # Define the prefix for the file name of generated files.
4614 if $1 && $automake_subdir_tests; then
4615 # When tests share the same Makefile as the whole project, they
4616 # share the same base prefix.
4617 if test "$2" = "$testsbase"; then
4618 echo " gl_source_base_prefix='\$(top_build_prefix)$sourcebase/'"
4620 echo " gl_source_base_prefix='\$(top_build_prefix)$2/'"
4622 elif ! $1 && $automake_subdir; then
4623 echo " gl_source_base_prefix='\$(top_build_prefix)$2/'"
4625 echo " gl_source_base_prefix="
4629 # func_emit_autoconf_snippet indentation
4630 # emits the autoconf snippet of a module.
4632 # - indentation spaces to prepend on each line
4633 # - local_gnulib_path from --local-dir
4634 # - modcache true or false, from --cache-modules/--no-cache-modules
4635 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4636 # - sed_replace_include_guard_prefix
4637 # sed expression for resolving ${gl_include_guard_prefix}
4638 # - module the module name
4639 # - toplevel true or false. 'false' means a subordinate use of
4641 # - disable_libtool true or false. It tells whether to disable libtool
4642 # handling even if it has been specified through the
4643 # command line options.
4644 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4646 func_emit_autoconf_snippet
()
4649 if { case $module in
4650 gnumakefile | maintainer-makefile
)
4651 # These modules are meant to be used only in the top-level directory.
4657 func_get_autoconf_snippet
"$module" \
4658 |
sed -e '/^$/d;' -e "s/^/$indentation/" \
4659 -e "$sed_replace_build_aux" \
4660 -e "$sed_replace_include_guard_prefix" \
4661 |
{ if $disable_libtool; then
4662 sed -e 's/\$gl_cond_libtool/false/g' \
4663 -e 's/gl_libdeps/gltests_libdeps/g' \
4664 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4669 |
{ if $disable_gettext; then
4670 sed -e 's/AM_GNU_GETTEXT(\[external])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
4672 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
4673 # autopoint through at least GNU gettext version 0.18.2.
4674 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
4677 if test "$module" = 'alloca' && test "$libtool" = true
&& ! $disable_libtool; then
4678 echo 'changequote(,)dnl'
4679 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4680 echo 'changequote([, ])dnl'
4681 echo 'AC_SUBST([LTALLOCA])'
4686 # func_emit_autoconf_snippets modules referenceable_modules verifier toplevel disable_libtool disable_gettext
4687 # collects and emit the autoconf snippets of a set of modules.
4689 # - local_gnulib_path from --local-dir
4690 # - modcache true or false, from --cache-modules/--no-cache-modules
4691 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4692 # - sed_replace_include_guard_prefix
4693 # sed expression for resolving ${gl_include_guard_prefix}
4694 # - modules the list of modules.
4695 # - referenceable_modules the list of modules which may be referenced as dependencies.
4696 # - verifier one of func_verify_module, func_verify_nontests_module,
4697 # func_verify_tests_module. It selects the subset of
4698 # $modules to consider.
4699 # - toplevel true or false. 'false' means a subordinate use of
4701 # - disable_libtool true or false. It tells whether to disable libtool
4702 # handling even if it has been specified through the
4703 # command line options.
4704 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4706 func_emit_autoconf_snippets
()
4708 referenceable_modules
="$2"
4711 disable_libtool
="$5"
4712 disable_gettext
="$6"
4713 if test "$cond_dependencies" = true
; then
4714 for m
in $referenceable_modules; do echo $m; done | LC_ALL
=C
sort -u > "$tmp"/modules
4715 # Emit the autoconf code for the unconditional modules.
4716 for module
in $1; do
4718 if test -n "$module"; then
4719 if func_cond_module_p
"$module"; then
4722 func_emit_autoconf_snippet
" "
4726 # Initialize the shell variables indicating that the modules are enabled.
4727 for module
in $1; do
4729 if test -n "$module"; then
4730 if func_cond_module_p
"$module"; then
4731 func_module_shellvar_name
"$module"
4732 echo " $shellvar=false"
4736 # Emit the autoconf code for the conditional modules, each in a separate
4737 # function. This makes it possible to support cycles among conditional
4739 for module
in $1; do
4741 if test -n "$module"; then
4742 if func_cond_module_p
"$module"; then
4743 func_module_shellfunc_name
"$module"
4744 func_module_shellvar_name
"$module"
4745 echo " $shellfunc ()"
4747 echo " if \$$shellvar; then :; else"
4748 func_emit_autoconf_snippet
" "
4749 echo " $shellvar=true"
4750 deps
=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4751 # Intersect $deps with the modules list $1.
4752 deps
=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4753 for dep
in $deps; do
4754 if func_cond_module_p
"$dep"; then
4755 func_module_shellfunc_name
"$dep"
4756 func_cond_module_condition
"$module" "$dep"
4757 if test "$condition" != true
; then
4758 echo " if $condition; then"
4765 # The autoconf code for $dep has already been emitted above and
4766 # therefore is already executed when this function is run.
4775 # Emit the dependencies from the unconditional to the conditional modules.
4776 for module
in $1; do
4778 if test -n "$module"; then
4779 if func_cond_module_p
"$module"; then
4782 deps
=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4783 # Intersect $deps with the modules list $1.
4784 deps
=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4785 for dep
in $deps; do
4786 if func_cond_module_p
"$dep"; then
4787 func_module_shellfunc_name
"$dep"
4788 func_cond_module_condition
"$module" "$dep"
4789 if test "$condition" != true
; then
4790 echo " if $condition; then"
4797 # The autoconf code for $dep has already been emitted above and
4798 # therefore is already executed when this code is run.
4805 # Define the Automake conditionals.
4806 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4807 for module
in $1; do
4809 if test -n "$module"; then
4810 if func_cond_module_p
"$module"; then
4811 func_module_conditional_name
"$module"
4812 func_module_shellvar_name
"$module"
4813 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4818 # Ignore the conditions, and enable all modules unconditionally.
4819 for module
in $1; do
4821 if test -n "$module"; then
4822 func_emit_autoconf_snippet
" "
4828 # func_emit_pre_early_macros require indentation modules
4829 # The require parameter can be ':' (AC_REQUIRE) or 'false' (direct call).
4830 func_emit_pre_early_macros
()
4833 echo "${2}# Pre-early section."
4835 _pre_early_snippet
="echo \"${2}AC_REQUIRE([\$_pre_early_macro])\""
4837 _pre_early_snippet
="echo \"${2}\$_pre_early_macro\""
4840 # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB. Doing
4841 # AC_REQUIRE in configure-ac.early is not early enough.
4842 _pre_early_macro
="gl_USE_SYSTEM_EXTENSIONS"
4843 case "${nl}${3}${nl}" in
4844 *${nl}extensions
${nl}*) eval "$_pre_early_snippet" ;;
4847 _pre_early_macro
="gl_PROG_AR_RANLIB"
4848 eval "$_pre_early_snippet"
4852 # func_reconstruct_cached_dir
4853 # callback for func_reconstruct_cached_local_gnulib_path
4855 # - destdir from --dir
4857 # - local_gnulib_path restored '--local-dir' path from cache
4858 func_reconstruct_cached_dir
()
4861 if test -n "$cached_dir"; then
4862 case "$cached_dir" in
4864 func_path_append local_gnulib_path
"$cached_dir" ;;
4868 # XXX This doesn't look right.
4869 func_path_append local_gnulib_path
"$destdir/$cached_dir" ;;
4871 func_relconcat
"$destdir" "$cached_dir"
4872 func_path_append local_gnulib_path
"$relconcat" ;;
4878 # func_reconstruct_cached_local_gnulib_path
4879 # reconstruct local_gnulib_path from cached_local_gnulib_path to be set
4880 # relatively to $destdir again.
4882 # - cached_local_gnulib_path local_gnulib_path stored within gnulib-cache.m4
4883 # - destdir from --dir
4885 # - local_gnulib_path restored '--local-dir' path from cache
4886 func_reconstruct_cached_local_gnulib_path
()
4888 func_path_foreach
"$cached_local_gnulib_path" func_reconstruct_cached_dir
%dir
%
4891 # func_import modules
4892 # Uses also the variables
4893 # - mode import or add-import or remove-import or update
4894 # - destdir target directory
4895 # - local_gnulib_path from --local-dir
4896 # - modcache true or false, from --cache-modules/--no-cache-modules
4897 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4898 # - libname library name
4899 # - supplied_libname true if --lib was given, blank otherwise
4900 # - sourcebase directory relative to destdir where to place source code
4901 # - m4base directory relative to destdir where to place *.m4 macros
4902 # - pobase directory relative to destdir where to place *.po files
4903 # - docbase directory relative to destdir where to place doc files
4904 # - testsbase directory relative to destdir where to place unit test code
4905 # - auxdir directory relative to destdir where to place build aux files
4906 # - inctests true if --with-tests was given, false otherwise
4907 # - incobsolete true if --with-obsolete was given, blank otherwise
4908 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4909 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4911 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4913 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4915 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4916 # - avoidlist list of modules to avoid, from --avoid
4917 # - cond_dependencies true if --conditional-dependencies was given, false if
4918 # --no-conditional-dependencies was given, blank otherwise
4919 # - lgpl yes or a number if library's license shall be LGPL,
4921 # - makefile_name from --makefile-name
4922 # - tests_makefile_name from --tests-makefile-name
4923 # - libtool true if --libtool was given, false if --no-libtool was
4924 # given, blank otherwise
4925 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4926 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4927 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4928 # - witness_c_macro from --witness-c-macro
4929 # - vc_files true if --vc-files was given, false if --no-vc-files was
4930 # given, blank otherwise
4931 # - autoconf_minversion minimum supported autoconf version
4932 # - doit : if actions shall be executed, false if only to be printed
4933 # - copymode copy mode for files in general
4934 # - lcopymode copy mode for files from local_gnulib_path
4937 # Get the cached settings.
4938 # In 'import' mode, we read them only for the purpose of knowing the old
4939 # installed file list, and don't use them as defaults.
4940 cached_local_gnulib_path
=
4941 cached_specified_modules
=
4943 cached_inc_cxx_tests
=
4944 cached_inc_longrunning_tests
=
4945 cached_inc_privileged_tests
=
4946 cached_inc_unportable_tests
=
4947 cached_inc_all_tests
=
4957 cached_makefile_name
=
4958 cached_tests_makefile_name
=
4959 cached_automake_subdir
=
4960 cached_cond_dependencies
=
4962 cached_macro_prefix
=
4964 cached_witness_c_macro
=
4967 if test -f "$destdir"/$m4base/gnulib-cache.
m4; then
4968 cached_libtool
=false
4974 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_path="\1",p
4984 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4986 /gl_WITH_OBSOLETE/ {
4987 s,^.*$,cached_incobsolete=true,p
4989 /gl_WITH_CXX_TESTS/ {
4990 s,^.*$,cached_inc_cxx_tests=true,p
4992 /gl_WITH_LONGRUNNING_TESTS/ {
4993 s,^.*$,cached_inc_longrunning_tests=true,p
4995 /gl_WITH_PRIVILEGED_TESTS/ {
4996 s,^.*$,cached_inc_privileged_tests=true,p
4998 /gl_WITH_UNPORTABLE_TESTS/ {
4999 s,^.*$,cached_inc_unportable_tests=true,p
5001 /gl_WITH_ALL_TESTS/ {
5002 s,^.*$,cached_inc_all_tests=true,p
5005 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
5008 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
5011 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
5014 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
5017 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
5020 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
5023 s,^.*$,cached_inctests=true,p
5026 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
5029 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
5032 s,^.*$,cached_lgpl=yes,p
5034 /gl_MAKEFILE_NAME(/ {
5035 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
5037 /gl_TESTS_MAKEFILE_NAME(/ {
5038 s,^.*gl_TESTS_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_tests_makefile_name="\1",p
5040 /gl_AUTOMAKE_SUBDIR/ {
5041 s,^.*$,cached_automake_subdir=true,p
5043 /gl_CONDITIONAL_DEPENDENCIES/ {
5044 s,^.*$,cached_cond_dependencies=true,p
5047 s,^.*$,cached_libtool=true,p
5049 /gl_MACRO_PREFIX(/ {
5050 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
5053 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
5055 /gl_WITNESS_C_MACRO(/ {
5056 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
5059 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
5061 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
5062 if test -f "$destdir"/$m4base/gnulib-comp.
m4; then
5067 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST], \[/ {
5068 s,^.*$,cached_files=",p
5081 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
5085 if test "$mode" = import
; then
5086 # In 'import' mode, the new set of specified modules overrides the cached
5087 # set of modules. Ignore the cached settings.
5088 specified_modules
="$1"
5090 # Merge the cached settings with the specified ones.
5091 # The m4base must be the same as expected from the pathname.
5092 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
5093 func_fatal_error
"$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
5095 # The local_gnulib_path defaults to the cached one. Recall that the cached one
5096 # is relative to $destdir, whereas the one we use is relative to . or absolute.
5097 if test -z "$local_gnulib_path"; then
5098 func_reconstruct_cached_local_gnulib_path
5102 # Append the cached and the specified module names. So that
5103 # "gnulib-tool --add-import foo" means to add the module foo.
5104 specified_modules
="$cached_specified_modules $1"
5107 # Take the cached module names, minus the specified module names.
5109 if $have_associative; then
5110 # Use an associative array, for O(N) worst-case run time.
5111 declare -A to_remove
5113 eval 'to_remove[$m]=yes'
5115 for module
in $cached_specified_modules; do
5116 if eval 'test -z "${to_remove[$module]}"'; then
5117 func_append specified_modules
"$module "
5121 # This loop has O(N**2) worst-case run time.
5122 for module
in $cached_specified_modules; do
5125 if test "$m" = "$module"; then
5130 if test -z "$to_remove"; then
5131 func_append specified_modules
"$module "
5137 # Take the cached module names. There are no specified module names.
5138 specified_modules
="$cached_specified_modules"
5141 # Included obsolete modules among the dependencies if specified either way.
5142 if test -z "$incobsolete"; then
5143 incobsolete
="$cached_incobsolete"
5145 # Included special kinds of tests modules among the dependencies if specified
5147 if test -z "$inc_cxx_tests"; then
5148 inc_cxx_tests
="$cached_inc_cxx_tests"
5150 if test -z "$inc_longrunning_tests"; then
5151 inc_longrunning_tests
="$cached_inc_longrunning_tests"
5153 if test -z "$inc_privileged_tests"; then
5154 inc_privileged_tests
="$cached_inc_privileged_tests"
5156 if test -z "$inc_unportable_tests"; then
5157 inc_unportable_tests
="$cached_inc_unportable_tests"
5159 if test -z "$inc_all_tests"; then
5160 inc_all_tests
="$cached_inc_all_tests"
5162 # Append the cached and the specified avoidlist. This is probably better
5163 # than dropping the cached one when --avoid is specified at least once.
5164 avoidlist
=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
5165 avoidlist
=`echo $avoidlist`
5167 # The sourcebase defaults to the cached one.
5168 if test -z "$sourcebase"; then
5169 sourcebase
="$cached_sourcebase"
5170 if test -z "$sourcebase"; then
5171 func_fatal_error
"missing --source-base option"
5174 # The pobase defaults to the cached one.
5175 if test -z "$pobase"; then
5176 pobase
="$cached_pobase"
5178 # The docbase defaults to the cached one.
5179 if test -z "$docbase"; then
5180 docbase
="$cached_docbase"
5181 if test -z "$docbase"; then
5182 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."
5185 # The testsbase defaults to the cached one.
5186 if test -z "$testsbase"; then
5187 testsbase
="$cached_testsbase"
5188 if test -z "$testsbase"; then
5189 func_fatal_error
"missing --tests-base option"
5192 # Require the tests if specified either way.
5193 if ! $inctests; then
5194 inctests
="$cached_inctests"
5195 if test -z "$inctests"; then
5199 # The libname defaults to the cached one.
5200 if test -z "$supplied_libname"; then
5201 libname
="$cached_libname"
5202 if test -z "$libname"; then
5203 func_fatal_error
"missing --lib option"
5206 # Require LGPL if specified either way.
5207 if test -z "$lgpl"; then
5210 # The makefile_name defaults to the cached one.
5211 if test -z "$makefile_name"; then
5212 makefile_name
="$cached_makefile_name"
5214 # The tests_makefile_name defaults to the cached one.
5215 if test -z "$tests_makefile_name"; then
5216 tests_makefile_name
="$cached_tests_makefile_name"
5218 # Use automake-subdir mode if specified either way.
5219 if ! $automake_subdir; then
5220 automake_subdir
="$cached_automake_subdir"
5221 if test -z "$automake_subdir"; then
5222 automake_subdir
=false
5225 # Use conditional dependencies if specified either way.
5226 if test -z "$cond_dependencies"; then
5227 cond_dependencies
="$cached_cond_dependencies"
5229 # Use libtool if specified either way, or if guessed.
5230 if test -z "$libtool"; then
5231 if test -n "$cached_m4base"; then
5232 libtool
="$cached_libtool"
5234 libtool
="$guessed_libtool"
5237 # The macro_prefix defaults to the cached one.
5238 if test -z "$macro_prefix"; then
5239 macro_prefix
="$cached_macro_prefix"
5240 if test -z "$macro_prefix"; then
5241 func_fatal_error
"missing --macro-prefix option"
5244 # The po_domain defaults to the cached one.
5245 if test -z "$po_domain"; then
5246 po_domain
="$cached_po_domain"
5248 # The witness_c_macro defaults to the cached one.
5249 if test -z "$witness_c_macro"; then
5250 witness_c_macro
="$cached_witness_c_macro"
5252 # The vc_files defaults to the cached one.
5253 if test -z "$vc_files"; then
5254 vc_files
="$cached_vc_files"
5256 # Ensure constraints.
5257 if test "$cond_dependencies" = true
&& $inctests; then
5258 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
5262 # --without-*-tests options are not supported here.
5264 excl_longrunning_tests
=
5265 excl_privileged_tests
=
5266 excl_unportable_tests
=
5268 # Canonicalize the list of specified modules.
5269 specified_modules
=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5271 # Include all kinds of tests modules if --with-all-tests was specified.
5272 inc_all_direct_tests
="$inc_all_tests"
5273 inc_all_indirect_tests
="$inc_all_tests"
5275 # Determine final module list.
5276 modules
="$specified_modules"
5277 func_modules_transitive_closure
5278 if test $verbose -ge 0; then
5279 func_show_module_list
5281 final_modules
="$modules"
5283 # Determine main module list and tests-related module list separately.
5284 func_modules_transitive_closure_separately
5286 # Determine whether a $testsbase/libtests.a is needed.
5287 func_determine_use_libtests
5289 # Add the dummy module to the main module list or to the tests-related module
5291 func_modules_add_dummy_separately
5293 # If --lgpl, verify that the licenses of modules are compatible.
5294 if test -n "$lgpl"; then
5295 license_incompatibilities
=
5296 for module
in $main_modules; do
5297 license
=`func_get_license $module`
5299 'GPLv2+ build tool' |
'GPLed build tool') ;;
5300 'public domain' |
'unlimited' |
'unmodifiable license text') ;;
5305 LGPLv2
+ |
'LGPLv3+ or GPLv2+' | LGPLv3
+ | LGPL
) ;;
5306 *) func_append license_incompatibilities
"$module $license$nl" ;;
5311 LGPLv2
+ |
'LGPLv3+ or GPLv2+') ;;
5312 *) func_append license_incompatibilities
"$module $license$nl" ;;
5318 *) func_append license_incompatibilities
"$module $license$nl" ;;
5321 *) func_fatal_error
"invalid value lgpl=$lgpl" ;;
5326 if test -n "$license_incompatibilities"; then
5327 # Format the license incompatibilities as a table.
5328 sed_expand_column1_width50_indent17
='s,^\([^ ]*\) ,\1 ,
5329 s,^\(.................................................[^ ]*\) *, \1 ,'
5330 license_incompatibilities
=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
5331 func_fatal_error
"incompatible license on modules:$nl$license_incompatibilities"
5335 # Show banner notice of every module.
5336 modules
="$main_modules"
5339 # Determine script to apply to imported library files.
5340 sed_transform_lib_file
=
5341 for module
in $main_modules; do
5342 if test $module = config-h
; then
5343 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
5344 sed_transform_lib_file
=$sed_transform_lib_file'
5345 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
5350 sed_transform_main_lib_file
="$sed_transform_lib_file"
5352 # Determine script to apply to auxiliary files that go into $auxdir/.
5353 sed_transform_build_aux_file
=
5355 # Determine script to apply to library files that go into $testsbase/.
5356 sed_transform_testsrelated_lib_file
="$sed_transform_lib_file"
5358 # Determine the final file lists.
5359 func_modules_to_filelist_separately
5362 || func_fatal_error
"refusing to do nothing"
5364 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
5365 new_files
="$files m4/gnulib-tool.m4"
5366 old_files
="$cached_files"
5367 if test -f "$destdir"/$m4base/gnulib-tool.
m4; then
5368 func_append old_files
" m4/gnulib-tool.m4"
5371 rewritten
='%REWRITTEN%'
5372 sed_rewrite_old_files
="\
5373 s,^build-aux/,$rewritten$auxdir/,
5374 s,^doc/,$rewritten$cached_docbase/,
5375 s,^lib/,$rewritten$cached_sourcebase/,
5376 s,^m4/,$rewritten$cached_m4base/,
5377 s,^tests/,$rewritten$cached_testsbase/,
5378 s,^tests=lib/,$rewritten$cached_testsbase/,
5381 sed_rewrite_new_files
="\
5382 s,^build-aux/,$rewritten$auxdir/,
5383 s,^doc/,$rewritten$docbase/,
5384 s,^lib/,$rewritten$sourcebase/,
5385 s,^m4/,$rewritten$m4base/,
5386 s,^tests/,$rewritten$testsbase/,
5387 s,^tests=lib/,$rewritten$testsbase/,
5391 # Determine whether to put anything into $testsbase.
5392 testsfiles
=`echo "$files" | sed -n -e 's,^tests/,,p' -e 's,^tests=lib/,,p'`
5393 if test -n "$testsfiles"; then
5399 # Create directories.
5400 { echo "$sourcebase"
5402 if test -n "$pobase"; then
5405 docfiles
=`echo "$files" | sed -n -e 's,^doc/,,p'`
5406 if test -n "$docfiles"; then
5413 for f
in $files; do echo $f; done \
5414 |
sed -e "$sed_rewrite_new_files" \
5415 |
sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5418 { # Rearrange file descriptors. Needed because "while ... done < ..."
5419 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5420 exec 5<&0 < "$tmp"/dirs
5422 if test ! -d "$destdir/$d"; then
5424 echo "Creating directory $destdir/$d"
5425 mkdir
-p "$destdir/$d" || func_fatal_error
"failed"
5427 echo "Create directory $destdir/$d"
5434 # Copy files or make symbolic links or hard links. Remove obsolete files.
5438 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5439 # representing the files according to the last gnulib-tool invocation.
5440 for f
in $old_files; do echo $f; done \
5441 |
sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
5444 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5445 # representing the files after this gnulib-tool invocation.
5446 for f
in $new_files; do echo $f; done \
5447 |
sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
5450 # First the files that are in old-files, but not in new-files:
5451 sed_take_first_column
='s,'"$delimiter"'.*,,'
5452 for g
in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
5453 # Remove the file. Do nothing if the user already removed it.
5454 if test -f "$destdir/$g" ||
test -h "$destdir/$g"; then
5456 echo "Removing file $g (backup in ${g}~)"
5457 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error
"failed"
5459 echo "Remove file $g (backup in ${g}~)"
5461 func_append removed_files
"$g$nl"
5464 # func_add_or_update handles a file that ought to be present afterwards.
5466 # - f the original file name
5467 # - g the rewritten file name
5468 # - already_present nonempty if the file should already exist, empty
5470 func_add_or_update
()
5474 tests
=lib
/*) f
=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5476 func_dest_tmpfilename
"$g"
5477 func_lookup_file
"$f"
5478 cp "$lookedup_file" "$tmpfile" || func_fatal_error
"failed"
5479 func_ensure_writable
"$tmpfile"
5482 # Don't process binary files with sed.
5485 if test -n "$sed_transform_main_lib_file"; then
5488 sed -e "$sed_transform_main_lib_file" \
5489 < "$lookedup_file" > "$tmpfile" || func_fatal_error
"failed"
5493 if test -n "$sed_transform_build_aux_file"; then
5496 sed -e "$sed_transform_build_aux_file" \
5497 < "$lookedup_file" > "$tmpfile" || func_fatal_error
"failed"
5501 if test -n "$sed_transform_testsrelated_lib_file"; then
5504 sed -e "$sed_transform_testsrelated_lib_file" \
5505 < "$lookedup_file" > "$tmpfile" || func_fatal_error
"failed"
5511 if test -f "$destdir/$g"; then
5512 # The file already exists.
5516 # Don't protest if the file should be there but isn't: it happens
5517 # frequently that developers don't put autogenerated files under version control.
5519 func_append added_files
"$g$nl"
5523 # Then the files that are in new-files, but not in old-files:
5524 sed_take_last_column
='s,^.*'"$delimiter"',,'
5526 LC_ALL
=C
join -t"$delimiter" -v2 "$tmp"/old-files
"$tmp"/new-files \
5527 |
sed -e "$sed_take_last_column" \
5528 |
sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
5529 { # Rearrange file descriptors. Needed because "while ... done < ..."
5530 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5531 exec 5<&0 < "$tmp"/added-files
5537 # Then the files that are in new-files and in old-files:
5538 already_present
=true
5539 LC_ALL
=C
join -t"$delimiter" "$tmp"/old-files
"$tmp"/new-files \
5540 |
sed -e "$sed_take_last_column" \
5541 |
sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
5542 { # Rearrange file descriptors. Needed because "while ... done < ..."
5543 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5544 exec 5<&0 < "$tmp"/kept-files
5551 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
5552 actioncmd
="# gnulib-tool --import"
5555 func_append_local_dir
()
5557 func_append
"$1" " --local-dir=$2"
5559 func_path_foreach
"$local_gnulib_path" func_append_local_dir actioncmd
%dir
%
5561 # Break the action command log into multiple lines.
5562 # Emacs puts some gnulib-tool log lines in its source repository, and
5563 # git send-email rejects patch lines longer than 998 characters.
5564 # Also, config.status uses awk, and the HP-UX 11.00 awk fails if a
5565 # line has length >= 3071; similarly, the IRIX 6.5 awk fails if a
5566 # line has length >= 3072.
5567 func_append_actionarg
()
5569 func_append actioncmd
" \\$nl# $1"
5571 func_append_actionarg
"--lib=$libname"
5572 func_append_actionarg
"--source-base=$sourcebase"
5573 func_append_actionarg
"--m4-base=$m4base"
5574 if test -n "$pobase"; then
5575 func_append_actionarg
"--po-base=$pobase"
5577 func_append_actionarg
"--doc-base=$docbase"
5578 func_append_actionarg
"--tests-base=$testsbase"
5579 func_append_actionarg
"--aux-dir=$auxdir"
5581 func_append_actionarg
"--with-tests"
5583 if test -n "$incobsolete"; then
5584 func_append_actionarg
"--with-obsolete"
5586 if test -n "$inc_cxx_tests"; then
5587 func_append_actionarg
"--with-c++-tests"
5589 if test -n "$inc_longrunning_tests"; then
5590 func_append_actionarg
"--with-longrunning-tests"
5592 if test -n "$inc_privileged_tests"; then
5593 func_append_actionarg
"--with-privileged-tests"
5595 if test -n "$inc_unportable_tests"; then
5596 func_append_actionarg
"--with-unportable-tests"
5598 if test -n "$inc_all_tests"; then
5599 func_append_actionarg
"--with-all-tests"
5601 if test -n "$lgpl"; then
5602 if test "$lgpl" = yes; then
5603 func_append_actionarg
"--lgpl"
5605 func_append_actionarg
"--lgpl=$lgpl"
5609 func_append_actionarg
"--gnu-make"
5611 if test -n "$makefile_name"; then
5612 func_append_actionarg
"--makefile-name=$makefile_name"
5614 if test -n "$tests_makefile_name"; then
5615 func_append_actionarg
"--tests-makefile-name=$tests_makefile_name"
5617 if $automake_subdir; then
5618 func_append_actionarg
"--automake-subdir"
5620 if $automake_subdir_tests; then
5621 func_append_actionarg
"--automake-subdir-tests"
5623 if test "$cond_dependencies" = true
; then
5624 func_append_actionarg
"--conditional-dependencies"
5626 func_append_actionarg
"--no-conditional-dependencies"
5628 if test "$libtool" = true
; then
5629 func_append_actionarg
"--libtool"
5631 func_append_actionarg
"--no-libtool"
5633 func_append_actionarg
"--macro-prefix=$macro_prefix"
5634 if test -n "$po_domain"; then
5635 func_append_actionarg
"--po-domain=$po_domain"
5637 if test -n "$witness_c_macro"; then
5638 func_append_actionarg
"--witness-c-macro=$witness_c_macro"
5640 if test -n "$vc_files"; then
5641 if test "$vc_files" = true
; then
5642 func_append_actionarg
"--vc-files"
5644 func_append_actionarg
"--no-vc-files"
5647 for module
in $avoidlist; do
5648 func_append_actionarg
"--avoid=$module"
5650 for module
in $specified_modules; do
5651 func_append_actionarg
"$module"
5654 # Determine include_guard_prefix and module_indicator_prefix.
5655 func_compute_include_guard_prefix
5657 # Default the source makefile name to Makefile.am.
5658 if test -n "$makefile_name"; then
5659 source_makefile_am
="$makefile_name"
5661 source_makefile_am
='Makefile.am'
5663 # Default the tests makefile name to the source makefile name.
5664 if test -n "$tests_makefile_name"; then
5665 tests_makefile_am
="$tests_makefile_name"
5667 tests_makefile_am
="$source_makefile_am"
5670 # Create normal Makefile.ams.
5673 # Setup list of Makefile.am edits that are to be performed afterwards.
5674 # Some of these edits apply to files that we will generate; others are
5675 # under the responsibility of the developer.
5677 # func_note_Makefile_am_edit dir var value [dotfirst]
5678 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
5680 # If ${dotfirst} is non-empty, this mention needs to be present after '.'.
5681 # This is a special hack for the SUBDIRS variable, cf.
5682 # <https://www.gnu.org/software/automake/manual/html_node/Subdirectories.html>.
5683 func_note_Makefile_am_edit
()
5685 makefile_am_edits
=`expr $makefile_am_edits + 1`
5686 eval makefile_am_edit
${makefile_am_edits}_dir
=\"\
$1\"
5687 eval makefile_am_edit
${makefile_am_edits}_var
=\"\
$2\"
5688 eval makefile_am_edit
${makefile_am_edits}_val
=\"\
$3\"
5689 eval makefile_am_edit
${makefile_am_edits}_dotfirst
=\"\
$4\"
5691 if test "$source_makefile_am" = Makefile.am
; then
5692 sourcebase_dir
=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
5693 sourcebase_base
=`basename "$sourcebase"`
5694 func_note_Makefile_am_edit
"$sourcebase_dir" SUBDIRS
"$sourcebase_base"
5696 if test -n "$pobase"; then
5697 pobase_dir
=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
5698 pobase_base
=`basename "$pobase"`
5699 func_note_Makefile_am_edit
"$pobase_dir" SUBDIRS
"$pobase_base"
5702 if test "$tests_makefile_am" = Makefile.am
; then
5703 testsbase_dir
=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
5704 testsbase_base
=`basename "$testsbase"`
5705 func_note_Makefile_am_edit
"$testsbase_dir" SUBDIRS
"$testsbase_base" true
5708 func_note_Makefile_am_edit
"" ACLOCAL_AMFLAGS
"${m4base}"
5710 # Find the first parent directory of $m4base that contains or will contain
5712 sed_last
='s,^.*/\([^/][^/]*\)//*$,\1/,
5714 sed_butlast
='s,[^/][^/]*//*$,,'
5715 dir1
="${m4base}/"; dir2
=""
5716 while test -n "$dir1" \
5717 && ! { test -f "${destdir}/${dir1}Makefile.am" \
5718 ||
test "${dir1}Makefile.am" = "$sourcebase/$source_makefile_am" \
5719 ||
test "./${dir1}Makefile.am" = "$sourcebase/$source_makefile_am" \
5721 && { test "${dir1}Makefile.am" = "$testsbase/$tests_makefile_am" \
5722 ||
test "./${dir1}Makefile.am" = "$testsbase/$tests_makefile_am"; }; }; }; do
5723 dir2
=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
5724 dir1
=`echo "$dir1" | sed -e "$sed_butlast"`
5726 func_note_Makefile_am_edit
"$dir1" EXTRA_DIST
"${dir2}gnulib-cache.m4"
5729 # Create po/ directory.
5730 if test -n "$pobase"; then
5731 # Create po makefile and auxiliary files.
5732 for file in Makefile.
in.
in remove-potcdate.sin
; do
5733 func_dest_tmpfilename
$pobase/$file
5734 func_lookup_file build-aux
/po
/$file
5735 cat "$lookedup_file" > "$tmpfile"
5736 if test -f "$destdir"/$pobase/$file; then
5737 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
5741 echo "Updating $pobase/$file (backup in $pobase/$file~)"
5742 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
5743 mv -f "$tmpfile" "$destdir"/$pobase/$file
5745 echo "Update $pobase/$file (backup in $pobase/$file~)"
5751 echo "Creating $pobase/$file"
5752 mv -f "$tmpfile" "$destdir"/$pobase/$file
5754 echo "Create $pobase/$file"
5757 func_append added_files
"$pobase/$file$nl"
5760 # Create po makefile parameterization, part 1.
5761 func_dest_tmpfilename
$pobase/Makevars
5762 func_emit_po_Makevars
> "$tmpfile"
5763 if test -f "$destdir"/$pobase/Makevars
; then
5764 if cmp -s "$destdir"/$pobase/Makevars
"$tmpfile"; then
5768 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
5769 mv -f "$destdir"/$pobase/Makevars
"$destdir"/$pobase/Makevars~
5770 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5772 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
5778 echo "Creating $pobase/Makevars"
5779 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5781 echo "Create $pobase/Makevars"
5784 func_append added_files
"$pobase/Makevars$nl"
5786 # Create po makefile parameterization, part 2.
5787 func_dest_tmpfilename
$pobase/POTFILES.
in
5788 func_emit_po_POTFILES_in
> "$tmpfile"
5789 if test -f "$destdir"/$pobase/POTFILES.
in; then
5790 if cmp -s "$destdir"/$pobase/POTFILES.
in "$tmpfile"; then
5794 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5795 mv -f "$destdir"/$pobase/POTFILES.
in "$destdir"/$pobase/POTFILES.
in~
5796 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.
in
5798 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5804 echo "Creating $pobase/POTFILES.in"
5805 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.
in
5807 echo "Create $pobase/POTFILES.in"
5810 func_append added_files
"$pobase/POTFILES.in$nl"
5813 TP_URL
="https://translationproject.org/latest/"
5815 echo "Fetching gnulib PO files from $TP_URL"
5816 (cd "$destdir"/$pobase \
5817 && wget
--no-verbose --mirror --level=1 -nd -A.po
-P .
"${TP_URL}gnulib/"
5820 echo "Fetch gnulib PO files from $TP_URL"
5822 # Create po/LINGUAS.
5824 func_dest_tmpfilename
$pobase/LINGUAS
5825 (cd "$destdir"/$pobase \
5826 && { echo '# Set of available languages.'
5827 LC_ALL
=C
ls -1 *.po |
sed -e 's,\.po$,,'
5830 if test -f "$destdir"/$pobase/LINGUAS
; then
5831 if cmp -s "$destdir"/$pobase/LINGUAS
"$tmpfile"; then
5834 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5835 mv -f "$destdir"/$pobase/LINGUAS
"$destdir"/$pobase/LINGUAS~
5836 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5839 echo "Creating $pobase/LINGUAS"
5840 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5841 func_append added_files
"$pobase/LINGUAS$nl"
5844 if test -f "$destdir"/$pobase/LINGUAS
; then
5845 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5847 echo "Create $pobase/LINGUAS"
5852 # func_compute_relative_local_gnulib_path
5853 # gl_LOCAL_DIR requires local_gnulib_path to be set relatively to destdir
5855 # - local_gnulib_path from --local-dir
5856 # - destdir from --dir
5858 # - relative_local_dir path to be stored into gl_LOCAL_DIR
5859 func_compute_relative_local_gnulib_path
()
5861 relative_local_gnulib_path
=
5863 IFS
="$PATH_SEPARATOR"
5864 for local_dir
in $local_gnulib_path
5867 # Store the local_dir relative to destdir.
5868 case "$local_dir" in
5870 relative_local_dir
="$local_dir" ;;
5874 # XXX This doesn't look right.
5875 relative_local_dir
="$local_dir" ;;
5877 # destdir, local_dir are both relative.
5878 func_relativize
"$destdir" "$local_dir"
5879 relative_local_dir
="$reldir" ;;
5882 func_path_append relative_local_gnulib_path
"$relative_local_dir"
5887 # Create m4/gnulib-cache.m4.
5888 func_dest_tmpfilename
$m4base/gnulib-cache.
m4
5890 func_emit_copyright_notice
5892 echo "# This file represents the specification of how gnulib-tool is used."
5893 echo "# It acts as a cache: It is written and read by gnulib-tool."
5894 echo "# In projects that use version control, this file is meant to be put under"
5895 echo "# version control, like the configure.ac and various Makefile.am files."
5898 echo "# Specification in the form of a command-line invocation:"
5899 printf '%s\n' "$actioncmd"
5901 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5902 func_compute_relative_local_gnulib_path
5903 echo "gl_LOCAL_DIR([$relative_local_gnulib_path])"
5905 echo "$specified_modules" |
sed -e 's/^/ /g'
5907 test -z "$incobsolete" ||
echo "gl_WITH_OBSOLETE"
5908 test -z "$inc_cxx_tests" ||
echo "gl_WITH_CXX_TESTS"
5909 test -z "$inc_longrunning_tests" ||
echo "gl_WITH_LONGRUNNING_TESTS"
5910 test -z "$inc_privileged_tests" ||
echo "gl_WITH_PRIVILEGED_TESTS"
5911 test -z "$inc_unportable_tests" ||
echo "gl_WITH_UNPORTABLE_TESTS"
5912 test -z "$inc_all_tests" ||
echo "gl_WITH_ALL_TESTS"
5913 echo "gl_AVOID([$avoidlist])"
5914 echo "gl_SOURCE_BASE([$sourcebase])"
5915 echo "gl_M4_BASE([$m4base])"
5916 echo "gl_PO_BASE([$pobase])"
5917 echo "gl_DOC_BASE([$docbase])"
5918 echo "gl_TESTS_BASE([$testsbase])"
5920 echo "gl_WITH_TESTS"
5922 echo "gl_LIB([$libname])"
5923 if test -n "$lgpl"; then
5924 if test "$lgpl" = yes; then
5927 echo "gl_LGPL([$lgpl])"
5930 echo "gl_MAKEFILE_NAME([$makefile_name])"
5931 if test -n "$tests_makefile_name"; then
5932 echo "gl_TESTS_MAKEFILE_NAME([$tests_makefile_name])"
5934 if test "$automake_subdir" = true
; then
5935 echo "gl_AUTOMAKE_SUBDIR"
5937 if test "$cond_dependencies" = true
; then
5938 echo "gl_CONDITIONAL_DEPENDENCIES"
5940 if test "$libtool" = true
; then
5943 echo "gl_MACRO_PREFIX([$macro_prefix])"
5944 echo "gl_PO_DOMAIN([$po_domain])"
5945 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5946 if test -n "$vc_files"; then
5947 echo "gl_VC_FILES([$vc_files])"
5950 if test -f "$destdir"/$m4base/gnulib-cache.
m4; then
5951 if cmp -s "$destdir"/$m4base/gnulib-cache.
m4 "$tmpfile"; then
5955 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5956 mv -f "$destdir"/$m4base/gnulib-cache.
m4 "$destdir"/$m4base/gnulib-cache.
m4~
5957 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.
m4
5959 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5963 echo "# gnulib-cache.m4 ends here"
5970 echo "Creating $m4base/gnulib-cache.m4"
5971 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.
m4
5973 echo "Create $m4base/gnulib-cache.m4"
5979 # Create m4/gnulib-comp.m4.
5980 func_dest_tmpfilename
$m4base/gnulib-comp.
m4
5982 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5983 func_emit_copyright_notice
5985 echo "# This file represents the compiled summary of the specification in"
5986 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5987 echo "# to be invoked from configure.ac."
5988 echo "# In projects that use version control, this file can be treated like"
5989 echo "# other built files."
5992 echo "# This macro should be invoked from $configure_ac, in the section"
5993 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5994 echo "# any checks for libraries, header files, types and library functions."
5995 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5997 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5998 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5999 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6000 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6002 func_emit_pre_early_macros
: ' ' "$final_modules"
6004 if ! $gnu_make && test -n "$uses_subdirs"; then
6005 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
6007 for module
in $final_modules; do
6009 if test -n "$module"; then
6010 echo "# Code from module $module:"
6011 func_get_autoconf_early_snippet
"$module"
6014 |
sed -e '/^$/d;' -e 's/^/ /'
6017 echo "# This macro should be invoked from $configure_ac, in the section"
6018 echo "# \"Check for header files, types and library functions\"."
6019 echo "AC_DEFUN([${macro_prefix}_INIT],"
6021 # This AC_CONFIG_LIBOBJ_DIR invocation silences an error from the automake
6023 # error: required file './alloca.c' not found
6024 # It is needed because of the last remaining use of AC_LIBSOURCES in
6025 # _AC_LIBOBJ_ALLOCA, invoked from AC_FUNC_ALLOCA.
6026 # All the m4_pushdef/m4_popdef logic in func_emit_initmacro_start/_end
6027 # does not help to avoid this error.
6028 if grep ' lib/alloca\.c$' "$tmp"/new-files
>/dev
/null
; then
6029 # alloca.c will be present in $sourcebase.
6030 echo " AC_CONFIG_LIBOBJ_DIR([$sourcebase])"
6032 if grep ' tests=lib/alloca\.c$' "$tmp"/new-files
>/dev
/null
; then
6033 # alloca.c will be present in $testsbase.
6034 echo " AC_CONFIG_LIBOBJ_DIR([$testsbase])"
6037 if test "$libtool" = true
; then
6038 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6039 echo " gl_cond_libtool=true"
6041 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6042 echo " gl_cond_libtool=false"
6044 echo " gl_ltlibdeps="
6046 if test "$auxdir" != "build-aux"; then
6047 sed_replace_build_aux
='
6049 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6050 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6054 sed_replace_build_aux
="$sed_noop"
6056 echo " gl_m4_base='$m4base'"
6057 func_emit_initmacro_start
$macro_prefix false
6058 func_emit_shellvars_init false
"$sourcebase"
6059 if test -n "$witness_c_macro"; then
6060 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
6062 func_emit_autoconf_snippets
"$main_modules" "$main_modules" func_verify_module true false true
6063 if test -n "$witness_c_macro"; then
6064 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6066 echo " # End of code from modules"
6067 func_emit_initmacro_end
$macro_prefix false
6068 echo " gltests_libdeps="
6069 echo " gltests_ltlibdeps="
6070 func_emit_initmacro_start
${macro_prefix}tests
$gentests
6071 func_emit_shellvars_init true
"$testsbase"
6072 # Define a tests witness macro that depends on the package.
6073 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
6074 # See <https://lists.gnu.org/r/automake/2009-05/msg00145.html>.
6075 echo "changequote(,)dnl"
6076 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"
6077 echo "changequote([, ])dnl"
6078 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6079 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6080 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6081 func_emit_autoconf_snippets
"$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true true true
6082 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6083 func_emit_initmacro_end
${macro_prefix}tests
$gentests
6084 echo " AC_REQUIRE([gl_CC_GNULIB_WARNINGS])"
6085 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6086 # created using libtool, because libtool already handles the dependencies.
6087 if test "$libtool" != true
; then
6088 libname_upper
=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6089 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6090 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6091 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6092 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6094 if $use_libtests; then
6095 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6096 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6099 func_emit_initmacro_done
$macro_prefix $sourcebase
6100 func_emit_initmacro_done
${macro_prefix}tests
$testsbase
6102 echo "# This macro records the list of files which have been installed by"
6103 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
6104 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
6105 echo "$files" |
sed -e 's,^, ,'
6108 if test -f "$destdir"/$m4base/gnulib-comp.
m4; then
6109 if cmp -s "$destdir"/$m4base/gnulib-comp.
m4 "$tmpfile"; then
6113 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
6114 mv -f "$destdir"/$m4base/gnulib-comp.
m4 "$destdir"/$m4base/gnulib-comp.
m4~
6115 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.
m4
6117 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
6121 echo "# gnulib-comp.m4 ends here"
6128 echo "Creating $m4base/gnulib-comp.m4"
6129 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.
m4
6131 echo "Create $m4base/gnulib-comp.m4"
6137 # Create library makefile.
6138 # Do this after creating gnulib-comp.m4, because func_emit_lib_Makefile_am
6139 # can run 'autoconf -t', which reads gnulib-comp.m4.
6140 func_dest_tmpfilename
$sourcebase/$source_makefile_am
6141 destfile
="$sourcebase/$source_makefile_am"
6142 modules
="$main_modules"
6143 if $automake_subdir; then
6144 func_emit_lib_Makefile_am |
"$gnulib_dir"/build-aux
/prefix-gnulib-mk
--from-gnulib-tool --lib-name="$libname" --prefix="$sourcebase/" > "$tmpfile"
6146 func_emit_lib_Makefile_am
> "$tmpfile"
6148 if test -f "$destdir"/$sourcebase/$source_makefile_am; then
6149 if cmp -s "$destdir"/$sourcebase/$source_makefile_am "$tmpfile"; then
6153 echo "Updating $sourcebase/$source_makefile_am (backup in $sourcebase/$source_makefile_am~)"
6154 mv -f "$destdir"/$sourcebase/$source_makefile_am "$destdir"/$sourcebase/$source_makefile_am~
6155 mv -f "$tmpfile" "$destdir"/$sourcebase/$source_makefile_am
6157 echo "Update $sourcebase/$source_makefile_am (backup in $sourcebase/$source_makefile_am~)"
6163 echo "Creating $sourcebase/$source_makefile_am"
6164 mv -f "$tmpfile" "$destdir"/$sourcebase/$source_makefile_am
6166 echo "Create $sourcebase/$source_makefile_am"
6169 func_append added_files
"$sourcebase/$source_makefile_am$nl"
6173 # Create tests makefile.
6174 func_dest_tmpfilename
$testsbase/$tests_makefile_am
6175 destfile
="$testsbase/$tests_makefile_am"
6176 modules
="$testsrelated_modules"
6177 func_emit_tests_Makefile_am
"${macro_prefix}tests_WITNESS" > "$tmpfile"
6178 if test -f "$destdir"/$testsbase/$tests_makefile_am; then
6179 if cmp -s "$destdir"/$testsbase/$tests_makefile_am "$tmpfile"; then
6183 echo "Updating $testsbase/$tests_makefile_am (backup in $testsbase/$tests_makefile_am~)"
6184 mv -f "$destdir"/$testsbase/$tests_makefile_am "$destdir"/$testsbase/$tests_makefile_am~
6185 mv -f "$tmpfile" "$destdir"/$testsbase/$tests_makefile_am
6187 echo "Update $testsbase/$tests_makefile_am (backup in $testsbase/$tests_makefile_am~)"
6193 echo "Creating $testsbase/$tests_makefile_am"
6194 mv -f "$tmpfile" "$destdir"/$testsbase/$tests_makefile_am
6196 echo "Create $testsbase/$tests_makefile_am"
6199 func_append added_files
"$testsbase/$tests_makefile_am$nl"
6203 if test "$vc_files" != false
; then
6204 # Update the .cvsignore and .gitignore files.
6205 { echo "$added_files" |
sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
6206 echo "$removed_files" |
sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
6207 # Treat gnulib-comp.m4 like an added file, even if it already existed.
6208 echo "$m4base/|A|gnulib-comp.m4"
6209 } | LC_ALL
=C
sort -t'|' -k1,1 > "$tmp"/fileset-changes
6210 { # Rearrange file descriptors. Needed because "while ... done < ..."
6211 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6212 exec 5<&0 < "$tmp"/fileset-changes
6213 func_update_ignorelist
()
6216 if test "$ignore" = .gitignore
; then
6217 # In a .gitignore file, "foo" applies to the current directory and all
6218 # subdirectories, whereas "/foo" applies to the current directory only.
6221 doubly_escaped_anchor
='\\/'
6225 doubly_escaped_anchor
=''
6227 if test -f "$destdir/$dir$ignore"; then
6228 if test -n "$dir_added" ||
test -n "$dir_removed"; then
6229 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL
=C
sort > "$tmp"/ignore
6230 (echo "$dir_added" |
sed -e '/^$/d' | LC_ALL
=C
sort -u \
6231 | LC_ALL
=C
join -v 1 - "$tmp"/ignore
> "$tmp"/ignore-added
6232 echo "$dir_removed" |
sed -e '/^$/d' | LC_ALL
=C
sort -u \
6233 > "$tmp"/ignore-removed
6235 if test -s "$tmp"/ignore-added ||
test -s "$tmp"/ignore-removed
; then
6237 echo "Updating $dir$ignore (backup in $dir${ignore}~)"
6238 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
6239 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
6240 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed
; fi
6241 } > "$tmp"/sed-ignore-removed
6242 { cat "$destdir/$dir$ignore"~
6243 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
6244 } |
sed -f "$tmp"/sed-ignore-removed \
6245 > "$destdir/$dir$ignore"
6247 echo "Update $dir$ignore (backup in $dir${ignore}~)"
6252 if test -n "$dir_added"; then
6254 echo "Creating $dir$ignore"
6256 if test "$ignore" = .cvsignore
; then
6258 # Automake generates Makefile rules that create .dirstamp files.
6261 echo "$dir_added" |
sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL
=C
sort -u
6262 } > "$destdir/$dir$ignore"
6264 echo "Create $dir$ignore"
6274 if test -d "$destdir/CVS" ||
test -d "$destdir/${dir}CVS" ||
test -f "$destdir/${dir}.cvsignore"; then
6275 func_update_ignorelist .cvsignore
6277 if test -d "$destdir/.git" ||
test -f "$destdir/${dir}.gitignore"; then
6278 func_update_ignorelist .gitignore
6285 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
6286 next_dir
=`echo "$line" | sed -e 's,|.*,,'`
6287 op
=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
6288 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
6289 if test "$next_dir" != "$last_dir"; then
6290 func_done_dir
"$last_dir" "$last_dir_added" "$last_dir_removed"
6291 last_dir
="$next_dir"
6296 A
) func_append last_dir_added
"$file$nl";;
6297 R
) func_append last_dir_removed
"$file$nl";;
6300 func_done_dir
"$last_dir" "$last_dir_added" "$last_dir_removed"
6307 echo "You may need to add #include directives for the following .h files."
6308 # Intersect $specified_modules and $main_modules
6309 # (since $specified_modules is not necessarily of subset of $main_modules
6310 # - some may have been skipped through --avoid, and since the elements of
6311 # $main_modules but not in $specified_modules can go away without explicit
6312 # notice - through changes in the module dependencies).
6313 echo "$specified_modules" > "$tmp"/modules1
# a sorted list, one module per line
6314 echo "$main_modules" > "$tmp"/modules2
# also a sorted list, one module per line
6315 # First the #include <...> directives without #ifs, sorted for convenience,
6316 # then the #include "..." directives without #ifs, sorted for convenience,
6317 # then the #include directives that are surrounded by #ifs. Not sorted.
6318 for module
in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
6319 include_directive
=`func_get_include_directive "$module"`
6320 case "$nl$include_directive" in
6322 echo "$include_directive" 1>&5
6325 echo "$include_directive" |
grep -v 'include "' 1>&6
6326 echo "$include_directive" |
grep 'include "' 1>&7
6329 done 5> "$tmp"/include-if
6> "$tmp"/include-angles
7> "$tmp"/include-quotes
6331 LC_ALL
=C
sort -u "$tmp"/include-angles
6332 LC_ALL
=C
sort -u "$tmp"/include-quotes
6333 cat "$tmp"/include-if
6334 ) |
sed -e '/^$/d' -e 's/^/ /'
6335 rm -f "$tmp"/include-angles
"$tmp"/include-quotes
"$tmp"/include-if
6337 for module
in $main_modules; do
6338 func_get_link_directive
"$module"
6340 | LC_ALL
=C
sort -u |
sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
6341 if test `wc -l < "$tmp"/link` != 0; then
6343 echo "You may need to use the following Makefile variables when linking."
6344 echo "Use them in <program>_LDADD when linking a program, or"
6345 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
6351 echo "Don't forget to"
6352 if test "$source_makefile_am" = Makefile.am
; then
6353 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
6355 echo " - \"include $source_makefile_am\" from within \"$sourcebase/Makefile.am\","
6357 if test -n "$pobase"; then
6358 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
6361 if test "$tests_makefile_am" = Makefile.am
; then
6362 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
6364 echo " - \"include $tests_makefile_am\" from within \"$testsbase/Makefile.am\","
6368 while test $edit != $makefile_am_edits; do
6369 edit
=`expr $edit + 1`
6370 eval dir
=\"\
$makefile_am_edit${edit}_dir
\"
6371 eval var
=\"\
$makefile_am_edit${edit}_var
\"
6372 eval val
=\"\
$makefile_am_edit${edit}_val
\"
6373 if test -n "$var"; then
6374 if test "$var" = ACLOCAL_AMFLAGS
; then
6375 echo " - mention \"-I ${val}\" in ${var} in ${dir}Makefile.am"
6376 echo " or add an AC_CONFIG_MACRO_DIRS([${val}]) invocation in $configure_ac,"
6378 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
6382 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev
/null
; then
6383 echo " - replace AC_PROG_CC_STDC with AC_PROG_CC in $configure_ac,"
6384 position_early_after
=AC_PROG_CC_STDC
6386 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev
/null
; then
6387 echo " - replace AC_PROG_CC_C99 with AC_PROG_CC in $configure_ac,"
6388 position_early_after
=AC_PROG_CC_C99
6390 position_early_after
=AC_PROG_CC
6393 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
6394 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
6397 # func_create_testdir testdir modules
6399 # - local_gnulib_path from --local-dir
6400 # - modcache true or false, from --cache-modules/--no-cache-modules
6401 # - auxdir directory relative to destdir where to place build aux files
6402 # - inctests true if tests should be included, false otherwise
6403 # - incobsolete true if obsolete modules among dependencies should be
6404 # included, blank otherwise
6405 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
6407 # - excl_longrunning_tests true if long-runnings tests should be excluded,
6409 # - excl_privileged_tests true if tests that require root privileges should be
6410 # excluded, blank otherwise
6411 # - excl_unportable_tests true if tests that fail on some platforms should be
6412 # excluded, blank otherwise
6413 # - single_configure true if a single configure file should be generated,
6414 # false for a separate configure file for the tests
6415 # - avoidlist list of modules to avoid
6416 # - cond_dependencies true if --conditional-dependencies was given, false if
6417 # --no-conditional-dependencies was given, blank otherwise
6418 # - libtool true if --libtool was given, false if --no-libtool was
6419 # given, blank otherwise
6420 # - copymode copy mode for files in general
6421 # - lcopymode copy mode for files from local_gnulib_path
6422 func_create_testdir
()
6426 if test -z "$modules"; then
6427 # All modules together.
6428 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6429 # Except non-recursive-gnulib-prefix-hack, which represents a nonstandard
6430 # way of using Automake.
6431 # Except timevar, which lacks the required file timevar.def.
6432 # Except mountlist, which aborts the configuration on mingw. FIXME.
6433 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
6434 modules
=`func_all_modules`
6435 modules
=`for m in $modules; do case $m in config-h | non-recursive-gnulib-prefix-hack | timevar | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
6437 specified_modules
="$modules"
6439 # Canonicalize the list of specified modules.
6440 specified_modules
=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
6442 # Test modules which invoke AC_CONFIG_FILES cannot be used with
6443 # --with-tests --single-configure. Avoid them.
6444 if $inctests && $single_configure; then
6445 avoidlist
="$avoidlist havelib-tests"
6448 # Unlike in func_import, here we want to include all kinds of tests for the
6449 # directly specified modules, but not for dependencies.
6450 inc_all_direct_tests
=true
6451 inc_all_indirect_tests
="$inc_all_tests"
6453 # Check that the license of every module is consistent with the license of
6455 saved_inctests
="$inctests"
6456 # When computing transitive closures, don't consider $module to depend on
6457 # $module-tests. Need this because tests are implicitly GPL and may depend
6458 # on GPL modules - therefore we don't want a warning in this case.
6460 for requested_module
in $specified_modules; do
6461 requested_license
=`func_get_license "$requested_module"`
6462 if test "$requested_license" != GPL
; then
6463 # Here we use func_modules_transitive_closure, not just
6464 # func_get_dependencies, so that we also detect weird situations like
6465 # an LGPL module which depends on a GPLed build tool module which depends
6467 modules
="$requested_module"
6468 func_modules_transitive_closure
6469 for module
in $modules; do
6470 license
=`func_get_license "$module"`
6472 'GPLv2+ build tool' |
'GPLed build tool') ;;
6473 'public domain' |
'unlimited' |
'unmodifiable license text') ;;
6475 case "$requested_license" in
6478 LGPLv2
+ |
'LGPLv3+ or GPLv2+' | LGPLv3
+ | LGPL | GPLv2
+ | GPLv3
+ | GPL
) ;;
6479 *) func_warning
"module $requested_module depends on a module with an incompatible license: $module" ;;
6484 LGPLv2
+ |
'LGPLv3+ or GPLv2+' | GPLv2
+) ;;
6485 *) func_warning
"module $requested_module depends on a module with an incompatible license: $module" ;;
6490 LGPLv2
+ |
'LGPLv3+ or GPLv2+' | LGPLv3
+ | LGPL
) ;;
6491 *) func_warning
"module $requested_module depends on a module with an incompatible license: $module" ;;
6494 'LGPLv3+ or GPLv2+')
6496 LGPLv2
+ |
'LGPLv3+ or GPLv2+') ;;
6497 *) func_warning
"module $requested_module depends on a module with an incompatible license: $module" ;;
6503 *) func_warning
"module $requested_module depends on a module with an incompatible license: $module" ;;
6512 inctests
="$saved_inctests"
6514 # Subdirectory names.
6525 # Determine final module list.
6526 modules
="$specified_modules"
6527 func_modules_transitive_closure
6528 if test $verbose -ge 0; then
6529 func_show_module_list
6531 final_modules
="$modules"
6533 if $single_configure; then
6534 # Determine main module list and tests-related module list separately.
6535 func_modules_transitive_closure_separately
6538 if $single_configure; then
6539 # Determine whether a $testsbase/libtests.a is needed.
6540 func_determine_use_libtests
6543 # Add the dummy module if needed.
6544 if $single_configure; then
6545 func_modules_add_dummy_separately
6547 func_modules_add_dummy
6551 # If $single_configure, we use the module lists $main_modules and
6552 # $testsrelated_modules; $modules is merely a temporary variable.
6553 # Whereas if ! $single_configure, the module list is $modules.
6555 # Show banner notice of every module.
6556 if $single_configure; then
6557 modules
="$main_modules"
6563 # Determine final file list.
6564 if $single_configure; then
6565 func_modules_to_filelist_separately
6567 main_modules
="$modules"
6568 testsrelated_modules
=`for module in $modules; do
6569 if \`func_repeat_module_in_tests\
`; then
6573 saved_modules
="$modules"
6574 func_modules_to_filelist_separately
6575 modules
="$saved_modules"
6577 # Add files for which the copy in gnulib is newer than the one that
6578 # "automake --add-missing --copy" would provide.
6579 files
="$files build-aux/config.guess"
6580 files
="$files build-aux/config.sub"
6581 files
=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
6583 rewritten
='%REWRITTEN%'
6584 sed_rewrite_files
="\
6585 s,^build-aux/,$rewritten$auxdir/,
6586 s,^doc/,$rewritten$docbase/,
6587 s,^lib/,$rewritten$sourcebase/,
6588 s,^m4/,$rewritten$m4base/,
6589 s,^tests/,$rewritten$testsbase/,
6590 s,^tests=lib/,$rewritten$testsbase/,
6594 # Create directories.
6595 for f
in $files; do echo $f; done \
6596 |
sed -e "$sed_rewrite_files" \
6597 |
sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
6598 | LC_ALL
=C
sort -u \
6600 { # Rearrange file descriptors. Needed because "while ... done < ..."
6601 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6602 exec 5<&0 < "$tmp"/dirs
6604 mkdir
-p "$testdir/$d"
6609 # Copy files or make symbolic links or hard links.
6611 for f
in $files; do echo $f; done \
6612 |
sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
6615 { # Rearrange file descriptors. Needed because "while ... done < ..."
6616 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6617 exec 5<&0 < "$tmp"/files
6620 tests
=lib
/*) f
=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
6622 func_lookup_file
"$f"
6623 if test -n "$lookedup_tmp"; then
6624 cp -p "$lookedup_file" "$testdir/$g"
6625 func_ensure_writable
"$testdir/$g"
6628 if test "$copyaction" = symlink
; then
6629 func_symlink
"$lookedup_file" "$testdir/$g"
6631 if test "$copyaction" = hardlink
; then
6632 func_hardlink
"$lookedup_file" "$testdir/$g"
6634 cp -p "$lookedup_file" "$testdir/$g"
6635 func_ensure_writable
"$testdir/$g"
6643 # Determine include_guard_prefix and module_indicator_prefix.
6644 func_compute_include_guard_prefix
6646 # Create Makefile.ams that are for testing.
6649 # No special edits are needed.
6652 # Create $sourcebase/Makefile.am.
6653 mkdir
-p "$testdir/$sourcebase"
6654 destfile
="$sourcebase/Makefile.am"
6655 if $single_configure; then
6656 modules
="$main_modules"
6658 func_emit_lib_Makefile_am
> "$testdir/$sourcebase/Makefile.am"
6659 any_uses_subdirs
="$uses_subdirs"
6661 # Create $m4base/Makefile.am.
6662 mkdir
-p "$testdir/$m4base"
6663 (echo "## Process this file with automake to produce Makefile.in."
6669 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
6672 ) > "$testdir/$m4base/Makefile.am"
6674 subdirs
="$sourcebase $m4base"
6675 subdirs_with_configure_ac
=""
6677 if false
&& test -f "$testdir"/$m4base/gettext.
m4; then
6678 # Avoid stupid error message from automake:
6679 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
6680 mkdir
-p "$testdir/po"
6681 (echo "## Process this file with automake to produce Makefile.in."
6682 ) > "$testdir/po/Makefile.am"
6683 func_append subdirs
" po"
6687 test -d "$testdir/$testsbase" || mkdir
"$testdir/$testsbase"
6688 if $single_configure; then
6689 # Create $testsbase/Makefile.am.
6690 destfile
="$testsbase/Makefile.am"
6691 modules
="$testsrelated_modules"
6692 func_emit_tests_Makefile_am
"${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
6694 # Viewed from the $testsbase subdirectory, $auxdir is different.
6695 saved_auxdir
="$auxdir"
6696 auxdir
=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
6697 # Create $testsbase/Makefile.am.
6699 destfile
="$testsbase/Makefile.am"
6700 func_emit_tests_Makefile_am
"" > "$testdir/$testsbase/Makefile.am"
6701 any_uses_subdirs
="$any_uses_subdirs$uses_subdirs"
6702 # Create $testsbase/configure.ac.
6703 (echo "# Process this file with autoconf to produce a configure script."
6704 echo "AC_INIT([dummy], [0])"
6705 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6706 echo "AM_INIT_AUTOMAKE"
6708 echo "AC_CONFIG_HEADERS([config.h])"
6711 echo "AC_PROG_INSTALL"
6712 echo "AC_PROG_MAKE_SET"
6714 func_emit_pre_early_macros false
'' "$modules"
6716 if test -n "$uses_subdirs"; then
6717 echo "AM_PROG_CC_C_O"
6720 for module
in $modules; do
6722 if test -n "$module"; then
6724 gnumakefile | maintainer-makefile
)
6725 # These modules are meant to be used only in the top-level directory.
6728 func_get_autoconf_early_snippet
"$module"
6733 |
sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)])/\1/'
6734 if test "$libtool" = true
; then
6735 echo "LT_INIT([win32-dll])"
6736 echo "LT_LANG([C++])"
6737 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6738 echo "gl_cond_libtool=true"
6740 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6741 echo "gl_cond_libtool=false"
6743 echo "gl_ltlibdeps="
6745 # Wrap the set of autoconf snippets into an autoconf macro that is then
6746 # invoked. This is needed because autoconf does not support AC_REQUIRE
6748 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6749 # but we want the AC_REQUIRE to have its normal meaning (provide one
6750 # expansion of the required macro before the current point, and only one
6752 echo "AC_DEFUN([gl_INIT], ["
6753 sed_replace_build_aux
='
6755 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6756 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6759 echo "gl_m4_base='../$m4base'"
6760 func_emit_initmacro_start
$macro_prefix true
6761 # We don't have explicit ordering constraints between the various
6762 # autoconf snippets. It's cleanest to put those of the library before
6763 # those of the tests.
6764 func_emit_shellvars_init true
"../$sourcebase"
6765 func_emit_autoconf_snippets
"$modules" "$modules" func_verify_nontests_module false false false
6766 func_emit_shellvars_init true
'.'
6767 func_emit_autoconf_snippets
"$modules" "$modules" func_verify_tests_module false false false
6768 func_emit_initmacro_end
$macro_prefix true
6769 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6770 # created using libtool, because libtool already handles the dependencies.
6771 if test "$libtool" != true
; then
6772 libname_upper
=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6773 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6774 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6775 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6776 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6779 func_emit_initmacro_done
$macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
6783 # Usually $testsbase/config.h will be a superset of config.h. Verify this
6784 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
6785 echo "AH_TOP([#include \"../config.h\"])"
6787 echo "AC_CONFIG_FILES([Makefile])"
6789 ) > "$testdir/$testsbase/configure.ac"
6790 auxdir
="$saved_auxdir"
6791 subdirs_with_configure_ac
="$subdirs_with_configure_ac $testsbase"
6793 func_append subdirs
" $testsbase"
6796 # Create Makefile.am.
6797 (echo "## Process this file with automake to produce Makefile.in."
6799 echo "AUTOMAKE_OPTIONS = 1.11 foreign"
6801 echo "SUBDIRS = $subdirs"
6803 echo "ACLOCAL_AMFLAGS = -I $m4base"
6804 ) > "$testdir/Makefile.am"
6806 # Create configure.ac.
6807 (echo "# Process this file with autoconf to produce a configure script."
6808 echo "AC_INIT([dummy], [0])"
6809 if test "$auxdir" != "."; then
6810 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6812 echo "AM_INIT_AUTOMAKE"
6814 echo "AC_CONFIG_HEADERS([config.h])"
6817 echo "AC_PROG_INSTALL"
6818 echo "AC_PROG_MAKE_SET"
6820 echo "# For autobuild."
6821 echo "AC_CANONICAL_BUILD"
6822 echo "AC_CANONICAL_HOST"
6824 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
6825 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
6826 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6827 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6829 func_emit_pre_early_macros false
'' "$final_modules"
6831 if test -n "$any_uses_subdirs"; then
6832 echo "AM_PROG_CC_C_O"
6835 for module
in $final_modules; do
6836 if $single_configure; then
6839 func_verify_nontests_module
6841 if test -n "$module"; then
6842 func_get_autoconf_early_snippet
"$module"
6845 |
sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)])/\1/'
6846 if test "$libtool" = true
; then
6847 echo "LT_INIT([win32-dll])"
6848 echo "LT_LANG([C++])"
6849 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6850 echo "gl_cond_libtool=true"
6852 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6853 echo "gl_cond_libtool=false"
6855 echo "gl_ltlibdeps="
6857 # Wrap the set of autoconf snippets into an autoconf macro that is then
6858 # invoked. This is needed because autoconf does not support AC_REQUIRE
6860 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6861 # but we want the AC_REQUIRE to have its normal meaning (provide one
6862 # expansion of the required macro before the current point, and only one
6864 echo "AC_DEFUN([gl_INIT], ["
6865 if test "$auxdir" != "build-aux"; then
6866 sed_replace_build_aux
='
6868 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6869 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6873 sed_replace_build_aux
="$sed_noop"
6875 echo "gl_m4_base='$m4base'"
6876 func_emit_initmacro_start
$macro_prefix false
6877 func_emit_shellvars_init false
"$sourcebase"
6878 if $single_configure; then
6879 func_emit_autoconf_snippets
"$main_modules" "$main_modules" func_verify_module true false false
6881 func_emit_autoconf_snippets
"$modules" "$modules" func_verify_nontests_module true false false
6883 func_emit_initmacro_end
$macro_prefix false
6884 if $single_configure; then
6885 echo " gltests_libdeps="
6886 echo " gltests_ltlibdeps="
6887 func_emit_initmacro_start
${macro_prefix}tests true
6888 func_emit_shellvars_init true
"$testsbase"
6889 # Define a tests witness macro.
6890 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
6891 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6892 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6893 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6894 func_emit_autoconf_snippets
"$testsrelated_modules" "$main_modules $testsrelated_modules" func_verify_module true false false
6895 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6896 func_emit_initmacro_end
${macro_prefix}tests true
6898 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6899 # created using libtool, because libtool already handles the dependencies.
6900 if test "$libtool" != true
; then
6901 libname_upper
=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6902 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6903 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6904 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6905 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6907 if $single_configure; then
6908 if $use_libtests; then
6909 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6910 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6914 func_emit_initmacro_done
$macro_prefix $sourcebase
6915 if $single_configure; then
6916 func_emit_initmacro_done
${macro_prefix}tests
$testsbase
6921 if test -n "$subdirs_with_configure_ac"; then
6922 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6924 makefiles
="Makefile"
6925 for d
in $subdirs; do
6926 # For subdirs that have a configure.ac by their own, it's the subdir's
6927 # configure.ac which creates the subdir's Makefile.am, not this one.
6928 case " $subdirs_with_configure_ac " in
6930 *) func_append makefiles
" $d/Makefile" ;;
6933 echo "AC_CONFIG_FILES([$makefiles])"
6935 ) > "$testdir/configure.ac"
6937 # Create autogenerated files.
6939 # Do not use "${AUTORECONF} --force --install", because it may invoke
6940 # autopoint, which brings in older versions of some of our .m4 files.
6941 if test -f $m4base/gettext.
m4; then
6942 func_execute_command
${AUTOPOINT} --force || func_exit
1
6943 for f
in $m4base/*.
m4~
; do
6945 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit
1
6949 if test "$libtool" = true
; then
6950 func_execute_command
${LIBTOOLIZE} --copy || func_exit
1
6952 func_execute_command
${ACLOCAL} -I $m4base || func_exit
1
6953 if ! test -d build-aux
; then
6954 func_execute_command mkdir build-aux || func_exit
1
6956 func_execute_command
${AUTOCONF} || func_exit
1
6957 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6958 func_execute_command
${AUTOHEADER} &&
6959 func_execute_command
touch config.h.
in ||
6961 func_execute_command
${AUTOMAKE} --add-missing --copy || func_exit
1
6962 rm -rf autom4te.cache
6964 if $inctests && ! $single_configure; then
6965 # Create autogenerated files.
6966 (cd "$testdir/$testsbase" || func_exit
1
6967 # Do not use "${AUTORECONF} --force --install", because it may invoke
6968 # autopoint, which brings in older versions of some of our .m4 files.
6969 if test -f ..
/$m4base/gettext.
m4; then
6970 func_execute_command
${AUTOPOINT} --force || func_exit
1
6971 for f
in ..
/$m4base/*.
m4~
; do
6973 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit
1
6977 func_execute_command
${ACLOCAL} -I ..
/$m4base || func_exit
1
6978 if ! test -d ..
/build-aux
; then
6979 func_execute_command mkdir ..
/build-aux
6981 func_execute_command
${AUTOCONF} || func_exit
1
6982 # Explicit 'touch config.h.in': see <https://savannah.gnu.org/support/index.php?109406>.
6983 func_execute_command
${AUTOHEADER} &&
6984 func_execute_command
touch config.h.
in ||
6986 func_execute_command
${AUTOMAKE} --add-missing --copy || func_exit
1
6987 rm -rf autom4te.cache
6990 # Need to run configure and make once, to create built files that are to be
6991 # distributed (such as parse-datetime.c).
6992 sed_remove_make_variables
='s,[$]([A-Za-z0-9_]*),,g'
6993 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6994 cleaned_files
=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6995 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6996 cleaned_files
=`for file in $cleaned_files; do echo " $file "; done`
6997 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6998 # such $(FOO_H) because they don't refer to distributed files.
6999 built_sources
=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
7000 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
7001 | sed -e "$sed_remove_make_variables"`
7002 distributed_built_sources
=`for file in $built_sources; do
7003 case "$cleaned_files" in
7008 tests_distributed_built_sources
=
7010 # Likewise for built files in the $testsbase directory.
7011 tests_cleaned_files
=`combine_lines < "$testdir/$testsbase/Makefile.am" \
7012 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
7013 tests_cleaned_files
=`for file in $tests_cleaned_files; do echo " $file "; done`
7014 tests_built_sources
=`combine_lines < "$testdir/$testsbase/Makefile.am" \
7015 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
7016 | sed -e "$sed_remove_make_variables"`
7017 tests_distributed_built_sources
=`for file in $tests_built_sources; do
7018 case "$tests_cleaned_files" in
7024 if test -n "$distributed_built_sources" ||
test -n "$tests_distributed_built_sources"; then
7026 .
/configure || func_exit
1
7027 if test -n "$distributed_built_sources"; then
7029 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
7030 $MAKE AUTOCONF
="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
7035 if test -n "$tests_distributed_built_sources"; then
7037 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
7038 $MAKE AUTOCONF
="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
7043 $MAKE AUTOCONF
="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
7049 if test -f build-aux
/test-driver
; then
7050 patch build-aux
/test-driver
< "$gnulib_dir"/build-aux
/test-driver.
diff \
7051 ||
patch build-aux
/test-driver
< "$gnulib_dir"/build-aux
/test-driver-1.16
.3.
diff \
7057 # func_create_megatestdir megatestdir allmodules
7059 # - local_gnulib_path from --local-dir
7060 # - modcache true or false, from --cache-modules/--no-cache-modules
7061 # - auxdir directory relative to destdir where to place build aux files
7062 func_create_megatestdir
()
7066 if test -z "$allmodules"; then
7067 allmodules
=`func_all_modules`
7071 # First, all modules one by one.
7072 for onemodule
in $allmodules; do
7073 func_create_testdir
"$megatestdir/$onemodule" $onemodule
7074 func_append megasubdirs
"$onemodule "
7076 # Then, all modules all together.
7077 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
7078 allmodules
=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
7079 func_create_testdir
"$megatestdir/ALL" "$allmodules"
7080 func_append megasubdirs
"ALL"
7083 cvsdate
=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
7084 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
7085 | sed -e 's,January,01,' -e 's,Jan,01,' \
7086 -e 's,February,02,' -e 's,Feb,02,' \
7087 -e 's,March,03,' -e 's,Mar,03,' \
7088 -e 's,April,04,' -e 's,Apr,04,' \
7090 -e 's,June,06,' -e 's,Jun,06,' \
7091 -e 's,July,07,' -e 's,Jul,07,' \
7092 -e 's,August,08,' -e 's,Aug,08,' \
7093 -e 's,September,09,' -e 's,Sep,09,' \
7094 -e 's,October,10,' -e 's,Oct,10,' \
7095 -e 's,November,11,' -e 's,Nov,11,' \
7096 -e 's,December,12,' -e 's,Dec,12,' \
7097 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
7098 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
7100 echo "CVSDATE=$cvsdate"
7101 echo ": \${MAKE=make}"
7102 echo "test -d logs || mkdir logs"
7103 echo "for module in $megasubdirs; do"
7104 echo " echo \"Working on module \$module...\""
7105 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
7106 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
7109 echo " : autobuild project... \$module"
7110 echo " : autobuild revision... cvs-\$CVSDATE-000000"
7111 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
7112 echo " : autobuild hostname... \`hostname\`"
7113 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
7115 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
7117 ) > "$megatestdir/do-autobuild"
7118 chmod a
+x
"$megatestdir/do-autobuild"
7120 # Create Makefile.am.
7121 (echo "## Process this file with automake to produce Makefile.in."
7123 echo "AUTOMAKE_OPTIONS = 1.11 foreign"
7125 echo "SUBDIRS = $megasubdirs"
7127 echo "EXTRA_DIST = do-autobuild"
7128 ) > "$megatestdir/Makefile.am"
7130 # Create configure.ac.
7131 (echo "# Process this file with autoconf to produce a configure script."
7132 echo "AC_INIT([dummy], [0])"
7133 if test "$auxdir" != "."; then
7134 echo "AC_CONFIG_AUX_DIR([$auxdir])"
7136 echo "AM_INIT_AUTOMAKE"
7138 echo "AC_PROG_MAKE_SET"
7140 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
7141 echo "AC_CONFIG_FILES([Makefile])"
7143 ) > "$megatestdir/configure.ac"
7145 # Create autogenerated files.
7147 # Do not use "${AUTORECONF} --install", because autoreconf operates
7148 # recursively, but the subdirectories are already finished, therefore
7149 # calling autoreconf here would only waste lots of CPU time.
7150 func_execute_command
${ACLOCAL} || func_exit
1
7151 func_execute_command mkdir build-aux
7152 func_execute_command
${AUTOCONF} || func_exit
1
7153 func_execute_command
${AUTOMAKE} --add-missing --copy || func_exit
1
7154 rm -rf autom4te.cache
7155 if test -f build-aux
/test-driver
; then
7156 patch build-aux
/test-driver
< "$gnulib_dir"/build-aux
/test-driver.
diff \
7157 ||
patch build-aux
/test-driver
< "$gnulib_dir"/build-aux
/test-driver-1.16
.3.
diff \
7165 func_fatal_error
"no mode specified" ;;
7172 # sed expression that converts a literal to a basic regular expression.
7173 # Needs to handle . [ \ * ^ $.
7174 sed_literal_to_basic_regex
='s/\\/\\\\/g
7178 # func_prefixed_modules_in_dir dir
7179 # outputs all module files in dir to standard output, with dir as prefix.
7180 func_prefixed_modules_in_dir
()
7182 (test -d "$1" && cd "$1" && find modules
-type f
-print |
sed -e "s|^|$1/|")
7186 if test -f "$gnulib_dir/$filename" \
7187 || func_lookup_local_file
"$filename"; then
7188 filename_anywhere_regex
=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
7189 filename_line_regex
='^'"$filename_anywhere_regex"'$'
7192 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
7193 func_path_foreach "$local_gnulib_path" func_prefixed_modules_in_dir %dir% | xargs -n 100 grep -l "$filename_anywhere_regex" /dev/null | sed -e 's,^.*/modules/,,' -e 's,\.diff$,,'
7195 | func_sanitize_modulelist \
7198 for module
in $module_candidates; do
7199 if func_get_filelist
$module |
grep "$filename_line_regex" > /dev
/null
; then
7204 func_warning
"file $filename does not exist"
7209 import | add-import | remove-import | update
)
7212 if test -z "$destdir"; then
7215 test -d "$destdir" \
7216 || func_fatal_error
"destination directory does not exist: $destdir"
7218 # Prefer configure.ac to configure.in.
7219 if test -f "$destdir"/configure.ac
; then
7220 configure_ac
="$destdir/configure.ac"
7222 if test -f "$destdir"/configure.
in; then
7223 configure_ac
="$destdir/configure.in"
7225 func_fatal_error
"cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
7229 # Analyze configure.ac.
7231 guessed_libtool
=false
7237 /AC_CONFIG_AUX_DIR/ {
7238 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
7240 /A[CM]_PROG_LIBTOOL/ {
7241 s,^.*$,guessed_libtool=true,p
7243 /AC_CONFIG_MACRO_DIR/ {
7244 s,^.*AC_CONFIG_MACRO_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_m4dirs="${guessed_m4dirs} \1",p
7246 /AC_CONFIG_MACRO_DIRS/ {
7247 s,^.*AC_CONFIG_MACRO_DIRS([[ ]*\([^]"$`\\)]*\).*$,guessed_m4dirs="${guessed_m4dirs} \1",p
7249 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
7251 if test -z "$auxdir"; then
7252 auxdir
="$guessed_auxdir"
7255 # Determine where to apply func_import.
7256 if test "$mode" = import
; then
7257 # Apply func_import to a particular gnulib directory.
7258 # The command line contains the complete specification; don't look at
7259 # the contents of gnulib-cache.m4.
7260 test -n "$supplied_libname" || supplied_libname
=true
7261 test -n "$sourcebase" || sourcebase
="lib"
7262 test -n "$m4base" || m4base
="m4"
7263 test -n "$docbase" || docbase
="doc"
7264 test -n "$testsbase" || testsbase
="tests"
7265 test -n "$macro_prefix" || macro_prefix
="gl"
7268 if test -n "$m4base"; then
7269 # Apply func_import to a particular gnulib directory.
7270 # Any number of additional modules can be given.
7271 if test ! -f "$destdir/$m4base"/gnulib-cache.
m4; then
7272 # First use of gnulib in the given m4base.
7273 test -n "$supplied_libname" || supplied_libname
=true
7274 test -n "$sourcebase" || sourcebase
="lib"
7275 test -n "$docbase" || docbase
="doc"
7276 test -n "$testsbase" || testsbase
="tests"
7277 test -n "$macro_prefix" || macro_prefix
="gl"
7281 # Apply func_import to all gnulib directories.
7282 # To get this list of directories, look at Makefile.am. (Not at
7283 # configure, because it may be omitted from version control. Also,
7284 # don't run "find $destdir -name gnulib-cache.m4", as it might be
7288 if test -f "$destdir"/Makefile.am
; then
7289 aclocal_amflags
=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
7291 for arg
in $aclocal_amflags; do
7292 if test -n "$m4dir_is_next"; then
7293 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
7297 if test -f "$destdir/$arg"/gnulib-cache.
m4; then
7298 func_append m4dirs
" $arg"
7299 m4dirs_count
=`expr $m4dirs_count + 1`
7305 if test "X$arg" = "X-I"; then
7312 for arg
in $guessed_m4dirs; do
7313 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
7317 if test -f "$destdir/$arg"/gnulib-cache.
m4; then
7318 func_append m4dirs
" $arg"
7319 m4dirs_count
=`expr $m4dirs_count + 1`
7325 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
7326 if test -f "$destdir"/aclocal.
m4; then
7327 sedexpr1
='s,^m4_include(\[\(.*\)])$,\1,p'
7328 sedexpr2
='s,^[^/]*$,.,'
7329 sedexpr3
='s,/[^/]*$,,'
7330 m4dirs
=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
7331 m4dirs
=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
7332 m4dirs_count
=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
7335 if test $m4dirs_count = 0; then
7336 # First use of gnulib in a package.
7337 # Any number of additional modules can be given.
7338 test -n "$supplied_libname" || supplied_libname
=true
7339 test -n "$sourcebase" || sourcebase
="lib"
7341 test -n "$docbase" || docbase
="doc"
7342 test -n "$testsbase" || testsbase
="tests"
7343 test -n "$macro_prefix" || macro_prefix
="gl"
7346 if test $m4dirs_count = 1; then
7347 # There's only one use of gnulib here. Assume the user means it.
7348 # Any number of additional modules can be given.
7349 for m4base
in $m4dirs; do
7353 # Ambiguous - guess what the user meant.
7354 if test $# = 0; then
7355 # No further arguments. Guess the user wants to update all of them.
7356 for m4base
in $m4dirs; do
7357 # Perform func_import in a subshell, so that variable values
7359 # local_gnulib_path, incobsolete, inc_cxx_tests,
7360 # inc_longrunning_tests, inc_privileged_tests,
7361 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
7362 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
7363 # makefile_name, tests_makefile_name, automake_subdir, libtool,
7364 # macro_prefix, po_domain, witness_c_macro, vc_files
7365 # don't propagate from one directory to another.
7366 (func_import
) || func_exit
1
7370 func_fatal_error
"Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
7379 if test -z "$destdir"; then
7380 func_fatal_error
"please specify --dir option"
7383 test -d "$destdir" \
7384 || func_fatal_error
"could not create destination directory"
7385 test -n "$auxdir" || auxdir
="build-aux"
7386 func_create_testdir
"$destdir" "$*"
7389 create-megatestdir
)
7390 if test -z "$destdir"; then
7391 func_fatal_error
"please specify --dir option"
7393 mkdir
"$destdir" || func_fatal_error
"could not create destination directory"
7394 test -n "$auxdir" || auxdir
="build-aux"
7395 func_create_megatestdir
"$destdir" "$*"
7399 test -n "$destdir" || destdir
=testdir$$
7400 mkdir
"$destdir" || func_fatal_error
"could not create destination directory"
7401 test -n "$auxdir" || auxdir
="build-aux"
7402 func_create_testdir
"$destdir" "$*"
7406 ..
/configure || func_exit
1
7407 $MAKE || func_exit
1
7408 $MAKE check || func_exit
1
7409 $MAKE distclean || func_exit
1
7410 remaining
=`find . -type f -print`
7411 if test -n "$remaining"; then
7412 echo "Remaining files:" $remaining 1>&2
7413 echo "gnulib-tool: *** Stop." 1>&2
7422 test -n "$destdir" || destdir
=testdir$$
7423 mkdir
"$destdir" || func_fatal_error
"could not create destination directory"
7424 test -n "$auxdir" || auxdir
="build-aux"
7425 func_create_megatestdir
"$destdir" "$*"
7433 remaining
=`find . -type f -print`
7434 if test -n "$remaining"; then
7435 echo "Remaining files:" $remaining 1>&2
7436 echo "gnulib-tool: *** Stop." 1>&2
7444 extract-description
)
7448 if test -n "$module"; then
7449 func_get_description
"$module"
7458 if test -n "$module"; then
7459 func_get_comment
"$module"
7468 if test -n "$module"; then
7469 func_get_status
"$module"
7478 if test -n "$module"; then
7479 func_get_notice
"$module"
7484 extract-applicability
)
7488 if test -n "$module"; then
7489 func_get_applicability
"$module"
7498 if test -n "$module"; then
7499 func_get_filelist
"$module"
7504 extract-dependencies
)
7505 if test -n "$avoidlist"; then
7506 func_fatal_error
"cannot combine --avoid and --extract-dependencies"
7511 if test -n "$module"; then
7512 func_get_dependencies
"$module"
7517 extract-recursive-dependencies
)
7518 if test -n "$avoidlist"; then
7519 func_fatal_error
"cannot combine --avoid and --extract-recursive-dependencies"
7524 if test -n "$module"; then
7525 func_get_dependencies_recursively
"$module"
7530 extract-autoconf-snippet
)
7534 if test -n "$module"; then
7535 func_get_autoconf_snippet
"$module"
7540 extract-automake-snippet
)
7544 if test -n "$module"; then
7545 func_get_automake_snippet
"$module"
7550 extract-include-directive
)
7554 if test -n "$module"; then
7555 func_get_include_directive
"$module"
7560 extract-link-directive
)
7564 if test -n "$module"; then
7565 func_get_link_directive
"$module"
7570 extract-recursive-link-directive
)
7571 if test -n "$avoidlist"; then
7572 func_fatal_error
"cannot combine --avoid and --extract-recursive-link-directive"
7577 if test -n "$module"; then
7578 func_get_link_directive_recursively
"$module"
7587 if test -n "$module"; then
7588 func_get_license
"$module"
7593 extract-maintainer
)
7597 if test -n "$module"; then
7598 func_get_maintainer
"$module"
7603 extract-tests-module
)
7607 if test -n "$module"; then
7608 func_get_tests_module
"$module"
7614 # Verify the number of arguments.
7615 if test $# -lt 1 ||
test $# -gt 2; then
7616 func_fatal_error
"invalid number of arguments for --$mode"
7619 # The first argument is the file to be copied.
7621 # Verify the file exists.
7622 func_lookup_file
"$f"
7624 # The second argument is the destination; either a directory ot a file.
7625 # It defaults to the current directory.
7627 test -n "$dest" || dest
='.'
7628 test -n "$sourcebase" || sourcebase
="lib"
7629 test -n "$m4base" || m4base
="m4"
7630 test -n "$docbase" || docbase
="doc"
7631 test -n "$testsbase" || testsbase
="tests"
7632 test -n "$auxdir" || auxdir
="build-aux"
7633 rewritten
='%REWRITTEN%'
7634 sed_rewrite_files
="\
7635 s,^build-aux/,$rewritten$auxdir/,
7636 s,^doc/,$rewritten$docbase/,
7637 s,^lib/,$rewritten$sourcebase/,
7638 s,^m4/,$rewritten$m4base/,
7639 s,^tests/,$rewritten$testsbase/,
7642 if test -d "$dest"; then
7644 g
=`echo "$f" | sed -e "$sed_rewrite_files"`
7646 destdir
=`dirname "$dest"`
7647 g
=`basename "$dest"`
7650 # Create the directory for destfile.
7651 d
=`dirname "$destdir/$g"`
7653 if test -n "$d" && test ! -d "$d"; then
7654 mkdir
-p "$d" || func_fatal_error
"failed"
7658 func_dest_tmpfilename
"$g"
7659 cp "$lookedup_file" "$tmpfile" || func_fatal_error
"failed"
7660 func_ensure_writable
"$tmpfile"
7661 already_present
=true
7662 if test -f "$destdir/$g"; then
7663 # The file already exists.
7667 # Don't protest if the file should be there but isn't: it happens
7668 # frequently that developers don't put autogenerated files under version
7676 func_fatal_error
"unknown operation mode --$mode" ;;
7679 if test "$copymode" = hardlink
-o "$lcopymode" = hardlink
; then
7680 # Setting hard links modifies the ctime of files in the gnulib checkout.
7681 # This disturbs the result of the next "gitk" invocation.
7682 # Workaround: Let git scan the files. This can be done through
7683 # "git update-index --refresh" or "git status" or "git diff".
7684 if test -d "$gnulib_dir"/.git \
7685 && (git
--version) >/dev
/null
2>/dev
/null
; then
7686 (cd "$gnulib_dir" && git update-index
--refresh >/dev
/null
)
7691 # Undo the effect of the previous 'trap' command. Some shellology:
7692 # We cannot use "trap - EXIT HUP INT QUIT PIPE TERM", because Solaris sh would
7693 # attempt to execute the command "-". "trap '' ..." is fine only for signal EXIT
7694 # (= normal exit); for the others we need to call 'exit' explicitly. The value
7695 # of $? is 128 + signal number and is set before the trap-registered command is
7698 trap 'func_exit $?' HUP INT QUIT PIPE TERM
7703 # indent-tabs-mode: nil
7704 # whitespace-check-buffer-indent: nil