3 # Copyright (C) 2002-2011 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
192 --dir=DIRECTORY Specify the target directory.
193 For --import, this specifies where your
194 configure.ac can be found. Defaults to current
196 --local-dir=DIRECTORY Specify a local override directory where to look
197 up files before looking in gnulib's directory.
198 --cache-modules Enable module caching optimization.
199 --no-cache-modules Disable module caching optimization.
200 --verbose Increase verbosity. May be repeated.
201 --quiet Decrease verbosity. May be repeated.
203 Options for --import, --add/remove-import, --update:
205 --dry-run Only print what would have been done.
207 Options for --import, --add/remove-import,
208 --create-[mega]testdir, --[mega]test:
210 --with-tests Include unit tests for the included modules.
211 --with-obsolete Include obsolete modules when they occur among the
212 dependencies. By default, dependencies to obsolete
214 --with-c++-tests Include even unit tests for C++ interoperability.
215 --with-longrunning-tests
216 Include even unit tests that are long-runners.
217 --with-privileged-tests
218 Include even unit tests that require root
220 --with-unportable-tests
221 Include even unit tests that fail on some platforms.
222 --with-all-tests Include all kinds of problematic unit tests.
223 --avoid=MODULE Avoid including the given MODULE. Useful if you
224 have code that provides equivalent functionality.
225 This option can be repeated.
226 --conditional-dependencies
227 Support conditional dependencies (may save configure
228 time and object code).
229 --no-conditional-dependencies
230 Don't use conditional dependencies.
231 --libtool Use libtool rules.
232 --no-libtool Don't use libtool rules.
234 Options for --import, --add/remove-import:
236 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
237 --source-base=DIRECTORY
238 Directory relative to --dir where source code is
239 placed (default \"lib\").
240 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
241 placed (default \"m4\").
242 --po-base=DIRECTORY Directory relative to --dir where *.po files are
243 placed (default \"po\").
244 --doc-base=DIRECTORY Directory relative to --dir where doc files are
245 placed (default \"doc\").
246 --tests-base=DIRECTORY
247 Directory relative to --dir where unit tests are
248 placed (default \"tests\").
249 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
250 tools are placed (default comes from configure.ac).
251 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
252 Also modify license template from GPL to LGPL.
253 The version number of the LGPL can be specified;
254 the default is currently LGPLv3.
255 --makefile-name=NAME Name of makefile in automake syntax in the
256 source-base and tests-base directories
257 (default \"Makefile.am\").
258 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
259 'gl_INIT'. Default is 'gl'.
260 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
261 the package name. A suffix '-gnulib' is appended.
262 --vc-files Update version control related files.
263 --no-vc-files Don't update version control related files
264 (.gitignore and/or .cvsignore).
265 --no-changelog Don't update or create ChangeLog files.
267 Options for --create-[mega]testdir, --[mega]test:
269 --without-c++-tests Exclude unit tests for C++ interoperability.
270 --without-longrunning-tests
271 Exclude unit tests that are long-runners.
272 --without-privileged-tests
273 Exclude unit tests that require root privileges.
274 --without-unportable-tests
275 Exclude unit tests that fail on some platforms.
276 --single-configure Generate a single configure file, not a separate
277 configure file for the tests directory.
279 Options for --import, --add/remove-import, --update,
280 --create-[mega]testdir, --[mega]test:
282 -s, --symbolic, --symlink Make symbolic links instead of copying files.
283 --local-symlink Make symbolic links instead of copying files, only
284 for files from the local override directory.
286 Options for --import, --add/remove-import, --update:
288 -S, --more-symlinks Make symbolic links instead of copying files, and
289 don't replace copyright notices.
291 Report bugs to <bug-gnulib@gnu.org>."
295 # outputs to stdout the --version message.
299 if test -d "$gnulib_dir"/.git \
300 && (git --version) >/dev/null 2>/dev/null \
301 && (date --version) >/dev/null 2>/dev/null; then
302 # gnulib checked out from git.
303 sed_extract_first_date='/^Date/{
307 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
308 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
309 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
310 date=`echo "$date" | sed -e "$sed_year_before_time"`
311 # Use GNU date to compute the time in GMT.
312 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
313 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
315 if test -d "$gnulib_dir"/CVS \
316 && (cvs --version) >/dev/null 2>/dev/null; then
317 # gnulib checked out from CVS.
318 sed_extract_first_date='/^date: /{
319 s/^date: \([0-9][0-9][0-9][0-9]\).\([0-9][0-9]\).\([0-9][0-9]\) \([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\).*/\1-\2-\3 \4/p
322 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
324 # gnulib copy without versioning information.
325 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 Written by" "Bruno Haible" "and" "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, distributed under the terms of the GNU"
350 echo "# General Public License. As a special exception to the GNU General"
351 echo "# Public License, this file may be distributed as part of a program"
352 echo "# that contains a configuration script generated by Autoconf, under"
353 echo "# the same distribution terms as the rest of that program."
355 echo "# Generated by gnulib-tool."
359 # exits with a given status.
360 # This function needs to be used, rather than 'exit', when a 'trap' handler is
361 # in effect that refers to $?.
368 # locates the directory where the gnulib repository lives
370 # - progname name of this program
372 # - self_abspathname absolute pathname of gnulib-tool
373 # - gnulib_dir absolute pathname of gnulib repository
377 /*) self_abspathname="$progname" ;;
378 */*) self_abspathname=`pwd`/"$progname" ;;
381 # Iterate through the elements of $PATH.
382 # We use IFS=: instead of
383 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
384 # because the latter does not work when some PATH element contains spaces.
385 # We use a canonicalized $pathx instead of $PATH, because empty PATH
386 # elements are by definition equivalent to '.', however field splitting
387 # according to IFS=: loses empty fields in many shells:
388 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
389 # beginning, at the end, and in the middle),
390 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
391 # at the beginning and at the end,
392 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
393 # Solaris lose empty fields at the end.
394 # The 'case' statement is an optimization, to avoid evaluating the
395 # explicit canonicalization command when $PATH contains no empty fields.
397 if test "${PATH_SEPARATOR+set}" != set; then
398 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
399 # contains only /bin. Note that ksh looks also at the FPATH variable,
400 # so we have to set that as well for the test.
402 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
403 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
404 || PATH_SEPARATOR=';'
407 if test "$PATH_SEPARATOR" = ";"; then
408 # On Windows, programs are searched in "." before $PATH.
411 # On Unix, we have to convert empty PATH elements to ".".
415 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
420 IFS="$PATH_SEPARATOR"
424 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
425 self_abspathname="$d/$progname"
430 if test -z "$self_abspathname"; then
431 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
435 while test -h "$self_abspathname"; do
436 # Resolve symbolic link.
437 linkval=`func_readlink "$self_abspathname"`
438 test -n "$linkval" || break
440 /* ) self_abspathname="$linkval" ;;
441 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
444 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
448 # creates a temporary directory.
450 # - progname name of this program
452 # - tmp pathname of freshly created temporary directory
455 # Use the environment variable TMPDIR, falling back to /tmp. This allows
456 # users to specify a different temporary directory, for example, if their
457 # /tmp is filled up or too small.
460 # Use the mktemp program if available. If not available, hide the error
462 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
463 test -n "$tmp" && test -d "$tmp"
466 # Use a simple mkdir command. It is guaranteed to fail if the directory
467 # already exists. $RANDOM is bash specific and expands to empty in shells
468 # other than bash, ksh and zsh. Its use does not increase security;
469 # rather, it minimizes the probability of failure in a very cluttered /tmp
471 tmp=$TMPDIR/gl$$-$RANDOM
472 (umask 077 && mkdir "$tmp")
475 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
480 # func_append var value
481 # appends the given value to the shell variable var.
482 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
483 # Use bash's += operator. It reduces complexity of appending repeatedly to
484 # a single variable from O(n^2) to O(n).
489 fast_func_append=true
493 eval "$1=\"\$$1\$2\""
495 fast_func_append=false
498 # func_remove_prefix var prefix
499 # removes the given prefix from the value of the shell variable var.
500 # var should be the name of a shell variable.
501 # Its value should not contain a newline and not start or end with whitespace.
502 # prefix should not contain the characters "$`\{}[]^|.
503 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
504 func_remove_prefix ()
508 fast_func_remove_prefix=true
510 func_remove_prefix ()
512 eval "value=\"\$$1\""
516 sed_escape_dots='s/\([.]\)/\\\1/g'
517 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
520 value=`echo "$value" | sed -e "s|^${prefix}||"`
521 eval "$1=\"\$value\""
523 fast_func_remove_prefix=false
526 # func_remove_suffix var suffix
527 # removes the given suffix from the value of the shell variable var.
528 # var should be the name of a shell variable.
529 # Its value should not contain a newline and not start or end with whitespace.
530 # suffix should not contain the characters "$`\{}[]^|.
531 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
532 func_remove_suffix ()
536 fast_func_remove_suffix=true
538 func_remove_suffix ()
540 eval "value=\"\$$1\""
544 sed_escape_dots='s/\([.]\)/\\\1/g'
545 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
548 value=`echo "$value" | sed -e "s|${suffix}\$||"`
549 eval "$1=\"\$value\""
551 fast_func_remove_suffix=false
554 # func_fatal_error message
555 # outputs to stderr a fatal error message, and terminates the program.
557 # - progname name of this program
560 echo "$progname: *** $1" 1>&2
561 echo "$progname: *** Stop." 1>&2
565 # func_warning message
566 # Outputs to stderr a warning message,
569 echo "gnulib-tool: warning: $1" 1>&2
572 # func_readlink SYMLINK
573 # outputs the target of the given symlink.
574 if (type -p readlink) > /dev/null 2>&1; then
577 # Use the readlink program from GNU coreutils.
583 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
584 # would do the wrong thing if the link target contains " -> ".
585 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
589 # func_relativize DIR1 DIR2
590 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
592 # - DIR1 relative pathname, relative to the current directory
593 # - DIR2 relative pathname, relative to the current directory
595 # - reldir relative pathname of DIR2, relative to DIR1
601 sed_first='s,^\([^/]*\)/.*$,\1,'
602 sed_rest='s,^[^/]*/*,,'
603 sed_last='s,^.*/\([^/]*\)$,\1,'
604 sed_butlast='s,/*[^/]*$,,'
605 while test -n "$dir1"; do
606 first=`echo "$dir1" | sed -e "$sed_first"`
607 if test "$first" != "."; then
608 if test "$first" = ".."; then
609 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
610 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
612 first2=`echo "$dir2" | sed -e "$sed_first"`
613 if test "$first2" = "$first"; then
614 dir2=`echo "$dir2" | sed -e "$sed_rest"`
618 dir0="$dir0"/"$first"
621 dir1=`echo "$dir1" | sed -e "$sed_rest"`
626 # func_relconcat DIR1 DIR2
627 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
629 # - DIR1 relative pathname, relative to the current directory
630 # - DIR2 relative pathname, relative to DIR1
632 # - relconcat DIR1/DIR2, relative to the current directory
637 sed_first='s,^\([^/]*\)/.*$,\1,'
638 sed_rest='s,^[^/]*/*,,'
639 sed_last='s,^.*/\([^/]*\)$,\1,'
640 sed_butlast='s,/*[^/]*$,,'
642 first=`echo "$dir2" | sed -e "$sed_first"`
643 if test "$first" = "."; then
644 dir2=`echo "$dir2" | sed -e "$sed_rest"`
645 if test -z "$dir2"; then
650 last=`echo "$dir1" | sed -e "$sed_last"`
651 while test "$last" = "."; do
652 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
653 last=`echo "$dir1" | sed -e "$sed_last"`
655 if test -z "$dir1"; then
659 if test "$first" = ".."; then
660 if test "$last" = ".."; then
661 relconcat="$dir1/$dir2"
664 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
665 dir2=`echo "$dir2" | sed -e "$sed_rest"`
666 if test -z "$dir1"; then
670 if test -z "$dir2"; then
675 relconcat="$dir1/$dir2"
683 # Like ln -s, except that SRC is given relative to the current directory (or
684 # absolute), not given relative to the directory of DEST.
690 *) # SRC is relative.
693 ln -s "`pwd`/$1" "$2" ;;
694 *) # DEST is relative too.
695 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
696 test -n "$ln_destdir" || ln_destdir="."
697 func_relativize "$ln_destdir" "$1"
705 # func_ln_if_changed SRC DEST
706 # Like func_ln, but avoids munging timestamps if the link is correct.
707 func_ln_if_changed ()
709 if test $# -ne 2; then
710 echo "usage: func_ln_if_changed SRC DEST" >&2
712 ln_target=`func_readlink "$2"`
713 if test -h "$2" && test "$1" = "$ln_target"; then
721 # Ensure an 'echo' command that
722 # 1. does not interpret backslashes and
723 # 2. does not print an error message "broken pipe" when writing into a pipe
726 # Test cases for problem 1:
727 # echo '\n' | wc -l prints 1 when OK, 2 when KO
728 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
729 # Test cases for problem 2:
730 # echo hi | true frequently prints
731 # "bash: echo: write error: Broken pipe"
732 # to standard error in bash 3.2.
734 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
735 # BSD echo interprets '-n' as an option, which is also not desirable).
736 # Nowadays the problem occurs in 4 situations:
737 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
738 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
739 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
740 # - in zsh, when sh-emulation is not set,
741 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
742 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
743 # - in Solaris /bin/sh and OSF/1 /bin/sh.
744 # We try the following workarounds:
745 # - for all: respawn using $CONFIG_SHELL if that is set and works.
746 # - for bash >= 2.04: unset the shell option xpg_echo.
747 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
748 # - for bash < 2.0: define echo to a function that uses cat of a here document.
749 # - for zsh: turn sh-emulation on.
750 # - for ksh: alias echo to 'print -r'.
751 # - for ksh: alias echo to a function that uses cat of a here document.
752 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
753 # the ksh workaround.
754 # - otherwise: respawn using /bin/sh and rely on the workarounds.
755 # When respawning, we pass --no-reexec as first argument, so as to avoid
756 # turning this script into a fork bomb in unlucky situations.
758 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
759 # the 'printf' built-in. See
760 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
761 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
762 # The workaround is: define echo to a function that uses the printf built-in.
764 if echo '\t' | grep t > /dev/null; then
765 have_echo=yes # Lucky!
767 # Try the workarounds.
768 # Respawn using $CONFIG_SHELL if that is set and works.
769 if test -z "$have_echo" \
770 && test "X$1" != "X--no-reexec" \
771 && test -n "$CONFIG_SHELL" \
772 && test -f "$CONFIG_SHELL" \
773 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
774 exec $CONFIG_SHELL "$0" --no-reexec "$@"
777 # For bash >= 2.04: unset the shell option xpg_echo.
778 if test -z "$have_echo" \
779 && test -n "$BASH_VERSION" \
780 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
784 # For bash >= 2.0: define echo to a function that uses the printf built-in.
785 # For bash < 2.0: define echo to a function that uses cat of a here document.
786 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
787 # Also handle problem 2, specific to bash 3.2, here.
788 if { test -z "$have_echo" \
789 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
791 && test -n "$BASH_VERSION"; then \
792 if type printf 2>/dev/null | grep / > /dev/null; then
793 # 'printf' is not a shell built-in.
801 # 'printf' is a shell built-in.
807 if echo '\t' | grep t > /dev/null; then
811 # For zsh: turn sh-emulation on.
812 if test -z "$have_echo" \
813 && test -n "$ZSH_VERSION" \
814 && (emulate sh) >/dev/null 2>&1; then
817 # For ksh: alias echo to 'print -r'.
818 if test -z "$have_echo" \
819 && (type print) >/dev/null 2>&1; then
820 # A 'print' command exists.
821 if type print 2>/dev/null | grep / > /dev/null; then
824 # 'print' is a shell built-in.
825 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
826 # 'print' is the ksh shell built-in.
827 alias echo='print -r'
831 if test -z "$have_echo" \
832 && echo '\t' | grep t > /dev/null; then
835 # For ksh: alias echo to a function that uses cat of a here document.
836 # The ksh manual page says:
837 # "Aliasing is performed when scripts are read, not while they are executed.
838 # Therefore, for an alias to take effect, the alias definition command has
839 # to be executed before the command which references the alias is read."
840 # Because of this, we have to play strange tricks with have_echo, to ensure
841 # that the top-level statement containing the test starts after the 'alias'
843 if test -z "$have_echo"; then
850 if (alias echo=bsd_echo) 2>/dev/null; then
851 alias echo=bsd_echo 2>/dev/null
854 if test -z "$have_echo" \
855 && echo '\t' | grep t > /dev/null; then
858 if test -z "$have_echo"; then
859 if (alias echo=bsd_echo) 2>/dev/null; then
860 unalias echo 2>/dev/null
863 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
864 if test -z "$have_echo" \
865 && test "X$1" != "X--no-reexec" \
866 && test -f /bin/ksh; then
867 exec /bin/ksh "$0" --no-reexec "$@"
870 # Otherwise: respawn using /bin/sh.
871 if test -z "$have_echo" \
872 && test "X$1" != "X--no-reexec" \
873 && test -f /bin/sh; then
874 exec /bin/sh "$0" --no-reexec "$@"
877 if test -z "$have_echo"; then
878 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
880 if echo '\t' | grep t > /dev/null; then
883 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
885 if test "X$1" = "X--no-reexec"; then
889 # Command-line option processing.
890 # Removes the OPTIONS from the arguments. Sets the variables:
891 # - mode list or import or add-import or remove-import or update
892 # or create-testdir or create-megatestdir
893 # - destdir from --dir
894 # - local_gnulib_dir from --local-dir
895 # - modcache true or false, from --cache-modules/--no-cache-modules
896 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
897 # - libname, supplied_libname from --lib
898 # - sourcebase from --source-base
899 # - m4base from --m4-base
900 # - pobase from --po-base
901 # - docbase from --doc-base
902 # - testsbase from --tests-base
903 # - auxdir from --aux-dir
904 # - inctests true if --with-tests was given, blank otherwise
905 # - incobsolete true if --with-obsolete was given, blank otherwise
906 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
907 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
909 # - inc_privileged_tests true if --with-privileged-tests was given, blank
911 # - inc_unportable_tests true if --with-unportable-tests was given, blank
913 # - inc_all_tests true if --with-all-tests was given, blank otherwise
914 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
915 # - excl_longrunning_tests true if --without-longrunning-tests was given,
917 # - excl_privileged_tests true if --without-privileged-tests was given, blank
919 # - excl_unportable_tests true if --without-unportable-tests was given, blank
921 # - single_configure true if --single-configure was given, false otherwise
922 # - avoidlist list of modules to avoid, from --avoid
923 # - cond_dependencies true if --conditional-dependencies was given, false if
924 # --no-conditional-dependencies was given, blank otherwise
925 # - lgpl yes or a number if --lgpl was given, blank otherwise
926 # - makefile_name from --makefile-name
927 # - libtool true if --libtool was given, false if --no-libtool was
928 # given, blank otherwise
929 # - macro_prefix from --macro-prefix
930 # - po_domain from --po-domain
931 # - vc_files true if --vc-files was given, false if --no-vc-files was
932 # given, blank otherwise
933 # - autoconf_minversion minimum supported autoconf version
934 # - do_changelog false if --no-changelog was given, : otherwise
935 # - doit : if actions shall be executed, false if only to be printed
936 # - symbolic true if --symlink or --more-symlinks was given, blank
938 # - lsymbolic true if --local-symlink was given, blank otherwise
939 # - do_copyrights blank if --more-symlinks was given, true otherwise
957 inc_longrunning_tests=
958 inc_privileged_tests=
959 inc_unportable_tests=
962 excl_longrunning_tests=
963 excl_privileged_tests=
964 excl_unportable_tests=
965 single_configure=false
982 while test $# -gt 0; do
987 --find | --fin | --fi | --f )
990 --import | --impor | --impo | --imp | --im | --i )
993 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
996 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
999 --update | --updat | --upda | --upd | --up | --u )
1002 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1005 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1006 mode=create-megatestdir
1008 --test | --tes | --te | --t )
1011 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1015 mode=`echo "X$1" | sed -e 's/^X--//'`
1017 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1022 if test $# = 0; then
1023 func_fatal_error "missing argument for --dir"
1028 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1032 if test $# = 0; then
1033 func_fatal_error "missing argument for --local-dir"
1038 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1040 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1043 --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 )
1046 --verbose | --verbos | --verbo | --verb )
1047 verbose=`expr $verbose + 1`
1049 --quiet | --quie | --qui | --qu | --q )
1050 verbose=`expr $verbose - 1`
1054 if test $# = 0; then
1055 func_fatal_error "missing argument for --lib"
1058 supplied_libname=true
1061 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1062 supplied_libname=true
1066 if test $# = 0; then
1067 func_fatal_error "missing argument for --source-base"
1072 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1076 if test $# = 0; then
1077 func_fatal_error "missing argument for --m4-base"
1082 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1086 if test $# = 0; then
1087 func_fatal_error "missing argument for --po-base"
1092 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1096 if test $# = 0; then
1097 func_fatal_error "missing argument for --doc-base"
1102 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1106 if test $# = 0; then
1107 func_fatal_error "missing argument for --tests-base"
1112 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1116 if test $# = 0; then
1117 func_fatal_error "missing argument for --aux-dir"
1122 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1124 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1127 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1130 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1133 --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)
1134 inc_longrunning_tests=true
1136 --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)
1137 inc_privileged_tests=true
1139 --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)
1140 inc_unportable_tests=true
1142 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1145 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1148 --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)
1149 excl_longrunning_tests=true
1151 --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)
1152 excl_privileged_tests=true
1154 --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)
1155 excl_unportable_tests=true
1157 --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)
1158 single_configure=true
1162 if test $# = 0; then
1163 func_fatal_error "missing argument for --avoid"
1165 func_append avoidlist " $1"
1168 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1169 func_append avoidlist " $arg"
1171 --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)
1172 cond_dependencies=true
1174 --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)
1175 cond_dependencies=false
1181 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1184 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1190 if test $# = 0; then
1191 func_fatal_error "missing argument for --makefile-name"
1196 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1206 if test $# = 0; then
1207 func_fatal_error "missing argument for --macro-prefix"
1212 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1216 if test $# = 0; then
1217 func_fatal_error "missing argument for --po-domain"
1222 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1230 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1236 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1239 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1242 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1246 --help | --hel | --he | --h )
1249 --version | --versio | --versi | --vers )
1253 # Stop option processing
1257 echo "gnulib-tool: unknown option $1" 1>&2
1258 echo "Try 'gnulib-tool --help' for more information." 1>&2
1265 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1266 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1267 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1268 || test "$single_configure" != false; then
1269 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1270 echo "Try 'gnulib-tool --help' for more information." 1>&2
1274 # This code helps migrating from --import to --add-import or --update. It can
1275 # be removed on 2012-01-01.
1276 if test "$mode" = import && test $# = 0; then
1277 echo "gnulib-tool: cowardly refusing to erase the module list." 1>&2
1278 echo "The meaning of the option '--import' has changed." 1>&2
1279 echo "See the documentation at" 1>&2
1280 echo "<http://www.gnu.org/software/gnulib/manual/html_node/Modified-imports.html>." 1>&2
1281 echo "For updating to a newer version of gnulib, use" 1>&2
1282 echo " gnulib-tool --add-import" 1>&2
1283 echo "For restoring files that were omitted from version control, use" 1>&2
1284 echo " gnulib-tool --update" 1>&2
1287 if test "$mode" = update; then
1288 if test $# != 0; then
1289 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1290 echo "Try 'gnulib-tool --help' for more information." 1>&2
1291 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1292 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1295 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1296 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1297 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1298 || test -n "$inctests" || test -n "$incobsolete" \
1299 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1300 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1301 || test -n "$inc_all_tests" \
1302 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1303 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1304 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1305 || test -n "$macro_prefix" || test -n "$po_domain" \
1306 || test -n "$vc_files"; then
1307 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1308 echo "Try 'gnulib-tool --help' for more information." 1>&2
1309 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1310 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1315 if test -n "$pobase" && test -z "$po_domain"; then
1316 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1317 echo "Try 'gnulib-tool --help' for more information." 1>&2
1320 if test -z "$pobase" && test -n "$po_domain"; then
1321 func_warning "--po-domain has no effect without a --po-base option"
1323 if test "$cond_dependencies" = true && test -n "$inctests"; then
1324 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1328 # Determine the minimum supported autoconf version from the project's
1330 DEFAULT_AUTOCONF_MINVERSION="2.59"
1331 autoconf_minversion=
1333 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1334 && test -n "$destdir"; then
1335 if test -f "$destdir"/configure.ac; then
1336 configure_ac="$destdir/configure.ac"
1338 if test -f "$destdir"/configure.in; then
1339 configure_ac="$destdir/configure.in"
1343 if test -f configure.ac; then
1344 configure_ac="configure.ac"
1346 if test -f configure.in; then
1347 configure_ac="configure.in"
1351 if test -n "$configure_ac"; then
1352 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1353 # because when some m4 files are omitted from a version control repository,
1354 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1355 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1356 # autom4te: m4 failed with exit status: 1
1363 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1365 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1366 if test -n "$prereqs"; then
1367 autoconf_minversion=`
1368 for version in $prereqs; do echo $version; done |
1369 LC_ALL=C sort -nru | sed -e 1q
1373 if test -z "$autoconf_minversion"; then
1374 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1376 case "$autoconf_minversion" in
1377 1.* | 2.[0-4]* | 2.5[0-8]*)
1378 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1381 # Remove trailing slashes from the directory names. This is necessary for
1382 # m4base (to avoid an error in func_import) and optional for the others.
1383 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1384 case "$local_gnulib_dir" in
1385 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1387 case "$sourcebase" in
1388 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1391 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1394 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1397 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1399 case "$testsbase" in
1400 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1403 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1409 trap 'exit_status=$?
1410 if test "$signal" != 0; then
1411 echo "caught signal $signal" >&2
1414 exit $exit_status' 0
1415 for signal in 1 2 3 13 15; do
1416 trap '{ signal='$signal'; func_exit 1; }' $signal
1420 # Note: The 'eval' silences stderr output in dash.
1421 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1422 # Zsh 4 and Bash 4 have associative arrays.
1423 have_associative=true
1425 # For other shells, use 'eval' with computed shell variable names.
1426 have_associative=false
1429 # func_lookup_file file
1430 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1433 # - local_gnulib_dir from --local-dir
1435 # - lookedup_file name of the merged (combined) file
1436 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1440 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1441 lookedup_file="$local_gnulib_dir/$lkfile"
1444 if test -f "$gnulib_dir/$lkfile"; then
1445 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1446 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1447 rm -f "$tmp/$lkbase"
1448 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1449 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1450 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1451 lookedup_file="$tmp/$lkbase"
1454 lookedup_file="$gnulib_dir/$lkfile"
1458 func_fatal_error "file $gnulib_dir/$lkfile not found"
1463 # func_sanitize_modulelist
1464 # receives a list of possible module names on standard input, one per line.
1465 # It removes those which are just file names unrelated to modules, and outputs
1466 # the resulting list to standard output, one per line.
1467 func_sanitize_modulelist ()
1469 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1470 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1471 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1472 -e '/^README$/d' -e '/\/README$/d' \
1473 -e '/^TEMPLATE$/d' \
1474 -e '/^TEMPLATE-EXTENDED$/d' \
1475 -e '/^TEMPLATE-TESTS$/d' \
1482 # - local_gnulib_dir from --local-dir
1485 # Filter out metainformation files like README, which are not modules.
1486 # Filter out unit test modules; they can be retrieved through
1487 # --extract-tests-module if desired.
1489 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1490 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1491 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1494 | func_sanitize_modulelist \
1495 | sed -e '/-tests$/d' \
1499 # func_exists_module module
1500 # tests whether a module, given by name, exists
1502 # - local_gnulib_dir from --local-dir
1503 func_exists_module ()
1505 { test -f "$gnulib_dir/modules/$1" \
1506 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1507 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1508 && test "CVS" != "$1" \
1509 && test "ChangeLog" != "$1" \
1510 && test "COPYING" != "$1" \
1511 && test "README" != "$1" \
1512 && test "TEMPLATE" != "$1" \
1513 && test "TEMPLATE-EXTENDED" != "$1" \
1514 && test "TEMPLATE-TESTS" != "$1"
1517 # func_verify_module
1518 # verifies a module name
1520 # - local_gnulib_dir from --local-dir
1521 # - module module name argument
1522 func_verify_module ()
1524 if func_exists_module "$module"; then
1525 # OK, $module is a correct module name.
1526 # Verify that building the module description with 'patch' succeeds.
1527 func_lookup_file "modules/$module"
1529 func_warning "module $module doesn't exist"
1534 # func_verify_nontests_module
1535 # verifies a module name, excluding tests modules
1537 # - local_gnulib_dir from --local-dir
1538 # - module module name argument
1539 func_verify_nontests_module ()
1542 *-tests ) module= ;;
1543 * ) func_verify_module ;;
1547 # func_verify_tests_module
1548 # verifies a module name, considering only tests modules
1550 # - local_gnulib_dir from --local-dir
1551 # - module module name argument
1552 func_verify_tests_module ()
1555 *-tests ) func_verify_module ;;
1560 # Suffix of a sed expression that extracts a particular field from a
1561 # module description.
1562 # A field starts with a line that contains a keyword, such as 'Description',
1563 # followed by a colon and optional whitespace. All following lines, up to
1564 # the next field (or end of file if there is none) form the contents of the
1566 # An absent field is equivalent to a field with empty contents.
1567 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1568 sed_extract_prog=':[ ]*$/ {
1571 s/^Description:[ ]*$//
1575 s/^Applicability:[ ]*$//
1577 s/^Depends-on:[ ]*$//
1578 s/^configure\.ac-early:[ ]*$//
1579 s/^configure\.ac:[ ]*$//
1580 s/^Makefile\.am:[ ]*$//
1584 s/^Maintainer:[ ]*$//
1591 # Piece of a sed expression that converts a field header line to a shell
1593 # NOTE: Keep this in sync with sed_extract_prog above!
1594 sed_extract_field_header='
1595 s/^Description:[ ]*$/description/
1596 s/^Comment:[ ]*$/comment/
1597 s/^Status:[ ]*$/status/
1598 s/^Notice:[ ]*$/notice/
1599 s/^Applicability:[ ]*$/applicability/
1600 s/^Files:[ ]*$/files/
1601 s/^Depends-on:[ ]*$/dependson/
1602 s/^configure\.ac-early:[ ]*$/configureac_early/
1603 s/^configure\.ac:[ ]*$/configureac/
1604 s/^Makefile\.am:[ ]*$/makefile/
1605 s/^Include:[ ]*$/include/
1607 s/^License:[ ]*$/license/
1608 s/^Maintainer:[ ]*$/maintainer/'
1612 if $have_associative; then
1614 # Declare the associative arrays.
1615 declare -A modcache_cached
1616 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1617 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1618 eval "$declare_script"
1622 # func_cache_var module
1623 # computes the cache variable name corresponding to $module.
1624 # Note: This computation can map different module names to the same
1625 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1626 # to protect against this case.
1628 # - cachevar a shell variable name
1629 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1630 # Bash 2.0 and newer, ksh, and zsh support the syntax
1631 # ${param//pattern/replacement}
1632 # as a shorthand for
1633 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1634 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1635 eval 'func_cache_var ()
1637 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1644 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1653 # func_init_sed_convert_to_cache_statements
1655 # - modcachevar_assignment
1657 # - sed_convert_to_cache_statements
1658 func_init_sed_convert_to_cache_statements ()
1660 # 'sed' script that turns a module description into shell script
1661 # assignments, suitable to be eval'ed. All active characters are escaped.
1664 # Some module's description
1669 # modcache_description[$1]=\
1670 # 'Some module'"'"'s description
1672 # modcache_files[$1]=\
1675 # c_MODULE_description_set=set; c_MODULE_description=\
1676 # 'Some module'"'"'s description
1678 # c_MODULE_files_set=set; c_MODULE_files=\
1680 # The script consists of two parts:
1681 # 1) Ignore the lines before the first field header.
1682 # 2) A loop, treating non-field-header lines by escaping single quotes
1683 # and adding a closing quote in the last line,
1684 sed_convert_to_cache_statements="
1686 # Here we have not yet seen a field header.
1688 # See if the current line contains a field header.
1691 ${sed_extract_field_header}
1694 # No field header. Ignore the line.
1696 # Read the next line. Upon EOF, just exit.
1701 # The current line contains a field header.
1703 # Turn it into the beginning of an assignment.
1704 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1706 # Move it to the hold space. Don't print it yet,
1707 # because we want no assignment if the field is empty.
1710 # Read the next line.
1711 # Upon EOF, the field was empty. Print no assignment. Just exit.
1714 # See if the current line contains a field header.
1717 ${sed_extract_field_header}
1718 # If it is, the previous field was empty. Print no assignment.
1721 # Not a field header.
1723 # Print the previous line, held in the hold space.
1728 # Transform single quotes.
1731 # Prepend a single quote.
1736 # Move it to the hold space.
1739 # Read the next line.
1746 # See if the current line contains a field header.
1749 ${sed_extract_field_header}
1752 # Print the previous line, held in the hold space.
1757 # Transform single quotes.
1764 # Print the previous line, held in the hold space, with a single quote
1765 # to end the assignment.
1775 # Print the previous line, held in the hold space, with a single quote
1776 # to end the assignment.
1783 if ! $sed_comments; then
1785 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1786 | sed -e 's/^ *//' -e 's/^#.*//'`
1790 if $have_associative; then
1791 # sed_convert_to_cache_statements does not depend on the module.
1792 modcachevar_assignment='modcache_\1[$1]='
1793 func_init_sed_convert_to_cache_statements
1796 # func_cache_lookup_module module
1798 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1799 # of its relevant data in a cache in the memory of the processing shell. If
1800 # already cached, it does not look it up again, thus saving file access time.
1802 # - module non-empty string
1803 # Output if $have_associative:
1804 # - modcache_cached[$module] set to yes
1805 # - modcache_description[$module] ==
1806 # - modcache_status[$module] \ set to the field's value, minus the
1807 # - ... / final newline,
1808 # - modcache_maintainer[$module] == or unset if the field's value is empty
1809 # Output if ! $have_associative:
1810 # - cachevar a shell variable name
1811 # - ${cachevar}_cached set to $module
1812 # - ${cachevar}_description ==
1813 # - ${cachevar}_status \ set to the field's value, minus the
1814 # - ... / final newline,
1815 # - ${cachevar}_maintainer == or unset if the field's value is empty
1816 # - ${cachevar}_description_set ==
1817 # - ${cachevar}_status_set \ set to non-empty if the field's value
1818 # - ... / is non-empty,
1819 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1820 func_cache_lookup_module ()
1822 if $have_associative; then
1823 eval 'cached=${modcache_cached[$1]}'
1826 eval "cached=\"\$${cachevar}_cached\""
1828 if test -z "$cached"; then
1829 # Not found in cache. Look it up on the file system.
1830 func_lookup_file "modules/$1"
1831 if $have_associative; then
1832 eval 'modcache_cached[$1]=yes'
1834 eval "${cachevar}_cached=\"\$1\""
1836 if ! $have_associative; then
1837 # sed_convert_to_cache_statements depends on the module.
1838 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1839 func_init_sed_convert_to_cache_statements
1841 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1842 eval "$cache_statements"
1844 if ! $have_associative; then
1845 if test "$1" != "$cached"; then
1846 func_fatal_error "cache variable collision between $1 and $cached"
1854 # func_get_description module
1856 # - local_gnulib_dir from --local-dir
1857 # - modcache true or false, from --cache-modules/--no-cache-modules
1858 func_get_description ()
1860 if ! $modcache; then
1861 func_lookup_file "modules/$1"
1862 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1864 func_cache_lookup_module "$1"
1865 # Output the field's value, including the final newline (if any).
1866 if $have_associative; then
1867 if eval 'test -n "${modcache_description[$1]+set}"'; then
1868 eval 'echo "${modcache_description[$1]}"'
1871 eval "field_set=\"\$${cachevar}_description_set\""
1872 if test -n "$field_set"; then
1873 eval "field_value=\"\$${cachevar}_description\""
1874 echo "${field_value}"
1880 # func_get_comment module
1882 # - local_gnulib_dir from --local-dir
1883 # - modcache true or false, from --cache-modules/--no-cache-modules
1886 if ! $modcache; then
1887 func_lookup_file "modules/$1"
1888 sed -n -e "/^Comment$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_comment[$1]+set}"'; then
1894 eval 'echo "${modcache_comment[$1]}"'
1897 eval "field_set=\"\$${cachevar}_comment_set\""
1898 if test -n "$field_set"; then
1899 eval "field_value=\"\$${cachevar}_comment\""
1900 echo "${field_value}"
1906 # func_get_status 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 "/^Status$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_status[$1]+set}"'; then
1920 eval 'echo "${modcache_status[$1]}"'
1923 eval "field_set=\"\$${cachevar}_status_set\""
1924 if test -n "$field_set"; then
1925 eval "field_value=\"\$${cachevar}_status\""
1926 echo "${field_value}"
1932 # func_get_notice 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 "/^Notice$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_notice[$1]+set}"'; then
1946 eval 'echo "${modcache_notice[$1]}"'
1949 eval "field_set=\"\$${cachevar}_notice_set\""
1950 if test -n "$field_set"; then
1951 eval "field_value=\"\$${cachevar}_notice\""
1952 echo "${field_value}"
1958 # func_get_applicability module
1960 # - local_gnulib_dir from --local-dir
1961 # - modcache true or false, from --cache-modules/--no-cache-modules
1962 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1963 func_get_applicability ()
1965 if ! $modcache; then
1966 func_lookup_file "modules/$1"
1967 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1969 func_cache_lookup_module "$1"
1970 # Get the field's value, without the final newline.
1971 if $have_associative; then
1972 eval 'my_applicability="${modcache_applicability[$1]}"'
1974 eval "my_applicability=\"\$${cachevar}_applicability\""
1977 if test -n "$my_applicability"; then
1978 echo $my_applicability
1980 # The default is 'main' or 'tests', depending on the module's name.
1982 *-tests) echo "tests";;
1988 # func_get_filelist module
1990 # - local_gnulib_dir from --local-dir
1991 # - modcache true or false, from --cache-modules/--no-cache-modules
1992 func_get_filelist ()
1994 if ! $modcache; then
1995 func_lookup_file "modules/$1"
1996 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1998 func_cache_lookup_module "$1"
1999 # Output the field's value, including the final newline (if any).
2000 if $have_associative; then
2001 if eval 'test -n "${modcache_files[$1]+set}"'; then
2002 eval 'echo "${modcache_files[$1]}"'
2005 eval "field_set=\"\$${cachevar}_files_set\""
2006 if test -n "$field_set"; then
2007 eval "field_value=\"\$${cachevar}_files\""
2008 echo "${field_value}"
2013 echo m4/gnulib-common.m4
2014 case "$autoconf_minversion" in
2021 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2022 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2023 # elements starting with prefix and ending with suffix are considered.
2024 # Processing: removed_prefix and removed_suffix are removed from each element,
2025 # added_prefix and added_suffix are added to each element.
2026 # prefix, suffix should not contain shell-special characters.
2027 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2028 # added_prefix, added_suffix should not contain the characters \|&.
2029 func_filter_filelist ()
2031 if test "$2" != "$nl" \
2032 || { $fast_func_append \
2033 && { test -z "$6" || $fast_func_remove_prefix; } \
2034 && { test -z "$7" || $fast_func_remove_suffix; }; \
2038 # Do not quote possibly-empty parameters in case patterns,
2039 # AIX and HP-UX ksh won't match them if they are empty.
2042 if test -n "$6"; then
2043 func_remove_prefix fff "$6"
2045 if test -n "$7"; then
2046 func_remove_suffix fff "$7"
2049 if test -z "$ffflist"; then
2052 func_append ffflist "$2${fff}"
2058 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2059 ffflist=`for fff in $3; do
2061 $4*$5) echo "$fff" ;;
2063 done | sed -e "$sed_fff_filter"`
2065 eval "$1=\"\$ffflist\""
2068 # func_get_dependencies module
2070 # - local_gnulib_dir from --local-dir
2071 # - modcache true or false, from --cache-modules/--no-cache-modules
2072 func_get_dependencies ()
2074 # ${module}-tests implicitly depends on ${module}, if that module exists.
2078 func_remove_suffix fgd1 '-tests'
2079 if func_exists_module "$fgd1"; then
2084 # Then the explicit dependencies listed in the module description.
2085 if ! $modcache; then
2086 func_lookup_file "modules/$1"
2087 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2089 func_cache_lookup_module "$1"
2090 # Output the field's value, including the final newline (if any).
2091 if $have_associative; then
2092 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2093 eval 'echo "${modcache_dependson[$1]}"'
2096 eval "field_set=\"\$${cachevar}_dependson_set\""
2097 if test -n "$field_set"; then
2098 eval "field_value=\"\$${cachevar}_dependson\""
2099 echo "${field_value}"
2105 # func_get_autoconf_early_snippet module
2107 # - local_gnulib_dir from --local-dir
2108 # - modcache true or false, from --cache-modules/--no-cache-modules
2109 func_get_autoconf_early_snippet ()
2111 if ! $modcache; then
2112 func_lookup_file "modules/$1"
2113 sed -n -e "/^configure\.ac-early$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_configureac_early[$1]+set}"'; then
2119 eval 'echo "${modcache_configureac_early[$1]}"'
2122 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2123 if test -n "$field_set"; then
2124 eval "field_value=\"\$${cachevar}_configureac_early\""
2125 echo "${field_value}"
2131 # func_get_autoconf_snippet module
2133 # - local_gnulib_dir from --local-dir
2134 # - modcache true or false, from --cache-modules/--no-cache-modules
2135 func_get_autoconf_snippet ()
2137 if ! $modcache; then
2138 func_lookup_file "modules/$1"
2139 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2141 func_cache_lookup_module "$1"
2142 # Output the field's value, including the final newline (if any).
2143 if $have_associative; then
2144 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2145 eval 'echo "${modcache_configureac[$1]}"'
2148 eval "field_set=\"\$${cachevar}_configureac_set\""
2149 if test -n "$field_set"; then
2150 eval "field_value=\"\$${cachevar}_configureac\""
2151 echo "${field_value}"
2157 # func_get_automake_snippet_conditional module
2158 # returns the part of the Makefile.am snippet that can be put inside Automake
2161 # - local_gnulib_dir from --local-dir
2162 # - modcache true or false, from --cache-modules/--no-cache-modules
2163 func_get_automake_snippet_conditional ()
2165 if ! $modcache; then
2166 func_lookup_file "modules/$1"
2167 sed -n -e "/^Makefile\.am$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_makefile[$1]+set}"'; then
2173 eval 'echo "${modcache_makefile[$1]}"'
2176 eval "field_set=\"\$${cachevar}_makefile_set\""
2177 if test -n "$field_set"; then
2178 eval "field_value=\"\$${cachevar}_makefile\""
2179 echo "${field_value}"
2185 # func_get_automake_snippet_unconditional module
2186 # returns the part of the Makefile.am snippet that must stay outside of
2187 # Automake conditionals.
2189 # - local_gnulib_dir from --local-dir
2190 # - modcache true or false, from --cache-modules/--no-cache-modules
2191 func_get_automake_snippet_unconditional ()
2195 # *-tests module live in tests/, not lib/.
2196 # Synthesize an EXTRA_DIST augmentation.
2197 all_files=`func_get_filelist $1`
2198 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2199 extra_files="$tests_files"
2200 if test -n "$extra_files"; then
2201 echo "EXTRA_DIST +=" $extra_files
2206 # Synthesize an EXTRA_DIST augmentation.
2207 sed_combine_lines='/\\$/{
2214 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2215 already_mentioned_files=` \
2216 { if ! $modcache; then
2217 func_lookup_file "modules/$1"
2218 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2220 func_cache_lookup_module "$1"
2221 if $have_associative; then
2222 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2223 eval 'echo "${modcache_makefile[$1]}"'
2226 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2227 if test -n "$field_set"; then
2228 eval 'field_value="$'"${cachevar}"'_makefile"'
2229 echo "${field_value}"
2234 | sed -e "$sed_combine_lines" \
2235 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2236 all_files=`func_get_filelist $1`
2237 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2238 # Remove $already_mentioned_files from $lib_files.
2239 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2240 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2241 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2242 if test -n "$extra_files"; then
2243 echo "EXTRA_DIST +=" $extra_files
2246 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2247 # This is necessary so that automake can generate the right list of
2249 # A possible approach would be to use autom4te --trace of the redefined
2250 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2251 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2252 # inside autoconf's built-in macros are not missed).
2253 # But it's simpler and more robust to do it here, based on the file list.
2254 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2255 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2256 # automake will generate a useless dependency; this is harmless.
2258 relocatable-prog-wrapper) ;;
2261 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2262 if test -n "$extra_files"; then
2263 echo "EXTRA_lib_SOURCES +=" $extra_files
2268 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2269 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2270 if test -n "$buildaux_files"; then
2271 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2272 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2275 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2276 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2277 if test -n "$top_files"; then
2278 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2279 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2286 # func_get_automake_snippet module
2288 # - local_gnulib_dir from --local-dir
2289 # - modcache true or false, from --cache-modules/--no-cache-modules
2290 func_get_automake_snippet ()
2292 func_get_automake_snippet_conditional "$1"
2293 func_get_automake_snippet_unconditional "$1"
2296 # func_get_include_directive module
2298 # - local_gnulib_dir from --local-dir
2299 # - modcache true or false, from --cache-modules/--no-cache-modules
2300 func_get_include_directive ()
2303 if ! $modcache; then
2304 func_lookup_file "modules/$1"
2305 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2307 func_cache_lookup_module "$1"
2308 # Output the field's value, including the final newline (if any).
2309 if $have_associative; then
2310 if eval 'test -n "${modcache_include[$1]+set}"'; then
2311 eval 'echo "${modcache_include[$1]}"'
2314 eval "field_set=\"\$${cachevar}_include_set\""
2315 if test -n "$field_set"; then
2316 eval "field_value=\"\$${cachevar}_include\""
2317 echo "${field_value}"
2321 } | sed -e 's/^\(["<]\)/#include \1/'
2324 # func_get_link_directive module
2326 # - local_gnulib_dir from --local-dir
2327 # - modcache true or false, from --cache-modules/--no-cache-modules
2328 func_get_link_directive ()
2330 if ! $modcache; then
2331 func_lookup_file "modules/$1"
2332 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2334 func_cache_lookup_module "$1"
2335 # Output the field's value, including the final newline (if any).
2336 if $have_associative; then
2337 if eval 'test -n "${modcache_link[$1]+set}"'; then
2338 eval 'echo "${modcache_link[$1]}"'
2341 eval "field_set=\"\$${cachevar}_link_set\""
2342 if test -n "$field_set"; then
2343 eval "field_value=\"\$${cachevar}_link\""
2344 echo "${field_value}"
2350 # func_get_license module
2352 # - local_gnulib_dir from --local-dir
2353 # - modcache true or false, from --cache-modules/--no-cache-modules
2357 if ! $modcache; then
2358 func_lookup_file "modules/$1"
2359 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2361 func_cache_lookup_module "$1"
2362 # Output the field's value, including the final newline (if any).
2363 if $have_associative; then
2364 if eval 'test -n "${modcache_license[$1]+set}"'; then
2365 eval 'echo "${modcache_license[$1]}"'
2368 eval "field_set=\"\$${cachevar}_license_set\""
2369 if test -n "$field_set"; then
2370 eval "field_value=\"\$${cachevar}_license\""
2371 echo "${field_value}"
2375 # The default is GPL.
2377 } | sed -e 's,^ *$,,' | sed -e 1q
2380 # func_get_maintainer module
2382 # - local_gnulib_dir from --local-dir
2383 # - modcache true or false, from --cache-modules/--no-cache-modules
2384 func_get_maintainer ()
2386 if ! $modcache; then
2387 func_lookup_file "modules/$1"
2388 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2390 func_cache_lookup_module "$1"
2391 # Output the field's value, including the final newline (if any).
2392 if $have_associative; then
2393 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2394 eval 'echo "${modcache_maintainer[$1]}"'
2397 eval "field_set=\"\$${cachevar}_maintainer_set\""
2398 if test -n "$field_set"; then
2399 eval "field_value=\"\$${cachevar}_maintainer\""
2400 echo "${field_value}"
2406 # func_get_tests_module module
2408 # - local_gnulib_dir from --local-dir
2409 func_get_tests_module ()
2411 # The naming convention for tests modules is hardwired: ${module}-tests.
2412 if test -f "$gnulib_dir/modules/$1"-tests \
2413 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2414 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2419 # func_acceptable module
2420 # tests whether a module is acceptable.
2422 # - avoidlist list of modules to avoid
2425 for avoid in $avoidlist; do
2426 if test "$avoid" = "$1"; then
2433 # sed expression to keep the first 32 characters of each line.
2434 sed_first_32_chars='s/^\(................................\).*/\1/'
2436 # func_module_shellfunc_name module
2437 # computes the shell function name that will contain the m4 macros for the module.
2439 # - macro_prefix prefix to use
2441 # - shellfunc shell function name
2442 func_module_shellfunc_name ()
2446 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2448 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2452 # func_module_shellvar_name module
2453 # computes the shell variable name the will be set to true once the m4 macros
2454 # for the module have been executed.
2456 # - shellvar shell variable name
2457 func_module_shellvar_name ()
2461 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2463 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2467 # func_module_conditional_name module
2468 # computes the automake conditional name for the module.
2470 # - conditional name of automake conditional
2471 func_module_conditional_name ()
2475 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2477 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2481 # func_uncond_add_module B
2482 # notes the presence of B as an unconditional module.
2484 # func_conddep_add_module A B cond
2485 # notes the presence of a conditional dependency from module A to module B,
2486 # subject to the condition that A is enabled and cond is true.
2488 # func_cond_module_p B
2489 # tests whether module B is conditional.
2491 # func_cond_module_condition A B
2492 # returns the condition when B should be enabled as a dependency of A, once the
2493 # m4 code for A has been executed.
2494 # Output: - condition
2496 if $have_associative; then
2497 declare -A conddep_isuncond
2498 declare -A conddep_dependers
2499 declare -A conddep_condition
2500 func_uncond_add_module ()
2502 eval 'conddep_isuncond[$1]=true'
2503 eval 'unset conddep_dependers[$1]'
2505 func_conddep_add_module ()
2507 eval 'isuncond="${conddep_isuncond[$2]}"'
2508 if test -z "$isuncond"; then
2509 # No unconditional dependency to B known at this point.
2510 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2511 eval 'conddep_condition[$1---$2]="$3"'
2514 func_cond_module_p ()
2516 eval 'previous_dependers="${conddep_dependers[$1]}"'
2517 test -n "$previous_dependers"
2519 func_cond_module_condition ()
2521 eval 'condition="${conddep_condition[$1---$2]}"'
2524 func_uncond_add_module ()
2528 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2532 eval 'conddep_isuncond_'"$suffix"'=true'
2533 eval 'unset conddep_dependers_'"$suffix"
2535 func_conddep_add_module ()
2539 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2543 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2544 if test -z "$isuncond"; then
2545 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2546 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2547 eval 'conddep_condition_'"$suffix"'="$3"'
2550 func_cond_module_p ()
2554 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2558 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2559 test -n "$previous_dependers"
2561 func_cond_module_condition ()
2563 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2564 eval 'condition="${conddep_condition_'"$suffix"'}"'
2568 sed_dependencies_without_conditions='s/ *\[.*//'
2570 # func_modules_transitive_closure
2572 # - local_gnulib_dir from --local-dir
2573 # - modcache true or false, from --cache-modules/--no-cache-modules
2574 # - modules list of specified modules
2575 # - inctests true if tests should be included, blank otherwise
2576 # - incobsolete true if obsolete modules among dependencies should be
2577 # included, blank otherwise
2578 # - inc_cxx_tests true if C++ interoperability tests should be included,
2580 # - inc_longrunning_tests true if long-runnings tests should be included,
2582 # - inc_privileged_tests true if tests that require root privileges should be
2583 # included, blank otherwise
2584 # - inc_unportable_tests true if tests that fail on some platforms should be
2585 # included, blank otherwise
2586 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2587 # the unit tests of the specified modules should be
2588 # included, blank otherwise
2589 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2590 # the unit tests of the dependencies should be
2591 # included, blank otherwise
2592 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2594 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2596 # - excl_privileged_tests true if tests that require root privileges should be
2597 # excluded, blank otherwise
2598 # - excl_unportable_tests true if tests that fail on some platforms should be
2599 # excluded, blank otherwise
2600 # - avoidlist list of modules to avoid
2601 # - cond_dependencies true if conditional dependencies shall be supported,
2603 # - tmp pathname of a temporary directory
2605 # - modules list of modules, including dependencies
2606 # - conddep_dependers, conddep_condition information about conditionally
2608 func_modules_transitive_closure ()
2610 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2611 # In order to process every module only once (for speed), process an "input
2612 # list" of modules, producing an "output list" of modules. During each round,
2613 # more modules can be queued in the input list. Once a module on the input
2614 # list has been processed, it is added to the "handled list", so we can avoid
2615 # to process it again.
2617 inmodules="$modules"
2619 fmtc_inc_all_tests="$inc_all_direct_tests"
2620 if test "$cond_dependencies" = true; then
2621 for module in $inmodules; do
2623 if test -n "$module"; then
2624 if func_acceptable $module; then
2625 func_uncond_add_module $module
2630 while test -n "$inmodules"; do
2631 inmodules_this_round="$inmodules"
2632 inmodules= # Accumulator, queue for next round
2633 for module in $inmodules_this_round; do
2635 if test -n "$module"; then
2636 if func_acceptable $module; then
2637 func_append outmodules " $module"
2638 if test "$cond_dependencies" = true; then
2639 if func_get_automake_snippet_conditional $module | grep '^if ' > /dev/null; then
2640 # A module whose Makefile.am snippet contains a reference to an
2641 # automake conditional. If we were to use it conditionally, we
2642 # would get an error
2643 # configure: error: conditional "..." was never defined.
2644 # because automake 1.11.1 does not handle nested conditionals
2645 # correctly. As a workaround, make the module unconditional.
2646 func_uncond_add_module $module
2648 if func_cond_module_p $module; then
2654 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2655 # Duplicate dependencies are harmless, but Jim wants a warning.
2656 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2657 if test -n "$duplicated_deps"; then
2658 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2660 if test -n "$inctests"; then
2661 testsmodule=`func_get_tests_module $module`
2662 if test -n "$testsmodule"; then
2663 deps="$deps $testsmodule"
2666 for dep in $deps; do
2667 # Determine whether to include the dependency or tests module.
2669 for word in `func_get_status $dep`; do
2672 test -n "$incobsolete" \
2676 test -z "$excl_cxx_tests" \
2678 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2682 test -z "$excl_longrunning_tests" \
2684 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2688 test -z "$excl_privileged_tests" \
2690 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2694 test -z "$excl_unportable_tests" \
2696 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2700 test -n "$fmtc_inc_all_tests" \
2706 func_append inmodules " $dep"
2707 if test "$cond_dependencies" = true; then
2708 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2709 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2712 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2713 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2715 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2716 if test "$condition" = true; then
2719 if test -n "$condition"; then
2720 func_conddep_add_module "$module" "$dep" "$condition"
2722 if $conditional; then
2723 func_conddep_add_module "$module" "$dep" true
2725 func_uncond_add_module "$dep"
2734 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2735 # Remove $handledmodules from $inmodules.
2736 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2737 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2738 fmtc_inc_all_tests="$inc_all_indirect_tests"
2740 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2741 rm -f "$tmp"/queued-modules
2744 # func_show_module_list
2746 # - specified_modules list of specified modules (one per line, sorted)
2747 # - modules complete list of modules (one per line, sorted)
2748 # - tmp pathname of a temporary directory
2749 func_show_module_list ()
2755 # Assume xterm compatible escape sequences.
2756 bold_on=`printf '\x1b[1m'`
2757 bold_off=`printf '\x1b[0m'`
2762 echo "Module list with included dependencies (indented):"
2763 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2764 echo "$modules" | sed -e '/^$/d' \
2765 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2766 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2769 # func_modules_transitive_closure_separately
2770 # Determine main module list and tests-related module list separately.
2771 # The main module list is the transitive closure of the specified modules,
2772 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2773 # is specified, it will consist only of LGPLed source.
2774 # The tests-related module list is the transitive closure of the specified
2775 # modules, including tests modules, minus the main module list excluding
2776 # modules of applicability 'all'. Its lib/* sources (brought in through
2777 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2778 # source, even if --lgpl is specified.
2780 # - local_gnulib_dir from --local-dir
2781 # - modcache true or false, from --cache-modules/--no-cache-modules
2782 # - specified_modules list of specified modules
2783 # - inctests true if tests should be included, blank otherwise
2784 # - incobsolete true if obsolete modules among dependencies should be
2785 # included, blank otherwise
2786 # - inc_cxx_tests true if C++ interoperability tests should be included,
2788 # - inc_longrunning_tests true if long-runnings tests should be included,
2790 # - inc_privileged_tests true if tests that require root privileges should be
2791 # included, blank otherwise
2792 # - inc_unportable_tests true if tests that fail on some platforms should be
2793 # included, blank otherwise
2794 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2795 # the unit tests of the specified modules should be
2796 # included, blank otherwise
2797 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2798 # the unit tests of the dependencies should be
2799 # included, blank otherwise
2800 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2802 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2804 # - excl_privileged_tests true if tests that require root privileges should be
2805 # excluded, blank otherwise
2806 # - excl_unportable_tests true if tests that fail on some platforms should be
2807 # excluded, blank otherwise
2808 # - avoidlist list of modules to avoid
2809 # - cond_dependencies true if conditional dependencies shall be supported,
2811 # - tmp pathname of a temporary directory
2813 # - main_modules list of modules, including dependencies
2814 # - testsrelated_modules list of tests-related modules, including dependencies
2815 # - conddep_dependers, conddep_condition information about conditionally
2817 func_modules_transitive_closure_separately ()
2819 # Determine main module list.
2820 saved_inctests="$inctests"
2822 modules="$specified_modules"
2823 func_modules_transitive_closure
2824 main_modules="$modules"
2825 inctests="$saved_inctests"
2826 if test $verbose -ge 1; then
2827 echo "Main module list:"
2828 echo "$main_modules" | sed -e 's/^/ /'
2830 # Determine tests-related module list.
2831 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2832 testsrelated_modules=`for module in $main_modules; do
2833 if test \`func_get_applicability $module\` = main; then
2837 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2838 if test $verbose -ge 1; then
2839 echo "Tests-related module list:"
2840 echo "$testsrelated_modules" | sed -e 's/^/ /'
2844 # func_determine_use_libtests
2845 # Determines whether a $testsbase/libtests.a is needed.
2847 # - local_gnulib_dir from --local-dir
2848 # - modcache true or false, from --cache-modules/--no-cache-modules
2849 # - testsrelated_modules list of tests-related modules, including dependencies
2851 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2852 func_determine_use_libtests ()
2855 for module in $testsrelated_modules; do
2856 func_verify_nontests_module
2857 if test -n "$module"; then
2858 all_files=`func_get_filelist $module`
2859 # Test whether some file in $all_files lies in lib/.
2860 for f in $all_files; do
2872 # func_modules_add_dummy
2874 # - local_gnulib_dir from --local-dir
2875 # - modcache true or false, from --cache-modules/--no-cache-modules
2876 # - modules list of modules, including dependencies
2878 # - modules list of modules, including 'dummy' if needed
2879 func_modules_add_dummy ()
2881 # Determine whether any module provides a lib_SOURCES augmentation.
2883 sed_remove_backslash_newline=':a
2890 for module in $modules; do
2891 func_verify_nontests_module
2892 if test -n "$module"; then
2893 # Extract the value of "lib_SOURCES += ...".
2894 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2895 # Ignore .h files since they are not compiled.
2899 have_lib_SOURCES=yes
2906 # Add the dummy module, to make sure the library will be non-empty.
2907 if test -z "$have_lib_SOURCES"; then
2908 if func_acceptable "dummy"; then
2909 func_append modules " dummy"
2914 # func_modules_add_dummy_separately
2916 # - local_gnulib_dir from --local-dir
2917 # - modcache true or false, from --cache-modules/--no-cache-modules
2918 # - main_modules list of modules, including dependencies
2919 # - testsrelated_modules list of tests-related modules, including dependencies
2920 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2922 # - main_modules list of modules, including 'dummy' if needed
2923 # - testsrelated_modules list of tests-related modules, including 'dummy' if
2925 func_modules_add_dummy_separately ()
2927 # Add the dummy module to the main module list if needed.
2928 modules="$main_modules"
2929 func_modules_add_dummy
2930 main_modules="$modules"
2932 # Add the dummy module to the tests-related module list if needed.
2933 if $use_libtests; then
2934 modules="$testsrelated_modules"
2935 func_modules_add_dummy
2936 testsrelated_modules="$modules"
2940 # func_modules_notice
2942 # - local_gnulib_dir from --local-dir
2943 # - modcache true or false, from --cache-modules/--no-cache-modules
2944 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2945 # - modules list of modules, including dependencies
2946 func_modules_notice ()
2948 if test $verbose -ge -1; then
2949 for module in $modules; do
2951 if test -n "$module"; then
2952 msg=`func_get_notice $module`
2953 if test -n "$msg"; then
2954 echo "Notice from module $module:"
2955 echo "$msg" | sed -e 's/^/ /'
2962 # func_modules_to_filelist
2964 # - local_gnulib_dir from --local-dir
2965 # - modcache true or false, from --cache-modules/--no-cache-modules
2966 # - modules list of modules, including dependencies
2968 # - files list of files
2969 func_modules_to_filelist ()
2972 for module in $modules; do
2974 if test -n "$module"; then
2975 fs=`func_get_filelist $module`
2976 func_append files " $fs"
2979 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2982 # func_modules_to_filelist_separately
2983 # Determine the final file lists.
2984 # They must be computed separately, because files in lib/* go into
2985 # $sourcebase/ if they are in the main file list but into $testsbase/
2986 # if they are in the tests-related file list. Furthermore lib/dummy.c
2989 # - local_gnulib_dir from --local-dir
2990 # - modcache true or false, from --cache-modules/--no-cache-modules
2991 # - main_modules list of modules, including dependencies
2992 # - testsrelated_modules list of tests-related modules, including dependencies
2993 func_modules_to_filelist_separately ()
2995 # Determine final main file list.
2996 modules="$main_modules"
2997 func_modules_to_filelist
2999 # Determine final tests-related file list.
3000 modules="$testsrelated_modules"
3001 func_modules_to_filelist
3002 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3003 # Merge both file lists.
3004 sed_remove_empty_lines='/^$/d'
3005 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3006 if test $verbose -ge 0; then
3008 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3009 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3013 # func_compute_include_guard_prefix
3014 # Determine include_guard_prefix.
3016 # - macro_prefix prefix of gl_LIBOBJS macros to use
3018 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3019 # - sed_replace_include_guard_prefix
3020 # sed expression for resolving ${gl_include_guard_prefix}
3021 func_compute_include_guard_prefix ()
3023 if test "$macro_prefix" = gl; then
3024 include_guard_prefix='GL'
3026 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3028 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3031 # func_execute_command command [args...]
3032 # Executes a command.
3033 # Uses also the variables
3034 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3035 func_execute_command ()
3037 if test $verbose -ge 0; then
3041 # Commands like automake produce output to stderr even when they succeed.
3042 # Turn this output off if the command succeeds.
3043 "$@" > "$tmp"/cmdout 2>&1
3045 if test $cmdret = 0; then
3049 cat "$tmp"/cmdout 1>&2
3056 # func_dest_tmpfilename file
3057 # determines the name of a temporary file (file is relative to destdir).
3059 # - destdir target directory
3060 # - doit : if actions shall be executed, false if only to be printed
3061 # - tmp pathname of a temporary directory
3063 # - tmpfile absolute filename of the temporary file
3064 func_dest_tmpfilename ()
3067 # Put the new contents of $file in a file in the same directory (needed
3068 # to guarantee that an 'mv' to "$destdir/$file" works).
3069 tmpfile="$destdir/$1.tmp"
3071 # Put the new contents of $file in a file in a temporary directory
3072 # (because the directory of "$file" might not exist).
3073 tmpfile="$tmp"/`basename "$1"`.tmp
3078 # copies a file from gnulib into the destination directory. The destination
3079 # is known to not exist.
3081 # - destdir target directory
3082 # - local_gnulib_dir from --local-dir
3083 # - modcache true or false, from --cache-modules/--no-cache-modules
3084 # - f the original file name
3085 # - lookedup_file name of the merged (combined) file
3086 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3087 # - g the rewritten file name
3088 # - tmpfile absolute filename of the temporary file
3089 # - doit : if actions shall be executed, false if only to be printed
3090 # - symbolic true if files should be symlinked, copied otherwise
3091 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3096 echo "Copying file $g"
3097 if { test -n "$symbolic" \
3098 || { test -n "$lsymbolic" \
3099 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3100 && test -z "$lookedup_tmp" \
3101 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
3102 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3104 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3112 # copies a file from gnulib into the destination directory. The destination
3113 # is known to exist.
3115 # - destdir target directory
3116 # - local_gnulib_dir from --local-dir
3117 # - modcache true or false, from --cache-modules/--no-cache-modules
3118 # - f the original file name
3119 # - lookedup_file name of the merged (combined) file
3120 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3121 # - g the rewritten file name
3122 # - tmpfile absolute filename of the temporary file
3123 # - doit : if actions shall be executed, false if only to be printed
3124 # - symbolic true if files should be symlinked, copied otherwise
3125 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3127 # - already_present nonempty if the file should already exist, empty otherwise
3130 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
3131 : # The file has not changed.
3135 if test -n "$already_present"; then
3136 echo "Updating file $g (backup in ${g}~)"
3138 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3140 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3141 if { test -n "$symbolic" \
3142 || { test -n "$lsymbolic" \
3143 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3144 && test -z "$lookedup_tmp" \
3145 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
3146 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3148 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3151 if test -n "$already_present"; then
3152 echo "Update file $g (backup in ${g}~)"
3154 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3160 # func_emit_lib_Makefile_am
3161 # emits the contents of library makefile to standard output.
3163 # - local_gnulib_dir from --local-dir
3164 # - modcache true or false, from --cache-modules/--no-cache-modules
3165 # - modules list of modules, including dependencies
3166 # - libname library name
3167 # - pobase directory relative to destdir where to place *.po files
3168 # - auxdir directory relative to destdir where to place build aux files
3169 # - makefile_name from --makefile-name
3170 # - libtool true if libtool will be used, false or blank otherwise
3171 # - macro_prefix prefix of gl_LIBOBJS macros to use
3172 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3173 # - actioncmd (optional) command that will reproduce this invocation
3174 # - for_test true if creating a package for testing, false otherwise
3175 # - sed_replace_include_guard_prefix
3176 # sed expression for resolving ${gl_include_guard_prefix}
3177 # - destfile filename relative to destdir of makefile being generated
3179 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3180 # list of edits to be done to Makefile.am variables
3182 # - uses_subdirs nonempty if object files in subdirs exist
3183 func_emit_lib_Makefile_am ()
3185 # When creating an includable Makefile.am snippet, augment variables with
3186 # += instead of assigning them.
3187 if test -n "$makefile_name"; then
3192 if test "$libtool" = true; then
3195 sed_eliminate_LDFLAGS="$sed_noop"
3199 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3202 # When creating a package for testing: Attempt to provoke failures,
3203 # especially link errors, already during "make" rather than during
3204 # "make check", because "make check" is not possible in a cross-compiling
3205 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3206 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3208 sed_transform_check_PROGRAMS="$sed_noop"
3210 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3211 echo "## Process this file with automake to produce Makefile.in."
3212 func_emit_copyright_notice
3213 if test -n "$actioncmd"; then
3214 # The maximum line length (excluding the terminating newline) of any file
3215 # that is to be preprocessed by config.status is 3070. config.status uses
3216 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3217 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3218 len=`echo "$actioncmd" | wc -c`
3219 if test -n "$len" && test "$len" -le 3000; then
3220 echo "# Reproduce by: $actioncmd"
3226 for module in $modules; do
3227 func_verify_nontests_module
3228 if test -n "$module"; then
3230 func_get_automake_snippet_conditional "$module" |
3232 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3233 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3234 -e "$sed_eliminate_LDFLAGS" \
3235 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3236 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3237 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3238 -e "$sed_transform_check_PROGRAMS" \
3239 -e "$sed_replace_include_guard_prefix"
3240 if test "$module" = 'alloca'; then
3241 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3242 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3244 } > "$tmp"/amsnippet1
3246 func_get_automake_snippet_unconditional "$module" |
3247 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3248 } > "$tmp"/amsnippet2
3249 # Skip the contents if it's entirely empty.
3250 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3251 echo "## begin gnulib module $module"
3253 if test "$cond_dependencies" = true; then
3254 if func_cond_module_p "$module"; then
3255 func_module_conditional_name "$module"
3256 echo "if $conditional"
3259 cat "$tmp"/amsnippet1
3260 if test "$cond_dependencies" = true; then
3261 if func_cond_module_p "$module"; then
3265 cat "$tmp"/amsnippet2
3266 echo "## end gnulib module $module"
3269 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3270 # Test whether there are some source files in subdirectories.
3271 for f in `func_get_filelist "$module"`; do
3281 } > "$tmp"/allsnippets
3282 if test -z "$makefile_name"; then
3283 # If there are source files in subdirectories, prevent collision of the
3284 # object files (example: hash.c and libxml/hash.c).
3286 if test -n "$uses_subdirs"; then
3287 subdir_options=' subdir-objects'
3289 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
3292 if test -z "$makefile_name"; then
3294 echo "noinst_HEADERS ="
3295 echo "noinst_LIBRARIES ="
3296 echo "noinst_LTLIBRARIES ="
3297 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3298 # if you specify pkgdata_DATA to empty. This is a workaround.
3299 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3300 echo "pkgdata_DATA ="
3303 echo "BUILT_SOURCES ="
3306 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3307 if test -z "$makefile_name"; then
3308 echo "MOSTLYCLEANDIRS ="
3310 echo "DISTCLEANFILES ="
3311 echo "MAINTAINERCLEANFILES ="
3313 # Execute edits that apply to the Makefile.am being generated.
3315 while test $edit != $makefile_am_edits; do
3316 edit=`expr $edit + 1`
3317 eval dir=\"\$makefile_am_edit${edit}_dir\"
3318 eval var=\"\$makefile_am_edit${edit}_var\"
3319 eval val=\"\$makefile_am_edit${edit}_val\"
3320 if test -n "$var"; then
3321 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3322 echo "${var} += ${val}"
3323 eval "makefile_am_edit${edit}_var="
3327 if test -z "$makefile_name"; then
3330 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
3332 echo "AM_CPPFLAGS ="
3337 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3338 || { test -n "$makefile_name" \
3339 && test -f "$sourcebase/Makefile.am" \
3340 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3342 # One of the snippets or the user's Makefile.am already specifies an
3343 # installation location for the library. Don't confuse automake by saying
3344 # it should not be installed.
3347 # By default, the generated library should not be installed.
3348 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3351 echo "${libname}_${libext}_SOURCES ="
3352 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3353 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3354 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3355 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3356 echo "EXTRA_${libname}_${libext}_SOURCES ="
3357 if test "$libtool" = true; then
3358 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3359 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3360 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3361 # the link dependencies of all modules.
3362 for module in $modules; do
3363 func_verify_nontests_module
3364 if test -n "$module"; then
3365 func_get_link_directive "$module"
3368 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3369 | LC_ALL=C sort -u \
3370 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3373 if test -n "$pobase"; then
3374 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3377 cat "$tmp"/allsnippets \
3378 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3380 echo "mostlyclean-local: mostlyclean-generic"
3381 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3382 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3383 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3387 rm -f "$tmp"/allsnippets
3390 # func_emit_po_Makevars
3391 # emits the contents of po/ makefile parameterization to standard output.
3393 # - local_gnulib_dir from --local-dir
3394 # - modcache true or false, from --cache-modules/--no-cache-modules
3395 # - sourcebase directory relative to destdir where to place source code
3396 # - pobase directory relative to destdir where to place *.po files
3397 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3398 func_emit_po_Makevars ()
3400 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3401 func_emit_copyright_notice
3403 echo "# Usually the message domain is the same as the package name."
3404 echo "# But here it has a '-gnulib' suffix."
3405 echo "DOMAIN = ${po_domain}-gnulib"
3407 echo "# These two variables depend on the location of this directory."
3408 echo "subdir = ${pobase}"
3409 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3412 # These options get passed to xgettext.
3413 XGETTEXT_OPTIONS = \
3414 --keyword=_ --flag=_:1:pass-c-format \
3415 --keyword=N_ --flag=N_:1:pass-c-format \
3416 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3417 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3418 --flag=error:3:c-format --flag=error_at_line:5:c-format
3420 # This is the copyright holder that gets inserted into the header of the
3421 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3422 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3424 # This is the email address or URL to which the translators shall report
3425 # bugs in the untranslated strings:
3426 # - Strings which are not entire sentences, see the maintainer guidelines
3427 # in the GNU gettext documentation, section 'Preparing Strings'.
3428 # - Strings which use unclear terms or require additional context to be
3430 # - Strings which make invalid assumptions about notation of date, time or
3432 # - Pluralisation problems.
3433 # - Incorrect English spelling.
3434 # - Incorrect formatting.
3435 # It can be your email address, or a mailing list address where translators
3436 # can write to without being subscribed, or the URL of a web page through
3437 # which the translators can contact you.
3438 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3440 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3441 # message catalogs shall be used. It is usually empty.
3442 EXTRA_LOCALE_CATEGORIES =
3444 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3445 # context. Possible values are "yes" and "no". Set this to yes if the
3446 # package uses functions taking also a message context, like pgettext(), or
3447 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3452 # func_emit_po_POTFILES_in
3453 # emits the file list to be passed to xgettext to standard output.
3455 # - local_gnulib_dir from --local-dir
3456 # - modcache true or false, from --cache-modules/--no-cache-modules
3457 # - sourcebase directory relative to destdir where to place source code
3458 # - files list of new files
3459 func_emit_po_POTFILES_in ()
3461 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3462 func_emit_copyright_notice
3464 echo "# List of files which contain translatable strings."
3465 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3468 # func_emit_tests_Makefile_am witness_macro
3469 # emits the contents of tests makefile to standard output.
3471 # - local_gnulib_dir from --local-dir
3472 # - modcache true or false, from --cache-modules/--no-cache-modules
3473 # - modules list of modules, including dependencies
3474 # - libname library name
3475 # - auxdir directory relative to destdir where to place build aux files
3476 # - makefile_name from --makefile-name
3477 # - libtool true if libtool will be used, false or blank otherwise
3478 # - sourcebase relative directory containing lib source code
3479 # - m4base relative directory containing autoconf macros
3480 # - testsbase relative directory containing unit test code
3481 # - macro_prefix prefix of gl_LIBOBJS macros to use
3482 # - for_test true if creating a package for testing, false otherwise
3483 # - single_configure true if a single configure file should be generated,
3484 # false for a separate configure file for the tests
3485 # - use_libtests true if a libtests.a should be built, false otherwise
3486 # - sed_replace_include_guard_prefix
3487 # sed expression for resolving ${gl_include_guard_prefix}
3488 # - destfile filename relative to destdir of makefile being generated
3490 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3491 # list of edits to be done to Makefile.am variables
3493 # - uses_subdirs nonempty if object files in subdirs exist
3494 func_emit_tests_Makefile_am ()
3497 if test "$libtool" = true; then
3499 sed_eliminate_LDFLAGS="$sed_noop"
3502 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3505 # When creating a package for testing: Attempt to provoke failures,
3506 # especially link errors, already during "make" rather than during
3507 # "make check", because "make check" is not possible in a cross-compiling
3508 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3509 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3511 sed_transform_check_PROGRAMS="$sed_noop"
3513 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3514 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3515 echo "## Process this file with automake to produce Makefile.in."
3516 func_emit_copyright_notice
3520 for module in $modules; do
3521 if $for_test && ! $single_configure; then
3522 func_verify_tests_module
3526 if test -n "$module"; then
3528 func_get_automake_snippet "$module" |
3530 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3531 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3532 -e "$sed_eliminate_LDFLAGS" \
3533 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3534 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3535 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3536 -e "$sed_transform_check_PROGRAMS" \
3537 -e "$sed_replace_include_guard_prefix"
3538 if $use_libtests && test "$module" = 'alloca'; then
3539 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3540 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3542 } > "$tmp"/amsnippet
3543 # Skip the contents if it's entirely empty.
3544 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3545 # Mention long-running tests at the end.
3547 for word in `func_get_status "$module"`; do
3548 if test "$word" = 'longrunning-test'; then
3553 { echo "## begin gnulib module $module"
3555 cat "$tmp"/amsnippet
3556 echo "## end gnulib module $module"
3560 rm -f "$tmp"/amsnippet
3561 # Test whether there are some source files in subdirectories.
3562 for f in `func_get_filelist "$module"`; do
3564 lib/*/*.c | tests/*/*.c)
3572 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3573 # Generate dependencies here, since it eases the debugging of test failures.
3574 # If there are source files in subdirectories, prevent collision of the
3575 # object files (example: hash.c and libxml/hash.c).
3577 if test -n "$uses_subdirs"; then
3578 subdir_options=' subdir-objects'
3580 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3582 if $for_test && ! $single_configure; then
3583 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3586 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3587 # variable is needed to avoid an error from automake:
3588 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3591 echo "XFAIL_TESTS ="
3592 echo "TESTS_ENVIRONMENT ="
3593 echo "noinst_PROGRAMS ="
3594 if ! $for_test; then
3595 echo "check_PROGRAMS ="
3597 echo "noinst_HEADERS ="
3598 echo "noinst_LIBRARIES ="
3599 if $use_libtests; then
3601 echo "noinst_LIBRARIES += libtests.a"
3603 echo "check_LIBRARIES = libtests.a"
3606 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3607 # if you specify pkgdata_DATA to empty. This is a workaround.
3608 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3609 echo "pkgdata_DATA ="
3612 echo "BUILT_SOURCES ="
3614 echo "MOSTLYCLEANFILES = core *.stackdump"
3615 echo "MOSTLYCLEANDIRS ="
3617 echo "DISTCLEANFILES ="
3618 echo "MAINTAINERCLEANFILES ="
3619 # Execute edits that apply to the Makefile.am being generated.
3621 while test $edit != $makefile_am_edits; do
3622 edit=`expr $edit + 1`
3623 eval dir=\"\$makefile_am_edit${edit}_dir\"
3624 eval var=\"\$makefile_am_edit${edit}_var\"
3625 eval val=\"\$makefile_am_edit${edit}_val\"
3626 if test -n "$var"; then
3627 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3628 echo "${var} += ${val}"
3629 eval "makefile_am_edit${edit}_var="
3634 echo "AM_CPPFLAGS = \\"
3636 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3638 if test -n "${witness_macro}"; then
3639 echo " -D@${witness_macro}@=1 \\"
3641 echo " -I. -I\$(srcdir) \\"
3642 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3643 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3645 local_ldadd_before=''
3646 local_ldadd_after=''
3647 if $use_libtests; then
3648 # All test programs need to be linked with libtests.a.
3649 # It needs to be passed to the linker before ${libname}.${libext}, since
3650 # the tests-related modules depend on the main modules.
3651 # It also needs to be passed to the linker after ${libname}.${libext}
3652 # because the latter might contain incomplete modules (such as the 'error'
3653 # module whose dependency to 'progname' is voluntarily omitted).
3654 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3656 local_ldadd_before=' libtests.a'
3657 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3659 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3661 if $use_libtests; then
3662 echo "libtests_a_SOURCES ="
3663 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3664 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3665 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3666 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3667 echo "EXTRA_libtests_a_SOURCES ="
3668 # The circular dependency in LDADD requires this.
3669 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3672 # Many test scripts use ${EXEEXT} or ${srcdir}.
3673 # EXEEXT is defined by AC_PROG_CC through autoconf.
3674 # srcdir is defined by autoconf and automake.
3675 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3677 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3678 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3679 echo "# Clean up after Solaris cc."
3681 echo " rm -rf SunWS_cache"
3683 echo "mostlyclean-local: mostlyclean-generic"
3684 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3685 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3686 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3690 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3693 # func_emit_initmacro_start macro_prefix
3694 # emits the first few statements of the gl_INIT macro to standard output.
3695 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3696 func_emit_initmacro_start ()
3698 macro_prefix_arg="$1"
3699 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3700 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3701 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3702 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3704 # Furthermore it avoids an automake error like this when a Makefile.am
3705 # that uses pieces of gnulib also uses $(LIBOBJ):
3706 # automatically discovered file `error.c' should not be explicitly mentioned
3707 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3708 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3709 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3710 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3711 # automatically discovered file `error.c' should not be explicitly mentioned
3712 # We let automake know about the files to be distributed through the
3713 # EXTRA_lib_SOURCES variable.
3714 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3715 # Create data variables for checking the presence of files that are mentioned
3716 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3717 # because we want the check to happen when the configure file is created,
3718 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3719 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3720 # in which to expect them.
3721 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3722 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3726 # func_emit_initmacro_end macro_prefix
3727 # emits the last few statements of the gl_INIT macro to standard output.
3728 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3729 func_emit_initmacro_end ()
3731 macro_prefix_arg="$1"
3732 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3733 # The check is performed only when autoconf is run from the directory where
3734 # the configure.ac resides; if it is run from a different directory, the
3736 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3737 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3738 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3739 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3740 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3744 echo " m4_if(m4_sysval, [0], [],"
3745 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3747 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3748 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3749 echo " m4_popdef([AC_LIBSOURCES])"
3750 echo " m4_popdef([AC_REPLACE_FUNCS])"
3751 echo " m4_popdef([AC_LIBOBJ])"
3752 echo " AC_CONFIG_COMMANDS_PRE(["
3753 echo " ${macro_prefix_arg}_libobjs="
3754 echo " ${macro_prefix_arg}_ltlibobjs="
3755 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3756 echo " # Remove the extension."
3757 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3758 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3759 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3760 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3763 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3764 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3768 # func_emit_initmacro_done macro_prefix sourcebase
3769 # emits a few statements after the gl_INIT macro to standard output.
3770 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3771 # - sourcebase directory relative to destdir where to place source code
3772 func_emit_initmacro_done ()
3774 macro_prefix_arg="$1"
3777 echo "# Like AC_LIBOBJ, except that the module name goes"
3778 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3779 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3780 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3781 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3784 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3785 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3786 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3787 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3788 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3791 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3792 echo "# expected is derived from the gnulib-tool parameterization,"
3793 echo "# and alloca is special cased (for the alloca-opt module)."
3794 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3795 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3796 echo " m4_foreach([_gl_NAME], [\$1], ["
3797 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3798 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3799 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3805 # func_emit_autoconf_snippet indentation
3806 # emits the autoconf snippet of a module.
3808 # - local_gnulib_dir from --local-dir
3809 # - modcache true or false, from --cache-modules/--no-cache-modules
3810 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3811 # - module the module name
3812 # - toplevel true or false. 'false' means a subordinate use of
3814 # - disable_libtool true or false. It tells whether to disable libtool
3815 # handling even if it has been specified through the
3816 # command line options.
3817 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3819 # - indentation spaces to prepend on each line
3820 func_emit_autoconf_snippet ()
3822 if { case $module in
3823 gnumakefile | maintainer-makefile)
3824 # These modules are meant to be used only in the top-level directory.
3830 func_get_autoconf_snippet "$module" \
3831 | sed -e '/^$/d;' -e "s/^/$indentation/" \
3832 -e "$sed_replace_build_aux" \
3833 | { if $disable_libtool; then
3834 sed -e 's/\$gl_cond_libtool/false/g' \
3835 -e 's/gl_libdeps/gltests_libdeps/g' \
3836 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3841 | { if $disable_gettext; then
3842 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
3847 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
3848 echo 'changequote(,)dnl'
3849 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3850 echo 'changequote([, ])dnl'
3851 echo 'AC_SUBST([LTALLOCA])'
3856 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
3857 # collects and emit the autoconf snippets of a set of modules.
3859 # - local_gnulib_dir from --local-dir
3860 # - modcache true or false, from --cache-modules/--no-cache-modules
3861 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3862 # - modules the list of modules.
3863 # - verifier one of func_verify_module, func_verify_nontests_module,
3864 # func_verify_tests_module. It selects the subset of
3865 # $modules to consider.
3866 # - toplevel true or false. 'false' means a subordinate use of
3868 # - disable_libtool true or false. It tells whether to disable libtool
3869 # handling even if it has been specified through the
3870 # command line options.
3871 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3873 func_emit_autoconf_snippets ()
3877 disable_libtool="$4"
3878 disable_gettext="$5"
3879 if test "$cond_dependencies" = true; then
3880 # Emit the autoconf code for the unconditional modules.
3881 for module in $1; do
3883 if test -n "$module"; then
3884 if func_cond_module_p "$module"; then
3887 func_emit_autoconf_snippet " "
3891 # Initialize the shell variables indicating that the modules are enabled.
3892 for module in $1; do
3894 if test -n "$module"; then
3895 if func_cond_module_p "$module"; then
3896 func_module_shellvar_name "$module"
3897 echo " $shellvar=false"
3901 # Emit the autoconf code for the conditional modules, each in a separate
3902 # function. This makes it possible to support cycles among conditional
3904 for module in $1; do
3906 if test -n "$module"; then
3907 if func_cond_module_p "$module"; then
3908 func_module_shellfunc_name "$module"
3909 func_module_shellvar_name "$module"
3910 echo " $shellfunc ()"
3912 echo " if ! \$$shellvar; then"
3913 func_emit_autoconf_snippet " "
3914 echo " $shellvar=true"
3915 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3916 for dep in $deps; do
3917 if func_cond_module_p "$dep"; then
3918 func_module_shellfunc_name "$dep"
3919 func_cond_module_condition "$module" "$dep"
3920 if test "$condition" != true; then
3921 echo ' if $condition; then'
3928 # The autoconf code for $dep has already been emitted above and
3929 # therefore is already executed when this function is run.
3938 # Emit the dependencies from the unconditional to the conditional modules.
3939 for module in $1; do
3941 if test -n "$module"; then
3942 if func_cond_module_p "$module"; then
3945 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3946 for dep in $deps; do
3947 if func_cond_module_p "$dep"; then
3948 func_module_shellfunc_name "$dep"
3949 func_cond_module_condition "$module" "$dep"
3950 if test "$condition" != true; then
3951 echo " if $condition; then"
3958 # The autoconf code for $dep has already been emitted above and
3959 # therefore is already executed when this code is run.
3966 # Define the Automake conditionals.
3967 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
3968 for module in $1; do
3970 if test -n "$module"; then
3971 if func_cond_module_p "$module"; then
3972 func_module_conditional_name "$module"
3973 func_module_shellvar_name "$module"
3974 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
3979 # Ignore the conditions, and enable all modules unconditionally.
3980 for module in $1; do
3982 if test -n "$module"; then
3983 func_emit_autoconf_snippet " "
3989 # func_import modules
3990 # Uses also the variables
3991 # - mode import or add-import or remove-import or update
3992 # - destdir target directory
3993 # - local_gnulib_dir from --local-dir
3994 # - modcache true or false, from --cache-modules/--no-cache-modules
3995 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3996 # - libname library name
3997 # - supplied_libname true if --lib was given, blank otherwise
3998 # - sourcebase directory relative to destdir where to place source code
3999 # - m4base directory relative to destdir where to place *.m4 macros
4000 # - pobase directory relative to destdir where to place *.po files
4001 # - docbase directory relative to destdir where to place doc files
4002 # - testsbase directory relative to destdir where to place unit test code
4003 # - auxdir directory relative to destdir where to place build aux files
4004 # - inctests true if --with-tests was given, blank otherwise
4005 # - incobsolete true if --with-obsolete was given, blank otherwise
4006 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4007 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4009 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4011 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4013 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4014 # - avoidlist list of modules to avoid, from --avoid
4015 # - cond_dependencies true if --conditional-dependencies was given, false if
4016 # --no-conditional-dependencies was given, blank otherwise
4017 # - lgpl yes or a number if library's license shall be LGPL,
4019 # - makefile_name from --makefile-name
4020 # - libtool true if --libtool was given, false if --no-libtool was
4021 # given, blank otherwise
4022 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4023 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4024 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4025 # - vc_files true if --vc-files was given, false if --no-vc-files was
4026 # given, blank otherwise
4027 # - autoconf_minversion minimum supported autoconf version
4028 # - doit : if actions shall be executed, false if only to be printed
4029 # - symbolic true if files should be symlinked, copied otherwise
4030 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4032 # - do_copyrights true if copyright notices in files should be replaced,
4036 # Get the cached settings.
4037 # In 'import' mode, we read them only for the purpose of knowing the old
4038 # installed file list, and don't use them as defaults.
4039 cached_local_gnulib_dir=
4040 cached_specified_modules=
4042 cached_inc_cxx_tests=
4043 cached_inc_longrunning_tests=
4044 cached_inc_privileged_tests=
4045 cached_inc_unportable_tests=
4046 cached_inc_all_tests=
4056 cached_makefile_name=
4057 cached_cond_dependencies=
4059 cached_macro_prefix=
4063 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4064 cached_libtool=false
4070 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
4080 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4082 /gl_WITH_OBSOLETE/ {
4083 s,^.*$,cached_incobsolete=true,p
4085 /gl_WITH_CXX_TESTS/ {
4086 s,^.*$,cached_inc_cxx_tests=true,p
4088 /gl_WITH_LONGRUNNING_TESTS/ {
4089 s,^.*$,cached_inc_longrunning_tests=true,p
4091 /gl_WITH_PRIVILEGED_TESTS/ {
4092 s,^.*$,cached_inc_privileged_tests=true,p
4094 /gl_WITH_UNPORTABLE_TESTS/ {
4095 s,^.*$,cached_inc_unportable_tests=true,p
4097 /gl_WITH_ALL_TESTS/ {
4098 s,^.*$,cached_inc_all_tests=true,p
4101 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4104 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4107 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4110 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4113 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4116 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4119 s,^.*$,cached_inctests=true,p
4122 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4125 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4128 s,^.*$,cached_lgpl=yes,p
4130 /gl_MAKEFILE_NAME(/ {
4131 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4133 /gl_CONDITIONAL_DEPENDENCIES/ {
4134 s,^.*$,cached_cond_dependencies=true,p
4137 s,^.*$,cached_libtool=true,p
4139 /gl_MACRO_PREFIX(/ {
4140 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4143 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4146 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4148 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4149 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4154 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4155 s,^.*$,cached_files=",p
4168 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4172 if test "$mode" = import; then
4173 # In 'import' mode, the new set of specified modules overrides the cached
4174 # set of modules. Ignore the cached settings.
4175 specified_modules="$1"
4177 # Merge the cached settings with the specified ones.
4178 # The m4base must be the same as expected from the pathname.
4179 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4180 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4182 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
4183 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4184 if test -z "$local_gnulib_dir"; then
4185 if test -n "$cached_local_gnulib_dir"; then
4188 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4190 case "$cached_local_gnulib_dir" in
4192 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4194 func_relconcat "$destdir" "$cached_local_gnulib_dir"
4195 local_gnulib_dir="$relconcat" ;;
4202 # Append the cached and the specified module names. So that
4203 # "gnulib-tool --add-import foo" means to add the module foo.
4204 specified_modules="$cached_specified_modules $1"
4207 # Take the cached module names, minus the specified module names.
4209 if $have_associative; then
4210 # Use an associative array, for O(N) worst-case run time.
4211 declare -A to_remove
4213 eval 'to_remove[$m]=yes'
4215 for module in $cached_specified_modules; do
4216 if eval 'test -z "${to_remove[$module]}"'; then
4217 func_append specified_modules "$module "
4221 # This loop has O(N²) worst-case run time.
4222 for module in $cached_specified_modules; do
4225 if test "$m" = "$module"; then
4230 if test -z "$to_remove"; then
4231 func_append specified_modules "$module "
4237 # Take the cached module names. There are no specified module names.
4238 specified_modules="$cached_specified_modules"
4241 # Included obsolete modules among the dependencies if specified either way.
4242 if test -z "$incobsolete"; then
4243 incobsolete="$cached_incobsolete"
4245 # Included special kinds of tests modules among the dependencies if specified
4247 if test -z "$inc_cxx_tests"; then
4248 inc_cxx_tests="$cached_inc_cxx_tests"
4250 if test -z "$inc_longrunning_tests"; then
4251 inc_longrunning_tests="$cached_inc_longrunning_tests"
4253 if test -z "$inc_privileged_tests"; then
4254 inc_privileged_tests="$cached_inc_privileged_tests"
4256 if test -z "$inc_unportable_tests"; then
4257 inc_unportable_tests="$cached_inc_unportable_tests"
4259 if test -z "$inc_all_tests"; then
4260 inc_all_tests="$cached_inc_all_tests"
4262 # Append the cached and the specified avoidlist. This is probably better
4263 # than dropping the cached one when --avoid is specified at least once.
4264 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4265 avoidlist=`echo $avoidlist`
4267 # The sourcebase defaults to the cached one.
4268 if test -z "$sourcebase"; then
4269 sourcebase="$cached_sourcebase"
4270 if test -z "$sourcebase"; then
4271 func_fatal_error "missing --source-base option"
4274 # The pobase defaults to the cached one.
4275 if test -z "$pobase"; then
4276 pobase="$cached_pobase"
4278 # The docbase defaults to the cached one.
4279 if test -z "$docbase"; then
4280 docbase="$cached_docbase"
4281 if test -z "$docbase"; then
4282 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."
4285 # The testsbase defaults to the cached one.
4286 if test -z "$testsbase"; then
4287 testsbase="$cached_testsbase"
4288 if test -z "$testsbase"; then
4289 func_fatal_error "missing --tests-base option"
4292 # Require the tests if specified either way.
4293 if test -z "$inctests"; then
4294 inctests="$cached_inctests"
4296 # The libname defaults to the cached one.
4297 if test -z "$supplied_libname"; then
4298 libname="$cached_libname"
4299 if test -z "$libname"; then
4300 func_fatal_error "missing --lib option"
4303 # Require LGPL if specified either way.
4304 if test -z "$lgpl"; then
4307 # The makefile_name defaults to the cached one.
4308 if test -z "$makefile_name"; then
4309 makefile_name="$cached_makefile_name"
4311 # Use conditional dependencies if specified either way.
4312 if test -z "$cond_dependencies"; then
4313 cond_dependencies="$cached_cond_dependencies"
4315 # Use libtool if specified either way, or if guessed.
4316 if test -z "$libtool"; then
4317 if test -n "$cached_m4base"; then
4318 libtool="$cached_libtool"
4320 libtool="$guessed_libtool"
4323 # The macro_prefix defaults to the cached one.
4324 if test -z "$macro_prefix"; then
4325 macro_prefix="$cached_macro_prefix"
4326 if test -z "$macro_prefix"; then
4327 func_fatal_error "missing --macro-prefix option"
4330 # The po_domain defaults to the cached one.
4331 if test -z "$po_domain"; then
4332 po_domain="$cached_po_domain"
4334 # The vc_files defaults to the cached one.
4335 if test -z "$vc_files"; then
4336 vc_files="$cached_vc_files"
4338 # Ensure constraints.
4339 if test "$cond_dependencies" = true && test -n "$inctests"; then
4340 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4344 # --without-*-tests options are not supported here.
4346 excl_longrunning_tests=
4347 excl_privileged_tests=
4348 excl_unportable_tests=
4350 # Canonicalize the list of specified modules.
4351 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4353 # Include all kinds of tests modules if --with-all-tests was specified.
4354 inc_all_direct_tests="$inc_all_tests"
4355 inc_all_indirect_tests="$inc_all_tests"
4357 # Determine final module list.
4358 modules="$specified_modules"
4359 func_modules_transitive_closure
4360 if test $verbose -ge 0; then
4361 func_show_module_list
4363 final_modules="$modules"
4365 # Determine main module list and tests-related module list separately.
4366 func_modules_transitive_closure_separately
4368 # Determine whether a $testsbase/libtests.a is needed.
4369 func_determine_use_libtests
4371 # Add the dummy module to the main module list or to the tests-related module
4373 func_modules_add_dummy_separately
4375 # If --lgpl, verify that the licenses of modules are compatible.
4376 if test -n "$lgpl"; then
4377 license_incompatibilities=
4378 for module in $main_modules; do
4379 license=`func_get_license $module`
4381 'GPLed build tool') ;;
4382 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4387 LGPL | LGPLv2+ | LGPLv3+) ;;
4388 *) func_append license_incompatibilities "$module $license$nl" ;;
4394 *) func_append license_incompatibilities "$module $license$nl" ;;
4397 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4402 if test -n "$license_incompatibilities"; then
4403 # Format the license incompatibilities as a table.
4404 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4405 s,^\(.................................................[^ ]*\) *, \1 ,'
4406 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4407 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4411 # Show banner notice of every module.
4412 modules="$main_modules"
4415 # Determine script to apply to imported library files.
4416 sed_transform_lib_file=
4417 for module in $main_modules; do
4418 if test $module = config-h; then
4419 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4420 sed_transform_lib_file=$sed_transform_lib_file'
4421 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4426 sed_transform_main_lib_file="$sed_transform_lib_file"
4427 if test -n "$do_copyrights"; then
4428 if test -n "$lgpl"; then
4432 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4433 s/GNU General/GNU Lesser General/g
4434 s/General Public License/Lesser General Public License/g
4435 s/Lesser Lesser General Public License/Lesser General Public License/g
4439 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4440 s/GNU General/GNU Lesser General/g
4441 s/General Public License/Lesser General Public License/g
4442 s/Lesser Lesser General Public License/Lesser General Public License/g
4444 s/version [23]\([ ,]\)/version 2.1\1/g
4447 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4451 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4452 s/GNU Lesser General/GNU General/g
4453 s/Lesser General Public License/General Public License/g
4455 s/GNU Library General/GNU General/g
4456 s/Library General Public License/General Public License/g
4458 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4463 # Determine script to apply to auxiliary files that go into $auxdir/.
4464 sed_transform_build_aux_file=
4465 if test -n "$do_copyrights"; then
4467 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4468 s/GNU Lesser General/GNU General/g
4469 s/Lesser General Public License/General Public License/g
4471 s/GNU Library General/GNU General/g
4472 s/Library General Public License/General Public License/g
4474 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4478 # Determine script to apply to library files that go into $testsbase/.
4479 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4480 if test -n "$do_copyrights"; then
4482 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4483 s/GNU Lesser General/GNU General/g
4484 s/Lesser General Public License/General Public License/g
4486 s/GNU Library General/GNU General/g
4487 s/Library General Public License/General Public License/g
4489 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4493 # Determine the final file lists.
4494 func_modules_to_filelist_separately
4497 || func_fatal_error "refusing to do nothing"
4499 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4500 new_files="$files m4/gnulib-tool.m4"
4501 old_files="$cached_files"
4502 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4503 func_append old_files " m4/gnulib-tool.m4"
4506 rewritten='%REWRITTEN%'
4507 sed_rewrite_old_files="\
4508 s,^build-aux/,$rewritten$auxdir/,
4509 s,^doc/,$rewritten$cached_docbase/,
4510 s,^lib/,$rewritten$cached_sourcebase/,
4511 s,^m4/,$rewritten$cached_m4base/,
4512 s,^tests/,$rewritten$cached_testsbase/,
4513 s,^tests=lib/,$rewritten$cached_testsbase/,
4516 sed_rewrite_new_files="\
4517 s,^build-aux/,$rewritten$auxdir/,
4518 s,^doc/,$rewritten$docbase/,
4519 s,^lib/,$rewritten$sourcebase/,
4520 s,^m4/,$rewritten$m4base/,
4521 s,^tests/,$rewritten$testsbase/,
4522 s,^tests=lib/,$rewritten$testsbase/,
4526 # Create directories.
4527 { echo "$sourcebase"
4529 if test -n "$pobase"; then
4532 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4533 if test -n "$docfiles"; then
4536 if test -n "$inctests"; then
4540 for f in $files; do echo $f; done \
4541 | sed -e "$sed_rewrite_new_files" \
4542 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4545 { # Rearrange file descriptors. Needed because "while ... done < ..."
4546 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4547 exec 5<&0 < "$tmp"/dirs
4549 if test ! -d "$destdir/$d"; then
4551 echo "Creating directory $destdir/$d"
4552 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4554 echo "Create directory $destdir/$d"
4561 # Copy files or make symbolic links. Remove obsolete files.
4565 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4566 # representing the files according to the last gnulib-tool invocation.
4567 for f in $old_files; do echo $f; done \
4568 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4571 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4572 # representing the files after this gnulib-tool invocation.
4573 for f in $new_files; do echo $f; done \
4574 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4577 # First the files that are in old-files, but not in new-files:
4578 sed_take_first_column='s,'"$delimiter"'.*,,'
4579 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4580 # Remove the file. Do nothing if the user already removed it.
4581 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4583 echo "Removing file $g (backup in ${g}~)"
4584 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4586 echo "Remove file $g (backup in ${g}~)"
4588 func_append removed_files "$g$nl"
4591 # func_add_or_update handles a file that ought to be present afterwards.
4593 # - f the original file name
4594 # - g the rewritten file name
4595 # - already_present nonempty if the file should already exist, empty
4597 func_add_or_update ()
4601 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4603 func_dest_tmpfilename "$g"
4604 func_lookup_file "$f"
4605 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4606 if test -n "$sed_transform_main_lib_file"; then
4609 sed -e "$sed_transform_main_lib_file" \
4610 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4614 if test -n "$sed_transform_build_aux_file"; then
4617 sed -e "$sed_transform_build_aux_file" \
4618 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4622 if test -n "$sed_transform_testsrelated_lib_file"; then
4625 sed -e "$sed_transform_testsrelated_lib_file" \
4626 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4630 if test -f "$destdir/$g"; then
4631 # The file already exists.
4635 # Don't protest if the file should be there but isn't: it happens
4636 # frequently that developers don't put autogenerated files under version control.
4638 func_append added_files "$g$nl"
4642 # Then the files that are in new-files, but not in old-files:
4643 sed_take_last_column='s,^.*'"$delimiter"',,'
4645 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4646 | sed -e "$sed_take_last_column" \
4647 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4648 { # Rearrange file descriptors. Needed because "while ... done < ..."
4649 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4650 exec 5<&0 < "$tmp"/added-files
4656 # Then the files that are in new-files and in old-files:
4657 already_present=true
4658 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4659 | sed -e "$sed_take_last_column" \
4660 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4661 { # Rearrange file descriptors. Needed because "while ... done < ..."
4662 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4663 exec 5<&0 < "$tmp"/kept-files
4670 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4671 actioncmd="gnulib-tool --import"
4672 func_append actioncmd " --dir=$destdir"
4673 if test -n "$local_gnulib_dir"; then
4674 func_append actioncmd " --local-dir=$local_gnulib_dir"
4676 func_append actioncmd " --lib=$libname"
4677 func_append actioncmd " --source-base=$sourcebase"
4678 func_append actioncmd " --m4-base=$m4base"
4679 if test -n "$pobase"; then
4680 func_append actioncmd " --po-base=$pobase"
4682 func_append actioncmd " --doc-base=$docbase"
4683 func_append actioncmd " --tests-base=$testsbase"
4684 func_append actioncmd " --aux-dir=$auxdir"
4685 if test -n "$inctests"; then
4686 func_append actioncmd " --with-tests"
4688 if test -n "$incobsolete"; then
4689 func_append actioncmd " --with-obsolete"
4691 if test -n "$inc_cxx_tests"; then
4692 func_append actioncmd " --with-c++-tests"
4694 if test -n "$inc_longrunning_tests"; then
4695 func_append actioncmd " --with-longrunning-tests"
4697 if test -n "$inc_privileged_tests"; then
4698 func_append actioncmd " --with-privileged-tests"
4700 if test -n "$inc_unportable_tests"; then
4701 func_append actioncmd " --with-unportable-tests"
4703 if test -n "$inc_all_tests"; then
4704 func_append actioncmd " --with-all-tests"
4706 for module in $avoidlist; do
4707 func_append actioncmd " --avoid=$module"
4709 if test -n "$lgpl"; then
4710 if test "$lgpl" = yes; then
4711 func_append actioncmd " --lgpl"
4713 func_append actioncmd " --lgpl=$lgpl"
4716 if test -n "$makefile_name"; then
4717 func_append actioncmd " --makefile-name=$makefile_name"
4719 if test "$cond_dependencies" = true; then
4720 func_append actioncmd " --conditional-dependencies"
4722 func_append actioncmd " --no-conditional-dependencies"
4724 if test "$libtool" = true; then
4725 func_append actioncmd " --libtool"
4727 func_append actioncmd " --no-libtool"
4729 func_append actioncmd " --macro-prefix=$macro_prefix"
4730 if test -n "$po_domain"; then
4731 func_append actioncmd " --po-domain=$po_domain"
4733 if test -n "$vc_files"; then
4734 if test "$vc_files" = true; then
4735 func_append actioncmd " --vc-files"
4737 func_append actioncmd " --no-vc-files"
4740 func_append actioncmd " `echo $specified_modules`"
4742 # Determine include_guard_prefix.
4743 func_compute_include_guard_prefix
4745 # Default the makefile name to Makefile.am.
4746 if test -n "$makefile_name"; then
4747 makefile_am=$makefile_name
4749 makefile_am=Makefile.am
4752 # Create normal Makefile.ams.
4755 # Setup list of Makefile.am edits that are to be performed afterwards.
4756 # Some of these edits apply to files that we will generate; others are
4757 # under the responsibility of the developer.
4759 # func_note_Makefile_am_edit dir var value
4760 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4762 func_note_Makefile_am_edit ()
4764 makefile_am_edits=`expr $makefile_am_edits + 1`
4765 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4766 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4767 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4769 if test "$makefile_am" = Makefile.am; then
4770 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4771 sourcebase_base=`basename "$sourcebase"`
4772 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4774 if test -n "$pobase"; then
4775 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4776 pobase_base=`basename "$pobase"`
4777 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4779 if test -n "$inctests"; then
4780 if test "$makefile_am" = Makefile.am; then
4781 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4782 testsbase_base=`basename "$testsbase"`
4783 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4786 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4788 # Find the first parent directory of $m4base that contains or will contain
4790 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4792 sed_butlast='s,[^/][^/]*//*$,,'
4793 dir1="${m4base}/"; dir2=""
4794 while test -n "$dir1" \
4795 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4796 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4797 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4798 || { test -n "$inctests" \
4799 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4800 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4801 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4802 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4804 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4807 # Create library makefile.
4808 func_dest_tmpfilename $sourcebase/$makefile_am
4809 destfile="$sourcebase/$makefile_am"
4810 modules="$main_modules"
4811 func_emit_lib_Makefile_am > "$tmpfile"
4812 if test -f "$destdir"/$sourcebase/$makefile_am; then
4813 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4817 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4818 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4819 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4821 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4827 echo "Creating $sourcebase/$makefile_am"
4828 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4830 echo "Create $sourcebase/$makefile_am"
4833 func_append added_files "$sourcebase/$makefile_am$nl"
4836 # Create po/ directory.
4837 if test -n "$pobase"; then
4838 # Create po makefile and auxiliary files.
4839 for file in Makefile.in.in remove-potcdate.sin; do
4840 func_dest_tmpfilename $pobase/$file
4841 func_lookup_file build-aux/po/$file
4842 cat "$lookedup_file" > "$tmpfile"
4843 if test -f "$destdir"/$pobase/$file; then
4844 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4848 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4849 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4850 mv -f "$tmpfile" "$destdir"/$pobase/$file
4852 echo "Update $pobase/$file (backup in $pobase/$file~)"
4858 echo "Creating $pobase/$file"
4859 mv -f "$tmpfile" "$destdir"/$pobase/$file
4861 echo "Create $pobase/$file"
4864 func_append added_files "$pobase/$file$nl"
4867 # Create po makefile parameterization, part 1.
4868 func_dest_tmpfilename $pobase/Makevars
4869 func_emit_po_Makevars > "$tmpfile"
4870 if test -f "$destdir"/$pobase/Makevars; then
4871 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4875 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4876 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4877 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4879 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4885 echo "Creating $pobase/Makevars"
4886 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4888 echo "Create $pobase/Makevars"
4891 func_append added_files "$pobase/Makevars$nl"
4893 # Create po makefile parameterization, part 2.
4894 func_dest_tmpfilename $pobase/POTFILES.in
4895 func_emit_po_POTFILES_in > "$tmpfile"
4896 if test -f "$destdir"/$pobase/POTFILES.in; then
4897 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4901 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4902 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4903 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4905 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4911 echo "Creating $pobase/POTFILES.in"
4912 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4914 echo "Create $pobase/POTFILES.in"
4917 func_append added_files "$pobase/POTFILES.in$nl"
4920 TP_URL="http://translationproject.org/latest/"
4921 TP_RSYNC_URI="translationproject.org::tp/latest/"
4923 echo "Fetching gnulib PO files from $TP_URL"
4924 (cd "$destdir"/$pobase \
4925 && { # Prefer rsync over wget if it is available, since it consumes
4926 # less network bandwidth, due to compression.
4927 if type rsync 2>/dev/null | grep / > /dev/null; then
4928 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4930 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4935 echo "Fetch gnulib PO files from $TP_URL"
4937 # Create po/LINGUAS.
4939 func_dest_tmpfilename $pobase/LINGUAS
4940 (cd "$destdir"/$pobase \
4941 && { echo '# Set of available languages.'
4942 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4945 if test -f "$destdir"/$pobase/LINGUAS; then
4946 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4949 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4950 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4951 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4954 echo "Creating $pobase/LINGUAS"
4955 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4956 func_append added_files "$pobase/LINGUAS$nl"
4959 if test -f "$destdir"/$pobase/LINGUAS; then
4960 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4962 echo "Create $pobase/LINGUAS"
4967 # Create m4/gnulib-cache.m4.
4968 func_dest_tmpfilename $m4base/gnulib-cache.m4
4970 func_emit_copyright_notice
4972 echo "# This file represents the specification of how gnulib-tool is used."
4973 echo "# It acts as a cache: It is written and read by gnulib-tool."
4974 echo "# In projects that use version control, this file is meant to be put under"
4975 echo "# version control, like the configure.ac and various Makefile.am files."
4978 echo "# Specification in the form of a command-line invocation:"
4981 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4982 # Store the local_gnulib_dir relative to destdir.
4983 case "$local_gnulib_dir" in
4985 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4988 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4990 # destdir, local_gnulib_dir are both relative.
4991 func_relativize "$destdir" "$local_gnulib_dir"
4992 relative_local_gnulib_dir="$reldir" ;;
4995 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4997 echo "$specified_modules" | sed -e 's/^/ /g'
4999 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5000 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5001 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5002 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5003 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5004 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5005 echo "gl_AVOID([$avoidlist])"
5006 echo "gl_SOURCE_BASE([$sourcebase])"
5007 echo "gl_M4_BASE([$m4base])"
5008 echo "gl_PO_BASE([$pobase])"
5009 echo "gl_DOC_BASE([$docbase])"
5010 echo "gl_TESTS_BASE([$testsbase])"
5011 test -z "$inctests" || echo "gl_WITH_TESTS"
5012 echo "gl_LIB([$libname])"
5013 if test -n "$lgpl"; then
5014 if test "$lgpl" = yes; then
5017 echo "gl_LGPL([$lgpl])"
5020 echo "gl_MAKEFILE_NAME([$makefile_name])"
5021 if test "$cond_dependencies" = true; then
5022 echo "gl_CONDITIONAL_DEPENDENCIES"
5024 if test "$libtool" = true; then
5027 echo "gl_MACRO_PREFIX([$macro_prefix])"
5028 echo "gl_PO_DOMAIN([$po_domain])"
5029 if test -n "$vc_files"; then
5030 echo "gl_VC_FILES([$vc_files])"
5033 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5034 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
5038 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5039 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5040 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5042 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5046 echo "# gnulib-cache.m4 ends here"
5053 echo "Creating $m4base/gnulib-cache.m4"
5054 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5056 echo "Create $m4base/gnulib-cache.m4"
5062 # Create m4/gnulib-comp.m4.
5063 func_dest_tmpfilename $m4base/gnulib-comp.m4
5065 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5066 func_emit_copyright_notice
5068 echo "# This file represents the compiled summary of the specification in"
5069 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5070 echo "# to be invoked from configure.ac."
5071 echo "# In projects that use version control, this file can be treated like"
5072 echo "# other built files."
5075 echo "# This macro should be invoked from $configure_ac, in the section"
5076 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5077 echo "# any checks for libraries, header files, types and library functions."
5078 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5080 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5081 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5082 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5083 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5084 echo " AC_REQUIRE([AC_PROG_RANLIB])"
5085 if test -n "$uses_subdirs"; then
5086 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5088 for module in $final_modules; do
5090 if test -n "$module"; then
5091 echo "# Code from module $module:"
5092 func_get_autoconf_early_snippet "$module"
5095 | sed -e '/^$/d;' -e 's/^/ /'
5098 echo "# This macro should be invoked from $configure_ac, in the section"
5099 echo "# \"Check for header files, types and library functions\"."
5100 echo "AC_DEFUN([${macro_prefix}_INIT],"
5102 if test "$libtool" = true; then
5103 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5104 echo " gl_cond_libtool=true"
5106 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5107 echo " gl_cond_libtool=false"
5109 echo " gl_ltlibdeps="
5111 if test "$auxdir" != "build-aux"; then
5112 sed_replace_build_aux='
5114 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5115 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5119 sed_replace_build_aux="$sed_noop"
5121 echo " gl_m4_base='$m4base'"
5122 func_emit_initmacro_start $macro_prefix
5123 echo " gl_source_base='$sourcebase'"
5124 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
5125 echo " # End of code from modules"
5126 func_emit_initmacro_end $macro_prefix
5127 echo " gltests_libdeps="
5128 echo " gltests_ltlibdeps="
5129 func_emit_initmacro_start ${macro_prefix}tests
5130 echo " gl_source_base='$testsbase'"
5131 # Define a tests witness macro that depends on the package.
5132 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5133 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5134 echo "changequote(,)dnl"
5135 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"
5136 echo "changequote([, ])dnl"
5137 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5138 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5139 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5140 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
5141 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5142 func_emit_initmacro_end ${macro_prefix}tests
5143 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5144 # created using libtool, because libtool already handles the dependencies.
5145 if test "$libtool" != true; then
5146 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5147 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5148 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5149 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5150 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5152 if $use_libtests; then
5153 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5154 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5157 func_emit_initmacro_done $macro_prefix $sourcebase
5158 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5160 echo "# This macro records the list of files which have been installed by"
5161 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5162 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5163 echo "$files" | sed -e 's,^, ,'
5166 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5167 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
5171 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5172 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5173 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5175 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5179 echo "# gnulib-comp.m4 ends here"
5186 echo "Creating $m4base/gnulib-comp.m4"
5187 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5189 echo "Create $m4base/gnulib-comp.m4"
5195 if test -n "$inctests"; then
5196 # Create tests makefile.
5197 func_dest_tmpfilename $testsbase/$makefile_am
5198 destfile="$testsbase/$makefile_am"
5199 modules="$testsrelated_modules"
5200 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5201 if test -f "$destdir"/$testsbase/$makefile_am; then
5202 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
5206 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5207 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5208 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5210 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5216 echo "Creating $testsbase/$makefile_am"
5217 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5219 echo "Create $testsbase/$makefile_am"
5222 func_append added_files "$testsbase/$makefile_am$nl"
5226 if test "$vc_files" != false; then
5227 # Update the .cvsignore and .gitignore files.
5228 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5229 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5230 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5231 echo "$m4base/|A|gnulib-comp.m4"
5232 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5233 { # Rearrange file descriptors. Needed because "while ... done < ..."
5234 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5235 exec 5<&0 < "$tmp"/fileset-changes
5236 func_update_ignorelist ()
5239 if test "$ignore" = .gitignore; then
5240 # In a .gitignore file, "foo" applies to the current directory and all
5241 # subdirectories, whereas "/foo" applies to the current directory only.
5244 doubly_escaped_anchor='\\/'
5248 doubly_escaped_anchor=''
5250 if test -f "$destdir/$dir$ignore"; then
5251 if test -n "$dir_added" || test -n "$dir_removed"; then
5252 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5253 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5254 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5255 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5256 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
5258 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5260 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5261 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5262 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5263 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5264 } > "$tmp"/sed-ignore-removed
5265 { cat "$destdir/$dir$ignore"~
5266 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5267 } | sed -f "$tmp"/sed-ignore-removed \
5268 > "$destdir/$dir$ignore"
5270 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5275 if test -n "$dir_added"; then
5277 echo "Creating $destdir/$dir$ignore"
5279 if test "$ignore" = .cvsignore; then
5281 # Automake generates Makefile rules that create .dirstamp files.
5284 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5285 } > "$destdir/$dir$ignore"
5287 echo "Create $destdir/$dir$ignore"
5297 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5298 func_update_ignorelist .cvsignore
5300 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5301 func_update_ignorelist .gitignore
5308 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5309 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5310 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5311 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5312 if test "$next_dir" != "$last_dir"; then
5313 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5314 last_dir="$next_dir"
5319 A) func_append last_dir_added "$file$nl";;
5320 R) func_append last_dir_removed "$file$nl";;
5323 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5330 echo "You may need to add #include directives for the following .h files."
5331 # Intersect $specified_modules and $main_modules
5332 # (since $specified_modules is not necessarily of subset of $main_modules
5333 # - some may have been skipped through --avoid, and since the elements of
5334 # $main_modules but not in $specified_modules can go away without explicit
5335 # notice - through changes in the module dependencies).
5336 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5337 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5338 # First the #include <...> directives without #ifs, sorted for convenience,
5339 # then the #include "..." directives without #ifs, sorted for convenience,
5340 # then the #include directives that are surrounded by #ifs. Not sorted.
5341 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5342 include_directive=`func_get_include_directive "$module"`
5343 case "$nl$include_directive" in
5345 echo "$include_directive" 1>&5
5348 echo "$include_directive" | grep -v 'include "' 1>&6
5349 echo "$include_directive" | grep 'include "' 1>&7
5352 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5354 LC_ALL=C sort -u "$tmp"/include-angles
5355 LC_ALL=C sort -u "$tmp"/include-quotes
5356 cat "$tmp"/include-if
5357 ) | sed -e '/^$/d' -e 's/^/ /'
5358 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5360 for module in $main_modules; do
5361 func_get_link_directive "$module"
5363 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5364 if test `wc -l < "$tmp"/link` != 0; then
5366 echo "You may need to use the following Makefile variables when linking."
5367 echo "Use them in <program>_LDADD when linking a program, or"
5368 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5374 echo "Don't forget to"
5375 if test "$makefile_am" = Makefile.am; then
5376 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5378 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5380 if test -n "$pobase"; then
5381 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5383 if test -n "$inctests"; then
5384 if test "$makefile_am" = Makefile.am; then
5385 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5387 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5391 while test $edit != $makefile_am_edits; do
5392 edit=`expr $edit + 1`
5393 eval dir=\"\$makefile_am_edit${edit}_dir\"
5394 eval var=\"\$makefile_am_edit${edit}_var\"
5395 eval val=\"\$makefile_am_edit${edit}_val\"
5396 if test -n "$var"; then
5397 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5400 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
5401 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5404 # func_create_testdir testdir modules
5406 # - local_gnulib_dir from --local-dir
5407 # - modcache true or false, from --cache-modules/--no-cache-modules
5408 # - auxdir directory relative to destdir where to place build aux files
5409 # - inctests true if tests should be included, blank otherwise
5410 # - incobsolete true if obsolete modules among dependencies should be
5411 # included, blank otherwise
5412 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5414 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5416 # - excl_privileged_tests true if tests that require root privileges should be
5417 # excluded, blank otherwise
5418 # - excl_unportable_tests true if tests that fail on some platforms should be
5419 # excluded, blank otherwise
5420 # - single_configure true if a single configure file should be generated,
5421 # false for a separate configure file for the tests
5422 # - avoidlist list of modules to avoid
5423 # - cond_dependencies true if --conditional-dependencies was given, false if
5424 # --no-conditional-dependencies was given, blank otherwise
5425 # - libtool true if --libtool was given, false if --no-libtool was
5426 # given, blank otherwise
5427 # - symbolic true if files should be symlinked, copied otherwise
5428 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
5430 func_create_testdir ()
5434 if test -z "$modules"; then
5435 # All modules together.
5436 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5437 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5438 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5439 modules=`func_all_modules`
5440 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5442 specified_modules="$modules"
5444 # Canonicalize the list of specified modules.
5445 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5447 # Unlike in func_import, here we want to include all kinds of tests for the
5448 # directly specified modules, but not for dependencies.
5449 inc_all_direct_tests=true
5450 inc_all_indirect_tests="$inc_all_tests"
5452 # Check that the license of every module is consistent with the license of
5454 saved_inctests="$inctests"
5455 # When computing transitive closures, don't consider $module to depend on
5456 # $module-tests. Need this becauses tests are implicitly GPL and may depend
5457 # on GPL modules - therefore we don't want a warning in this case.
5459 for requested_module in $specified_modules; do
5460 requested_license=`func_get_license "$requested_module"`
5461 if test "$requested_license" != GPL; then
5462 # Here we use func_modules_transitive_closure, not just
5463 # func_get_dependencies, so that we also detect weird situations like
5464 # an LGPL module which depends on a GPLed build tool module which depends
5466 modules="$requested_module"
5467 func_modules_transitive_closure
5468 for module in $modules; do
5469 license=`func_get_license "$module"`
5471 'GPLed build tool') ;;
5472 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5474 case "$requested_license" in
5477 GPLv2+ | LGPLv2+) ;;
5478 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5484 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5490 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5499 inctests="$saved_inctests"
5501 # Subdirectory names.
5511 # Determine final module list.
5512 modules="$specified_modules"
5513 func_modules_transitive_closure
5514 if test $verbose -ge 0; then
5515 func_show_module_list
5517 final_modules="$modules"
5519 if $single_configure; then
5520 # Determine main module list and tests-related module list separately.
5521 func_modules_transitive_closure_separately
5524 if $single_configure; then
5525 # Determine whether a $testsbase/libtests.a is needed.
5526 func_determine_use_libtests
5529 # Add the dummy module if needed.
5530 if $single_configure; then
5531 func_modules_add_dummy_separately
5533 func_modules_add_dummy
5536 # Show banner notice of every module.
5537 if $single_configure; then
5538 modules="$main_modules"
5544 # Determine final file list.
5545 if $single_configure; then
5546 func_modules_to_filelist_separately
5548 func_modules_to_filelist
5549 if test $verbose -ge 0; then
5551 echo "$files" | sed -e 's/^/ /'
5554 # Add files for which the copy in gnulib is newer than the one that
5555 # "automake --add-missing --copy" would provide.
5556 files="$files build-aux/config.guess"
5557 files="$files build-aux/config.sub"
5558 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5560 rewritten='%REWRITTEN%'
5561 sed_rewrite_files="\
5562 s,^build-aux/,$rewritten$auxdir/,
5563 s,^doc/,$rewritten$docbase/,
5564 s,^lib/,$rewritten$sourcebase/,
5565 s,^m4/,$rewritten$m4base/,
5566 s,^tests/,$rewritten$testsbase/,
5567 s,^tests=lib/,$rewritten$testsbase/,
5571 # Create directories.
5572 for f in $files; do echo $f; done \
5573 | sed -e "$sed_rewrite_files" \
5574 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5575 | LC_ALL=C sort -u \
5577 { # Rearrange file descriptors. Needed because "while ... done < ..."
5578 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5579 exec 5<&0 < "$tmp"/dirs
5581 mkdir -p "$testdir/$d"
5586 # Copy files or make symbolic links.
5588 for f in $files; do echo $f; done \
5589 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5592 { # Rearrange file descriptors. Needed because "while ... done < ..."
5593 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5594 exec 5<&0 < "$tmp"/files
5597 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5599 func_lookup_file "$f"
5600 if test -n "$lookedup_tmp"; then
5601 cp -p "$lookedup_file" "$testdir/$g"
5603 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5604 if { test -n "$symbolic" \
5605 || { test -n "$lsymbolic" \
5606 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5607 func_ln "$lookedup_file" "$testdir/$g"
5609 cp -p "$lookedup_file" "$testdir/$g"
5616 # Determine include_guard_prefix.
5617 func_compute_include_guard_prefix
5619 # Create Makefile.ams that are for testing.
5622 # No special edits are needed.
5625 # Create $sourcebase/Makefile.am.
5626 mkdir -p "$testdir/$sourcebase"
5627 destfile="$sourcebase/Makefile.am"
5628 if $single_configure; then
5629 modules="$main_modules"
5631 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5632 any_uses_subdirs="$uses_subdirs"
5634 # Create $m4base/Makefile.am.
5635 mkdir -p "$testdir/$m4base"
5636 (echo "## Process this file with automake to produce Makefile.in."
5642 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5645 ) > "$testdir/$m4base/Makefile.am"
5647 subdirs="$sourcebase $m4base"
5648 subdirs_with_configure_ac=""
5650 if false && test -f "$testdir"/$m4base/gettext.m4; then
5651 # Avoid stupid error message from automake:
5652 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5653 mkdir -p "$testdir/po"
5654 (echo "## Process this file with automake to produce Makefile.in."
5655 ) > "$testdir/po/Makefile.am"
5656 func_append subdirs " po"
5659 if test -n "$inctests"; then
5660 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5661 if $single_configure; then
5662 # Create $testsbase/Makefile.am.
5663 destfile="$testsbase/Makefile.am"
5664 modules="$testsrelated_modules"
5665 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
5667 # Viewed from the $testsbase subdirectory, $auxdir is different.
5668 saved_auxdir="$auxdir"
5669 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5670 # Create $testsbase/Makefile.am.
5672 destfile="$testsbase/Makefile.am"
5673 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5674 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5675 # Create $testsbase/configure.ac.
5676 (echo "# Process this file with autoconf to produce a configure script."
5677 echo "AC_INIT([dummy], [0])"
5678 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5679 echo "AM_INIT_AUTOMAKE"
5681 echo "AC_CONFIG_HEADERS([config.h])"
5684 echo "AC_PROG_INSTALL"
5685 echo "AC_PROG_MAKE_SET"
5686 echo "AC_PROG_RANLIB"
5688 if test -n "$uses_subdirs"; then
5689 echo "AM_PROG_CC_C_O"
5692 for module in $modules; do
5694 if test -n "$module"; then
5696 gnumakefile | maintainer-makefile)
5697 # These modules are meant to be used only in the top-level directory.
5700 func_get_autoconf_early_snippet "$module"
5705 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5706 if test "$libtool" = true; then
5707 echo "LT_INIT([win32-dll])"
5708 echo "LT_LANG([C++])"
5709 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5710 echo "gl_cond_libtool=true"
5712 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5713 echo "gl_cond_libtool=false"
5715 echo "gl_ltlibdeps="
5717 # Wrap the set of autoconf snippets into an autoconf macro that is then
5718 # invoked. This is needed because autoconf does not support AC_REQUIRE
5720 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5721 # but we want the AC_REQUIRE to have its normal meaning (provide one
5722 # expansion of the required macro before the current point, and only one
5724 echo "AC_DEFUN([gl_INIT], ["
5725 sed_replace_build_aux='
5727 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5728 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5731 echo "gl_m4_base='../$m4base'"
5732 func_emit_initmacro_start $macro_prefix
5733 # We don't have explicit ordering constraints between the various
5734 # autoconf snippets. It's cleanest to put those of the library before
5735 # those of the tests.
5736 echo "gl_source_base='../$sourcebase'"
5737 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
5738 echo "gl_source_base='.'"
5739 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
5740 func_emit_initmacro_end $macro_prefix
5741 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5742 # created using libtool, because libtool already handles the dependencies.
5743 if test "$libtool" != true; then
5744 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5745 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5746 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5747 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5748 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5751 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5755 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5756 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5757 echo "AH_TOP([#include \"../config.h\"])"
5759 echo "AC_CONFIG_FILES([Makefile])"
5761 ) > "$testdir/$testsbase/configure.ac"
5762 auxdir="$saved_auxdir"
5763 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5765 func_append subdirs " $testsbase"
5768 # Create Makefile.am.
5769 (echo "## Process this file with automake to produce Makefile.in."
5771 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5773 echo "SUBDIRS = $subdirs"
5775 echo "ACLOCAL_AMFLAGS = -I $m4base"
5776 ) > "$testdir/Makefile.am"
5778 # Create configure.ac.
5779 (echo "# Process this file with autoconf to produce a configure script."
5780 echo "AC_INIT([dummy], [0])"
5781 if test "$auxdir" != "."; then
5782 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5784 echo "AM_INIT_AUTOMAKE"
5786 echo "AC_CONFIG_HEADERS([config.h])"
5789 echo "AC_PROG_INSTALL"
5790 echo "AC_PROG_MAKE_SET"
5792 echo "# For autobuild."
5793 echo "AC_CANONICAL_BUILD"
5794 echo "AC_CANONICAL_HOST"
5796 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5797 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5798 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5799 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5801 echo "AC_PROG_RANLIB"
5803 if test -n "$any_uses_subdirs"; then
5804 echo "AM_PROG_CC_C_O"
5807 for module in $final_modules; do
5808 if $single_configure; then
5811 func_verify_nontests_module
5813 if test -n "$module"; then
5814 func_get_autoconf_early_snippet "$module"
5817 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5818 if test "$libtool" = true; then
5819 echo "LT_INIT([win32-dll])"
5820 echo "LT_LANG([C++])"
5821 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5822 echo "gl_cond_libtool=true"
5824 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5825 echo "gl_cond_libtool=false"
5827 echo "gl_ltlibdeps="
5829 # Wrap the set of autoconf snippets into an autoconf macro that is then
5830 # invoked. This is needed because autoconf does not support AC_REQUIRE
5832 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5833 # but we want the AC_REQUIRE to have its normal meaning (provide one
5834 # expansion of the required macro before the current point, and only one
5836 echo "AC_DEFUN([gl_INIT], ["
5837 if test "$auxdir" != "build-aux"; then
5838 sed_replace_build_aux='
5840 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5841 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5845 sed_replace_build_aux="$sed_noop"
5847 echo "gl_m4_base='$m4base'"
5848 func_emit_initmacro_start $macro_prefix
5849 echo "gl_source_base='$sourcebase'"
5850 if $single_configure; then
5851 func_emit_autoconf_snippets "$main_modules" func_verify_module true false false
5853 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
5855 func_emit_initmacro_end $macro_prefix
5856 if $single_configure; then
5857 echo " gltests_libdeps="
5858 echo " gltests_ltlibdeps="
5859 func_emit_initmacro_start ${macro_prefix}tests
5860 echo " gl_source_base='$testsbase'"
5861 # Define a tests witness macro.
5862 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
5863 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5864 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5865 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5866 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true false false
5867 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5868 func_emit_initmacro_end ${macro_prefix}tests
5870 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5871 # created using libtool, because libtool already handles the dependencies.
5872 if test "$libtool" != true; then
5873 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5874 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5875 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5876 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5877 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5879 if $single_configure; then
5880 if $use_libtests; then
5881 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5882 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5886 func_emit_initmacro_done $macro_prefix $sourcebase
5887 if $single_configure; then
5888 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5893 if test -n "$subdirs_with_configure_ac"; then
5894 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5896 makefiles="Makefile"
5897 for d in $subdirs; do
5898 # For subdirs that have a configure.ac by their own, it's the subdir's
5899 # configure.ac which creates the subdir's Makefile.am, not this one.
5900 case " $subdirs_with_configure_ac " in
5902 *) func_append makefiles " $d/Makefile" ;;
5905 echo "AC_CONFIG_FILES([$makefiles])"
5907 ) > "$testdir/configure.ac"
5909 # Create autogenerated files.
5911 # Do not use "${AUTORECONF} --force --install", because it may invoke
5912 # autopoint, which brings in older versions of some of our .m4 files.
5913 if test -f $m4base/gettext.m4; then
5914 func_execute_command ${AUTOPOINT} --force || func_exit 1
5915 for f in $m4base/*.m4~; do
5917 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5921 if test "$libtool" = true; then
5922 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5924 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5925 if ! test -d build-aux; then
5926 func_execute_command mkdir build-aux || func_exit 1
5928 func_execute_command ${AUTOCONF} || func_exit 1
5929 func_execute_command ${AUTOHEADER} || func_exit 1
5930 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5932 if test -n "$inctests" && ! $single_configure; then
5933 # Create autogenerated files.
5934 (cd "$testdir/$testsbase" || func_exit 1
5935 # Do not use "${AUTORECONF} --force --install", because it may invoke
5936 # autopoint, which brings in older versions of some of our .m4 files.
5937 if test -f ../$m4base/gettext.m4; then
5938 func_execute_command ${AUTOPOINT} --force || func_exit 1
5939 for f in ../$m4base/*.m4~; do
5941 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5945 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5946 if ! test -d ../build-aux; then
5947 func_execute_command mkdir ../build-aux
5949 func_execute_command ${AUTOCONF} || func_exit 1
5950 func_execute_command ${AUTOHEADER} || func_exit 1
5951 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5954 # Need to run configure and make once, to create built files that are to be
5955 # distributed (such as parse-datetime.c).
5956 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5957 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5958 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5959 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5960 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5961 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5962 # such $(FOO_H) because they don't refer to distributed files.
5963 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5964 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5965 | sed -e "$sed_remove_make_variables"`
5966 distributed_built_sources=`for file in $built_sources; do
5967 case "$cleaned_files" in
5972 tests_distributed_built_sources=
5973 if test -n "$inctests"; then
5974 # Likewise for built files in the $testsbase directory.
5975 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5976 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5977 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5978 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5979 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5980 | sed -e "$sed_remove_make_variables"`
5981 tests_distributed_built_sources=`for file in $tests_built_sources; do
5982 case "$tests_cleaned_files" in
5988 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5990 ./configure || func_exit 1
5991 if test -n "$distributed_built_sources"; then
5993 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5994 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5999 if test -n "$tests_distributed_built_sources"; then
6001 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6002 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6007 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6014 # func_create_megatestdir megatestdir allmodules
6016 # - local_gnulib_dir from --local-dir
6017 # - modcache true or false, from --cache-modules/--no-cache-modules
6018 # - auxdir directory relative to destdir where to place build aux files
6019 func_create_megatestdir ()
6023 if test -z "$allmodules"; then
6024 allmodules=`func_all_modules`
6028 # First, all modules one by one.
6029 for onemodule in $allmodules; do
6030 func_create_testdir "$megatestdir/$onemodule" $onemodule
6031 func_append megasubdirs "$onemodule "
6033 # Then, all modules all together.
6034 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6035 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6036 func_create_testdir "$megatestdir/ALL" "$allmodules"
6037 func_append megasubdirs "ALL"
6040 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
6041 vc_witness="$gnulib_dir/CVS/Entries"; \
6043 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6045 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6046 | sed -e 's,January,01,' -e 's,Jan,01,' \
6047 -e 's,February,02,' -e 's,Feb,02,' \
6048 -e 's,March,03,' -e 's,Mar,03,' \
6049 -e 's,April,04,' -e 's,Apr,04,' \
6051 -e 's,June,06,' -e 's,Jun,06,' \
6052 -e 's,July,07,' -e 's,Jul,07,' \
6053 -e 's,August,08,' -e 's,Aug,08,' \
6054 -e 's,September,09,' -e 's,Sep,09,' \
6055 -e 's,October,10,' -e 's,Oct,10,' \
6056 -e 's,November,11,' -e 's,Nov,11,' \
6057 -e 's,December,12,' -e 's,Dec,12,' \
6058 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6059 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6061 echo "CVSDATE=$cvsdate"
6062 echo ": \${MAKE=make}"
6063 echo "test -d logs || mkdir logs"
6064 echo "for module in $megasubdirs; do"
6065 echo " echo \"Working on module \$module...\""
6066 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6067 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6070 echo " : autobuild project... \$module"
6071 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6072 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6073 echo " : autobuild hostname... \`hostname\`"
6074 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6076 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6078 ) > "$megatestdir/do-autobuild"
6079 chmod a+x "$megatestdir/do-autobuild"
6081 # Create Makefile.am.
6082 (echo "## Process this file with automake to produce Makefile.in."
6084 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
6086 echo "SUBDIRS = $megasubdirs"
6088 echo "EXTRA_DIST = do-autobuild"
6089 ) > "$megatestdir/Makefile.am"
6091 # Create configure.ac.
6092 (echo "# Process this file with autoconf to produce a configure script."
6093 echo "AC_INIT([dummy], [0])"
6094 if test "$auxdir" != "."; then
6095 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6097 echo "AM_INIT_AUTOMAKE"
6099 echo "AC_PROG_MAKE_SET"
6101 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6102 echo "AC_CONFIG_FILES([Makefile])"
6104 ) > "$megatestdir/configure.ac"
6106 # Create autogenerated files.
6108 # Do not use "${AUTORECONF} --install", because autoreconf operates
6109 # recursively, but the subdirectories are already finished, therefore
6110 # calling autoreconf here would only waste lots of CPU time.
6111 func_execute_command ${ACLOCAL} || func_exit 1
6112 func_execute_command mkdir build-aux
6113 func_execute_command ${AUTOCONF} || func_exit 1
6114 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6120 func_fatal_error "no mode specified" ;;
6127 # sed expression that converts a literal to a basic regular expression.
6128 # Needs to handle . [ \ * ^ $.
6129 sed_literal_to_basic_regex='s/\\/\\\\/g
6135 if test -f "$gnulib_dir/$filename" \
6136 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
6137 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6138 filename_line_regex='^'"$filename_anywhere_regex"'$'
6141 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6142 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
6143 (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$,,')
6146 | func_sanitize_modulelist \
6149 for module in $module_candidates; do
6150 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6155 func_warning "file $filename does not exist"
6160 import | add-import | remove-import | update )
6163 if test -z "$destdir"; then
6166 test -d "$destdir" \
6167 || func_fatal_error "destination directory does not exist: $destdir"
6169 # Prefer configure.ac to configure.in.
6170 if test -f "$destdir"/configure.ac; then
6171 configure_ac="$destdir/configure.ac"
6173 if test -f "$destdir"/configure.in; then
6174 configure_ac="$destdir/configure.in"
6176 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6180 # Analyze configure.ac.
6182 guessed_libtool=false
6187 /AC_CONFIG_AUX_DIR/ {
6188 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6190 /A[CM]_PROG_LIBTOOL/ {
6191 s,^.*$,guessed_libtool=true,p
6193 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6195 if test -z "$auxdir"; then
6196 auxdir="$guessed_auxdir"
6199 # Determine where to apply func_import.
6200 if test "$mode" = import; then
6201 # Apply func_import to a particular gnulib directory.
6202 # The command line contains the complete specification; don't look at
6203 # the contents of gnulib-cache.m4.
6204 test -n "$supplied_libname" || supplied_libname=true
6205 test -n "$sourcebase" || sourcebase="lib"
6206 test -n "$m4base" || m4base="m4"
6207 test -n "$docbase" || docbase="doc"
6208 test -n "$testsbase" || testsbase="tests"
6209 test -n "$macro_prefix" || macro_prefix="gl"
6212 if test -n "$m4base"; then
6213 # Apply func_import to a particular gnulib directory.
6214 # Any number of additional modules can be given.
6215 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6216 # First use of gnulib in the given m4base.
6217 test -n "$supplied_libname" || supplied_libname=true
6218 test -n "$sourcebase" || sourcebase="lib"
6219 test -n "$docbase" || docbase="doc"
6220 test -n "$testsbase" || testsbase="tests"
6221 test -n "$macro_prefix" || macro_prefix="gl"
6225 # Apply func_import to all gnulib directories.
6226 # To get this list of directories, look at Makefile.am. (Not at
6227 # configure, because it may be omitted from version control. Also,
6228 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6232 if test -f "$destdir"/Makefile.am; then
6233 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6235 for arg in $aclocal_amflags; do
6236 if test -n "$m4dir_is_next"; then
6237 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6241 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6242 func_append m4dirs " $arg"
6243 m4dirs_count=`expr $m4dirs_count + 1`
6249 if test "X$arg" = "X-I"; then
6257 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6258 if test -f "$destdir"/aclocal.m4; then
6259 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6260 sedexpr2='s,^[^/]*$,.,'
6261 sedexpr3='s,/[^/]*$,,'
6262 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6263 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6264 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6267 if test $m4dirs_count = 0; then
6268 # First use of gnulib in a package.
6269 # Any number of additional modules can be given.
6270 test -n "$supplied_libname" || supplied_libname=true
6271 test -n "$sourcebase" || sourcebase="lib"
6273 test -n "$docbase" || docbase="doc"
6274 test -n "$testsbase" || testsbase="tests"
6275 test -n "$macro_prefix" || macro_prefix="gl"
6278 if test $m4dirs_count = 1; then
6279 # There's only one use of gnulib here. Assume the user means it.
6280 # Any number of additional modules can be given.
6281 for m4base in $m4dirs; do
6285 # Ambiguous - guess what the user meant.
6286 if test $# = 0; then
6287 # No further arguments. Guess the user wants to update all of them.
6288 for m4base in $m4dirs; do
6289 # Perform func_import in a subshell, so that variable values
6291 # local_gnulib_dir, incobsolete, inc_cxx_tests,
6292 # inc_longrunning_tests, inc_privileged_tests,
6293 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6294 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6295 # makefile_name, libtool, macro_prefix, po_domain, vc_files
6296 # don't propagate from one directory to another.
6297 (func_import) || func_exit 1
6301 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6310 if test -z "$destdir"; then
6311 func_fatal_error "please specify --dir option"
6314 test -d "$destdir" \
6315 || func_fatal_error "could not create destination directory"
6316 test -n "$auxdir" || auxdir="build-aux"
6317 func_create_testdir "$destdir" "$*"
6320 create-megatestdir )
6321 if test -z "$destdir"; then
6322 func_fatal_error "please specify --dir option"
6324 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6325 test -n "$auxdir" || auxdir="build-aux"
6326 func_create_megatestdir "$destdir" "$*"
6330 test -n "$destdir" || destdir=testdir$$
6331 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6332 test -n "$auxdir" || auxdir="build-aux"
6333 func_create_testdir "$destdir" "$*"
6337 ../configure || func_exit 1
6338 $MAKE || func_exit 1
6339 $MAKE check || func_exit 1
6340 $MAKE distclean || func_exit 1
6341 remaining=`find . -type f -print`
6342 if test -n "$remaining"; then
6343 echo "Remaining files:" $remaining 1>&2
6344 echo "gnulib-tool: *** Stop." 1>&2
6353 test -n "$destdir" || destdir=testdir$$
6354 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6355 test -n "$auxdir" || auxdir="build-aux"
6356 func_create_megatestdir "$destdir" "$*"
6364 remaining=`find . -type f -print`
6365 if test -n "$remaining"; then
6366 echo "Remaining files:" $remaining 1>&2
6367 echo "gnulib-tool: *** Stop." 1>&2
6375 extract-description )
6379 if test -n "$module"; then
6380 func_get_description "$module"
6389 if test -n "$module"; then
6390 func_get_comment "$module"
6399 if test -n "$module"; then
6400 func_get_status "$module"
6409 if test -n "$module"; then
6410 func_get_notice "$module"
6415 extract-applicability )
6419 if test -n "$module"; then
6420 func_get_applicability "$module"
6429 if test -n "$module"; then
6430 func_get_filelist "$module"
6435 extract-dependencies )
6439 if test -n "$module"; then
6440 func_get_dependencies "$module"
6445 extract-autoconf-snippet )
6449 if test -n "$module"; then
6450 func_get_autoconf_snippet "$module"
6455 extract-automake-snippet )
6459 if test -n "$module"; then
6460 func_get_automake_snippet "$module"
6465 extract-include-directive )
6469 if test -n "$module"; then
6470 func_get_include_directive "$module"
6475 extract-link-directive )
6479 if test -n "$module"; then
6480 func_get_link_directive "$module"
6489 if test -n "$module"; then
6490 func_get_license "$module"
6495 extract-maintainer )
6499 if test -n "$module"; then
6500 func_get_maintainer "$module"
6505 extract-tests-module )
6509 if test -n "$module"; then
6510 func_get_tests_module "$module"
6516 # Verify the number of arguments.
6517 if test $# -lt 1 || test $# -gt 2; then
6518 func_fatal_error "invalid number of arguments for --$mode"
6521 # The first argument is the file to be copied.
6523 # Verify the file exists.
6524 func_lookup_file "$f"
6526 # The second argument is the destination; either a directory ot a file.
6527 # It defaults to the current directory.
6529 test -n "$dest" || dest='.'
6530 test -n "$sourcebase" || sourcebase="lib"
6531 test -n "$m4base" || m4base="m4"
6532 test -n "$docbase" || docbase="doc"
6533 test -n "$testsbase" || testsbase="tests"
6534 test -n "$auxdir" || auxdir="build-aux"
6535 rewritten='%REWRITTEN%'
6536 sed_rewrite_files="\
6537 s,^build-aux/,$rewritten$auxdir/,
6538 s,^doc/,$rewritten$docbase/,
6539 s,^lib/,$rewritten$sourcebase/,
6540 s,^m4/,$rewritten$m4base/,
6541 s,^tests/,$rewritten$testsbase/,
6544 if test -d "$dest"; then
6546 g=`echo "$f" | sed -e "$sed_rewrite_files"`
6548 destdir=`dirname "$dest"`
6549 g=`basename "$dest"`
6552 # Create the directory for destfile.
6553 d=`dirname "$destdir/$g"`
6555 if test -n "$d" && test ! -d "$d"; then
6556 mkdir -p "$d" || func_fatal_error "failed"
6560 func_dest_tmpfilename "$g"
6561 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
6562 already_present=true
6563 if test -f "$destdir/$g"; then
6564 # The file already exists.
6568 # Don't protest if the file should be there but isn't: it happens
6569 # frequently that developers don't put autogenerated files under version
6577 func_fatal_error "unknown operation mode --$mode" ;;
6581 # Undo the effect of the previous 'trap' command. Some shellology:
6582 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6583 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6584 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6585 # 128 + signal number and is set before the trap-registered command is run.
6587 trap 'func_exit $?' 1 2 3 13 15
6592 # indent-tabs-mode: nil
6593 # whitespace-check-buffer-indent: nil