3 # Copyright (C) 2002-2013 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 <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
75 if test -z "${MAKE}"; then
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # AIX 5.3 sed barfs over indented comments.
113 if echo fo | sed -e 's/f/g/
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
123 # outputs to stdout the --help usage message.
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
130 gnulib-tool --add-import [module1 ... moduleN]
131 gnulib-tool --remove-import [module1 ... moduleN]
133 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
134 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
135 gnulib-tool --test --dir=directory module1 ... moduleN
136 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
137 gnulib-tool --extract-description module
138 gnulib-tool --extract-comment module
139 gnulib-tool --extract-status module
140 gnulib-tool --extract-notice module
141 gnulib-tool --extract-applicability module
142 gnulib-tool --extract-filelist module
143 gnulib-tool --extract-dependencies module
144 gnulib-tool --extract-autoconf-snippet module
145 gnulib-tool --extract-automake-snippet module
146 gnulib-tool --extract-include-directive module
147 gnulib-tool --extract-link-directive module
148 gnulib-tool --extract-license module
149 gnulib-tool --extract-maintainer module
150 gnulib-tool --extract-tests-module module
151 gnulib-tool --copy-file file [destination]
155 --list print the available module names
156 --find find the modules which contain the specified file
157 --import import the given modules into the current package
158 --add-import augment the list of imports from gnulib into the
159 current package, by adding the given modules;
160 if no modules are specified, update the current
161 package from the current gnulib
162 --remove-import reduce the list of imports from gnulib into the
163 current package, by removing the given modules
164 --update update the current package, restore files omitted
166 --create-testdir create a scratch package with the given modules
167 --create-megatestdir create a mega scratch package with the given modules
168 one by one and all together
169 --test test the combination of the given modules
170 (recommended to use CC=\"gcc -Wall\" here)
171 --megatest test the given modules one by one and all together
172 (recommended to use CC=\"gcc -Wall\" here)
173 --extract-description extract the description
174 --extract-comment extract the comment
175 --extract-status extract the status (obsolete etc.)
176 --extract-notice extract the notice or banner
177 --extract-applicability extract the applicability
178 --extract-filelist extract the list of files
179 --extract-dependencies extract the dependencies
180 --extract-autoconf-snippet extract the snippet for configure.ac
181 --extract-automake-snippet extract the snippet for library makefile
182 --extract-include-directive extract the #include directive
183 --extract-link-directive extract the linker directive
184 --extract-license report the license terms of the source files
186 --extract-maintainer report the maintainer(s) inside gnulib
187 --extract-tests-module report the unit test module, if it exists
188 --copy-file copy a file that is not part of any module
189 --help Show this help text.
190 --version Show version and authorship information.
194 --dir=DIRECTORY Specify the target directory.
195 For --import, this specifies where your
196 configure.ac can be found. Defaults to current
198 --local-dir=DIRECTORY Specify a local override directory where to look
199 up files before looking in gnulib's directory.
200 --cache-modules Enable module caching optimization.
201 --no-cache-modules Disable module caching optimization.
202 --verbose Increase verbosity. May be repeated.
203 --quiet Decrease verbosity. May be repeated.
205 Options for --import, --add/remove-import, --update:
207 --dry-run Only print what would have been done.
209 Options for --import, --add/remove-import:
211 --with-tests Include unit tests for the included modules.
213 Options for --create-[mega]testdir, --[mega]test:
215 --without-tests Don't include unit tests for the included modules.
217 Options for --import, --add/remove-import,
218 --create-[mega]testdir, --[mega]test:
220 --with-obsolete Include obsolete modules when they occur among the
221 dependencies. By default, dependencies to obsolete
223 --with-c++-tests Include even unit tests for C++ interoperability.
224 --without-c++-tests Exclude unit tests for C++ interoperability.
225 --with-longrunning-tests
226 Include even unit tests that are long-runners.
227 --without-longrunning-tests
228 Exclude unit tests that are long-runners.
229 --with-privileged-tests
230 Include even unit tests that require root
232 --without-privileged-tests
233 Exclude unit tests that require root privileges.
234 --with-unportable-tests
235 Include even unit tests that fail on some platforms.
236 --without-unportable-tests
237 Exclude unit tests that fail on some platforms.
238 --with-all-tests Include all kinds of problematic unit tests.
239 --avoid=MODULE Avoid including the given MODULE. Useful if you
240 have code that provides equivalent functionality.
241 This option can be repeated.
242 --conditional-dependencies
243 Support conditional dependencies (may save configure
244 time and object code).
245 --no-conditional-dependencies
246 Don't use conditional dependencies.
247 --libtool Use libtool rules.
248 --no-libtool Don't use libtool rules.
250 Options for --import, --add/remove-import:
252 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
253 --source-base=DIRECTORY
254 Directory relative to --dir where source code is
255 placed (default \"lib\").
256 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
257 placed (default \"m4\").
258 --po-base=DIRECTORY Directory relative to --dir where *.po files are
259 placed (default \"po\").
260 --doc-base=DIRECTORY Directory relative to --dir where doc files are
261 placed (default \"doc\").
262 --tests-base=DIRECTORY
263 Directory relative to --dir where unit tests are
264 placed (default \"tests\").
265 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
266 tools are placed (default comes from configure.ac).
267 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
268 Also modify license template from GPL to LGPL.
269 The version number of the LGPL can be specified;
270 the default is currently LGPLv3.
271 --makefile-name=NAME Name of makefile in automake syntax in the
272 source-base and tests-base directories
273 (default \"Makefile.am\").
274 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
275 'gl_INIT'. Default is 'gl'.
276 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
277 the package name. A suffix '-gnulib' is appended.
278 --witness-c-macro=NAME Specify the C macro that is defined when the
279 sources in this directory are compiled or used.
280 --vc-files Update version control related files.
281 --no-vc-files Don't update version control related files
282 (.gitignore and/or .cvsignore).
284 Options for --create-[mega]testdir, --[mega]test:
286 --single-configure Generate a single configure file, not a separate
287 configure file for the tests directory.
289 Options for --import, --add/remove-import, --update,
290 --create-[mega]testdir, --[mega]test:
292 -s, --symbolic, --symlink Make symbolic links instead of copying files.
293 --local-symlink Make symbolic links instead of copying files, only
294 for files from the local override directory.
296 Options for --import, --add/remove-import, --update:
298 -S, --more-symlinks Make symbolic links instead of copying files, and
299 don't replace copyright notices.
301 Report bugs to <bug-gnulib@gnu.org>."
305 # outputs to stdout the --version message.
309 if test -d "$gnulib_dir"/.git \
310 && (git --version) >/dev/null 2>/dev/null \
311 && (date --version) >/dev/null 2>/dev/null; then
312 # gnulib checked out from git.
313 sed_extract_first_date='/^Date/{
317 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
318 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
319 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
320 date=`echo "$date" | sed -e "$sed_year_before_time"`
321 # Use GNU date to compute the time in GMT.
322 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
323 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
325 # gnulib copy without versioning information.
326 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
329 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
331 gnulib-tool (GNU $package $date)$version
332 Copyright (C) $year Free Software Foundation, Inc.
333 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
334 This is free software: you are free to change and redistribute it.
335 There is NO WARRANTY, to the extent permitted by law.
337 printf "Written by %s, %s, and %s.\n" "Bruno Haible" "Paul Eggert" "Simon Josefsson"
340 # func_emit_copyright_notice
341 # outputs to stdout a header for a generated file.
342 func_emit_copyright_notice ()
344 sed -n -e '/Copyright/ {
347 }' < "$self_abspathname"
349 echo "# This file is free software; you can redistribute it and/or modify"
350 echo "# it under the terms of the GNU General Public License as published by"
351 echo "# the Free Software Foundation; either version 3 of the License, or"
352 echo "# (at your option) any later version."
354 echo "# This file is distributed in the hope that it will be useful,"
355 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
356 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
357 echo "# GNU General Public License for more details."
359 echo "# You should have received a copy of the GNU General Public License"
360 echo "# along with this file. If not, see <http://www.gnu.org/licenses/>."
362 echo "# As a special exception to the GNU General Public License,"
363 echo "# this file may be distributed as part of a program that"
364 echo "# contains a configuration script generated by Autoconf, under"
365 echo "# the same distribution terms as the rest of that program."
367 echo "# Generated by gnulib-tool."
371 # exits with a given status.
372 # This function needs to be used, rather than 'exit', when a 'trap' handler is
373 # in effect that refers to $?.
380 # locates the directory where the gnulib repository lives
382 # - progname name of this program
384 # - self_abspathname absolute pathname of gnulib-tool
385 # - gnulib_dir absolute pathname of gnulib repository
389 /*) self_abspathname="$progname" ;;
390 */*) self_abspathname=`pwd`/"$progname" ;;
393 # Iterate through the elements of $PATH.
394 # We use IFS=: instead of
395 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
396 # because the latter does not work when some PATH element contains spaces.
397 # We use a canonicalized $pathx instead of $PATH, because empty PATH
398 # elements are by definition equivalent to '.', however field splitting
399 # according to IFS=: loses empty fields in many shells:
400 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
401 # beginning, at the end, and in the middle),
402 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
403 # at the beginning and at the end,
404 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
405 # Solaris lose empty fields at the end.
406 # The 'case' statement is an optimization, to avoid evaluating the
407 # explicit canonicalization command when $PATH contains no empty fields.
409 if test "${PATH_SEPARATOR+set}" != set; then
410 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
411 # contains only /bin. Note that ksh looks also at the FPATH variable,
412 # so we have to set that as well for the test.
414 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
415 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
416 || PATH_SEPARATOR=';'
419 if test "$PATH_SEPARATOR" = ";"; then
420 # On Windows, programs are searched in "." before $PATH.
423 # On Unix, we have to convert empty PATH elements to ".".
427 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
432 IFS="$PATH_SEPARATOR"
436 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
437 self_abspathname="$d/$progname"
442 if test -z "$self_abspathname"; then
443 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
447 while test -h "$self_abspathname"; do
448 # Resolve symbolic link.
449 linkval=`func_readlink "$self_abspathname"`
450 test -n "$linkval" || break
452 /* ) self_abspathname="$linkval" ;;
453 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
456 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
460 # creates a temporary directory.
462 # - progname name of this program
464 # - tmp pathname of freshly created temporary directory
467 # Use the environment variable TMPDIR, falling back to /tmp. This allows
468 # users to specify a different temporary directory, for example, if their
469 # /tmp is filled up or too small.
472 # Use the mktemp program if available. If not available, hide the error
474 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
475 test -n "$tmp" && test -d "$tmp"
478 # Use a simple mkdir command. It is guaranteed to fail if the directory
479 # already exists. $RANDOM is bash specific and expands to empty in shells
480 # other than bash, ksh and zsh. Its use does not increase security;
481 # rather, it minimizes the probability of failure in a very cluttered /tmp
483 tmp=$TMPDIR/gl$$-$RANDOM
484 (umask 077 && mkdir "$tmp")
487 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
492 # func_append var value
493 # appends the given value to the shell variable var.
494 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
495 # Use bash's += operator. It reduces complexity of appending repeatedly to
496 # a single variable from O(n^2) to O(n).
501 fast_func_append=true
505 eval "$1=\"\$$1\$2\""
507 fast_func_append=false
510 # func_remove_prefix var prefix
511 # removes the given prefix from the value of the shell variable var.
512 # var should be the name of a shell variable.
513 # Its value should not contain a newline and not start or end with whitespace.
514 # prefix should not contain the characters "$`\{}[]^|.
515 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
516 func_remove_prefix ()
520 fast_func_remove_prefix=true
522 func_remove_prefix ()
524 eval "value=\"\$$1\""
528 sed_escape_dots='s/\([.]\)/\\\1/g'
529 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
532 value=`echo "$value" | sed -e "s|^${prefix}||"`
533 eval "$1=\"\$value\""
535 fast_func_remove_prefix=false
538 # func_remove_suffix var suffix
539 # removes the given suffix from the value of the shell variable var.
540 # var should be the name of a shell variable.
541 # Its value should not contain a newline and not start or end with whitespace.
542 # suffix should not contain the characters "$`\{}[]^|.
543 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
544 func_remove_suffix ()
548 fast_func_remove_suffix=true
550 func_remove_suffix ()
552 eval "value=\"\$$1\""
556 sed_escape_dots='s/\([.]\)/\\\1/g'
557 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
560 value=`echo "$value" | sed -e "s|${suffix}\$||"`
561 eval "$1=\"\$value\""
563 fast_func_remove_suffix=false
566 # func_fatal_error message
567 # outputs to stderr a fatal error message, and terminates the program.
569 # - progname name of this program
572 echo "$progname: *** $1" 1>&2
573 echo "$progname: *** Stop." 1>&2
577 # func_warning message
578 # Outputs to stderr a warning message,
581 echo "gnulib-tool: warning: $1" 1>&2
584 # func_readlink SYMLINK
585 # outputs the target of the given symlink.
586 if (type readlink) > /dev/null 2>&1; then
589 # Use the readlink program from GNU coreutils.
595 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
596 # would do the wrong thing if the link target contains " -> ".
597 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
601 # func_relativize DIR1 DIR2
602 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
604 # - DIR1 relative pathname, relative to the current directory
605 # - DIR2 relative pathname, relative to the current directory
607 # - reldir relative pathname of DIR2, relative to DIR1
613 sed_first='s,^\([^/]*\)/.*$,\1,'
614 sed_rest='s,^[^/]*/*,,'
615 sed_last='s,^.*/\([^/]*\)$,\1,'
616 sed_butlast='s,/*[^/]*$,,'
617 while test -n "$dir1"; do
618 first=`echo "$dir1" | sed -e "$sed_first"`
619 if test "$first" != "."; then
620 if test "$first" = ".."; then
621 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
622 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
624 first2=`echo "$dir2" | sed -e "$sed_first"`
625 if test "$first2" = "$first"; then
626 dir2=`echo "$dir2" | sed -e "$sed_rest"`
630 dir0="$dir0"/"$first"
633 dir1=`echo "$dir1" | sed -e "$sed_rest"`
638 # func_relconcat DIR1 DIR2
639 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
641 # - DIR1 relative pathname, relative to the current directory
642 # - DIR2 relative pathname, relative to DIR1
644 # - relconcat DIR1/DIR2, relative to the current directory
649 sed_first='s,^\([^/]*\)/.*$,\1,'
650 sed_rest='s,^[^/]*/*,,'
651 sed_last='s,^.*/\([^/]*\)$,\1,'
652 sed_butlast='s,/*[^/]*$,,'
654 first=`echo "$dir2" | sed -e "$sed_first"`
655 if test "$first" = "."; then
656 dir2=`echo "$dir2" | sed -e "$sed_rest"`
657 if test -z "$dir2"; then
662 last=`echo "$dir1" | sed -e "$sed_last"`
663 while test "$last" = "."; do
664 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
665 last=`echo "$dir1" | sed -e "$sed_last"`
667 if test -z "$dir1"; then
671 if test "$first" = ".."; then
672 if test "$last" = ".."; then
673 relconcat="$dir1/$dir2"
676 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
677 dir2=`echo "$dir2" | sed -e "$sed_rest"`
678 if test -z "$dir1"; then
682 if test -z "$dir2"; then
687 relconcat="$dir1/$dir2"
695 # Like ln -s, except that SRC is given relative to the current directory (or
696 # absolute), not given relative to the directory of DEST.
702 *) # SRC is relative.
705 ln -s "`pwd`/$1" "$2" ;;
706 *) # DEST is relative too.
707 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
708 test -n "$ln_destdir" || ln_destdir="."
709 func_relativize "$ln_destdir" "$1"
717 # func_ln_if_changed SRC DEST
718 # Like func_ln, but avoids munging timestamps if the link is correct.
719 func_ln_if_changed ()
721 if test $# -ne 2; then
722 echo "usage: func_ln_if_changed SRC DEST" >&2
724 ln_target=`func_readlink "$2"`
725 if test -h "$2" && test "$1" = "$ln_target"; then
733 # Ensure an 'echo' command that
734 # 1. does not interpret backslashes and
735 # 2. does not print an error message "broken pipe" when writing into a pipe
738 # Test cases for problem 1:
739 # echo '\n' | wc -l prints 1 when OK, 2 when KO
740 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
741 # Test cases for problem 2:
742 # echo hi | true frequently prints
743 # "bash: echo: write error: Broken pipe"
744 # to standard error in bash 3.2.
746 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
747 # BSD echo interprets '-n' as an option, which is also not desirable).
748 # Nowadays the problem occurs in 4 situations:
749 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
750 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
751 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
752 # - in zsh, when sh-emulation is not set,
753 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
754 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
755 # - in Solaris /bin/sh and OSF/1 /bin/sh.
756 # We try the following workarounds:
757 # - for all: respawn using $CONFIG_SHELL if that is set and works.
758 # - for bash >= 2.04: unset the shell option xpg_echo.
759 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
760 # - for bash < 2.0: define echo to a function that uses cat of a here document.
761 # - for zsh: turn sh-emulation on.
762 # - for ksh: alias echo to 'print -r'.
763 # - for ksh: alias echo to a function that uses cat of a here document.
764 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
765 # the ksh workaround.
766 # - otherwise: respawn using /bin/sh and rely on the workarounds.
767 # When respawning, we pass --no-reexec as first argument, so as to avoid
768 # turning this script into a fork bomb in unlucky situations.
770 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
771 # the 'printf' built-in. See
772 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
773 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
774 # The workaround is: define echo to a function that uses the printf built-in.
776 if echo '\t' | grep t > /dev/null; then
777 have_echo=yes # Lucky!
779 # Try the workarounds.
780 # Respawn using $CONFIG_SHELL if that is set and works.
781 if test -z "$have_echo" \
782 && test "X$1" != "X--no-reexec" \
783 && test -n "$CONFIG_SHELL" \
784 && test -f "$CONFIG_SHELL" \
785 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
786 exec $CONFIG_SHELL "$0" --no-reexec "$@"
789 # For bash >= 2.04: unset the shell option xpg_echo.
790 if test -z "$have_echo" \
791 && test -n "$BASH_VERSION" \
792 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
796 # For bash >= 2.0: define echo to a function that uses the printf built-in.
797 # For bash < 2.0: define echo to a function that uses cat of a here document.
798 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
799 # Also handle problem 2, specific to bash 3.2, here.
800 if { test -z "$have_echo" \
801 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
803 && test -n "$BASH_VERSION"; then \
804 if type printf 2>/dev/null | grep / > /dev/null; then
805 # 'printf' is not a shell built-in.
813 # 'printf' is a shell built-in.
819 if echo '\t' | grep t > /dev/null; then
823 # For zsh: turn sh-emulation on.
824 if test -z "$have_echo" \
825 && test -n "$ZSH_VERSION" \
826 && (emulate sh) >/dev/null 2>&1; then
829 # For ksh: alias echo to 'print -r'.
830 if test -z "$have_echo" \
831 && (type print) >/dev/null 2>&1; then
832 # A 'print' command exists.
833 if type print 2>/dev/null | grep / > /dev/null; then
836 # 'print' is a shell built-in.
837 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
838 # 'print' is the ksh shell built-in.
839 alias echo='print -r'
843 if test -z "$have_echo" \
844 && echo '\t' | grep t > /dev/null; then
847 # For ksh: alias echo to a function that uses cat of a here document.
848 # The ksh manual page says:
849 # "Aliasing is performed when scripts are read, not while they are executed.
850 # Therefore, for an alias to take effect, the alias definition command has
851 # to be executed before the command which references the alias is read."
852 # Because of this, we have to play strange tricks with have_echo, to ensure
853 # that the top-level statement containing the test starts after the 'alias'
855 if test -z "$have_echo"; then
862 if (alias echo=bsd_echo) 2>/dev/null; then
863 alias echo=bsd_echo 2>/dev/null
866 if test -z "$have_echo" \
867 && echo '\t' | grep t > /dev/null; then
870 if test -z "$have_echo"; then
871 if (alias echo=bsd_echo) 2>/dev/null; then
872 unalias echo 2>/dev/null
875 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
876 if test -z "$have_echo" \
877 && test "X$1" != "X--no-reexec" \
878 && test -f /bin/ksh; then
879 exec /bin/ksh "$0" --no-reexec "$@"
882 # Otherwise: respawn using /bin/sh.
883 if test -z "$have_echo" \
884 && test "X$1" != "X--no-reexec" \
885 && test -f /bin/sh; then
886 exec /bin/sh "$0" --no-reexec "$@"
889 if test -z "$have_echo"; then
890 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
892 if echo '\t' | grep t > /dev/null; then
895 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
897 if test "X$1" = "X--no-reexec"; then
901 # Command-line option processing.
902 # Removes the OPTIONS from the arguments. Sets the variables:
903 # - mode one of: list, find, import, add-import, remove-import,
904 # update, create-testdir, create-megatestdir, test, megatest,
906 # - destdir from --dir
907 # - local_gnulib_dir from --local-dir
908 # - modcache true or false, from --cache-modules/--no-cache-modules
909 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
910 # - libname, supplied_libname from --lib
911 # - sourcebase from --source-base
912 # - m4base from --m4-base
913 # - pobase from --po-base
914 # - docbase from --doc-base
915 # - testsbase from --tests-base
916 # - auxdir from --aux-dir
917 # - inctests true if --with-tests was given, false if --without-tests
918 # was given, blank otherwise
919 # - incobsolete true if --with-obsolete was given, blank otherwise
920 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
921 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
923 # - inc_privileged_tests true if --with-privileged-tests was given, blank
925 # - inc_unportable_tests true if --with-unportable-tests was given, blank
927 # - inc_all_tests true if --with-all-tests was given, blank otherwise
928 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
929 # - excl_longrunning_tests true if --without-longrunning-tests was given,
931 # - excl_privileged_tests true if --without-privileged-tests was given, blank
933 # - excl_unportable_tests true if --without-unportable-tests was given, blank
935 # - single_configure true if --single-configure was given, false otherwise
936 # - avoidlist list of modules to avoid, from --avoid
937 # - cond_dependencies true if --conditional-dependencies was given, false if
938 # --no-conditional-dependencies was given, blank otherwise
939 # - lgpl yes or a number if --lgpl was given, blank otherwise
940 # - makefile_name from --makefile-name
941 # - libtool true if --libtool was given, false if --no-libtool was
942 # given, blank otherwise
943 # - macro_prefix from --macro-prefix
944 # - po_domain from --po-domain
945 # - witness_c_macro from --witness-c-macro
946 # - vc_files true if --vc-files was given, false if --no-vc-files was
947 # given, blank otherwise
948 # - autoconf_minversion minimum supported autoconf version
949 # - doit : if actions shall be executed, false if only to be printed
950 # - symbolic true if --symlink or --more-symlinks was given, blank
952 # - lsymbolic true if --local-symlink was given, blank otherwise
953 # - do_copyrights blank if --more-symlinks was given, true otherwise
971 inc_longrunning_tests=
972 inc_privileged_tests=
973 inc_unportable_tests=
976 excl_longrunning_tests=
977 excl_privileged_tests=
978 excl_unportable_tests=
979 single_configure=false
996 while test $# -gt 0; do
1001 --find | --fin | --fi | --f )
1004 --import | --impor | --impo | --imp | --im | --i )
1007 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1010 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1013 --update | --updat | --upda | --upd | --up | --u )
1016 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1019 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1020 mode=create-megatestdir
1022 --test | --tes | --te | --t )
1025 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1029 mode=`echo "X$1" | sed -e 's/^X--//'`
1031 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1036 if test $# = 0; then
1037 func_fatal_error "missing argument for --dir"
1042 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1046 if test $# = 0; then
1047 func_fatal_error "missing argument for --local-dir"
1052 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1054 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1057 --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 )
1060 --verbose | --verbos | --verbo | --verb )
1061 verbose=`expr $verbose + 1`
1063 --quiet | --quie | --qui | --qu | --q )
1064 verbose=`expr $verbose - 1`
1068 if test $# = 0; then
1069 func_fatal_error "missing argument for --lib"
1072 supplied_libname=true
1075 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1076 supplied_libname=true
1080 if test $# = 0; then
1081 func_fatal_error "missing argument for --source-base"
1086 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1090 if test $# = 0; then
1091 func_fatal_error "missing argument for --m4-base"
1096 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1100 if test $# = 0; then
1101 func_fatal_error "missing argument for --po-base"
1106 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1110 if test $# = 0; then
1111 func_fatal_error "missing argument for --doc-base"
1116 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1120 if test $# = 0; then
1121 func_fatal_error "missing argument for --tests-base"
1126 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1130 if test $# = 0; then
1131 func_fatal_error "missing argument for --aux-dir"
1136 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1138 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1141 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1144 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1147 --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)
1148 inc_longrunning_tests=true
1150 --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)
1151 inc_privileged_tests=true
1153 --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)
1154 inc_unportable_tests=true
1156 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1159 --without-tests | --without-test | --without-tes | --without-te | --without-t)
1162 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1165 --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)
1166 excl_longrunning_tests=true
1168 --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)
1169 excl_privileged_tests=true
1171 --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)
1172 excl_unportable_tests=true
1174 --single-configure | --single-configur | --single-configu | --single-config | --single-confi | --single-conf | --single-con | --single-con | --single-co | --single-c | --single- | --single | --singl | --sing | --sin | --si)
1175 single_configure=true
1179 if test $# = 0; then
1180 func_fatal_error "missing argument for --avoid"
1182 func_append avoidlist " $1"
1185 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1186 func_append avoidlist " $arg"
1188 --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)
1189 cond_dependencies=true
1191 --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)
1192 cond_dependencies=false
1198 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1201 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1207 if test $# = 0; then
1208 func_fatal_error "missing argument for --makefile-name"
1213 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1223 if test $# = 0; then
1224 func_fatal_error "missing argument for --macro-prefix"
1229 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1233 if test $# = 0; then
1234 func_fatal_error "missing argument for --po-domain"
1239 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1243 if test $# = 0; then
1244 func_fatal_error "missing argument for --witness-c-macro"
1246 witness_c_macro="$1"
1248 --witness-c-macro=* )
1249 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1257 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1258 # A no-op for backward compatibility.
1263 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1266 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1269 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1273 --help | --hel | --he | --h )
1276 --version | --versio | --versi | --vers )
1280 # Stop option processing
1284 echo "gnulib-tool: unknown option $1" 1>&2
1285 echo "Try 'gnulib-tool --help' for more information." 1>&2
1292 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1293 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1294 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1295 || test "$single_configure" != false; then
1296 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1297 echo "Try 'gnulib-tool --help' for more information." 1>&2
1301 if test "$mode" = update; then
1302 if test $# != 0; then
1303 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1304 echo "Try 'gnulib-tool --help' for more information." 1>&2
1305 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1306 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1309 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1310 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1311 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1312 || test -n "$inctests" || test -n "$incobsolete" \
1313 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1314 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1315 || test -n "$inc_all_tests" \
1316 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1317 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1318 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1319 || test -n "$macro_prefix" || test -n "$po_domain" \
1320 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1321 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1322 echo "Try 'gnulib-tool --help' for more information." 1>&2
1323 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1324 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1328 if test -n "$pobase" && test -z "$po_domain"; then
1329 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1330 echo "Try 'gnulib-tool --help' for more information." 1>&2
1333 if test -z "$pobase" && test -n "$po_domain"; then
1334 func_warning "--po-domain has no effect without a --po-base option"
1336 # Canonicalize the inctests variable.
1338 import | add-import | remove-import | update)
1339 if test -z "$inctests"; then
1343 create-testdir | create-megatestdir | test | megatest)
1344 if test -z "$inctests"; then
1349 # Now the only possible values of "$inctests" are true and false
1350 # (or blank but then it is irrelevant).
1351 if test "$cond_dependencies" = true && test "$inctests" = true; then
1352 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1356 # Determine the minimum supported autoconf version from the project's
1358 DEFAULT_AUTOCONF_MINVERSION="2.59"
1359 autoconf_minversion=
1361 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1362 && test -n "$destdir"; then
1363 if test -f "$destdir"/configure.ac; then
1364 configure_ac="$destdir/configure.ac"
1366 if test -f "$destdir"/configure.in; then
1367 configure_ac="$destdir/configure.in"
1371 if test -f configure.ac; then
1372 configure_ac="configure.ac"
1374 if test -f configure.in; then
1375 configure_ac="configure.in"
1379 if test -n "$configure_ac"; then
1380 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1381 # because when some m4 files are omitted from a version control repository,
1382 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1383 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1384 # autom4te: m4 failed with exit status: 1
1391 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1393 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1394 if test -n "$prereqs"; then
1395 autoconf_minversion=`
1396 for version in $prereqs; do echo $version; done |
1397 LC_ALL=C sort -nru | sed -e 1q
1401 if test -z "$autoconf_minversion"; then
1402 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1404 case "$autoconf_minversion" in
1405 1.* | 2.[0-4]* | 2.5[0-8]*)
1406 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1409 # Remove trailing slashes from the directory names. This is necessary for
1410 # m4base (to avoid an error in func_import) and optional for the others.
1411 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1412 case "$local_gnulib_dir" in
1413 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1415 case "$sourcebase" in
1416 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1419 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1422 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1425 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1427 case "$testsbase" in
1428 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1431 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1437 trap 'exit_status=$?
1438 if test "$signal" != 0; then
1439 echo "caught signal $signal" >&2
1442 exit $exit_status' 0
1443 for signal in 1 2 3 13 15; do
1444 trap '{ signal='$signal'; func_exit 1; }' $signal
1448 # Note: The 'eval' silences stderr output in dash.
1449 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1450 # Zsh 4 and Bash 4 have associative arrays.
1451 have_associative=true
1453 # For other shells, use 'eval' with computed shell variable names.
1454 have_associative=false
1457 # func_lookup_file file
1458 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1461 # - local_gnulib_dir from --local-dir
1463 # - lookedup_file name of the merged (combined) file
1464 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1468 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1469 lookedup_file="$local_gnulib_dir/$lkfile"
1472 if test -f "$gnulib_dir/$lkfile"; then
1473 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1474 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1475 rm -f "$tmp/$lkbase"
1476 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1477 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1478 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1479 lookedup_file="$tmp/$lkbase"
1482 lookedup_file="$gnulib_dir/$lkfile"
1486 func_fatal_error "file $gnulib_dir/$lkfile not found"
1491 # func_sanitize_modulelist
1492 # receives a list of possible module names on standard input, one per line.
1493 # It removes those which are just file names unrelated to modules, and outputs
1494 # the resulting list to standard output, one per line.
1495 func_sanitize_modulelist ()
1497 sed -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1498 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1499 -e '/^README$/d' -e '/\/README$/d' \
1500 -e '/^TEMPLATE$/d' \
1501 -e '/^TEMPLATE-EXTENDED$/d' \
1502 -e '/^TEMPLATE-TESTS$/d' \
1509 # - local_gnulib_dir from --local-dir
1512 # Filter out metainformation files like README, which are not modules.
1513 # Filter out unit test modules; they can be retrieved through
1514 # --extract-tests-module if desired.
1516 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1517 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1518 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1521 | func_sanitize_modulelist \
1522 | sed -e '/-tests$/d' \
1526 # func_exists_module module
1527 # tests whether a module, given by name, exists
1529 # - local_gnulib_dir from --local-dir
1530 func_exists_module ()
1532 { test -f "$gnulib_dir/modules/$1" \
1533 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1534 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1535 && test "ChangeLog" != "$1" \
1536 && test "COPYING" != "$1" \
1537 && test "README" != "$1" \
1538 && test "TEMPLATE" != "$1" \
1539 && test "TEMPLATE-EXTENDED" != "$1" \
1540 && test "TEMPLATE-TESTS" != "$1"
1543 # func_verify_module
1544 # verifies a module name
1546 # - local_gnulib_dir from --local-dir
1547 # - module module name argument
1548 func_verify_module ()
1550 if func_exists_module "$module"; then
1551 # OK, $module is a correct module name.
1552 # Verify that building the module description with 'patch' succeeds.
1553 func_lookup_file "modules/$module"
1555 func_warning "module $module doesn't exist"
1560 # func_verify_nontests_module
1561 # verifies a module name, excluding tests modules
1563 # - local_gnulib_dir from --local-dir
1564 # - module module name argument
1565 func_verify_nontests_module ()
1568 *-tests ) module= ;;
1569 * ) func_verify_module ;;
1573 # func_verify_tests_module
1574 # verifies a module name, considering only tests modules
1576 # - local_gnulib_dir from --local-dir
1577 # - module module name argument
1578 func_verify_tests_module ()
1581 *-tests ) func_verify_module ;;
1586 # Suffix of a sed expression that extracts a particular field from a
1587 # module description.
1588 # A field starts with a line that contains a keyword, such as 'Description',
1589 # followed by a colon and optional whitespace. All following lines, up to
1590 # the next field (or end of file if there is none) form the contents of the
1592 # An absent field is equivalent to a field with empty contents.
1593 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1594 sed_extract_prog=':[ ]*$/ {
1597 s/^Description:[ ]*$//
1601 s/^Applicability:[ ]*$//
1603 s/^Depends-on:[ ]*$//
1604 s/^configure\.ac-early:[ ]*$//
1605 s/^configure\.ac:[ ]*$//
1606 s/^Makefile\.am:[ ]*$//
1610 s/^Maintainer:[ ]*$//
1617 # Piece of a sed expression that converts a field header line to a shell
1619 # NOTE: Keep this in sync with sed_extract_prog above!
1620 sed_extract_field_header='
1621 s/^Description:[ ]*$/description/
1622 s/^Comment:[ ]*$/comment/
1623 s/^Status:[ ]*$/status/
1624 s/^Notice:[ ]*$/notice/
1625 s/^Applicability:[ ]*$/applicability/
1626 s/^Files:[ ]*$/files/
1627 s/^Depends-on:[ ]*$/dependson/
1628 s/^configure\.ac-early:[ ]*$/configureac_early/
1629 s/^configure\.ac:[ ]*$/configureac/
1630 s/^Makefile\.am:[ ]*$/makefile/
1631 s/^Include:[ ]*$/include/
1633 s/^License:[ ]*$/license/
1634 s/^Maintainer:[ ]*$/maintainer/'
1638 if $have_associative; then
1640 # Declare the associative arrays.
1641 declare -A modcache_cached
1642 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1643 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1644 eval "$declare_script"
1648 # func_cache_var module
1649 # computes the cache variable name corresponding to $module.
1650 # Note: This computation can map different module names to the same
1651 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1652 # to protect against this case.
1654 # - cachevar a shell variable name
1655 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1656 # Bash 2.0 and newer, ksh, and zsh support the syntax
1657 # ${param//pattern/replacement}
1658 # as a shorthand for
1659 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1660 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1661 eval 'func_cache_var ()
1663 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1670 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1679 # func_init_sed_convert_to_cache_statements
1681 # - modcachevar_assignment
1683 # - sed_convert_to_cache_statements
1684 func_init_sed_convert_to_cache_statements ()
1686 # 'sed' script that turns a module description into shell script
1687 # assignments, suitable to be eval'ed. All active characters are escaped.
1690 # Some module's description
1695 # modcache_description[$1]=\
1696 # 'Some module'"'"'s description
1698 # modcache_files[$1]=\
1701 # c_MODULE_description_set=set; c_MODULE_description=\
1702 # 'Some module'"'"'s description
1704 # c_MODULE_files_set=set; c_MODULE_files=\
1706 # The script consists of two parts:
1707 # 1) Ignore the lines before the first field header.
1708 # 2) A loop, treating non-field-header lines by escaping single quotes
1709 # and adding a closing quote in the last line,
1710 sed_convert_to_cache_statements="
1712 # Here we have not yet seen a field header.
1714 # See if the current line contains a field header.
1717 ${sed_extract_field_header}
1720 # No field header. Ignore the line.
1722 # Read the next line. Upon EOF, just exit.
1727 # The current line contains a field header.
1729 # Turn it into the beginning of an assignment.
1730 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1732 # Move it to the hold space. Don't print it yet,
1733 # because we want no assignment if the field is empty.
1736 # Read the next line.
1737 # Upon EOF, the field was empty. Print no assignment. Just exit.
1740 # See if the current line contains a field header.
1743 ${sed_extract_field_header}
1744 # If it is, the previous field was empty. Print no assignment.
1747 # Not a field header.
1749 # Print the previous line, held in the hold space.
1754 # Transform single quotes.
1757 # Prepend a single quote.
1762 # Move it to the hold space.
1765 # Read the next line.
1772 # See if the current line contains a field header.
1775 ${sed_extract_field_header}
1778 # Print the previous line, held in the hold space.
1783 # Transform single quotes.
1790 # Print the previous line, held in the hold space, with a single quote
1791 # to end the assignment.
1801 # Print the previous line, held in the hold space, with a single quote
1802 # to end the assignment.
1809 if ! $sed_comments; then
1811 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1812 | sed -e 's/^ *//' -e 's/^#.*//'`
1816 if $have_associative; then
1817 # sed_convert_to_cache_statements does not depend on the module.
1818 modcachevar_assignment='modcache_\1[$1]='
1819 func_init_sed_convert_to_cache_statements
1822 # func_cache_lookup_module module
1824 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1825 # of its relevant data in a cache in the memory of the processing shell. If
1826 # already cached, it does not look it up again, thus saving file access time.
1828 # - module non-empty string
1829 # Output if $have_associative:
1830 # - modcache_cached[$module] set to yes
1831 # - modcache_description[$module] ==
1832 # - modcache_status[$module] \ set to the field's value, minus the
1833 # - ... / final newline,
1834 # - modcache_maintainer[$module] == or unset if the field's value is empty
1835 # Output if ! $have_associative:
1836 # - cachevar a shell variable name
1837 # - ${cachevar}_cached set to $module
1838 # - ${cachevar}_description ==
1839 # - ${cachevar}_status \ set to the field's value, minus the
1840 # - ... / final newline,
1841 # - ${cachevar}_maintainer == or unset if the field's value is empty
1842 # - ${cachevar}_description_set ==
1843 # - ${cachevar}_status_set \ set to non-empty if the field's value
1844 # - ... / is non-empty,
1845 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1846 func_cache_lookup_module ()
1848 if $have_associative; then
1849 eval 'cached=${modcache_cached[$1]}'
1852 eval "cached=\"\$${cachevar}_cached\""
1854 if test -z "$cached"; then
1855 # Not found in cache. Look it up on the file system.
1856 func_lookup_file "modules/$1"
1857 if $have_associative; then
1858 eval 'modcache_cached[$1]=yes'
1860 eval "${cachevar}_cached=\"\$1\""
1862 if ! $have_associative; then
1863 # sed_convert_to_cache_statements depends on the module.
1864 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1865 func_init_sed_convert_to_cache_statements
1867 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1868 eval "$cache_statements"
1870 if ! $have_associative; then
1871 if test "$1" != "$cached"; then
1872 func_fatal_error "cache variable collision between $1 and $cached"
1880 # func_get_description module
1882 # - local_gnulib_dir from --local-dir
1883 # - modcache true or false, from --cache-modules/--no-cache-modules
1884 func_get_description ()
1886 if ! $modcache; then
1887 func_lookup_file "modules/$1"
1888 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1890 func_cache_lookup_module "$1"
1891 # Output the field's value, including the final newline (if any).
1892 if $have_associative; then
1893 if eval 'test -n "${modcache_description[$1]+set}"'; then
1894 eval 'echo "${modcache_description[$1]}"'
1897 eval "field_set=\"\$${cachevar}_description_set\""
1898 if test -n "$field_set"; then
1899 eval "field_value=\"\$${cachevar}_description\""
1900 echo "${field_value}"
1906 # func_get_comment module
1908 # - local_gnulib_dir from --local-dir
1909 # - modcache true or false, from --cache-modules/--no-cache-modules
1912 if ! $modcache; then
1913 func_lookup_file "modules/$1"
1914 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1916 func_cache_lookup_module "$1"
1917 # Output the field's value, including the final newline (if any).
1918 if $have_associative; then
1919 if eval 'test -n "${modcache_comment[$1]+set}"'; then
1920 eval 'echo "${modcache_comment[$1]}"'
1923 eval "field_set=\"\$${cachevar}_comment_set\""
1924 if test -n "$field_set"; then
1925 eval "field_value=\"\$${cachevar}_comment\""
1926 echo "${field_value}"
1932 # func_get_status module
1934 # - local_gnulib_dir from --local-dir
1935 # - modcache true or false, from --cache-modules/--no-cache-modules
1938 if ! $modcache; then
1939 func_lookup_file "modules/$1"
1940 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1942 func_cache_lookup_module "$1"
1943 # Output the field's value, including the final newline (if any).
1944 if $have_associative; then
1945 if eval 'test -n "${modcache_status[$1]+set}"'; then
1946 eval 'echo "${modcache_status[$1]}"'
1949 eval "field_set=\"\$${cachevar}_status_set\""
1950 if test -n "$field_set"; then
1951 eval "field_value=\"\$${cachevar}_status\""
1952 echo "${field_value}"
1958 # func_get_notice module
1960 # - local_gnulib_dir from --local-dir
1961 # - modcache true or false, from --cache-modules/--no-cache-modules
1964 if ! $modcache; then
1965 func_lookup_file "modules/$1"
1966 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1968 func_cache_lookup_module "$1"
1969 # Output the field's value, including the final newline (if any).
1970 if $have_associative; then
1971 if eval 'test -n "${modcache_notice[$1]+set}"'; then
1972 eval 'echo "${modcache_notice[$1]}"'
1975 eval "field_set=\"\$${cachevar}_notice_set\""
1976 if test -n "$field_set"; then
1977 eval "field_value=\"\$${cachevar}_notice\""
1978 echo "${field_value}"
1984 # func_get_applicability module
1986 # - local_gnulib_dir from --local-dir
1987 # - modcache true or false, from --cache-modules/--no-cache-modules
1988 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1989 func_get_applicability ()
1991 if ! $modcache; then
1992 func_lookup_file "modules/$1"
1993 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1995 func_cache_lookup_module "$1"
1996 # Get the field's value, without the final newline.
1997 if $have_associative; then
1998 eval 'my_applicability="${modcache_applicability[$1]}"'
2000 eval "my_applicability=\"\$${cachevar}_applicability\""
2003 if test -n "$my_applicability"; then
2004 echo $my_applicability
2006 # The default is 'main' or 'tests', depending on the module's name.
2008 *-tests) echo "tests";;
2014 # func_get_filelist module
2016 # - local_gnulib_dir from --local-dir
2017 # - modcache true or false, from --cache-modules/--no-cache-modules
2018 func_get_filelist ()
2020 if ! $modcache; then
2021 func_lookup_file "modules/$1"
2022 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2024 func_cache_lookup_module "$1"
2025 # Output the field's value, including the final newline (if any).
2026 if $have_associative; then
2027 if eval 'test -n "${modcache_files[$1]+set}"'; then
2028 eval 'echo "${modcache_files[$1]}"'
2031 eval "field_set=\"\$${cachevar}_files_set\""
2032 if test -n "$field_set"; then
2033 eval "field_value=\"\$${cachevar}_files\""
2034 echo "${field_value}"
2039 echo m4/gnulib-common.m4
2040 case "$autoconf_minversion" in
2047 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2048 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2049 # elements starting with prefix and ending with suffix are considered.
2050 # Processing: removed_prefix and removed_suffix are removed from each element,
2051 # added_prefix and added_suffix are added to each element.
2052 # prefix, suffix should not contain shell-special characters.
2053 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2054 # added_prefix, added_suffix should not contain the characters \|&.
2055 func_filter_filelist ()
2057 if test "$2" != "$nl" \
2058 || { $fast_func_append \
2059 && { test -z "$6" || $fast_func_remove_prefix; } \
2060 && { test -z "$7" || $fast_func_remove_suffix; }; \
2064 # Do not quote possibly-empty parameters in case patterns,
2065 # AIX and HP-UX ksh won't match them if they are empty.
2068 if test -n "$6"; then
2069 func_remove_prefix fff "$6"
2071 if test -n "$7"; then
2072 func_remove_suffix fff "$7"
2075 if test -z "$ffflist"; then
2078 func_append ffflist "$2${fff}"
2084 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2085 ffflist=`for fff in $3; do
2087 $4*$5) echo "$fff" ;;
2089 done | sed -e "$sed_fff_filter"`
2091 eval "$1=\"\$ffflist\""
2094 # func_get_dependencies module
2096 # - local_gnulib_dir from --local-dir
2097 # - modcache true or false, from --cache-modules/--no-cache-modules
2098 func_get_dependencies ()
2100 # ${module}-tests implicitly depends on ${module}, if that module exists.
2104 func_remove_suffix fgd1 '-tests'
2105 if func_exists_module "$fgd1"; then
2110 # Then the explicit dependencies listed in the module description.
2111 { if ! $modcache; then
2112 func_lookup_file "modules/$1"
2113 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2115 func_cache_lookup_module "$1"
2116 # Output the field's value, including the final newline (if any).
2117 if $have_associative; then
2118 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2119 eval 'echo "${modcache_dependson[$1]}"'
2122 eval "field_set=\"\$${cachevar}_dependson_set\""
2123 if test -n "$field_set"; then
2124 eval "field_value=\"\$${cachevar}_dependson\""
2125 echo "${field_value}"
2133 # func_get_autoconf_early_snippet module
2135 # - local_gnulib_dir from --local-dir
2136 # - modcache true or false, from --cache-modules/--no-cache-modules
2137 func_get_autoconf_early_snippet ()
2139 if ! $modcache; then
2140 func_lookup_file "modules/$1"
2141 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2143 func_cache_lookup_module "$1"
2144 # Output the field's value, including the final newline (if any).
2145 if $have_associative; then
2146 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2147 eval 'echo "${modcache_configureac_early[$1]}"'
2150 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2151 if test -n "$field_set"; then
2152 eval "field_value=\"\$${cachevar}_configureac_early\""
2153 echo "${field_value}"
2159 # func_get_autoconf_snippet module
2161 # - local_gnulib_dir from --local-dir
2162 # - modcache true or false, from --cache-modules/--no-cache-modules
2163 func_get_autoconf_snippet ()
2165 if ! $modcache; then
2166 func_lookup_file "modules/$1"
2167 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2169 func_cache_lookup_module "$1"
2170 # Output the field's value, including the final newline (if any).
2171 if $have_associative; then
2172 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2173 eval 'echo "${modcache_configureac[$1]}"'
2176 eval "field_set=\"\$${cachevar}_configureac_set\""
2177 if test -n "$field_set"; then
2178 eval "field_value=\"\$${cachevar}_configureac\""
2179 echo "${field_value}"
2185 # func_get_automake_snippet_conditional module
2186 # returns the part of the Makefile.am snippet that can be put inside Automake
2189 # - local_gnulib_dir from --local-dir
2190 # - modcache true or false, from --cache-modules/--no-cache-modules
2191 func_get_automake_snippet_conditional ()
2193 if ! $modcache; then
2194 func_lookup_file "modules/$1"
2195 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2197 func_cache_lookup_module "$1"
2198 # Output the field's value, including the final newline (if any).
2199 if $have_associative; then
2200 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2201 eval 'echo "${modcache_makefile[$1]}"'
2204 eval "field_set=\"\$${cachevar}_makefile_set\""
2205 if test -n "$field_set"; then
2206 eval "field_value=\"\$${cachevar}_makefile\""
2207 echo "${field_value}"
2213 # func_get_automake_snippet_unconditional module
2214 # returns the part of the Makefile.am snippet that must stay outside of
2215 # Automake conditionals.
2217 # - local_gnulib_dir from --local-dir
2218 # - modcache true or false, from --cache-modules/--no-cache-modules
2219 func_get_automake_snippet_unconditional ()
2223 # *-tests module live in tests/, not lib/.
2224 # Synthesize an EXTRA_DIST augmentation.
2225 all_files=`func_get_filelist $1`
2226 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2227 extra_files="$tests_files"
2228 if test -n "$extra_files"; then
2229 echo "EXTRA_DIST +=" $extra_files
2234 # Synthesize an EXTRA_DIST augmentation.
2235 sed_combine_lines='/\\$/{
2242 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2243 already_mentioned_files=` \
2244 { if ! $modcache; then
2245 func_lookup_file "modules/$1"
2246 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2248 func_cache_lookup_module "$1"
2249 if $have_associative; then
2250 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2251 eval 'echo "${modcache_makefile[$1]}"'
2254 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2255 if test -n "$field_set"; then
2256 eval 'field_value="$'"${cachevar}"'_makefile"'
2257 echo "${field_value}"
2262 | sed -e "$sed_combine_lines" \
2263 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2264 all_files=`func_get_filelist $1`
2265 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2266 # Remove $already_mentioned_files from $lib_files.
2267 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2268 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2269 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2270 if test -n "$extra_files"; then
2271 echo "EXTRA_DIST +=" $extra_files
2274 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2275 # This is necessary so that automake can generate the right list of
2277 # A possible approach would be to use autom4te --trace of the redefined
2278 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2279 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2280 # inside autoconf's built-in macros are not missed).
2281 # But it's simpler and more robust to do it here, based on the file list.
2282 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2283 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2284 # automake will generate a useless dependency; this is harmless.
2286 relocatable-prog-wrapper) ;;
2289 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2290 if test -n "$extra_files"; then
2291 echo "EXTRA_lib_SOURCES +=" $extra_files
2296 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2297 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2298 if test -n "$buildaux_files"; then
2299 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2300 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2303 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2304 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2305 if test -n "$top_files"; then
2306 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2307 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2314 # func_get_automake_snippet module
2316 # - local_gnulib_dir from --local-dir
2317 # - modcache true or false, from --cache-modules/--no-cache-modules
2318 func_get_automake_snippet ()
2320 func_get_automake_snippet_conditional "$1"
2321 func_get_automake_snippet_unconditional "$1"
2324 # func_get_include_directive module
2326 # - local_gnulib_dir from --local-dir
2327 # - modcache true or false, from --cache-modules/--no-cache-modules
2328 func_get_include_directive ()
2331 if ! $modcache; then
2332 func_lookup_file "modules/$1"
2333 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2335 func_cache_lookup_module "$1"
2336 # Output the field's value, including the final newline (if any).
2337 if $have_associative; then
2338 if eval 'test -n "${modcache_include[$1]+set}"'; then
2339 eval 'echo "${modcache_include[$1]}"'
2342 eval "field_set=\"\$${cachevar}_include_set\""
2343 if test -n "$field_set"; then
2344 eval "field_value=\"\$${cachevar}_include\""
2345 echo "${field_value}"
2349 } | sed -e 's/^\(["<]\)/#include \1/'
2352 # func_get_link_directive module
2354 # - local_gnulib_dir from --local-dir
2355 # - modcache true or false, from --cache-modules/--no-cache-modules
2356 func_get_link_directive ()
2358 if ! $modcache; then
2359 func_lookup_file "modules/$1"
2360 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2362 func_cache_lookup_module "$1"
2363 # Output the field's value, including the final newline (if any).
2364 if $have_associative; then
2365 if eval 'test -n "${modcache_link[$1]+set}"'; then
2366 eval 'echo "${modcache_link[$1]}"'
2369 eval "field_set=\"\$${cachevar}_link_set\""
2370 if test -n "$field_set"; then
2371 eval "field_value=\"\$${cachevar}_link\""
2372 echo "${field_value}"
2378 # func_get_license_raw module
2380 # - local_gnulib_dir from --local-dir
2381 # - modcache true or false, from --cache-modules/--no-cache-modules
2382 func_get_license_raw ()
2384 if ! $modcache; then
2385 func_lookup_file "modules/$1"
2386 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2388 func_cache_lookup_module "$1"
2389 # Output the field's value, including the final newline (if any).
2390 if $have_associative; then
2391 if eval 'test -n "${modcache_license[$1]+set}"'; then
2392 eval 'echo "${modcache_license[$1]}"'
2395 eval "field_set=\"\$${cachevar}_license_set\""
2396 if test -n "$field_set"; then
2397 eval "field_value=\"\$${cachevar}_license\""
2398 echo "${field_value}"
2404 # func_get_license module
2406 # - local_gnulib_dir from --local-dir
2407 # - modcache true or false, from --cache-modules/--no-cache-modules
2410 # Warn if the License field is missing.
2414 license=`func_get_license_raw "$1"`
2415 if test -z "$license"; then
2416 func_warning "module $1 lacks a License"
2421 func_get_license_raw "$1"
2422 # The default is GPL.
2424 } | sed -e 's,^ *$,,' | sed -e 1q
2427 # func_get_maintainer module
2429 # - local_gnulib_dir from --local-dir
2430 # - modcache true or false, from --cache-modules/--no-cache-modules
2431 func_get_maintainer ()
2433 if ! $modcache; then
2434 func_lookup_file "modules/$1"
2435 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2437 func_cache_lookup_module "$1"
2438 # Output the field's value, including the final newline (if any).
2439 if $have_associative; then
2440 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2441 eval 'echo "${modcache_maintainer[$1]}"'
2444 eval "field_set=\"\$${cachevar}_maintainer_set\""
2445 if test -n "$field_set"; then
2446 eval "field_value=\"\$${cachevar}_maintainer\""
2447 echo "${field_value}"
2453 # func_get_tests_module module
2455 # - local_gnulib_dir from --local-dir
2456 func_get_tests_module ()
2458 # The naming convention for tests modules is hardwired: ${module}-tests.
2459 if test -f "$gnulib_dir/modules/$1"-tests \
2460 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2461 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2466 # func_acceptable module
2467 # tests whether a module is acceptable.
2469 # - avoidlist list of modules to avoid
2472 for avoid in $avoidlist; do
2473 if test "$avoid" = "$1"; then
2480 # sed expression to keep the first 32 characters of each line.
2481 sed_first_32_chars='s/^\(................................\).*/\1/'
2483 # func_module_shellfunc_name module
2484 # computes the shell function name that will contain the m4 macros for the module.
2486 # - macro_prefix prefix to use
2488 # - shellfunc shell function name
2489 func_module_shellfunc_name ()
2493 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2495 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2499 # func_module_shellvar_name module
2500 # computes the shell variable name the will be set to true once the m4 macros
2501 # for the module have been executed.
2503 # - shellvar shell variable name
2504 func_module_shellvar_name ()
2508 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2510 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2514 # func_module_conditional_name module
2515 # computes the automake conditional name for the module.
2517 # - conditional name of automake conditional
2518 func_module_conditional_name ()
2522 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2524 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2528 # func_uncond_add_module B
2529 # notes the presence of B as an unconditional module.
2531 # func_conddep_add_module A B cond
2532 # notes the presence of a conditional dependency from module A to module B,
2533 # subject to the condition that A is enabled and cond is true.
2535 # func_cond_module_p B
2536 # tests whether module B is conditional.
2538 # func_cond_module_condition A B
2539 # returns the condition when B should be enabled as a dependency of A, once the
2540 # m4 code for A has been executed.
2541 # Output: - condition
2543 if $have_associative; then
2544 declare -A conddep_isuncond
2545 declare -A conddep_dependers
2546 declare -A conddep_condition
2547 func_uncond_add_module ()
2549 eval 'conddep_isuncond[$1]=true'
2550 eval 'unset conddep_dependers[$1]'
2552 func_conddep_add_module ()
2554 eval 'isuncond="${conddep_isuncond[$2]}"'
2555 if test -z "$isuncond"; then
2556 # No unconditional dependency to B known at this point.
2557 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2558 eval 'conddep_condition[$1---$2]="$3"'
2561 func_cond_module_p ()
2563 eval 'previous_dependers="${conddep_dependers[$1]}"'
2564 test -n "$previous_dependers"
2566 func_cond_module_condition ()
2568 eval 'condition="${conddep_condition[$1---$2]}"'
2571 func_uncond_add_module ()
2575 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2579 eval 'conddep_isuncond_'"$suffix"'=true'
2580 eval 'unset conddep_dependers_'"$suffix"
2582 func_conddep_add_module ()
2586 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2590 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2591 if test -z "$isuncond"; then
2592 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2593 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2594 eval 'conddep_condition_'"$suffix"'="$3"'
2597 func_cond_module_p ()
2601 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2605 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2606 test -n "$previous_dependers"
2608 func_cond_module_condition ()
2610 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2611 eval 'condition="${conddep_condition_'"$suffix"'}"'
2615 sed_dependencies_without_conditions='s/ *\[.*//'
2617 # func_modules_transitive_closure
2619 # - local_gnulib_dir from --local-dir
2620 # - modcache true or false, from --cache-modules/--no-cache-modules
2621 # - modules list of specified modules
2622 # - inctests true if tests should be included, false otherwise
2623 # - incobsolete true if obsolete modules among dependencies should be
2624 # included, blank otherwise
2625 # - inc_cxx_tests true if C++ interoperability tests should be included,
2627 # - inc_longrunning_tests true if long-runnings tests should be included,
2629 # - inc_privileged_tests true if tests that require root privileges should be
2630 # included, blank otherwise
2631 # - inc_unportable_tests true if tests that fail on some platforms should be
2632 # included, blank otherwise
2633 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2634 # the unit tests of the specified modules should be
2635 # included, blank otherwise
2636 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2637 # the unit tests of the dependencies should be
2638 # included, blank otherwise
2639 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2641 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2643 # - excl_privileged_tests true if tests that require root privileges should be
2644 # excluded, blank otherwise
2645 # - excl_unportable_tests true if tests that fail on some platforms should be
2646 # excluded, blank otherwise
2647 # - avoidlist list of modules to avoid
2648 # - cond_dependencies true if conditional dependencies shall be supported,
2650 # - tmp pathname of a temporary directory
2652 # - modules list of modules, including dependencies
2653 # - conddep_dependers, conddep_condition information about conditionally
2655 func_modules_transitive_closure ()
2657 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2658 # In order to process every module only once (for speed), process an "input
2659 # list" of modules, producing an "output list" of modules. During each round,
2660 # more modules can be queued in the input list. Once a module on the input
2661 # list has been processed, it is added to the "handled list", so we can avoid
2662 # to process it again.
2664 inmodules="$modules"
2666 fmtc_inc_all_tests="$inc_all_direct_tests"
2667 if test "$cond_dependencies" = true; then
2668 for module in $inmodules; do
2670 if test -n "$module"; then
2671 if func_acceptable $module; then
2672 func_uncond_add_module $module
2677 while test -n "$inmodules"; do
2678 inmodules_this_round="$inmodules"
2679 inmodules= # Accumulator, queue for next round
2680 for module in $inmodules_this_round; do
2682 if test -n "$module"; then
2683 if func_acceptable $module; then
2684 func_append outmodules " $module"
2685 if test "$cond_dependencies" = true; then
2686 if func_get_automake_snippet_conditional $module | grep '^if ' > /dev/null; then
2687 # A module whose Makefile.am snippet contains a reference to an
2688 # automake conditional. If we were to use it conditionally, we
2689 # would get an error
2690 # configure: error: conditional "..." was never defined.
2691 # because automake 1.11.1 does not handle nested conditionals
2692 # correctly. As a workaround, make the module unconditional.
2693 func_uncond_add_module $module
2695 if func_cond_module_p $module; then
2701 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2702 # Duplicate dependencies are harmless, but Jim wants a warning.
2703 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2704 if test -n "$duplicated_deps"; then
2705 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2708 testsmodule=`func_get_tests_module $module`
2709 if test -n "$testsmodule"; then
2710 deps="$deps $testsmodule"
2713 for dep in $deps; do
2714 # Determine whether to include the dependency or tests module.
2716 for word in `func_get_status $dep`; do
2719 test -n "$incobsolete" \
2723 test -z "$excl_cxx_tests" \
2725 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2729 test -z "$excl_longrunning_tests" \
2731 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2735 test -z "$excl_privileged_tests" \
2737 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2741 test -z "$excl_unportable_tests" \
2743 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2747 test -n "$fmtc_inc_all_tests" \
2752 if $inc && func_acceptable "$dep"; then
2753 func_append inmodules " $dep"
2754 if test "$cond_dependencies" = true; then
2755 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2756 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2759 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2760 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2762 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2763 if test "$condition" = true; then
2766 if test -n "$condition"; then
2767 func_conddep_add_module "$module" "$dep" "$condition"
2769 if $conditional; then
2770 func_conddep_add_module "$module" "$dep" true
2772 func_uncond_add_module "$dep"
2781 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2782 # Remove $handledmodules from $inmodules.
2783 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2784 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2785 fmtc_inc_all_tests="$inc_all_indirect_tests"
2787 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2788 rm -f "$tmp"/queued-modules
2791 # func_show_module_list
2793 # - specified_modules list of specified modules (one per line, sorted)
2794 # - modules complete list of modules (one per line, sorted)
2795 # - tmp pathname of a temporary directory
2796 func_show_module_list ()
2802 # Assume xterm compatible escape sequences.
2803 bold_on=`printf '\x1b[1m'`
2804 bold_off=`printf '\x1b[0m'`
2809 echo "Module list with included dependencies (indented):"
2810 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2811 echo "$modules" | sed -e '/^$/d' \
2812 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2813 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2816 # func_modules_transitive_closure_separately
2817 # Determine main module list and tests-related module list separately.
2818 # The main module list is the transitive closure of the specified modules,
2819 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2820 # is specified, it will consist only of LGPLed source.
2821 # The tests-related module list is the transitive closure of the specified
2822 # modules, including tests modules, minus the main module list excluding
2823 # modules of applicability 'all'. Its lib/* sources (brought in through
2824 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2825 # source, even if --lgpl is specified.
2827 # - local_gnulib_dir from --local-dir
2828 # - modcache true or false, from --cache-modules/--no-cache-modules
2829 # - specified_modules list of specified modules
2830 # - inctests true if tests should be included, false otherwise
2831 # - incobsolete true if obsolete modules among dependencies should be
2832 # included, blank otherwise
2833 # - inc_cxx_tests true if C++ interoperability tests should be included,
2835 # - inc_longrunning_tests true if long-runnings tests should be included,
2837 # - inc_privileged_tests true if tests that require root privileges should be
2838 # included, blank otherwise
2839 # - inc_unportable_tests true if tests that fail on some platforms should be
2840 # included, blank otherwise
2841 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2842 # the unit tests of the specified modules should be
2843 # included, blank otherwise
2844 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2845 # the unit tests of the dependencies should be
2846 # included, blank otherwise
2847 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2849 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2851 # - excl_privileged_tests true if tests that require root privileges should be
2852 # excluded, blank otherwise
2853 # - excl_unportable_tests true if tests that fail on some platforms should be
2854 # excluded, blank otherwise
2855 # - avoidlist list of modules to avoid
2856 # - cond_dependencies true if conditional dependencies shall be supported,
2858 # - tmp pathname of a temporary directory
2860 # - main_modules list of modules, including dependencies
2861 # - testsrelated_modules list of tests-related modules, including dependencies
2862 # - conddep_dependers, conddep_condition information about conditionally
2864 func_modules_transitive_closure_separately ()
2866 # Determine main module list.
2867 saved_inctests="$inctests"
2869 modules="$specified_modules"
2870 func_modules_transitive_closure
2871 main_modules="$modules"
2872 inctests="$saved_inctests"
2873 if test $verbose -ge 1; then
2874 echo "Main module list:"
2875 echo "$main_modules" | sed -e 's/^/ /'
2877 # Determine tests-related module list.
2878 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2879 testsrelated_modules=`for module in $main_modules; do
2880 if test \`func_get_applicability $module\` = main; then
2884 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2885 if test $verbose -ge 1; then
2886 echo "Tests-related module list:"
2887 echo "$testsrelated_modules" | sed -e 's/^/ /'
2891 # func_determine_use_libtests
2892 # Determines whether a $testsbase/libtests.a is needed.
2894 # - local_gnulib_dir from --local-dir
2895 # - modcache true or false, from --cache-modules/--no-cache-modules
2896 # - testsrelated_modules list of tests-related modules, including dependencies
2898 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2899 func_determine_use_libtests ()
2902 for module in $testsrelated_modules; do
2903 func_verify_nontests_module
2904 if test -n "$module"; then
2905 all_files=`func_get_filelist $module`
2906 # Test whether some file in $all_files lies in lib/.
2907 for f in $all_files; do
2919 # func_modules_add_dummy
2921 # - local_gnulib_dir from --local-dir
2922 # - modcache true or false, from --cache-modules/--no-cache-modules
2923 # - modules list of modules, including dependencies
2925 # - modules list of modules, including 'dummy' if needed
2926 func_modules_add_dummy ()
2928 # Determine whether any module provides a lib_SOURCES augmentation.
2930 sed_remove_backslash_newline=':a
2937 for module in $modules; do
2938 func_verify_nontests_module
2939 if test -n "$module"; then
2940 # Extract the value of "lib_SOURCES += ...".
2941 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2942 # Ignore .h files since they are not compiled.
2946 have_lib_SOURCES=yes
2953 # Add the dummy module, to make sure the library will be non-empty.
2954 if test -z "$have_lib_SOURCES"; then
2955 if func_acceptable "dummy"; then
2956 func_append modules " dummy"
2961 # func_modules_add_dummy_separately
2963 # - local_gnulib_dir from --local-dir
2964 # - modcache true or false, from --cache-modules/--no-cache-modules
2965 # - main_modules list of modules, including dependencies
2966 # - testsrelated_modules list of tests-related modules, including dependencies
2967 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2969 # - main_modules list of modules, including 'dummy' if needed
2970 # - testsrelated_modules list of tests-related modules, including 'dummy' if
2972 func_modules_add_dummy_separately ()
2974 # Add the dummy module to the main module list if needed.
2975 modules="$main_modules"
2976 func_modules_add_dummy
2977 main_modules="$modules"
2979 # Add the dummy module to the tests-related module list if needed.
2980 if $use_libtests; then
2981 modules="$testsrelated_modules"
2982 func_modules_add_dummy
2983 testsrelated_modules="$modules"
2987 # func_modules_notice
2989 # - local_gnulib_dir from --local-dir
2990 # - modcache true or false, from --cache-modules/--no-cache-modules
2991 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2992 # - modules list of modules, including dependencies
2993 func_modules_notice ()
2995 if test $verbose -ge -1; then
2996 for module in $modules; do
2998 if test -n "$module"; then
2999 msg=`func_get_notice $module`
3000 if test -n "$msg"; then
3001 echo "Notice from module $module:"
3002 echo "$msg" | sed -e 's/^/ /'
3009 # func_modules_to_filelist
3011 # - local_gnulib_dir from --local-dir
3012 # - modcache true or false, from --cache-modules/--no-cache-modules
3013 # - modules list of modules, including dependencies
3015 # - files list of files
3016 func_modules_to_filelist ()
3019 for module in $modules; do
3021 if test -n "$module"; then
3022 fs=`func_get_filelist $module`
3023 func_append files " $fs"
3026 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3029 # func_modules_to_filelist_separately
3030 # Determine the final file lists.
3031 # They must be computed separately, because files in lib/* go into
3032 # $sourcebase/ if they are in the main file list but into $testsbase/
3033 # if they are in the tests-related file list. Furthermore lib/dummy.c
3036 # - local_gnulib_dir from --local-dir
3037 # - modcache true or false, from --cache-modules/--no-cache-modules
3038 # - main_modules list of modules, including dependencies
3039 # - testsrelated_modules list of tests-related modules, including dependencies
3040 func_modules_to_filelist_separately ()
3042 # Determine final main file list.
3043 modules="$main_modules"
3044 func_modules_to_filelist
3046 # Determine final tests-related file list.
3047 modules="$testsrelated_modules"
3048 func_modules_to_filelist
3049 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3050 # Merge both file lists.
3051 sed_remove_empty_lines='/^$/d'
3052 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3053 if test $verbose -ge 0; then
3055 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3056 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3060 # func_compute_include_guard_prefix
3061 # Determine include_guard_prefix.
3063 # - macro_prefix prefix of gl_LIBOBJS macros to use
3065 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3066 # - sed_replace_include_guard_prefix
3067 # sed expression for resolving ${gl_include_guard_prefix}
3068 func_compute_include_guard_prefix ()
3070 if test "$macro_prefix" = gl; then
3071 include_guard_prefix='GL'
3073 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3075 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3078 # func_execute_command command [args...]
3079 # Executes a command.
3080 # Uses also the variables
3081 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3082 func_execute_command ()
3084 if test $verbose -ge 0; then
3088 # Commands like automake produce output to stderr even when they succeed.
3089 # Turn this output off if the command succeeds.
3090 "$@" > "$tmp"/cmdout 2>&1
3092 if test $cmdret = 0; then
3096 cat "$tmp"/cmdout 1>&2
3103 # func_dest_tmpfilename file
3104 # determines the name of a temporary file (file is relative to destdir).
3106 # - destdir target directory
3107 # - doit : if actions shall be executed, false if only to be printed
3108 # - tmp pathname of a temporary directory
3110 # - tmpfile absolute filename of the temporary file
3111 func_dest_tmpfilename ()
3114 # Put the new contents of $file in a file in the same directory (needed
3115 # to guarantee that an 'mv' to "$destdir/$file" works).
3116 tmpfile="$destdir/$1.tmp"
3118 # Put the new contents of $file in a file in a temporary directory
3119 # (because the directory of "$file" might not exist).
3120 tmpfile="$tmp"/`basename "$1"`.tmp
3125 # copies a file from gnulib into the destination directory. The destination
3126 # is known to not exist.
3128 # - destdir target directory
3129 # - local_gnulib_dir from --local-dir
3130 # - modcache true or false, from --cache-modules/--no-cache-modules
3131 # - f the original file name
3132 # - lookedup_file name of the merged (combined) file
3133 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3134 # - g the rewritten file name
3135 # - tmpfile absolute filename of the temporary file
3136 # - doit : if actions shall be executed, false if only to be printed
3137 # - symbolic true if files should be symlinked, copied otherwise
3138 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3143 echo "Copying file $g"
3144 if { test -n "$symbolic" \
3145 || { test -n "$lsymbolic" \
3146 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3147 && test -z "$lookedup_tmp" \
3148 && cmp -s "$lookedup_file" "$tmpfile"; then
3149 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3151 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3159 # copies a file from gnulib into the destination directory. The destination
3160 # is known to exist.
3162 # - destdir target directory
3163 # - local_gnulib_dir from --local-dir
3164 # - modcache true or false, from --cache-modules/--no-cache-modules
3165 # - f the original file name
3166 # - lookedup_file name of the merged (combined) file
3167 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3168 # - g the rewritten file name
3169 # - tmpfile absolute filename of the temporary file
3170 # - doit : if actions shall be executed, false if only to be printed
3171 # - symbolic true if files should be symlinked, copied otherwise
3172 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3174 # - already_present nonempty if the file should already exist, empty otherwise
3177 if cmp -s "$destdir/$g" "$tmpfile"; then
3178 : # The file has not changed.
3182 if test -n "$already_present"; then
3183 echo "Updating file $g (backup in ${g}~)"
3185 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3187 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3188 if { test -n "$symbolic" \
3189 || { test -n "$lsymbolic" \
3190 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3191 && test -z "$lookedup_tmp" \
3192 && cmp -s "$lookedup_file" "$tmpfile"; then
3193 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3195 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3198 if test -n "$already_present"; then
3199 echo "Update file $g (backup in ${g}~)"
3201 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3207 # func_emit_lib_Makefile_am
3208 # emits the contents of library makefile to standard output.
3210 # - local_gnulib_dir from --local-dir
3211 # - modcache true or false, from --cache-modules/--no-cache-modules
3212 # - modules list of modules, including dependencies
3213 # - libname library name
3214 # - pobase directory relative to destdir where to place *.po files
3215 # - auxdir directory relative to destdir where to place build aux files
3216 # - makefile_name from --makefile-name
3217 # - libtool true if libtool will be used, false or blank otherwise
3218 # - macro_prefix prefix of gl_LIBOBJS macros to use
3219 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3220 # - witness_c_macro from --witness-c-macro
3221 # - actioncmd (optional) command that will reproduce this invocation
3222 # - for_test true if creating a package for testing, false otherwise
3223 # - sed_replace_include_guard_prefix
3224 # sed expression for resolving ${gl_include_guard_prefix}
3225 # - destfile filename relative to destdir of makefile being generated
3227 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3228 # list of edits to be done to Makefile.am variables
3230 # - uses_subdirs nonempty if object files in subdirs exist
3231 func_emit_lib_Makefile_am ()
3233 # When creating an includable Makefile.am snippet, augment variables with
3234 # += instead of assigning them.
3235 if test -n "$makefile_name"; then
3240 if test "$libtool" = true; then
3243 sed_eliminate_LDFLAGS="$sed_noop"
3247 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3250 # When creating a package for testing: Attempt to provoke failures,
3251 # especially link errors, already during "make" rather than during
3252 # "make check", because "make check" is not possible in a cross-compiling
3253 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3254 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3256 sed_transform_check_PROGRAMS="$sed_noop"
3258 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3259 echo "## Process this file with automake to produce Makefile.in."
3260 func_emit_copyright_notice
3261 if test -n "$actioncmd"; then
3262 # The maximum line length (excluding the terminating newline) of any file
3263 # that is to be preprocessed by config.status is 3070. config.status uses
3264 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3265 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3266 len=`echo "$actioncmd" | wc -c`
3267 if test -n "$len" && test "$len" -le 3000; then
3268 echo "# Reproduce by: $actioncmd"
3274 for module in $modules; do
3275 func_verify_nontests_module
3276 if test -n "$module"; then
3278 func_get_automake_snippet_conditional "$module" |
3280 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3281 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3282 -e "$sed_eliminate_LDFLAGS" \
3283 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3284 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3285 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3286 -e "$sed_transform_check_PROGRAMS" \
3287 -e "$sed_replace_include_guard_prefix"
3288 if test "$module" = 'alloca'; then
3289 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3290 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3292 } > "$tmp"/amsnippet1
3294 func_get_automake_snippet_unconditional "$module" |
3295 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3296 } > "$tmp"/amsnippet2
3297 # Skip the contents if it's entirely empty.
3298 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3299 echo "## begin gnulib module $module"
3301 if test "$cond_dependencies" = true; then
3302 if func_cond_module_p "$module"; then
3303 func_module_conditional_name "$module"
3304 echo "if $conditional"
3307 cat "$tmp"/amsnippet1
3308 if test "$cond_dependencies" = true; then
3309 if func_cond_module_p "$module"; then
3313 cat "$tmp"/amsnippet2
3314 echo "## end gnulib module $module"
3317 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3318 # Test whether there are some source files in subdirectories.
3319 for f in `func_get_filelist "$module"`; do
3329 } > "$tmp"/allsnippets
3330 if test -z "$makefile_name"; then
3331 # If there are source files in subdirectories, prevent collision of the
3332 # object files (example: hash.c and libxml/hash.c).
3334 if test -n "$uses_subdirs"; then
3335 subdir_options=' subdir-objects'
3337 echo "AUTOMAKE_OPTIONS = 1.9.6 gnits${subdir_options}"
3340 if test -z "$makefile_name"; then
3342 echo "noinst_HEADERS ="
3343 echo "noinst_LIBRARIES ="
3344 echo "noinst_LTLIBRARIES ="
3345 # Automake versions < 1.11.4 create an empty pkgdatadir at
3346 # installation time if you specify pkgdata_DATA to empty.
3347 # See automake bugs #10997 and #11030:
3348 # * http://debbugs.gnu.org/10997
3349 # * http://debbugs.gnu.org/11030
3350 # So we need this workaround.
3351 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3352 echo "pkgdata_DATA ="
3355 echo "BUILT_SOURCES ="
3358 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3359 if test -z "$makefile_name"; then
3360 echo "MOSTLYCLEANDIRS ="
3362 echo "DISTCLEANFILES ="
3363 echo "MAINTAINERCLEANFILES ="
3365 # Execute edits that apply to the Makefile.am being generated.
3367 while test $edit != $makefile_am_edits; do
3368 edit=`expr $edit + 1`
3369 eval dir=\"\$makefile_am_edit${edit}_dir\"
3370 eval var=\"\$makefile_am_edit${edit}_var\"
3371 eval val=\"\$makefile_am_edit${edit}_val\"
3372 if test -n "$var"; then
3373 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3374 echo "${var} += ${val}"
3375 eval "makefile_am_edit${edit}_var="
3379 if test -n "$witness_c_macro"; then
3380 cppflags_part1=" -D$witness_c_macro=1"
3385 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3389 if test -z "$makefile_name"; then
3391 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3394 if test -n "$cppflags_part1$cppflags_part2"; then
3396 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3400 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3401 || { test -n "$makefile_name" \
3402 && test -f "$sourcebase/Makefile.am" \
3403 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3405 # One of the snippets or the user's Makefile.am already specifies an
3406 # installation location for the library. Don't confuse automake by saying
3407 # it should not be installed.
3410 # By default, the generated library should not be installed.
3411 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3414 echo "${libname}_${libext}_SOURCES ="
3415 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3416 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3417 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3418 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3419 echo "EXTRA_${libname}_${libext}_SOURCES ="
3420 if test "$libtool" = true; then
3421 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3422 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3423 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3424 # the link dependencies of all modules.
3425 for module in $modules; do
3426 func_verify_nontests_module
3427 if test -n "$module"; then
3428 func_get_link_directive "$module"
3431 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3432 | LC_ALL=C sort -u \
3433 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3436 if test -n "$pobase"; then
3437 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3440 cat "$tmp"/allsnippets \
3441 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3443 echo "mostlyclean-local: mostlyclean-generic"
3444 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3445 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3446 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3450 rm -f "$tmp"/allsnippets
3453 # func_emit_po_Makevars
3454 # emits the contents of po/ makefile parameterization to standard output.
3456 # - local_gnulib_dir from --local-dir
3457 # - modcache true or false, from --cache-modules/--no-cache-modules
3458 # - sourcebase directory relative to destdir where to place source code
3459 # - pobase directory relative to destdir where to place *.po files
3460 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3461 func_emit_po_Makevars ()
3463 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3464 func_emit_copyright_notice
3466 echo "# Usually the message domain is the same as the package name."
3467 echo "# But here it has a '-gnulib' suffix."
3468 echo "DOMAIN = ${po_domain}-gnulib"
3470 echo "# These two variables depend on the location of this directory."
3471 echo "subdir = ${pobase}"
3472 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3475 # These options get passed to xgettext.
3476 XGETTEXT_OPTIONS = \
3477 --keyword=_ --flag=_:1:pass-c-format \
3478 --keyword=N_ --flag=N_:1:pass-c-format \
3479 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3480 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3481 --flag=error:3:c-format --flag=error_at_line:5:c-format
3483 # This is the copyright holder that gets inserted into the header of the
3484 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3485 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3487 # This is the email address or URL to which the translators shall report
3488 # bugs in the untranslated strings:
3489 # - Strings which are not entire sentences, see the maintainer guidelines
3490 # in the GNU gettext documentation, section 'Preparing Strings'.
3491 # - Strings which use unclear terms or require additional context to be
3493 # - Strings which make invalid assumptions about notation of date, time or
3495 # - Pluralisation problems.
3496 # - Incorrect English spelling.
3497 # - Incorrect formatting.
3498 # It can be your email address, or a mailing list address where translators
3499 # can write to without being subscribed, or the URL of a web page through
3500 # which the translators can contact you.
3501 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3503 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3504 # message catalogs shall be used. It is usually empty.
3505 EXTRA_LOCALE_CATEGORIES =
3507 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3508 # context. Possible values are "yes" and "no". Set this to yes if the
3509 # package uses functions taking also a message context, like pgettext(), or
3510 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3515 # func_emit_po_POTFILES_in
3516 # emits the file list to be passed to xgettext to standard output.
3518 # - local_gnulib_dir from --local-dir
3519 # - modcache true or false, from --cache-modules/--no-cache-modules
3520 # - sourcebase directory relative to destdir where to place source code
3521 # - files list of new files
3522 func_emit_po_POTFILES_in ()
3524 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3525 func_emit_copyright_notice
3527 echo "# List of files which contain translatable strings."
3528 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3531 # func_emit_tests_Makefile_am witness_macro
3532 # emits the contents of tests makefile to standard output.
3534 # - local_gnulib_dir from --local-dir
3535 # - modcache true or false, from --cache-modules/--no-cache-modules
3536 # - modules list of modules, including dependencies
3537 # - libname library name
3538 # - auxdir directory relative to destdir where to place build aux files
3539 # - makefile_name from --makefile-name
3540 # - libtool true if libtool will be used, false or blank otherwise
3541 # - sourcebase relative directory containing lib source code
3542 # - m4base relative directory containing autoconf macros
3543 # - testsbase relative directory containing unit test code
3544 # - macro_prefix prefix of gl_LIBOBJS macros to use
3545 # - witness_c_macro from --witness-c-macro
3546 # - for_test true if creating a package for testing, false otherwise
3547 # - single_configure true if a single configure file should be generated,
3548 # false for a separate configure file for the tests
3549 # - use_libtests true if a libtests.a should be built, false otherwise
3550 # - sed_replace_include_guard_prefix
3551 # sed expression for resolving ${gl_include_guard_prefix}
3552 # - destfile filename relative to destdir of makefile being generated
3554 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3555 # list of edits to be done to Makefile.am variables
3557 # - uses_subdirs nonempty if object files in subdirs exist
3558 func_emit_tests_Makefile_am ()
3561 if test "$libtool" = true; then
3564 sed_eliminate_LDFLAGS="$sed_noop"
3568 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3571 # When creating a package for testing: Attempt to provoke failures,
3572 # especially link errors, already during "make" rather than during
3573 # "make check", because "make check" is not possible in a cross-compiling
3574 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3575 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3577 sed_transform_check_PROGRAMS="$sed_noop"
3579 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3580 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3581 echo "## Process this file with automake to produce Makefile.in."
3582 func_emit_copyright_notice
3586 for module in $modules; do
3587 if $for_test && ! $single_configure; then
3588 func_verify_tests_module
3592 if test -n "$module"; then
3594 func_get_automake_snippet "$module" |
3596 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3597 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3598 -e "$sed_eliminate_LDFLAGS" \
3599 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3600 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3601 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3602 -e "$sed_transform_check_PROGRAMS" \
3603 -e "$sed_replace_include_guard_prefix"
3604 if $use_libtests && test "$module" = 'alloca'; then
3605 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3606 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3608 } > "$tmp"/amsnippet
3609 # Skip the contents if it's entirely empty.
3610 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3611 # Mention long-running tests at the end.
3613 for word in `func_get_status "$module"`; do
3614 if test "$word" = 'longrunning-test'; then
3619 { echo "## begin gnulib module $module"
3621 cat "$tmp"/amsnippet
3622 echo "## end gnulib module $module"
3626 rm -f "$tmp"/amsnippet
3627 # Test whether there are some source files in subdirectories.
3628 for f in `func_get_filelist "$module"`; do
3630 lib/*/*.c | tests/*/*.c)
3638 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3639 # Generate dependencies here, since it eases the debugging of test failures.
3640 # If there are source files in subdirectories, prevent collision of the
3641 # object files (example: hash.c and libxml/hash.c).
3643 if test -n "$uses_subdirs"; then
3644 subdir_options=' subdir-objects'
3646 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign${subdir_options}"
3648 if $for_test && ! $single_configure; then
3649 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3652 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3653 # variable is needed to avoid an error from automake:
3654 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3657 echo "XFAIL_TESTS ="
3658 echo "TESTS_ENVIRONMENT ="
3659 echo "noinst_PROGRAMS ="
3660 if ! $for_test; then
3661 echo "check_PROGRAMS ="
3663 echo "noinst_HEADERS ="
3664 echo "noinst_LIBRARIES ="
3665 if $use_libtests; then
3667 echo "noinst_LIBRARIES += libtests.a"
3669 echo "check_LIBRARIES = libtests.a"
3672 # Automake versions < 1.11.4 create an empty pkgdatadir at
3673 # installation time if you specify pkgdata_DATA to empty.
3674 # See automake bugs #10997 and #11030:
3675 # * http://debbugs.gnu.org/10997
3676 # * http://debbugs.gnu.org/11030
3677 # So we need this workaround.
3678 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3679 echo "pkgdata_DATA ="
3682 echo "BUILT_SOURCES ="
3684 echo "MOSTLYCLEANFILES = core *.stackdump"
3685 echo "MOSTLYCLEANDIRS ="
3687 echo "DISTCLEANFILES ="
3688 echo "MAINTAINERCLEANFILES ="
3689 # Execute edits that apply to the Makefile.am being generated.
3691 while test $edit != $makefile_am_edits; do
3692 edit=`expr $edit + 1`
3693 eval dir=\"\$makefile_am_edit${edit}_dir\"
3694 eval var=\"\$makefile_am_edit${edit}_var\"
3695 eval val=\"\$makefile_am_edit${edit}_val\"
3696 if test -n "$var"; then
3697 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3698 echo "${var} += ${val}"
3699 eval "makefile_am_edit${edit}_var="
3704 echo "AM_CPPFLAGS = \\"
3706 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3708 if test -n "$witness_c_macro"; then
3709 echo " -D$witness_c_macro=1 \\"
3711 if test -n "${witness_macro}"; then
3712 echo " -D@${witness_macro}@=1 \\"
3714 echo " -I. -I\$(srcdir) \\"
3715 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3716 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3718 local_ldadd_before=''
3719 local_ldadd_after=''
3720 if $use_libtests; then
3721 # All test programs need to be linked with libtests.a.
3722 # It needs to be passed to the linker before ${libname}.${libext}, since
3723 # the tests-related modules depend on the main modules.
3724 # It also needs to be passed to the linker after ${libname}.${libext}
3725 # because the latter might contain incomplete modules (such as the 'error'
3726 # module whose dependency to 'progname' is voluntarily omitted).
3727 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3729 local_ldadd_before=' libtests.a'
3730 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3732 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3734 if $use_libtests; then
3735 echo "libtests_a_SOURCES ="
3736 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3737 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3738 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3739 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3740 echo "EXTRA_libtests_a_SOURCES ="
3741 # The circular dependency in LDADD requires this.
3742 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3745 # Many test scripts use ${EXEEXT} or ${srcdir}.
3746 # EXEEXT is defined by AC_PROG_CC through autoconf.
3747 # srcdir is defined by autoconf and automake.
3748 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3750 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3751 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3752 echo "# Clean up after Solaris cc."
3754 echo " rm -rf SunWS_cache"
3756 echo "mostlyclean-local: mostlyclean-generic"
3757 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3758 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3759 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3763 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3766 # func_emit_initmacro_start macro_prefix
3767 # emits the first few statements of the gl_INIT macro to standard output.
3768 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3769 func_emit_initmacro_start ()
3771 macro_prefix_arg="$1"
3772 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3773 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3774 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3775 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3777 # Furthermore it avoids an automake error like this when a Makefile.am
3778 # that uses pieces of gnulib also uses $(LIBOBJ):
3779 # automatically discovered file `error.c' should not be explicitly mentioned
3780 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3781 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3782 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3783 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3784 # automatically discovered file `error.c' should not be explicitly mentioned
3785 # We let automake know about the files to be distributed through the
3786 # EXTRA_lib_SOURCES variable.
3787 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3788 # Create data variables for checking the presence of files that are mentioned
3789 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3790 # because we want the check to happen when the configure file is created,
3791 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3792 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3793 # in which to expect them.
3794 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3795 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3799 # func_emit_initmacro_end macro_prefix
3800 # emits the last few statements of the gl_INIT macro to standard output.
3801 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3802 func_emit_initmacro_end ()
3804 macro_prefix_arg="$1"
3805 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3806 # The check is performed only when autoconf is run from the directory where
3807 # the configure.ac resides; if it is run from a different directory, the
3809 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3810 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3811 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3812 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3813 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3817 echo " m4_if(m4_sysval, [0], [],"
3818 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3820 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3821 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3822 echo " m4_popdef([AC_LIBSOURCES])"
3823 echo " m4_popdef([AC_REPLACE_FUNCS])"
3824 echo " m4_popdef([AC_LIBOBJ])"
3825 echo " AC_CONFIG_COMMANDS_PRE(["
3826 echo " ${macro_prefix_arg}_libobjs="
3827 echo " ${macro_prefix_arg}_ltlibobjs="
3828 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3829 echo " # Remove the extension."
3830 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3831 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3832 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3833 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3836 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3837 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3841 # func_emit_initmacro_done macro_prefix sourcebase
3842 # emits a few statements after the gl_INIT macro to standard output.
3843 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3844 # - sourcebase directory relative to destdir where to place source code
3845 func_emit_initmacro_done ()
3847 macro_prefix_arg="$1"
3850 echo "# Like AC_LIBOBJ, except that the module name goes"
3851 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3852 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3853 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3854 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3857 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3858 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3859 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3860 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3861 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3864 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3865 echo "# expected is derived from the gnulib-tool parameterization,"
3866 echo "# and alloca is special cased (for the alloca-opt module)."
3867 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3868 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3869 echo " m4_foreach([_gl_NAME], [\$1], ["
3870 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3871 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3872 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3878 # func_emit_autoconf_snippet indentation
3879 # emits the autoconf snippet of a module.
3881 # - indentation spaces to prepend on each line
3882 # - local_gnulib_dir from --local-dir
3883 # - modcache true or false, from --cache-modules/--no-cache-modules
3884 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3885 # - sed_replace_include_guard_prefix
3886 # sed expression for resolving ${gl_include_guard_prefix}
3887 # - module the module name
3888 # - toplevel true or false. 'false' means a subordinate use of
3890 # - disable_libtool true or false. It tells whether to disable libtool
3891 # handling even if it has been specified through the
3892 # command line options.
3893 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3895 func_emit_autoconf_snippet ()
3898 if { case $module in
3899 gnumakefile | maintainer-makefile)
3900 # These modules are meant to be used only in the top-level directory.
3906 func_get_autoconf_snippet "$module" \
3907 | sed -e '/^$/d;' -e "s/^/$indentation/" \
3908 -e "$sed_replace_build_aux" \
3909 -e "$sed_replace_include_guard_prefix" \
3910 | { if $disable_libtool; then
3911 sed -e 's/\$gl_cond_libtool/false/g' \
3912 -e 's/gl_libdeps/gltests_libdeps/g' \
3913 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3918 | { if $disable_gettext; then
3919 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
3921 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
3922 # autopoint through at least GNU gettext version 0.18.2.
3923 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
3926 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
3927 echo 'changequote(,)dnl'
3928 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3929 echo 'changequote([, ])dnl'
3930 echo 'AC_SUBST([LTALLOCA])'
3935 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
3936 # collects and emit the autoconf snippets of a set of modules.
3938 # - local_gnulib_dir from --local-dir
3939 # - modcache true or false, from --cache-modules/--no-cache-modules
3940 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3941 # - sed_replace_include_guard_prefix
3942 # sed expression for resolving ${gl_include_guard_prefix}
3943 # - modules the list of modules.
3944 # - verifier one of func_verify_module, func_verify_nontests_module,
3945 # func_verify_tests_module. It selects the subset of
3946 # $modules to consider.
3947 # - toplevel true or false. 'false' means a subordinate use of
3949 # - disable_libtool true or false. It tells whether to disable libtool
3950 # handling even if it has been specified through the
3951 # command line options.
3952 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3954 func_emit_autoconf_snippets ()
3958 disable_libtool="$4"
3959 disable_gettext="$5"
3960 if test "$cond_dependencies" = true; then
3961 for m in $modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
3962 # Emit the autoconf code for the unconditional modules.
3963 for module in $1; do
3965 if test -n "$module"; then
3966 if func_cond_module_p "$module"; then
3969 func_emit_autoconf_snippet " "
3973 # Initialize the shell variables indicating that the modules are enabled.
3974 for module in $1; do
3976 if test -n "$module"; then
3977 if func_cond_module_p "$module"; then
3978 func_module_shellvar_name "$module"
3979 echo " $shellvar=false"
3983 # Emit the autoconf code for the conditional modules, each in a separate
3984 # function. This makes it possible to support cycles among conditional
3986 for module in $1; do
3988 if test -n "$module"; then
3989 if func_cond_module_p "$module"; then
3990 func_module_shellfunc_name "$module"
3991 func_module_shellvar_name "$module"
3992 echo " $shellfunc ()"
3994 echo " if ! \$$shellvar; then"
3995 func_emit_autoconf_snippet " "
3996 echo " $shellvar=true"
3997 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3998 # Intersect $deps with the modules list $1.
3999 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4000 for dep in $deps; do
4001 if func_cond_module_p "$dep"; then
4002 func_module_shellfunc_name "$dep"
4003 func_cond_module_condition "$module" "$dep"
4004 if test "$condition" != true; then
4005 echo " if $condition; then"
4012 # The autoconf code for $dep has already been emitted above and
4013 # therefore is already executed when this function is run.
4022 # Emit the dependencies from the unconditional to the conditional modules.
4023 for module in $1; do
4025 if test -n "$module"; then
4026 if func_cond_module_p "$module"; then
4029 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4030 # Intersect $deps with the modules list $1.
4031 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4032 for dep in $deps; do
4033 if func_cond_module_p "$dep"; then
4034 func_module_shellfunc_name "$dep"
4035 func_cond_module_condition "$module" "$dep"
4036 if test "$condition" != true; then
4037 echo " if $condition; then"
4044 # The autoconf code for $dep has already been emitted above and
4045 # therefore is already executed when this code is run.
4052 # Define the Automake conditionals.
4053 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4054 for module in $1; do
4056 if test -n "$module"; then
4057 if func_cond_module_p "$module"; then
4058 func_module_conditional_name "$module"
4059 func_module_shellvar_name "$module"
4060 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4065 # Ignore the conditions, and enable all modules unconditionally.
4066 for module in $1; do
4068 if test -n "$module"; then
4069 func_emit_autoconf_snippet " "
4075 # func_import modules
4076 # Uses also the variables
4077 # - mode import or add-import or remove-import or update
4078 # - destdir target directory
4079 # - local_gnulib_dir from --local-dir
4080 # - modcache true or false, from --cache-modules/--no-cache-modules
4081 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4082 # - libname library name
4083 # - supplied_libname true if --lib was given, blank otherwise
4084 # - sourcebase directory relative to destdir where to place source code
4085 # - m4base directory relative to destdir where to place *.m4 macros
4086 # - pobase directory relative to destdir where to place *.po files
4087 # - docbase directory relative to destdir where to place doc files
4088 # - testsbase directory relative to destdir where to place unit test code
4089 # - auxdir directory relative to destdir where to place build aux files
4090 # - inctests true if --with-tests was given, false otherwise
4091 # - incobsolete true if --with-obsolete was given, blank otherwise
4092 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4093 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4095 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4097 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4099 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4100 # - avoidlist list of modules to avoid, from --avoid
4101 # - cond_dependencies true if --conditional-dependencies was given, false if
4102 # --no-conditional-dependencies was given, blank otherwise
4103 # - lgpl yes or a number if library's license shall be LGPL,
4105 # - makefile_name from --makefile-name
4106 # - libtool true if --libtool was given, false if --no-libtool was
4107 # given, blank otherwise
4108 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4109 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4110 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4111 # - witness_c_macro from --witness-c-macro
4112 # - vc_files true if --vc-files was given, false if --no-vc-files was
4113 # given, blank otherwise
4114 # - autoconf_minversion minimum supported autoconf version
4115 # - doit : if actions shall be executed, false if only to be printed
4116 # - symbolic true if files should be symlinked, copied otherwise
4117 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4119 # - do_copyrights true if copyright notices in files should be replaced,
4123 # Get the cached settings.
4124 # In 'import' mode, we read them only for the purpose of knowing the old
4125 # installed file list, and don't use them as defaults.
4126 cached_local_gnulib_dir=
4127 cached_specified_modules=
4129 cached_inc_cxx_tests=
4130 cached_inc_longrunning_tests=
4131 cached_inc_privileged_tests=
4132 cached_inc_unportable_tests=
4133 cached_inc_all_tests=
4143 cached_makefile_name=
4144 cached_cond_dependencies=
4146 cached_macro_prefix=
4148 cached_witness_c_macro=
4151 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4152 cached_libtool=false
4158 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
4168 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4170 /gl_WITH_OBSOLETE/ {
4171 s,^.*$,cached_incobsolete=true,p
4173 /gl_WITH_CXX_TESTS/ {
4174 s,^.*$,cached_inc_cxx_tests=true,p
4176 /gl_WITH_LONGRUNNING_TESTS/ {
4177 s,^.*$,cached_inc_longrunning_tests=true,p
4179 /gl_WITH_PRIVILEGED_TESTS/ {
4180 s,^.*$,cached_inc_privileged_tests=true,p
4182 /gl_WITH_UNPORTABLE_TESTS/ {
4183 s,^.*$,cached_inc_unportable_tests=true,p
4185 /gl_WITH_ALL_TESTS/ {
4186 s,^.*$,cached_inc_all_tests=true,p
4189 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4192 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4195 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4198 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4201 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4204 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4207 s,^.*$,cached_inctests=true,p
4210 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4213 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4216 s,^.*$,cached_lgpl=yes,p
4218 /gl_MAKEFILE_NAME(/ {
4219 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4221 /gl_CONDITIONAL_DEPENDENCIES/ {
4222 s,^.*$,cached_cond_dependencies=true,p
4225 s,^.*$,cached_libtool=true,p
4227 /gl_MACRO_PREFIX(/ {
4228 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4231 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4233 /gl_WITNESS_C_MACRO(/ {
4234 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4237 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4239 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4240 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4245 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4246 s,^.*$,cached_files=",p
4259 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4263 if test "$mode" = import; then
4264 # In 'import' mode, the new set of specified modules overrides the cached
4265 # set of modules. Ignore the cached settings.
4266 specified_modules="$1"
4268 # Merge the cached settings with the specified ones.
4269 # The m4base must be the same as expected from the pathname.
4270 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4271 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4273 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
4274 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4275 if test -z "$local_gnulib_dir"; then
4276 if test -n "$cached_local_gnulib_dir"; then
4279 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4281 case "$cached_local_gnulib_dir" in
4283 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4285 func_relconcat "$destdir" "$cached_local_gnulib_dir"
4286 local_gnulib_dir="$relconcat" ;;
4293 # Append the cached and the specified module names. So that
4294 # "gnulib-tool --add-import foo" means to add the module foo.
4295 specified_modules="$cached_specified_modules $1"
4298 # Take the cached module names, minus the specified module names.
4300 if $have_associative; then
4301 # Use an associative array, for O(N) worst-case run time.
4302 declare -A to_remove
4304 eval 'to_remove[$m]=yes'
4306 for module in $cached_specified_modules; do
4307 if eval 'test -z "${to_remove[$module]}"'; then
4308 func_append specified_modules "$module "
4312 # This loop has O(N²) worst-case run time.
4313 for module in $cached_specified_modules; do
4316 if test "$m" = "$module"; then
4321 if test -z "$to_remove"; then
4322 func_append specified_modules "$module "
4328 # Take the cached module names. There are no specified module names.
4329 specified_modules="$cached_specified_modules"
4332 # Included obsolete modules among the dependencies if specified either way.
4333 if test -z "$incobsolete"; then
4334 incobsolete="$cached_incobsolete"
4336 # Included special kinds of tests modules among the dependencies if specified
4338 if test -z "$inc_cxx_tests"; then
4339 inc_cxx_tests="$cached_inc_cxx_tests"
4341 if test -z "$inc_longrunning_tests"; then
4342 inc_longrunning_tests="$cached_inc_longrunning_tests"
4344 if test -z "$inc_privileged_tests"; then
4345 inc_privileged_tests="$cached_inc_privileged_tests"
4347 if test -z "$inc_unportable_tests"; then
4348 inc_unportable_tests="$cached_inc_unportable_tests"
4350 if test -z "$inc_all_tests"; then
4351 inc_all_tests="$cached_inc_all_tests"
4353 # Append the cached and the specified avoidlist. This is probably better
4354 # than dropping the cached one when --avoid is specified at least once.
4355 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4356 avoidlist=`echo $avoidlist`
4358 # The sourcebase defaults to the cached one.
4359 if test -z "$sourcebase"; then
4360 sourcebase="$cached_sourcebase"
4361 if test -z "$sourcebase"; then
4362 func_fatal_error "missing --source-base option"
4365 # The pobase defaults to the cached one.
4366 if test -z "$pobase"; then
4367 pobase="$cached_pobase"
4369 # The docbase defaults to the cached one.
4370 if test -z "$docbase"; then
4371 docbase="$cached_docbase"
4372 if test -z "$docbase"; then
4373 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."
4376 # The testsbase defaults to the cached one.
4377 if test -z "$testsbase"; then
4378 testsbase="$cached_testsbase"
4379 if test -z "$testsbase"; then
4380 func_fatal_error "missing --tests-base option"
4383 # Require the tests if specified either way.
4384 if ! $inctests; then
4385 inctests="$cached_inctests"
4386 if test -z "$inctests"; then
4390 # The libname defaults to the cached one.
4391 if test -z "$supplied_libname"; then
4392 libname="$cached_libname"
4393 if test -z "$libname"; then
4394 func_fatal_error "missing --lib option"
4397 # Require LGPL if specified either way.
4398 if test -z "$lgpl"; then
4401 # The makefile_name defaults to the cached one.
4402 if test -z "$makefile_name"; then
4403 makefile_name="$cached_makefile_name"
4405 # Use conditional dependencies if specified either way.
4406 if test -z "$cond_dependencies"; then
4407 cond_dependencies="$cached_cond_dependencies"
4409 # Use libtool if specified either way, or if guessed.
4410 if test -z "$libtool"; then
4411 if test -n "$cached_m4base"; then
4412 libtool="$cached_libtool"
4414 libtool="$guessed_libtool"
4417 # The macro_prefix defaults to the cached one.
4418 if test -z "$macro_prefix"; then
4419 macro_prefix="$cached_macro_prefix"
4420 if test -z "$macro_prefix"; then
4421 func_fatal_error "missing --macro-prefix option"
4424 # The po_domain defaults to the cached one.
4425 if test -z "$po_domain"; then
4426 po_domain="$cached_po_domain"
4428 # The witness_c_macro defaults to the cached one.
4429 if test -z "$witness_c_macro"; then
4430 witness_c_macro="$cached_witness_c_macro"
4432 # The vc_files defaults to the cached one.
4433 if test -z "$vc_files"; then
4434 vc_files="$cached_vc_files"
4436 # Ensure constraints.
4437 if test "$cond_dependencies" = true && $inctests; then
4438 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4442 # --without-*-tests options are not supported here.
4444 excl_longrunning_tests=
4445 excl_privileged_tests=
4446 excl_unportable_tests=
4448 # Canonicalize the list of specified modules.
4449 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4451 # Include all kinds of tests modules if --with-all-tests was specified.
4452 inc_all_direct_tests="$inc_all_tests"
4453 inc_all_indirect_tests="$inc_all_tests"
4455 # Determine final module list.
4456 modules="$specified_modules"
4457 func_modules_transitive_closure
4458 if test $verbose -ge 0; then
4459 func_show_module_list
4461 final_modules="$modules"
4463 # Determine main module list and tests-related module list separately.
4464 func_modules_transitive_closure_separately
4466 # Determine whether a $testsbase/libtests.a is needed.
4467 func_determine_use_libtests
4469 # Add the dummy module to the main module list or to the tests-related module
4471 func_modules_add_dummy_separately
4473 # If --lgpl, verify that the licenses of modules are compatible.
4474 if test -n "$lgpl"; then
4475 license_incompatibilities=
4476 for module in $main_modules; do
4477 license=`func_get_license $module`
4479 'GPLed build tool') ;;
4480 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4485 LGPL | LGPLv2+ | LGPLv3+) ;;
4486 *) func_append license_incompatibilities "$module $license$nl" ;;
4492 *) func_append license_incompatibilities "$module $license$nl" ;;
4495 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4500 if test -n "$license_incompatibilities"; then
4501 # Format the license incompatibilities as a table.
4502 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4503 s,^\(.................................................[^ ]*\) *, \1 ,'
4504 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4505 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4509 # Show banner notice of every module.
4510 modules="$main_modules"
4513 # Determine script to apply to imported library files.
4514 sed_transform_lib_file=
4515 for module in $main_modules; do
4516 if test $module = config-h; then
4517 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4518 sed_transform_lib_file=$sed_transform_lib_file'
4519 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4524 sed_transform_main_lib_file="$sed_transform_lib_file"
4525 if test -n "$do_copyrights"; then
4526 if test -n "$lgpl"; then
4530 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4531 s/GNU General/GNU Lesser General/g
4532 s/General Public License/Lesser General Public License/g
4533 s/Lesser Lesser General Public License/Lesser General Public License/g
4537 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4538 s/GNU General/GNU Lesser General/g
4539 s/General Public License/Lesser General Public License/g
4540 s/Lesser Lesser General Public License/Lesser General Public License/g
4542 s/version [23]\([ ,]\)/version 2.1\1/g
4545 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4549 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4550 s/GNU Lesser General/GNU General/g
4551 s/Lesser General Public License/General Public License/g
4553 s/GNU Library General/GNU General/g
4554 s/Library General Public License/General Public License/g
4556 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4561 # Determine script to apply to auxiliary files that go into $auxdir/.
4562 sed_transform_build_aux_file=
4563 if test -n "$do_copyrights"; then
4565 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4566 s/GNU Lesser General/GNU General/g
4567 s/Lesser General Public License/General Public License/g
4569 s/GNU Library General/GNU General/g
4570 s/Library General Public License/General Public License/g
4572 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4576 # Determine script to apply to library files that go into $testsbase/.
4577 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4578 if test -n "$do_copyrights"; then
4580 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4581 s/GNU Lesser General/GNU General/g
4582 s/Lesser General Public License/General Public License/g
4584 s/GNU Library General/GNU General/g
4585 s/Library General Public License/General Public License/g
4587 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4591 # Determine the final file lists.
4592 func_modules_to_filelist_separately
4595 || func_fatal_error "refusing to do nothing"
4597 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4598 new_files="$files m4/gnulib-tool.m4"
4599 old_files="$cached_files"
4600 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4601 func_append old_files " m4/gnulib-tool.m4"
4604 rewritten='%REWRITTEN%'
4605 sed_rewrite_old_files="\
4606 s,^build-aux/,$rewritten$auxdir/,
4607 s,^doc/,$rewritten$cached_docbase/,
4608 s,^lib/,$rewritten$cached_sourcebase/,
4609 s,^m4/,$rewritten$cached_m4base/,
4610 s,^tests/,$rewritten$cached_testsbase/,
4611 s,^tests=lib/,$rewritten$cached_testsbase/,
4614 sed_rewrite_new_files="\
4615 s,^build-aux/,$rewritten$auxdir/,
4616 s,^doc/,$rewritten$docbase/,
4617 s,^lib/,$rewritten$sourcebase/,
4618 s,^m4/,$rewritten$m4base/,
4619 s,^tests/,$rewritten$testsbase/,
4620 s,^tests=lib/,$rewritten$testsbase/,
4624 # Create directories.
4625 { echo "$sourcebase"
4627 if test -n "$pobase"; then
4630 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4631 if test -n "$docfiles"; then
4638 for f in $files; do echo $f; done \
4639 | sed -e "$sed_rewrite_new_files" \
4640 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4643 { # Rearrange file descriptors. Needed because "while ... done < ..."
4644 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4645 exec 5<&0 < "$tmp"/dirs
4647 if test ! -d "$destdir/$d"; then
4649 echo "Creating directory $destdir/$d"
4650 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4652 echo "Create directory $destdir/$d"
4659 # Copy files or make symbolic links. Remove obsolete files.
4663 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4664 # representing the files according to the last gnulib-tool invocation.
4665 for f in $old_files; do echo $f; done \
4666 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4669 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4670 # representing the files after this gnulib-tool invocation.
4671 for f in $new_files; do echo $f; done \
4672 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4675 # First the files that are in old-files, but not in new-files:
4676 sed_take_first_column='s,'"$delimiter"'.*,,'
4677 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4678 # Remove the file. Do nothing if the user already removed it.
4679 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4681 echo "Removing file $g (backup in ${g}~)"
4682 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4684 echo "Remove file $g (backup in ${g}~)"
4686 func_append removed_files "$g$nl"
4689 # func_add_or_update handles a file that ought to be present afterwards.
4691 # - f the original file name
4692 # - g the rewritten file name
4693 # - already_present nonempty if the file should already exist, empty
4695 func_add_or_update ()
4699 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4701 func_dest_tmpfilename "$g"
4702 func_lookup_file "$f"
4703 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4704 if test -n "$sed_transform_main_lib_file"; then
4707 sed -e "$sed_transform_main_lib_file" \
4708 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4712 if test -n "$sed_transform_build_aux_file"; then
4715 sed -e "$sed_transform_build_aux_file" \
4716 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4720 if test -n "$sed_transform_testsrelated_lib_file"; then
4723 sed -e "$sed_transform_testsrelated_lib_file" \
4724 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4728 if test -f "$destdir/$g"; then
4729 # The file already exists.
4733 # Don't protest if the file should be there but isn't: it happens
4734 # frequently that developers don't put autogenerated files under version control.
4736 func_append added_files "$g$nl"
4740 # Then the files that are in new-files, but not in old-files:
4741 sed_take_last_column='s,^.*'"$delimiter"',,'
4743 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4744 | sed -e "$sed_take_last_column" \
4745 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4746 { # Rearrange file descriptors. Needed because "while ... done < ..."
4747 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4748 exec 5<&0 < "$tmp"/added-files
4754 # Then the files that are in new-files and in old-files:
4755 already_present=true
4756 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4757 | sed -e "$sed_take_last_column" \
4758 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4759 { # Rearrange file descriptors. Needed because "while ... done < ..."
4760 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4761 exec 5<&0 < "$tmp"/kept-files
4768 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4769 actioncmd="gnulib-tool --import"
4770 func_append actioncmd " --dir=$destdir"
4771 if test -n "$local_gnulib_dir"; then
4772 func_append actioncmd " --local-dir=$local_gnulib_dir"
4774 func_append actioncmd " --lib=$libname"
4775 func_append actioncmd " --source-base=$sourcebase"
4776 func_append actioncmd " --m4-base=$m4base"
4777 if test -n "$pobase"; then
4778 func_append actioncmd " --po-base=$pobase"
4780 func_append actioncmd " --doc-base=$docbase"
4781 func_append actioncmd " --tests-base=$testsbase"
4782 func_append actioncmd " --aux-dir=$auxdir"
4784 func_append actioncmd " --with-tests"
4786 if test -n "$incobsolete"; then
4787 func_append actioncmd " --with-obsolete"
4789 if test -n "$inc_cxx_tests"; then
4790 func_append actioncmd " --with-c++-tests"
4792 if test -n "$inc_longrunning_tests"; then
4793 func_append actioncmd " --with-longrunning-tests"
4795 if test -n "$inc_privileged_tests"; then
4796 func_append actioncmd " --with-privileged-tests"
4798 if test -n "$inc_unportable_tests"; then
4799 func_append actioncmd " --with-unportable-tests"
4801 if test -n "$inc_all_tests"; then
4802 func_append actioncmd " --with-all-tests"
4804 for module in $avoidlist; do
4805 func_append actioncmd " --avoid=$module"
4807 if test -n "$lgpl"; then
4808 if test "$lgpl" = yes; then
4809 func_append actioncmd " --lgpl"
4811 func_append actioncmd " --lgpl=$lgpl"
4814 if test -n "$makefile_name"; then
4815 func_append actioncmd " --makefile-name=$makefile_name"
4817 if test "$cond_dependencies" = true; then
4818 func_append actioncmd " --conditional-dependencies"
4820 func_append actioncmd " --no-conditional-dependencies"
4822 if test "$libtool" = true; then
4823 func_append actioncmd " --libtool"
4825 func_append actioncmd " --no-libtool"
4827 func_append actioncmd " --macro-prefix=$macro_prefix"
4828 if test -n "$po_domain"; then
4829 func_append actioncmd " --po-domain=$po_domain"
4831 if test -n "$witness_c_macro"; then
4832 func_append actioncmd " --witness-c-macro=$witness_c_macro"
4834 if test -n "$vc_files"; then
4835 if test "$vc_files" = true; then
4836 func_append actioncmd " --vc-files"
4838 func_append actioncmd " --no-vc-files"
4841 func_append actioncmd " `echo $specified_modules`"
4843 # Determine include_guard_prefix.
4844 func_compute_include_guard_prefix
4846 # Default the makefile name to Makefile.am.
4847 if test -n "$makefile_name"; then
4848 makefile_am=$makefile_name
4850 makefile_am=Makefile.am
4853 # Create normal Makefile.ams.
4856 # Setup list of Makefile.am edits that are to be performed afterwards.
4857 # Some of these edits apply to files that we will generate; others are
4858 # under the responsibility of the developer.
4860 # func_note_Makefile_am_edit dir var value
4861 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4863 func_note_Makefile_am_edit ()
4865 makefile_am_edits=`expr $makefile_am_edits + 1`
4866 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4867 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4868 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4870 if test "$makefile_am" = Makefile.am; then
4871 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4872 sourcebase_base=`basename "$sourcebase"`
4873 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4875 if test -n "$pobase"; then
4876 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4877 pobase_base=`basename "$pobase"`
4878 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4881 if test "$makefile_am" = Makefile.am; then
4882 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4883 testsbase_base=`basename "$testsbase"`
4884 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4887 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4889 # Find the first parent directory of $m4base that contains or will contain
4891 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4893 sed_butlast='s,[^/][^/]*//*$,,'
4894 dir1="${m4base}/"; dir2=""
4895 while test -n "$dir1" \
4896 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4897 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4898 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4900 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4901 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4902 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4903 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4905 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4908 # Create library makefile.
4909 func_dest_tmpfilename $sourcebase/$makefile_am
4910 destfile="$sourcebase/$makefile_am"
4911 modules="$main_modules"
4912 func_emit_lib_Makefile_am > "$tmpfile"
4913 if test -f "$destdir"/$sourcebase/$makefile_am; then
4914 if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
4918 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4919 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4920 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4922 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4928 echo "Creating $sourcebase/$makefile_am"
4929 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4931 echo "Create $sourcebase/$makefile_am"
4934 func_append added_files "$sourcebase/$makefile_am$nl"
4937 # Create po/ directory.
4938 if test -n "$pobase"; then
4939 # Create po makefile and auxiliary files.
4940 for file in Makefile.in.in remove-potcdate.sin; do
4941 func_dest_tmpfilename $pobase/$file
4942 func_lookup_file build-aux/po/$file
4943 cat "$lookedup_file" > "$tmpfile"
4944 if test -f "$destdir"/$pobase/$file; then
4945 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
4949 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4950 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4951 mv -f "$tmpfile" "$destdir"/$pobase/$file
4953 echo "Update $pobase/$file (backup in $pobase/$file~)"
4959 echo "Creating $pobase/$file"
4960 mv -f "$tmpfile" "$destdir"/$pobase/$file
4962 echo "Create $pobase/$file"
4965 func_append added_files "$pobase/$file$nl"
4968 # Create po makefile parameterization, part 1.
4969 func_dest_tmpfilename $pobase/Makevars
4970 func_emit_po_Makevars > "$tmpfile"
4971 if test -f "$destdir"/$pobase/Makevars; then
4972 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
4976 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4977 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4978 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4980 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4986 echo "Creating $pobase/Makevars"
4987 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4989 echo "Create $pobase/Makevars"
4992 func_append added_files "$pobase/Makevars$nl"
4994 # Create po makefile parameterization, part 2.
4995 func_dest_tmpfilename $pobase/POTFILES.in
4996 func_emit_po_POTFILES_in > "$tmpfile"
4997 if test -f "$destdir"/$pobase/POTFILES.in; then
4998 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5002 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5003 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5004 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5006 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5012 echo "Creating $pobase/POTFILES.in"
5013 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5015 echo "Create $pobase/POTFILES.in"
5018 func_append added_files "$pobase/POTFILES.in$nl"
5021 TP_URL="http://translationproject.org/latest/"
5022 TP_RSYNC_URI="translationproject.org::tp/latest/"
5024 echo "Fetching gnulib PO files from $TP_URL"
5025 (cd "$destdir"/$pobase \
5026 && { # Prefer rsync over wget if it is available, since it consumes
5027 # less network bandwidth, due to compression.
5028 if type rsync 2>/dev/null | grep / > /dev/null; then
5029 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
5031 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
5036 echo "Fetch gnulib PO files from $TP_URL"
5038 # Create po/LINGUAS.
5040 func_dest_tmpfilename $pobase/LINGUAS
5041 (cd "$destdir"/$pobase \
5042 && { echo '# Set of available languages.'
5043 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5046 if test -f "$destdir"/$pobase/LINGUAS; then
5047 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5050 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5051 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5052 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5055 echo "Creating $pobase/LINGUAS"
5056 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5057 func_append added_files "$pobase/LINGUAS$nl"
5060 if test -f "$destdir"/$pobase/LINGUAS; then
5061 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5063 echo "Create $pobase/LINGUAS"
5068 # Create m4/gnulib-cache.m4.
5069 func_dest_tmpfilename $m4base/gnulib-cache.m4
5071 func_emit_copyright_notice
5073 echo "# This file represents the specification of how gnulib-tool is used."
5074 echo "# It acts as a cache: It is written and read by gnulib-tool."
5075 echo "# In projects that use version control, this file is meant to be put under"
5076 echo "# version control, like the configure.ac and various Makefile.am files."
5079 echo "# Specification in the form of a command-line invocation:"
5082 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5083 # Store the local_gnulib_dir relative to destdir.
5084 case "$local_gnulib_dir" in
5086 relative_local_gnulib_dir="$local_gnulib_dir" ;;
5089 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
5091 # destdir, local_gnulib_dir are both relative.
5092 func_relativize "$destdir" "$local_gnulib_dir"
5093 relative_local_gnulib_dir="$reldir" ;;
5096 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
5098 echo "$specified_modules" | sed -e 's/^/ /g'
5100 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5101 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5102 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5103 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5104 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5105 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5106 echo "gl_AVOID([$avoidlist])"
5107 echo "gl_SOURCE_BASE([$sourcebase])"
5108 echo "gl_M4_BASE([$m4base])"
5109 echo "gl_PO_BASE([$pobase])"
5110 echo "gl_DOC_BASE([$docbase])"
5111 echo "gl_TESTS_BASE([$testsbase])"
5113 echo "gl_WITH_TESTS"
5115 echo "gl_LIB([$libname])"
5116 if test -n "$lgpl"; then
5117 if test "$lgpl" = yes; then
5120 echo "gl_LGPL([$lgpl])"
5123 echo "gl_MAKEFILE_NAME([$makefile_name])"
5124 if test "$cond_dependencies" = true; then
5125 echo "gl_CONDITIONAL_DEPENDENCIES"
5127 if test "$libtool" = true; then
5130 echo "gl_MACRO_PREFIX([$macro_prefix])"
5131 echo "gl_PO_DOMAIN([$po_domain])"
5132 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5133 if test -n "$vc_files"; then
5134 echo "gl_VC_FILES([$vc_files])"
5137 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5138 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
5142 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5143 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5144 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5146 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5150 echo "# gnulib-cache.m4 ends here"
5157 echo "Creating $m4base/gnulib-cache.m4"
5158 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5160 echo "Create $m4base/gnulib-cache.m4"
5166 # Create m4/gnulib-comp.m4.
5167 func_dest_tmpfilename $m4base/gnulib-comp.m4
5169 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5170 func_emit_copyright_notice
5172 echo "# This file represents the compiled summary of the specification in"
5173 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5174 echo "# to be invoked from configure.ac."
5175 echo "# In projects that use version control, this file can be treated like"
5176 echo "# other built files."
5179 echo "# This macro should be invoked from $configure_ac, in the section"
5180 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5181 echo "# any checks for libraries, header files, types and library functions."
5182 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5184 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5185 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5186 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5187 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5188 echo " AC_REQUIRE([gl_PROG_AR_RANLIB])"
5189 if test -n "$uses_subdirs"; then
5190 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5192 for module in $final_modules; do
5194 if test -n "$module"; then
5195 echo "# Code from module $module:"
5196 func_get_autoconf_early_snippet "$module"
5199 | sed -e '/^$/d;' -e 's/^/ /'
5202 echo "# This macro should be invoked from $configure_ac, in the section"
5203 echo "# \"Check for header files, types and library functions\"."
5204 echo "AC_DEFUN([${macro_prefix}_INIT],"
5206 if test "$libtool" = true; then
5207 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5208 echo " gl_cond_libtool=true"
5210 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5211 echo " gl_cond_libtool=false"
5213 echo " gl_ltlibdeps="
5215 if test "$auxdir" != "build-aux"; then
5216 sed_replace_build_aux='
5218 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5219 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5223 sed_replace_build_aux="$sed_noop"
5225 echo " gl_m4_base='$m4base'"
5226 func_emit_initmacro_start $macro_prefix
5227 echo " gl_source_base='$sourcebase'"
5228 if test -n "$witness_c_macro"; then
5229 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5231 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
5232 if test -n "$witness_c_macro"; then
5233 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5235 echo " # End of code from modules"
5236 func_emit_initmacro_end $macro_prefix
5237 echo " gltests_libdeps="
5238 echo " gltests_ltlibdeps="
5239 func_emit_initmacro_start ${macro_prefix}tests
5240 echo " gl_source_base='$testsbase'"
5241 # Define a tests witness macro that depends on the package.
5242 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5243 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5244 echo "changequote(,)dnl"
5245 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"
5246 echo "changequote([, ])dnl"
5247 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5248 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5249 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5250 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
5251 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5252 func_emit_initmacro_end ${macro_prefix}tests
5253 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5254 # created using libtool, because libtool already handles the dependencies.
5255 if test "$libtool" != true; then
5256 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5257 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5258 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5259 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5260 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5262 if $use_libtests; then
5263 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5264 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5267 func_emit_initmacro_done $macro_prefix $sourcebase
5268 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5270 echo "# This macro records the list of files which have been installed by"
5271 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5272 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5273 echo "$files" | sed -e 's,^, ,'
5276 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5277 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
5281 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5282 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5283 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5285 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5289 echo "# gnulib-comp.m4 ends here"
5296 echo "Creating $m4base/gnulib-comp.m4"
5297 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5299 echo "Create $m4base/gnulib-comp.m4"
5306 # Create tests makefile.
5307 func_dest_tmpfilename $testsbase/$makefile_am
5308 destfile="$testsbase/$makefile_am"
5309 modules="$testsrelated_modules"
5310 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5311 if test -f "$destdir"/$testsbase/$makefile_am; then
5312 if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
5316 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5317 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5318 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5320 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5326 echo "Creating $testsbase/$makefile_am"
5327 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5329 echo "Create $testsbase/$makefile_am"
5332 func_append added_files "$testsbase/$makefile_am$nl"
5336 if test "$vc_files" != false; then
5337 # Update the .cvsignore and .gitignore files.
5338 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5339 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5340 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5341 echo "$m4base/|A|gnulib-comp.m4"
5342 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5343 { # Rearrange file descriptors. Needed because "while ... done < ..."
5344 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5345 exec 5<&0 < "$tmp"/fileset-changes
5346 func_update_ignorelist ()
5349 if test "$ignore" = .gitignore; then
5350 # In a .gitignore file, "foo" applies to the current directory and all
5351 # subdirectories, whereas "/foo" applies to the current directory only.
5354 doubly_escaped_anchor='\\/'
5358 doubly_escaped_anchor=''
5360 if test -f "$destdir/$dir$ignore"; then
5361 if test -n "$dir_added" || test -n "$dir_removed"; then
5362 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5363 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5364 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5365 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5366 > "$tmp"/ignore-removed
5368 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5370 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5371 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5372 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5373 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5374 } > "$tmp"/sed-ignore-removed
5375 { cat "$destdir/$dir$ignore"~
5376 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5377 } | sed -f "$tmp"/sed-ignore-removed \
5378 > "$destdir/$dir$ignore"
5380 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5385 if test -n "$dir_added"; then
5387 echo "Creating $destdir/$dir$ignore"
5389 if test "$ignore" = .cvsignore; then
5391 # Automake generates Makefile rules that create .dirstamp files.
5394 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5395 } > "$destdir/$dir$ignore"
5397 echo "Create $destdir/$dir$ignore"
5407 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5408 func_update_ignorelist .cvsignore
5410 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5411 func_update_ignorelist .gitignore
5418 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5419 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5420 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5421 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5422 if test "$next_dir" != "$last_dir"; then
5423 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5424 last_dir="$next_dir"
5429 A) func_append last_dir_added "$file$nl";;
5430 R) func_append last_dir_removed "$file$nl";;
5433 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5440 echo "You may need to add #include directives for the following .h files."
5441 # Intersect $specified_modules and $main_modules
5442 # (since $specified_modules is not necessarily of subset of $main_modules
5443 # - some may have been skipped through --avoid, and since the elements of
5444 # $main_modules but not in $specified_modules can go away without explicit
5445 # notice - through changes in the module dependencies).
5446 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5447 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5448 # First the #include <...> directives without #ifs, sorted for convenience,
5449 # then the #include "..." directives without #ifs, sorted for convenience,
5450 # then the #include directives that are surrounded by #ifs. Not sorted.
5451 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5452 include_directive=`func_get_include_directive "$module"`
5453 case "$nl$include_directive" in
5455 echo "$include_directive" 1>&5
5458 echo "$include_directive" | grep -v 'include "' 1>&6
5459 echo "$include_directive" | grep 'include "' 1>&7
5462 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5464 LC_ALL=C sort -u "$tmp"/include-angles
5465 LC_ALL=C sort -u "$tmp"/include-quotes
5466 cat "$tmp"/include-if
5467 ) | sed -e '/^$/d' -e 's/^/ /'
5468 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5470 for module in $main_modules; do
5471 func_get_link_directive "$module"
5473 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5474 if test `wc -l < "$tmp"/link` != 0; then
5476 echo "You may need to use the following Makefile variables when linking."
5477 echo "Use them in <program>_LDADD when linking a program, or"
5478 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5484 echo "Don't forget to"
5485 if test "$makefile_am" = Makefile.am; then
5486 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5488 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5490 if test -n "$pobase"; then
5491 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5494 if test "$makefile_am" = Makefile.am; then
5495 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5497 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5501 while test $edit != $makefile_am_edits; do
5502 edit=`expr $edit + 1`
5503 eval dir=\"\$makefile_am_edit${edit}_dir\"
5504 eval var=\"\$makefile_am_edit${edit}_var\"
5505 eval val=\"\$makefile_am_edit${edit}_val\"
5506 if test -n "$var"; then
5507 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5510 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
5511 position_early_after=AC_PROG_CC_STDC
5513 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
5514 position_early_after=AC_PROG_CC_C99
5516 position_early_after=AC_PROG_CC
5519 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
5520 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5523 # func_create_testdir testdir modules
5525 # - local_gnulib_dir from --local-dir
5526 # - modcache true or false, from --cache-modules/--no-cache-modules
5527 # - auxdir directory relative to destdir where to place build aux files
5528 # - inctests true if tests should be included, false otherwise
5529 # - incobsolete true if obsolete modules among dependencies should be
5530 # included, blank otherwise
5531 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5533 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5535 # - excl_privileged_tests true if tests that require root privileges should be
5536 # excluded, blank otherwise
5537 # - excl_unportable_tests true if tests that fail on some platforms should be
5538 # excluded, blank otherwise
5539 # - single_configure true if a single configure file should be generated,
5540 # false for a separate configure file for the tests
5541 # - avoidlist list of modules to avoid
5542 # - cond_dependencies true if --conditional-dependencies was given, false if
5543 # --no-conditional-dependencies was given, blank otherwise
5544 # - libtool true if --libtool was given, false if --no-libtool was
5545 # given, blank otherwise
5546 # - symbolic true if files should be symlinked, copied otherwise
5547 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
5549 func_create_testdir ()
5553 if test -z "$modules"; then
5554 # All modules together.
5555 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5556 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5557 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5558 modules=`func_all_modules`
5559 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5561 specified_modules="$modules"
5563 # Canonicalize the list of specified modules.
5564 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5566 # Unlike in func_import, here we want to include all kinds of tests for the
5567 # directly specified modules, but not for dependencies.
5568 inc_all_direct_tests=true
5569 inc_all_indirect_tests="$inc_all_tests"
5571 # Check that the license of every module is consistent with the license of
5573 saved_inctests="$inctests"
5574 # When computing transitive closures, don't consider $module to depend on
5575 # $module-tests. Need this because tests are implicitly GPL and may depend
5576 # on GPL modules - therefore we don't want a warning in this case.
5578 for requested_module in $specified_modules; do
5579 requested_license=`func_get_license "$requested_module"`
5580 if test "$requested_license" != GPL; then
5581 # Here we use func_modules_transitive_closure, not just
5582 # func_get_dependencies, so that we also detect weird situations like
5583 # an LGPL module which depends on a GPLed build tool module which depends
5585 modules="$requested_module"
5586 func_modules_transitive_closure
5587 for module in $modules; do
5588 license=`func_get_license "$module"`
5590 'GPLed build tool') ;;
5591 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5593 case "$requested_license" in
5596 GPLv2+ | LGPLv2+) ;;
5597 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5603 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5609 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5618 inctests="$saved_inctests"
5620 # Subdirectory names.
5631 # Determine final module list.
5632 modules="$specified_modules"
5633 func_modules_transitive_closure
5634 if test $verbose -ge 0; then
5635 func_show_module_list
5637 final_modules="$modules"
5639 if $single_configure; then
5640 # Determine main module list and tests-related module list separately.
5641 func_modules_transitive_closure_separately
5644 if $single_configure; then
5645 # Determine whether a $testsbase/libtests.a is needed.
5646 func_determine_use_libtests
5649 # Add the dummy module if needed.
5650 if $single_configure; then
5651 func_modules_add_dummy_separately
5653 func_modules_add_dummy
5656 # Show banner notice of every module.
5657 if $single_configure; then
5658 modules="$main_modules"
5664 # Determine final file list.
5665 if $single_configure; then
5666 func_modules_to_filelist_separately
5668 func_modules_to_filelist
5669 if test $verbose -ge 0; then
5671 echo "$files" | sed -e 's/^/ /'
5674 # Add files for which the copy in gnulib is newer than the one that
5675 # "automake --add-missing --copy" would provide.
5676 files="$files build-aux/config.guess"
5677 files="$files build-aux/config.sub"
5678 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5680 rewritten='%REWRITTEN%'
5681 sed_rewrite_files="\
5682 s,^build-aux/,$rewritten$auxdir/,
5683 s,^doc/,$rewritten$docbase/,
5684 s,^lib/,$rewritten$sourcebase/,
5685 s,^m4/,$rewritten$m4base/,
5686 s,^tests/,$rewritten$testsbase/,
5687 s,^tests=lib/,$rewritten$testsbase/,
5691 # Create directories.
5692 for f in $files; do echo $f; done \
5693 | sed -e "$sed_rewrite_files" \
5694 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5695 | LC_ALL=C sort -u \
5697 { # Rearrange file descriptors. Needed because "while ... done < ..."
5698 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5699 exec 5<&0 < "$tmp"/dirs
5701 mkdir -p "$testdir/$d"
5706 # Copy files or make symbolic links.
5708 for f in $files; do echo $f; done \
5709 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5712 { # Rearrange file descriptors. Needed because "while ... done < ..."
5713 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5714 exec 5<&0 < "$tmp"/files
5717 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5719 func_lookup_file "$f"
5720 if test -n "$lookedup_tmp"; then
5721 cp -p "$lookedup_file" "$testdir/$g"
5723 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5724 if { test -n "$symbolic" \
5725 || { test -n "$lsymbolic" \
5726 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5727 func_ln "$lookedup_file" "$testdir/$g"
5729 cp -p "$lookedup_file" "$testdir/$g"
5736 # Determine include_guard_prefix.
5737 func_compute_include_guard_prefix
5739 # Create Makefile.ams that are for testing.
5742 # No special edits are needed.
5745 # Create $sourcebase/Makefile.am.
5746 mkdir -p "$testdir/$sourcebase"
5747 destfile="$sourcebase/Makefile.am"
5748 if $single_configure; then
5749 modules="$main_modules"
5751 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5752 any_uses_subdirs="$uses_subdirs"
5754 # Create $m4base/Makefile.am.
5755 mkdir -p "$testdir/$m4base"
5756 (echo "## Process this file with automake to produce Makefile.in."
5762 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5765 ) > "$testdir/$m4base/Makefile.am"
5767 subdirs="$sourcebase $m4base"
5768 subdirs_with_configure_ac=""
5770 if false && test -f "$testdir"/$m4base/gettext.m4; then
5771 # Avoid stupid error message from automake:
5772 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5773 mkdir -p "$testdir/po"
5774 (echo "## Process this file with automake to produce Makefile.in."
5775 ) > "$testdir/po/Makefile.am"
5776 func_append subdirs " po"
5780 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5781 if $single_configure; then
5782 # Create $testsbase/Makefile.am.
5783 destfile="$testsbase/Makefile.am"
5784 modules="$testsrelated_modules"
5785 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
5787 # Viewed from the $testsbase subdirectory, $auxdir is different.
5788 saved_auxdir="$auxdir"
5789 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5790 # Create $testsbase/Makefile.am.
5792 destfile="$testsbase/Makefile.am"
5793 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5794 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5795 # Create $testsbase/configure.ac.
5796 (echo "# Process this file with autoconf to produce a configure script."
5797 echo "AC_INIT([dummy], [0])"
5798 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5799 echo "AM_INIT_AUTOMAKE"
5801 echo "AC_CONFIG_HEADERS([config.h])"
5804 echo "AC_PROG_INSTALL"
5805 echo "AC_PROG_MAKE_SET"
5806 echo "gl_PROG_AR_RANLIB"
5808 if test -n "$uses_subdirs"; then
5809 echo "AM_PROG_CC_C_O"
5812 for module in $modules; do
5814 if test -n "$module"; then
5816 gnumakefile | maintainer-makefile)
5817 # These modules are meant to be used only in the top-level directory.
5820 func_get_autoconf_early_snippet "$module"
5825 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5826 if test "$libtool" = true; then
5827 echo "LT_INIT([win32-dll])"
5828 echo "LT_LANG([C++])"
5829 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5830 echo "gl_cond_libtool=true"
5832 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5833 echo "gl_cond_libtool=false"
5835 echo "gl_ltlibdeps="
5837 # Wrap the set of autoconf snippets into an autoconf macro that is then
5838 # invoked. This is needed because autoconf does not support AC_REQUIRE
5840 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5841 # but we want the AC_REQUIRE to have its normal meaning (provide one
5842 # expansion of the required macro before the current point, and only one
5844 echo "AC_DEFUN([gl_INIT], ["
5845 sed_replace_build_aux='
5847 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5848 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5851 echo "gl_m4_base='../$m4base'"
5852 func_emit_initmacro_start $macro_prefix
5853 # We don't have explicit ordering constraints between the various
5854 # autoconf snippets. It's cleanest to put those of the library before
5855 # those of the tests.
5856 echo "gl_source_base='../$sourcebase'"
5857 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
5858 echo "gl_source_base='.'"
5859 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
5860 func_emit_initmacro_end $macro_prefix
5861 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5862 # created using libtool, because libtool already handles the dependencies.
5863 if test "$libtool" != true; then
5864 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5865 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5866 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5867 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5868 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5871 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5875 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5876 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5877 echo "AH_TOP([#include \"../config.h\"])"
5879 echo "AC_CONFIG_FILES([Makefile])"
5881 ) > "$testdir/$testsbase/configure.ac"
5882 auxdir="$saved_auxdir"
5883 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5885 func_append subdirs " $testsbase"
5888 # Create Makefile.am.
5889 (echo "## Process this file with automake to produce Makefile.in."
5891 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
5893 echo "SUBDIRS = $subdirs"
5895 echo "ACLOCAL_AMFLAGS = -I $m4base"
5896 ) > "$testdir/Makefile.am"
5898 # Create configure.ac.
5899 (echo "# Process this file with autoconf to produce a configure script."
5900 echo "AC_INIT([dummy], [0])"
5901 if test "$auxdir" != "."; then
5902 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5904 echo "AM_INIT_AUTOMAKE"
5906 echo "AC_CONFIG_HEADERS([config.h])"
5909 echo "AC_PROG_INSTALL"
5910 echo "AC_PROG_MAKE_SET"
5912 echo "# For autobuild."
5913 echo "AC_CANONICAL_BUILD"
5914 echo "AC_CANONICAL_HOST"
5916 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5917 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5918 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5919 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5921 echo "gl_PROG_AR_RANLIB"
5923 if test -n "$any_uses_subdirs"; then
5924 echo "AM_PROG_CC_C_O"
5927 for module in $final_modules; do
5928 if $single_configure; then
5931 func_verify_nontests_module
5933 if test -n "$module"; then
5934 func_get_autoconf_early_snippet "$module"
5937 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5938 if test "$libtool" = true; then
5939 echo "LT_INIT([win32-dll])"
5940 echo "LT_LANG([C++])"
5941 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5942 echo "gl_cond_libtool=true"
5944 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5945 echo "gl_cond_libtool=false"
5947 echo "gl_ltlibdeps="
5949 # Wrap the set of autoconf snippets into an autoconf macro that is then
5950 # invoked. This is needed because autoconf does not support AC_REQUIRE
5952 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5953 # but we want the AC_REQUIRE to have its normal meaning (provide one
5954 # expansion of the required macro before the current point, and only one
5956 echo "AC_DEFUN([gl_INIT], ["
5957 if test "$auxdir" != "build-aux"; then
5958 sed_replace_build_aux='
5960 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5961 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5965 sed_replace_build_aux="$sed_noop"
5967 echo "gl_m4_base='$m4base'"
5968 func_emit_initmacro_start $macro_prefix
5969 echo "gl_source_base='$sourcebase'"
5970 if $single_configure; then
5971 func_emit_autoconf_snippets "$main_modules" func_verify_module true false false
5973 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
5975 func_emit_initmacro_end $macro_prefix
5976 if $single_configure; then
5977 echo " gltests_libdeps="
5978 echo " gltests_ltlibdeps="
5979 func_emit_initmacro_start ${macro_prefix}tests
5980 echo " gl_source_base='$testsbase'"
5981 # Define a tests witness macro.
5982 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
5983 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5984 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5985 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5986 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true false false
5987 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5988 func_emit_initmacro_end ${macro_prefix}tests
5990 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5991 # created using libtool, because libtool already handles the dependencies.
5992 if test "$libtool" != true; then
5993 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5994 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5995 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5996 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5997 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5999 if $single_configure; then
6000 if $use_libtests; then
6001 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6002 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6006 func_emit_initmacro_done $macro_prefix $sourcebase
6007 if $single_configure; then
6008 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6013 if test -n "$subdirs_with_configure_ac"; then
6014 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6016 makefiles="Makefile"
6017 for d in $subdirs; do
6018 # For subdirs that have a configure.ac by their own, it's the subdir's
6019 # configure.ac which creates the subdir's Makefile.am, not this one.
6020 case " $subdirs_with_configure_ac " in
6022 *) func_append makefiles " $d/Makefile" ;;
6025 echo "AC_CONFIG_FILES([$makefiles])"
6027 ) > "$testdir/configure.ac"
6029 # Create autogenerated files.
6031 # Do not use "${AUTORECONF} --force --install", because it may invoke
6032 # autopoint, which brings in older versions of some of our .m4 files.
6033 if test -f $m4base/gettext.m4; then
6034 func_execute_command ${AUTOPOINT} --force || func_exit 1
6035 for f in $m4base/*.m4~; do
6037 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6041 if test "$libtool" = true; then
6042 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6044 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6045 if ! test -d build-aux; then
6046 func_execute_command mkdir build-aux || func_exit 1
6048 func_execute_command ${AUTOCONF} || func_exit 1
6049 func_execute_command ${AUTOHEADER} || func_exit 1
6050 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6052 if $inctests && ! $single_configure; then
6053 # Create autogenerated files.
6054 (cd "$testdir/$testsbase" || func_exit 1
6055 # Do not use "${AUTORECONF} --force --install", because it may invoke
6056 # autopoint, which brings in older versions of some of our .m4 files.
6057 if test -f ../$m4base/gettext.m4; then
6058 func_execute_command ${AUTOPOINT} --force || func_exit 1
6059 for f in ../$m4base/*.m4~; do
6061 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6065 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6066 if ! test -d ../build-aux; then
6067 func_execute_command mkdir ../build-aux
6069 func_execute_command ${AUTOCONF} || func_exit 1
6070 func_execute_command ${AUTOHEADER} || func_exit 1
6071 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6074 # Need to run configure and make once, to create built files that are to be
6075 # distributed (such as parse-datetime.c).
6076 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6077 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6078 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6079 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6080 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6081 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6082 # such $(FOO_H) because they don't refer to distributed files.
6083 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6084 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6085 | sed -e "$sed_remove_make_variables"`
6086 distributed_built_sources=`for file in $built_sources; do
6087 case "$cleaned_files" in
6092 tests_distributed_built_sources=
6094 # Likewise for built files in the $testsbase directory.
6095 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6096 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6097 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6098 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6099 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6100 | sed -e "$sed_remove_make_variables"`
6101 tests_distributed_built_sources=`for file in $tests_built_sources; do
6102 case "$tests_cleaned_files" in
6108 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6110 ./configure || func_exit 1
6111 if test -n "$distributed_built_sources"; then
6113 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6114 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6119 if test -n "$tests_distributed_built_sources"; then
6121 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6122 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6127 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6134 # func_create_megatestdir megatestdir allmodules
6136 # - local_gnulib_dir from --local-dir
6137 # - modcache true or false, from --cache-modules/--no-cache-modules
6138 # - auxdir directory relative to destdir where to place build aux files
6139 func_create_megatestdir ()
6143 if test -z "$allmodules"; then
6144 allmodules=`func_all_modules`
6148 # First, all modules one by one.
6149 for onemodule in $allmodules; do
6150 func_create_testdir "$megatestdir/$onemodule" $onemodule
6151 func_append megasubdirs "$onemodule "
6153 # Then, all modules all together.
6154 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6155 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6156 func_create_testdir "$megatestdir/ALL" "$allmodules"
6157 func_append megasubdirs "ALL"
6160 cvsdate=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6161 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6162 | sed -e 's,January,01,' -e 's,Jan,01,' \
6163 -e 's,February,02,' -e 's,Feb,02,' \
6164 -e 's,March,03,' -e 's,Mar,03,' \
6165 -e 's,April,04,' -e 's,Apr,04,' \
6167 -e 's,June,06,' -e 's,Jun,06,' \
6168 -e 's,July,07,' -e 's,Jul,07,' \
6169 -e 's,August,08,' -e 's,Aug,08,' \
6170 -e 's,September,09,' -e 's,Sep,09,' \
6171 -e 's,October,10,' -e 's,Oct,10,' \
6172 -e 's,November,11,' -e 's,Nov,11,' \
6173 -e 's,December,12,' -e 's,Dec,12,' \
6174 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6175 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6177 echo "CVSDATE=$cvsdate"
6178 echo ": \${MAKE=make}"
6179 echo "test -d logs || mkdir logs"
6180 echo "for module in $megasubdirs; do"
6181 echo " echo \"Working on module \$module...\""
6182 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6183 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6186 echo " : autobuild project... \$module"
6187 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6188 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6189 echo " : autobuild hostname... \`hostname\`"
6190 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6192 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6194 ) > "$megatestdir/do-autobuild"
6195 chmod a+x "$megatestdir/do-autobuild"
6197 # Create Makefile.am.
6198 (echo "## Process this file with automake to produce Makefile.in."
6200 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
6202 echo "SUBDIRS = $megasubdirs"
6204 echo "EXTRA_DIST = do-autobuild"
6205 ) > "$megatestdir/Makefile.am"
6207 # Create configure.ac.
6208 (echo "# Process this file with autoconf to produce a configure script."
6209 echo "AC_INIT([dummy], [0])"
6210 if test "$auxdir" != "."; then
6211 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6213 echo "AM_INIT_AUTOMAKE"
6215 echo "AC_PROG_MAKE_SET"
6217 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6218 echo "AC_CONFIG_FILES([Makefile])"
6220 ) > "$megatestdir/configure.ac"
6222 # Create autogenerated files.
6224 # Do not use "${AUTORECONF} --install", because autoreconf operates
6225 # recursively, but the subdirectories are already finished, therefore
6226 # calling autoreconf here would only waste lots of CPU time.
6227 func_execute_command ${ACLOCAL} || func_exit 1
6228 func_execute_command mkdir build-aux
6229 func_execute_command ${AUTOCONF} || func_exit 1
6230 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6236 func_fatal_error "no mode specified" ;;
6243 # sed expression that converts a literal to a basic regular expression.
6244 # Needs to handle . [ \ * ^ $.
6245 sed_literal_to_basic_regex='s/\\/\\\\/g
6251 if test -f "$gnulib_dir/$filename" \
6252 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
6253 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6254 filename_line_regex='^'"$filename_anywhere_regex"'$'
6257 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6258 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
6259 (cd "$local_gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_anywhere_regex" /dev/null | sed -e 's,^modules/,,' -e 's,\.diff$,,')
6262 | func_sanitize_modulelist \
6265 for module in $module_candidates; do
6266 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6271 func_warning "file $filename does not exist"
6276 import | add-import | remove-import | update )
6279 if test -z "$destdir"; then
6282 test -d "$destdir" \
6283 || func_fatal_error "destination directory does not exist: $destdir"
6285 # Prefer configure.ac to configure.in.
6286 if test -f "$destdir"/configure.ac; then
6287 configure_ac="$destdir/configure.ac"
6289 if test -f "$destdir"/configure.in; then
6290 configure_ac="$destdir/configure.in"
6292 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6296 # Analyze configure.ac.
6298 guessed_libtool=false
6303 /AC_CONFIG_AUX_DIR/ {
6304 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6306 /A[CM]_PROG_LIBTOOL/ {
6307 s,^.*$,guessed_libtool=true,p
6309 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6311 if test -z "$auxdir"; then
6312 auxdir="$guessed_auxdir"
6315 # Determine where to apply func_import.
6316 if test "$mode" = import; then
6317 # Apply func_import to a particular gnulib directory.
6318 # The command line contains the complete specification; don't look at
6319 # the contents of gnulib-cache.m4.
6320 test -n "$supplied_libname" || supplied_libname=true
6321 test -n "$sourcebase" || sourcebase="lib"
6322 test -n "$m4base" || m4base="m4"
6323 test -n "$docbase" || docbase="doc"
6324 test -n "$testsbase" || testsbase="tests"
6325 test -n "$macro_prefix" || macro_prefix="gl"
6328 if test -n "$m4base"; then
6329 # Apply func_import to a particular gnulib directory.
6330 # Any number of additional modules can be given.
6331 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6332 # First use of gnulib in the given m4base.
6333 test -n "$supplied_libname" || supplied_libname=true
6334 test -n "$sourcebase" || sourcebase="lib"
6335 test -n "$docbase" || docbase="doc"
6336 test -n "$testsbase" || testsbase="tests"
6337 test -n "$macro_prefix" || macro_prefix="gl"
6341 # Apply func_import to all gnulib directories.
6342 # To get this list of directories, look at Makefile.am. (Not at
6343 # configure, because it may be omitted from version control. Also,
6344 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6348 if test -f "$destdir"/Makefile.am; then
6349 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6351 for arg in $aclocal_amflags; do
6352 if test -n "$m4dir_is_next"; then
6353 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6357 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6358 func_append m4dirs " $arg"
6359 m4dirs_count=`expr $m4dirs_count + 1`
6365 if test "X$arg" = "X-I"; then
6373 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6374 if test -f "$destdir"/aclocal.m4; then
6375 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6376 sedexpr2='s,^[^/]*$,.,'
6377 sedexpr3='s,/[^/]*$,,'
6378 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6379 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6380 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6383 if test $m4dirs_count = 0; then
6384 # First use of gnulib in a package.
6385 # Any number of additional modules can be given.
6386 test -n "$supplied_libname" || supplied_libname=true
6387 test -n "$sourcebase" || sourcebase="lib"
6389 test -n "$docbase" || docbase="doc"
6390 test -n "$testsbase" || testsbase="tests"
6391 test -n "$macro_prefix" || macro_prefix="gl"
6394 if test $m4dirs_count = 1; then
6395 # There's only one use of gnulib here. Assume the user means it.
6396 # Any number of additional modules can be given.
6397 for m4base in $m4dirs; do
6401 # Ambiguous - guess what the user meant.
6402 if test $# = 0; then
6403 # No further arguments. Guess the user wants to update all of them.
6404 for m4base in $m4dirs; do
6405 # Perform func_import in a subshell, so that variable values
6407 # local_gnulib_dir, incobsolete, inc_cxx_tests,
6408 # inc_longrunning_tests, inc_privileged_tests,
6409 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6410 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6411 # makefile_name, libtool, macro_prefix, po_domain,
6412 # witness_c_macro, vc_files
6413 # don't propagate from one directory to another.
6414 (func_import) || func_exit 1
6418 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6427 if test -z "$destdir"; then
6428 func_fatal_error "please specify --dir option"
6431 test -d "$destdir" \
6432 || func_fatal_error "could not create destination directory"
6433 test -n "$auxdir" || auxdir="build-aux"
6434 func_create_testdir "$destdir" "$*"
6437 create-megatestdir )
6438 if test -z "$destdir"; then
6439 func_fatal_error "please specify --dir option"
6441 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6442 test -n "$auxdir" || auxdir="build-aux"
6443 func_create_megatestdir "$destdir" "$*"
6447 test -n "$destdir" || destdir=testdir$$
6448 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6449 test -n "$auxdir" || auxdir="build-aux"
6450 func_create_testdir "$destdir" "$*"
6454 ../configure || func_exit 1
6455 $MAKE || func_exit 1
6456 $MAKE check || func_exit 1
6457 $MAKE distclean || func_exit 1
6458 remaining=`find . -type f -print`
6459 if test -n "$remaining"; then
6460 echo "Remaining files:" $remaining 1>&2
6461 echo "gnulib-tool: *** Stop." 1>&2
6470 test -n "$destdir" || destdir=testdir$$
6471 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6472 test -n "$auxdir" || auxdir="build-aux"
6473 func_create_megatestdir "$destdir" "$*"
6481 remaining=`find . -type f -print`
6482 if test -n "$remaining"; then
6483 echo "Remaining files:" $remaining 1>&2
6484 echo "gnulib-tool: *** Stop." 1>&2
6492 extract-description )
6496 if test -n "$module"; then
6497 func_get_description "$module"
6506 if test -n "$module"; then
6507 func_get_comment "$module"
6516 if test -n "$module"; then
6517 func_get_status "$module"
6526 if test -n "$module"; then
6527 func_get_notice "$module"
6532 extract-applicability )
6536 if test -n "$module"; then
6537 func_get_applicability "$module"
6546 if test -n "$module"; then
6547 func_get_filelist "$module"
6552 extract-dependencies )
6553 if test -n "$avoidlist"; then
6554 func_fatal_error "cannot combine --avoid and --extract-dependencies"
6559 if test -n "$module"; then
6560 func_get_dependencies "$module"
6565 extract-autoconf-snippet )
6569 if test -n "$module"; then
6570 func_get_autoconf_snippet "$module"
6575 extract-automake-snippet )
6579 if test -n "$module"; then
6580 func_get_automake_snippet "$module"
6585 extract-include-directive )
6589 if test -n "$module"; then
6590 func_get_include_directive "$module"
6595 extract-link-directive )
6599 if test -n "$module"; then
6600 func_get_link_directive "$module"
6609 if test -n "$module"; then
6610 func_get_license "$module"
6615 extract-maintainer )
6619 if test -n "$module"; then
6620 func_get_maintainer "$module"
6625 extract-tests-module )
6629 if test -n "$module"; then
6630 func_get_tests_module "$module"
6636 # Verify the number of arguments.
6637 if test $# -lt 1 || test $# -gt 2; then
6638 func_fatal_error "invalid number of arguments for --$mode"
6641 # The first argument is the file to be copied.
6643 # Verify the file exists.
6644 func_lookup_file "$f"
6646 # The second argument is the destination; either a directory ot a file.
6647 # It defaults to the current directory.
6649 test -n "$dest" || dest='.'
6650 test -n "$sourcebase" || sourcebase="lib"
6651 test -n "$m4base" || m4base="m4"
6652 test -n "$docbase" || docbase="doc"
6653 test -n "$testsbase" || testsbase="tests"
6654 test -n "$auxdir" || auxdir="build-aux"
6655 rewritten='%REWRITTEN%'
6656 sed_rewrite_files="\
6657 s,^build-aux/,$rewritten$auxdir/,
6658 s,^doc/,$rewritten$docbase/,
6659 s,^lib/,$rewritten$sourcebase/,
6660 s,^m4/,$rewritten$m4base/,
6661 s,^tests/,$rewritten$testsbase/,
6664 if test -d "$dest"; then
6666 g=`echo "$f" | sed -e "$sed_rewrite_files"`
6668 destdir=`dirname "$dest"`
6669 g=`basename "$dest"`
6672 # Create the directory for destfile.
6673 d=`dirname "$destdir/$g"`
6675 if test -n "$d" && test ! -d "$d"; then
6676 mkdir -p "$d" || func_fatal_error "failed"
6680 func_dest_tmpfilename "$g"
6681 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
6682 already_present=true
6683 if test -f "$destdir/$g"; then
6684 # The file already exists.
6688 # Don't protest if the file should be there but isn't: it happens
6689 # frequently that developers don't put autogenerated files under version
6697 func_fatal_error "unknown operation mode --$mode" ;;
6701 # Undo the effect of the previous 'trap' command. Some shellology:
6702 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6703 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6704 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6705 # 128 + signal number and is set before the trap-registered command is run.
6707 trap 'func_exit $?' 1 2 3 13 15
6712 # indent-tabs-mode: nil
6713 # whitespace-check-buffer-indent: nil