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 --witness-c-macro=NAME Specify the C macro that is defined when the
263 sources in this directory are compiled or used.
264 --vc-files Update version control related files.
265 --no-vc-files Don't update version control related files
266 (.gitignore and/or .cvsignore).
267 --no-changelog Don't update or create ChangeLog files.
269 Options for --create-[mega]testdir, --[mega]test:
271 --without-c++-tests Exclude unit tests for C++ interoperability.
272 --without-longrunning-tests
273 Exclude unit tests that are long-runners.
274 --without-privileged-tests
275 Exclude unit tests that require root privileges.
276 --without-unportable-tests
277 Exclude unit tests that fail on some platforms.
278 --single-configure Generate a single configure file, not a separate
279 configure file for the tests directory.
281 Options for --import, --add/remove-import, --update,
282 --create-[mega]testdir, --[mega]test:
284 -s, --symbolic, --symlink Make symbolic links instead of copying files.
285 --local-symlink Make symbolic links instead of copying files, only
286 for files from the local override directory.
288 Options for --import, --add/remove-import, --update:
290 -S, --more-symlinks Make symbolic links instead of copying files, and
291 don't replace copyright notices.
293 Report bugs to <bug-gnulib@gnu.org>."
297 # outputs to stdout the --version message.
301 if test -d "$gnulib_dir"/.git \
302 && (git --version) >/dev/null 2>/dev/null \
303 && (date --version) >/dev/null 2>/dev/null; then
304 # gnulib checked out from git.
305 sed_extract_first_date='/^Date/{
309 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
310 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
311 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
312 date=`echo "$date" | sed -e "$sed_year_before_time"`
313 # Use GNU date to compute the time in GMT.
314 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
315 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
317 if test -d "$gnulib_dir"/CVS \
318 && (cvs --version) >/dev/null 2>/dev/null; then
319 # gnulib checked out from CVS.
320 sed_extract_first_date='/^date: /{
321 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
324 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
326 # gnulib copy without versioning information.
327 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
331 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
333 gnulib-tool (GNU $package $date)$version
334 Copyright (C) $year Free Software Foundation, Inc.
335 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
336 This is free software: you are free to change and redistribute it.
337 There is NO WARRANTY, to the extent permitted by law.
339 Written by" "Bruno Haible" "and" "Simon Josefsson"
342 # func_emit_copyright_notice
343 # outputs to stdout a header for a generated file.
344 func_emit_copyright_notice ()
346 sed -n -e '/Copyright/ {
349 }' < "$self_abspathname"
351 echo "# This file is free software, distributed under the terms of the GNU"
352 echo "# General Public License. As a special exception to the GNU General"
353 echo "# Public License, this file may be distributed as part of a program"
354 echo "# that contains a configuration script generated by Autoconf, under"
355 echo "# the same distribution terms as the rest of that program."
357 echo "# Generated by gnulib-tool."
361 # exits with a given status.
362 # This function needs to be used, rather than 'exit', when a 'trap' handler is
363 # in effect that refers to $?.
370 # locates the directory where the gnulib repository lives
372 # - progname name of this program
374 # - self_abspathname absolute pathname of gnulib-tool
375 # - gnulib_dir absolute pathname of gnulib repository
379 /*) self_abspathname="$progname" ;;
380 */*) self_abspathname=`pwd`/"$progname" ;;
383 # Iterate through the elements of $PATH.
384 # We use IFS=: instead of
385 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
386 # because the latter does not work when some PATH element contains spaces.
387 # We use a canonicalized $pathx instead of $PATH, because empty PATH
388 # elements are by definition equivalent to '.', however field splitting
389 # according to IFS=: loses empty fields in many shells:
390 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
391 # beginning, at the end, and in the middle),
392 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
393 # at the beginning and at the end,
394 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
395 # Solaris lose empty fields at the end.
396 # The 'case' statement is an optimization, to avoid evaluating the
397 # explicit canonicalization command when $PATH contains no empty fields.
399 if test "${PATH_SEPARATOR+set}" != set; then
400 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
401 # contains only /bin. Note that ksh looks also at the FPATH variable,
402 # so we have to set that as well for the test.
404 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
405 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
406 || PATH_SEPARATOR=';'
409 if test "$PATH_SEPARATOR" = ";"; then
410 # On Windows, programs are searched in "." before $PATH.
413 # On Unix, we have to convert empty PATH elements to ".".
417 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
422 IFS="$PATH_SEPARATOR"
426 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
427 self_abspathname="$d/$progname"
432 if test -z "$self_abspathname"; then
433 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
437 while test -h "$self_abspathname"; do
438 # Resolve symbolic link.
439 linkval=`func_readlink "$self_abspathname"`
440 test -n "$linkval" || break
442 /* ) self_abspathname="$linkval" ;;
443 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
446 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
450 # creates a temporary directory.
452 # - progname name of this program
454 # - tmp pathname of freshly created temporary directory
457 # Use the environment variable TMPDIR, falling back to /tmp. This allows
458 # users to specify a different temporary directory, for example, if their
459 # /tmp is filled up or too small.
462 # Use the mktemp program if available. If not available, hide the error
464 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
465 test -n "$tmp" && test -d "$tmp"
468 # Use a simple mkdir command. It is guaranteed to fail if the directory
469 # already exists. $RANDOM is bash specific and expands to empty in shells
470 # other than bash, ksh and zsh. Its use does not increase security;
471 # rather, it minimizes the probability of failure in a very cluttered /tmp
473 tmp=$TMPDIR/gl$$-$RANDOM
474 (umask 077 && mkdir "$tmp")
477 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
482 # func_append var value
483 # appends the given value to the shell variable var.
484 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
485 # Use bash's += operator. It reduces complexity of appending repeatedly to
486 # a single variable from O(n^2) to O(n).
491 fast_func_append=true
495 eval "$1=\"\$$1\$2\""
497 fast_func_append=false
500 # func_remove_prefix var prefix
501 # removes the given prefix from the value of the shell variable var.
502 # var should be the name of a shell variable.
503 # Its value should not contain a newline and not start or end with whitespace.
504 # prefix should not contain the characters "$`\{}[]^|.
505 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
506 func_remove_prefix ()
510 fast_func_remove_prefix=true
512 func_remove_prefix ()
514 eval "value=\"\$$1\""
518 sed_escape_dots='s/\([.]\)/\\\1/g'
519 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
522 value=`echo "$value" | sed -e "s|^${prefix}||"`
523 eval "$1=\"\$value\""
525 fast_func_remove_prefix=false
528 # func_remove_suffix var suffix
529 # removes the given suffix from the value of the shell variable var.
530 # var should be the name of a shell variable.
531 # Its value should not contain a newline and not start or end with whitespace.
532 # suffix should not contain the characters "$`\{}[]^|.
533 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
534 func_remove_suffix ()
538 fast_func_remove_suffix=true
540 func_remove_suffix ()
542 eval "value=\"\$$1\""
546 sed_escape_dots='s/\([.]\)/\\\1/g'
547 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
550 value=`echo "$value" | sed -e "s|${suffix}\$||"`
551 eval "$1=\"\$value\""
553 fast_func_remove_suffix=false
556 # func_fatal_error message
557 # outputs to stderr a fatal error message, and terminates the program.
559 # - progname name of this program
562 echo "$progname: *** $1" 1>&2
563 echo "$progname: *** Stop." 1>&2
567 # func_warning message
568 # Outputs to stderr a warning message,
571 echo "gnulib-tool: warning: $1" 1>&2
574 # func_readlink SYMLINK
575 # outputs the target of the given symlink.
576 if (type -p readlink) > /dev/null 2>&1; then
579 # Use the readlink program from GNU coreutils.
585 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
586 # would do the wrong thing if the link target contains " -> ".
587 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
591 # func_relativize DIR1 DIR2
592 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
594 # - DIR1 relative pathname, relative to the current directory
595 # - DIR2 relative pathname, relative to the current directory
597 # - reldir relative pathname of DIR2, relative to DIR1
603 sed_first='s,^\([^/]*\)/.*$,\1,'
604 sed_rest='s,^[^/]*/*,,'
605 sed_last='s,^.*/\([^/]*\)$,\1,'
606 sed_butlast='s,/*[^/]*$,,'
607 while test -n "$dir1"; do
608 first=`echo "$dir1" | sed -e "$sed_first"`
609 if test "$first" != "."; then
610 if test "$first" = ".."; then
611 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
612 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
614 first2=`echo "$dir2" | sed -e "$sed_first"`
615 if test "$first2" = "$first"; then
616 dir2=`echo "$dir2" | sed -e "$sed_rest"`
620 dir0="$dir0"/"$first"
623 dir1=`echo "$dir1" | sed -e "$sed_rest"`
628 # func_relconcat DIR1 DIR2
629 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
631 # - DIR1 relative pathname, relative to the current directory
632 # - DIR2 relative pathname, relative to DIR1
634 # - relconcat DIR1/DIR2, relative to the current directory
639 sed_first='s,^\([^/]*\)/.*$,\1,'
640 sed_rest='s,^[^/]*/*,,'
641 sed_last='s,^.*/\([^/]*\)$,\1,'
642 sed_butlast='s,/*[^/]*$,,'
644 first=`echo "$dir2" | sed -e "$sed_first"`
645 if test "$first" = "."; then
646 dir2=`echo "$dir2" | sed -e "$sed_rest"`
647 if test -z "$dir2"; then
652 last=`echo "$dir1" | sed -e "$sed_last"`
653 while test "$last" = "."; do
654 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
655 last=`echo "$dir1" | sed -e "$sed_last"`
657 if test -z "$dir1"; then
661 if test "$first" = ".."; then
662 if test "$last" = ".."; then
663 relconcat="$dir1/$dir2"
666 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
667 dir2=`echo "$dir2" | sed -e "$sed_rest"`
668 if test -z "$dir1"; then
672 if test -z "$dir2"; then
677 relconcat="$dir1/$dir2"
685 # Like ln -s, except that SRC is given relative to the current directory (or
686 # absolute), not given relative to the directory of DEST.
692 *) # SRC is relative.
695 ln -s "`pwd`/$1" "$2" ;;
696 *) # DEST is relative too.
697 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
698 test -n "$ln_destdir" || ln_destdir="."
699 func_relativize "$ln_destdir" "$1"
707 # func_ln_if_changed SRC DEST
708 # Like func_ln, but avoids munging timestamps if the link is correct.
709 func_ln_if_changed ()
711 if test $# -ne 2; then
712 echo "usage: func_ln_if_changed SRC DEST" >&2
714 ln_target=`func_readlink "$2"`
715 if test -h "$2" && test "$1" = "$ln_target"; then
723 # Ensure an 'echo' command that
724 # 1. does not interpret backslashes and
725 # 2. does not print an error message "broken pipe" when writing into a pipe
728 # Test cases for problem 1:
729 # echo '\n' | wc -l prints 1 when OK, 2 when KO
730 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
731 # Test cases for problem 2:
732 # echo hi | true frequently prints
733 # "bash: echo: write error: Broken pipe"
734 # to standard error in bash 3.2.
736 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
737 # BSD echo interprets '-n' as an option, which is also not desirable).
738 # Nowadays the problem occurs in 4 situations:
739 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
740 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
741 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
742 # - in zsh, when sh-emulation is not set,
743 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
744 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
745 # - in Solaris /bin/sh and OSF/1 /bin/sh.
746 # We try the following workarounds:
747 # - for all: respawn using $CONFIG_SHELL if that is set and works.
748 # - for bash >= 2.04: unset the shell option xpg_echo.
749 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
750 # - for bash < 2.0: define echo to a function that uses cat of a here document.
751 # - for zsh: turn sh-emulation on.
752 # - for ksh: alias echo to 'print -r'.
753 # - for ksh: alias echo to a function that uses cat of a here document.
754 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
755 # the ksh workaround.
756 # - otherwise: respawn using /bin/sh and rely on the workarounds.
757 # When respawning, we pass --no-reexec as first argument, so as to avoid
758 # turning this script into a fork bomb in unlucky situations.
760 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
761 # the 'printf' built-in. See
762 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
763 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
764 # The workaround is: define echo to a function that uses the printf built-in.
766 if echo '\t' | grep t > /dev/null; then
767 have_echo=yes # Lucky!
769 # Try the workarounds.
770 # Respawn using $CONFIG_SHELL if that is set and works.
771 if test -z "$have_echo" \
772 && test "X$1" != "X--no-reexec" \
773 && test -n "$CONFIG_SHELL" \
774 && test -f "$CONFIG_SHELL" \
775 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
776 exec $CONFIG_SHELL "$0" --no-reexec "$@"
779 # For bash >= 2.04: unset the shell option xpg_echo.
780 if test -z "$have_echo" \
781 && test -n "$BASH_VERSION" \
782 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
786 # For bash >= 2.0: define echo to a function that uses the printf built-in.
787 # For bash < 2.0: define echo to a function that uses cat of a here document.
788 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
789 # Also handle problem 2, specific to bash 3.2, here.
790 if { test -z "$have_echo" \
791 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
793 && test -n "$BASH_VERSION"; then \
794 if type printf 2>/dev/null | grep / > /dev/null; then
795 # 'printf' is not a shell built-in.
803 # 'printf' is a shell built-in.
809 if echo '\t' | grep t > /dev/null; then
813 # For zsh: turn sh-emulation on.
814 if test -z "$have_echo" \
815 && test -n "$ZSH_VERSION" \
816 && (emulate sh) >/dev/null 2>&1; then
819 # For ksh: alias echo to 'print -r'.
820 if test -z "$have_echo" \
821 && (type print) >/dev/null 2>&1; then
822 # A 'print' command exists.
823 if type print 2>/dev/null | grep / > /dev/null; then
826 # 'print' is a shell built-in.
827 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
828 # 'print' is the ksh shell built-in.
829 alias echo='print -r'
833 if test -z "$have_echo" \
834 && echo '\t' | grep t > /dev/null; then
837 # For ksh: alias echo to a function that uses cat of a here document.
838 # The ksh manual page says:
839 # "Aliasing is performed when scripts are read, not while they are executed.
840 # Therefore, for an alias to take effect, the alias definition command has
841 # to be executed before the command which references the alias is read."
842 # Because of this, we have to play strange tricks with have_echo, to ensure
843 # that the top-level statement containing the test starts after the 'alias'
845 if test -z "$have_echo"; then
852 if (alias echo=bsd_echo) 2>/dev/null; then
853 alias echo=bsd_echo 2>/dev/null
856 if test -z "$have_echo" \
857 && echo '\t' | grep t > /dev/null; then
860 if test -z "$have_echo"; then
861 if (alias echo=bsd_echo) 2>/dev/null; then
862 unalias echo 2>/dev/null
865 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
866 if test -z "$have_echo" \
867 && test "X$1" != "X--no-reexec" \
868 && test -f /bin/ksh; then
869 exec /bin/ksh "$0" --no-reexec "$@"
872 # Otherwise: respawn using /bin/sh.
873 if test -z "$have_echo" \
874 && test "X$1" != "X--no-reexec" \
875 && test -f /bin/sh; then
876 exec /bin/sh "$0" --no-reexec "$@"
879 if test -z "$have_echo"; then
880 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
882 if echo '\t' | grep t > /dev/null; then
885 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
887 if test "X$1" = "X--no-reexec"; then
891 # Command-line option processing.
892 # Removes the OPTIONS from the arguments. Sets the variables:
893 # - mode list or import or add-import or remove-import or update
894 # or create-testdir or create-megatestdir
895 # - destdir from --dir
896 # - local_gnulib_dir from --local-dir
897 # - modcache true or false, from --cache-modules/--no-cache-modules
898 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
899 # - libname, supplied_libname from --lib
900 # - sourcebase from --source-base
901 # - m4base from --m4-base
902 # - pobase from --po-base
903 # - docbase from --doc-base
904 # - testsbase from --tests-base
905 # - auxdir from --aux-dir
906 # - inctests true if --with-tests was given, blank otherwise
907 # - incobsolete true if --with-obsolete was given, blank otherwise
908 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
909 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
911 # - inc_privileged_tests true if --with-privileged-tests was given, blank
913 # - inc_unportable_tests true if --with-unportable-tests was given, blank
915 # - inc_all_tests true if --with-all-tests was given, blank otherwise
916 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
917 # - excl_longrunning_tests true if --without-longrunning-tests was given,
919 # - excl_privileged_tests true if --without-privileged-tests was given, blank
921 # - excl_unportable_tests true if --without-unportable-tests was given, blank
923 # - single_configure true if --single-configure was given, false otherwise
924 # - avoidlist list of modules to avoid, from --avoid
925 # - cond_dependencies true if --conditional-dependencies was given, false if
926 # --no-conditional-dependencies was given, blank otherwise
927 # - lgpl yes or a number if --lgpl was given, blank otherwise
928 # - makefile_name from --makefile-name
929 # - libtool true if --libtool was given, false if --no-libtool was
930 # given, blank otherwise
931 # - macro_prefix from --macro-prefix
932 # - po_domain from --po-domain
933 # - witness_c_macro from --witness-c-macro
934 # - vc_files true if --vc-files was given, false if --no-vc-files was
935 # given, blank otherwise
936 # - autoconf_minversion minimum supported autoconf version
937 # - do_changelog false if --no-changelog was given, : otherwise
938 # - doit : if actions shall be executed, false if only to be printed
939 # - symbolic true if --symlink or --more-symlinks was given, blank
941 # - lsymbolic true if --local-symlink was given, blank otherwise
942 # - do_copyrights blank if --more-symlinks was given, true otherwise
960 inc_longrunning_tests=
961 inc_privileged_tests=
962 inc_unportable_tests=
965 excl_longrunning_tests=
966 excl_privileged_tests=
967 excl_unportable_tests=
968 single_configure=false
986 while test $# -gt 0; do
991 --find | --fin | --fi | --f )
994 --import | --impor | --impo | --imp | --im | --i )
997 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1000 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1003 --update | --updat | --upda | --upd | --up | --u )
1006 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1009 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1010 mode=create-megatestdir
1012 --test | --tes | --te | --t )
1015 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1019 mode=`echo "X$1" | sed -e 's/^X--//'`
1021 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1026 if test $# = 0; then
1027 func_fatal_error "missing argument for --dir"
1032 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1036 if test $# = 0; then
1037 func_fatal_error "missing argument for --local-dir"
1042 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1044 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1047 --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 )
1050 --verbose | --verbos | --verbo | --verb )
1051 verbose=`expr $verbose + 1`
1053 --quiet | --quie | --qui | --qu | --q )
1054 verbose=`expr $verbose - 1`
1058 if test $# = 0; then
1059 func_fatal_error "missing argument for --lib"
1062 supplied_libname=true
1065 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1066 supplied_libname=true
1070 if test $# = 0; then
1071 func_fatal_error "missing argument for --source-base"
1076 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1080 if test $# = 0; then
1081 func_fatal_error "missing argument for --m4-base"
1086 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1090 if test $# = 0; then
1091 func_fatal_error "missing argument for --po-base"
1096 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1100 if test $# = 0; then
1101 func_fatal_error "missing argument for --doc-base"
1106 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1110 if test $# = 0; then
1111 func_fatal_error "missing argument for --tests-base"
1116 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1120 if test $# = 0; then
1121 func_fatal_error "missing argument for --aux-dir"
1126 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1128 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1131 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1134 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1137 --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)
1138 inc_longrunning_tests=true
1140 --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)
1141 inc_privileged_tests=true
1143 --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)
1144 inc_unportable_tests=true
1146 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1149 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1152 --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)
1153 excl_longrunning_tests=true
1155 --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)
1156 excl_privileged_tests=true
1158 --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)
1159 excl_unportable_tests=true
1161 --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)
1162 single_configure=true
1166 if test $# = 0; then
1167 func_fatal_error "missing argument for --avoid"
1169 func_append avoidlist " $1"
1172 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1173 func_append avoidlist " $arg"
1175 --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)
1176 cond_dependencies=true
1178 --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)
1179 cond_dependencies=false
1185 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1188 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1194 if test $# = 0; then
1195 func_fatal_error "missing argument for --makefile-name"
1200 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1210 if test $# = 0; then
1211 func_fatal_error "missing argument for --macro-prefix"
1216 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1220 if test $# = 0; then
1221 func_fatal_error "missing argument for --po-domain"
1226 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1230 if test $# = 0; then
1231 func_fatal_error "missing argument for --witness-c-macro"
1233 witness_c_macro="$1"
1235 --witness-c-macro=* )
1236 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1244 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1250 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1253 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1256 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1260 --help | --hel | --he | --h )
1263 --version | --versio | --versi | --vers )
1267 # Stop option processing
1271 echo "gnulib-tool: unknown option $1" 1>&2
1272 echo "Try 'gnulib-tool --help' for more information." 1>&2
1279 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1280 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1281 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1282 || test "$single_configure" != false; then
1283 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1284 echo "Try 'gnulib-tool --help' for more information." 1>&2
1288 # This code helps migrating from --import to --add-import or --update. It can
1289 # be removed on 2012-01-01.
1290 if test "$mode" = import && test $# = 0; then
1291 echo "gnulib-tool: cowardly refusing to erase the module list." 1>&2
1292 echo "The meaning of the option '--import' has changed." 1>&2
1293 echo "See the documentation at" 1>&2
1294 echo "<http://www.gnu.org/software/gnulib/manual/html_node/Modified-imports.html>." 1>&2
1295 echo "For updating to a newer version of gnulib, use" 1>&2
1296 echo " gnulib-tool --add-import" 1>&2
1297 echo "For restoring files that were omitted from version control, use" 1>&2
1298 echo " gnulib-tool --update" 1>&2
1301 if test "$mode" = update; then
1302 if test $# != 0; then
1303 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1304 echo "Try 'gnulib-tool --help' for more information." 1>&2
1305 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1306 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1309 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1310 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1311 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1312 || test -n "$inctests" || test -n "$incobsolete" \
1313 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1314 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1315 || test -n "$inc_all_tests" \
1316 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1317 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1318 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1319 || test -n "$macro_prefix" || test -n "$po_domain" \
1320 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1321 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1322 echo "Try 'gnulib-tool --help' for more information." 1>&2
1323 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1324 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1329 if test -n "$pobase" && test -z "$po_domain"; then
1330 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1331 echo "Try 'gnulib-tool --help' for more information." 1>&2
1334 if test -z "$pobase" && test -n "$po_domain"; then
1335 func_warning "--po-domain has no effect without a --po-base option"
1337 if test "$cond_dependencies" = true && test -n "$inctests"; then
1338 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1342 # Determine the minimum supported autoconf version from the project's
1344 DEFAULT_AUTOCONF_MINVERSION="2.59"
1345 autoconf_minversion=
1347 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1348 && test -n "$destdir"; then
1349 if test -f "$destdir"/configure.ac; then
1350 configure_ac="$destdir/configure.ac"
1352 if test -f "$destdir"/configure.in; then
1353 configure_ac="$destdir/configure.in"
1357 if test -f configure.ac; then
1358 configure_ac="configure.ac"
1360 if test -f configure.in; then
1361 configure_ac="configure.in"
1365 if test -n "$configure_ac"; then
1366 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1367 # because when some m4 files are omitted from a version control repository,
1368 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1369 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1370 # autom4te: m4 failed with exit status: 1
1377 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1379 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1380 if test -n "$prereqs"; then
1381 autoconf_minversion=`
1382 for version in $prereqs; do echo $version; done |
1383 LC_ALL=C sort -nru | sed -e 1q
1387 if test -z "$autoconf_minversion"; then
1388 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1390 case "$autoconf_minversion" in
1391 1.* | 2.[0-4]* | 2.5[0-8]*)
1392 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1395 # Remove trailing slashes from the directory names. This is necessary for
1396 # m4base (to avoid an error in func_import) and optional for the others.
1397 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1398 case "$local_gnulib_dir" in
1399 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1401 case "$sourcebase" in
1402 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1405 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1408 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1411 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1413 case "$testsbase" in
1414 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1417 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1423 trap 'exit_status=$?
1424 if test "$signal" != 0; then
1425 echo "caught signal $signal" >&2
1428 exit $exit_status' 0
1429 for signal in 1 2 3 13 15; do
1430 trap '{ signal='$signal'; func_exit 1; }' $signal
1434 # Note: The 'eval' silences stderr output in dash.
1435 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1436 # Zsh 4 and Bash 4 have associative arrays.
1437 have_associative=true
1439 # For other shells, use 'eval' with computed shell variable names.
1440 have_associative=false
1443 # func_lookup_file file
1444 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1447 # - local_gnulib_dir from --local-dir
1449 # - lookedup_file name of the merged (combined) file
1450 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1454 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1455 lookedup_file="$local_gnulib_dir/$lkfile"
1458 if test -f "$gnulib_dir/$lkfile"; then
1459 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1460 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1461 rm -f "$tmp/$lkbase"
1462 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1463 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1464 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1465 lookedup_file="$tmp/$lkbase"
1468 lookedup_file="$gnulib_dir/$lkfile"
1472 func_fatal_error "file $gnulib_dir/$lkfile not found"
1477 # func_sanitize_modulelist
1478 # receives a list of possible module names on standard input, one per line.
1479 # It removes those which are just file names unrelated to modules, and outputs
1480 # the resulting list to standard output, one per line.
1481 func_sanitize_modulelist ()
1483 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1484 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1485 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1486 -e '/^README$/d' -e '/\/README$/d' \
1487 -e '/^TEMPLATE$/d' \
1488 -e '/^TEMPLATE-EXTENDED$/d' \
1489 -e '/^TEMPLATE-TESTS$/d' \
1496 # - local_gnulib_dir from --local-dir
1499 # Filter out metainformation files like README, which are not modules.
1500 # Filter out unit test modules; they can be retrieved through
1501 # --extract-tests-module if desired.
1503 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1504 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1505 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1508 | func_sanitize_modulelist \
1509 | sed -e '/-tests$/d' \
1513 # func_exists_module module
1514 # tests whether a module, given by name, exists
1516 # - local_gnulib_dir from --local-dir
1517 func_exists_module ()
1519 { test -f "$gnulib_dir/modules/$1" \
1520 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1521 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1522 && test "CVS" != "$1" \
1523 && test "ChangeLog" != "$1" \
1524 && test "COPYING" != "$1" \
1525 && test "README" != "$1" \
1526 && test "TEMPLATE" != "$1" \
1527 && test "TEMPLATE-EXTENDED" != "$1" \
1528 && test "TEMPLATE-TESTS" != "$1"
1531 # func_verify_module
1532 # verifies a module name
1534 # - local_gnulib_dir from --local-dir
1535 # - module module name argument
1536 func_verify_module ()
1538 if func_exists_module "$module"; then
1539 # OK, $module is a correct module name.
1540 # Verify that building the module description with 'patch' succeeds.
1541 func_lookup_file "modules/$module"
1543 func_warning "module $module doesn't exist"
1548 # func_verify_nontests_module
1549 # verifies a module name, excluding tests modules
1551 # - local_gnulib_dir from --local-dir
1552 # - module module name argument
1553 func_verify_nontests_module ()
1556 *-tests ) module= ;;
1557 * ) func_verify_module ;;
1561 # func_verify_tests_module
1562 # verifies a module name, considering only tests modules
1564 # - local_gnulib_dir from --local-dir
1565 # - module module name argument
1566 func_verify_tests_module ()
1569 *-tests ) func_verify_module ;;
1574 # Suffix of a sed expression that extracts a particular field from a
1575 # module description.
1576 # A field starts with a line that contains a keyword, such as 'Description',
1577 # followed by a colon and optional whitespace. All following lines, up to
1578 # the next field (or end of file if there is none) form the contents of the
1580 # An absent field is equivalent to a field with empty contents.
1581 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1582 sed_extract_prog=':[ ]*$/ {
1585 s/^Description:[ ]*$//
1589 s/^Applicability:[ ]*$//
1591 s/^Depends-on:[ ]*$//
1592 s/^configure\.ac-early:[ ]*$//
1593 s/^configure\.ac:[ ]*$//
1594 s/^Makefile\.am:[ ]*$//
1598 s/^Maintainer:[ ]*$//
1605 # Piece of a sed expression that converts a field header line to a shell
1607 # NOTE: Keep this in sync with sed_extract_prog above!
1608 sed_extract_field_header='
1609 s/^Description:[ ]*$/description/
1610 s/^Comment:[ ]*$/comment/
1611 s/^Status:[ ]*$/status/
1612 s/^Notice:[ ]*$/notice/
1613 s/^Applicability:[ ]*$/applicability/
1614 s/^Files:[ ]*$/files/
1615 s/^Depends-on:[ ]*$/dependson/
1616 s/^configure\.ac-early:[ ]*$/configureac_early/
1617 s/^configure\.ac:[ ]*$/configureac/
1618 s/^Makefile\.am:[ ]*$/makefile/
1619 s/^Include:[ ]*$/include/
1621 s/^License:[ ]*$/license/
1622 s/^Maintainer:[ ]*$/maintainer/'
1626 if $have_associative; then
1628 # Declare the associative arrays.
1629 declare -A modcache_cached
1630 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1631 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1632 eval "$declare_script"
1636 # func_cache_var module
1637 # computes the cache variable name corresponding to $module.
1638 # Note: This computation can map different module names to the same
1639 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1640 # to protect against this case.
1642 # - cachevar a shell variable name
1643 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1644 # Bash 2.0 and newer, ksh, and zsh support the syntax
1645 # ${param//pattern/replacement}
1646 # as a shorthand for
1647 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1648 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1649 eval 'func_cache_var ()
1651 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1658 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1667 # func_init_sed_convert_to_cache_statements
1669 # - modcachevar_assignment
1671 # - sed_convert_to_cache_statements
1672 func_init_sed_convert_to_cache_statements ()
1674 # 'sed' script that turns a module description into shell script
1675 # assignments, suitable to be eval'ed. All active characters are escaped.
1678 # Some module's description
1683 # modcache_description[$1]=\
1684 # 'Some module'"'"'s description
1686 # modcache_files[$1]=\
1689 # c_MODULE_description_set=set; c_MODULE_description=\
1690 # 'Some module'"'"'s description
1692 # c_MODULE_files_set=set; c_MODULE_files=\
1694 # The script consists of two parts:
1695 # 1) Ignore the lines before the first field header.
1696 # 2) A loop, treating non-field-header lines by escaping single quotes
1697 # and adding a closing quote in the last line,
1698 sed_convert_to_cache_statements="
1700 # Here we have not yet seen a field header.
1702 # See if the current line contains a field header.
1705 ${sed_extract_field_header}
1708 # No field header. Ignore the line.
1710 # Read the next line. Upon EOF, just exit.
1715 # The current line contains a field header.
1717 # Turn it into the beginning of an assignment.
1718 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1720 # Move it to the hold space. Don't print it yet,
1721 # because we want no assignment if the field is empty.
1724 # Read the next line.
1725 # Upon EOF, the field was empty. Print no assignment. Just exit.
1728 # See if the current line contains a field header.
1731 ${sed_extract_field_header}
1732 # If it is, the previous field was empty. Print no assignment.
1735 # Not a field header.
1737 # Print the previous line, held in the hold space.
1742 # Transform single quotes.
1745 # Prepend a single quote.
1750 # Move it to the hold space.
1753 # Read the next line.
1760 # See if the current line contains a field header.
1763 ${sed_extract_field_header}
1766 # Print the previous line, held in the hold space.
1771 # Transform single quotes.
1778 # Print the previous line, held in the hold space, with a single quote
1779 # to end the assignment.
1789 # Print the previous line, held in the hold space, with a single quote
1790 # to end the assignment.
1797 if ! $sed_comments; then
1799 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1800 | sed -e 's/^ *//' -e 's/^#.*//'`
1804 if $have_associative; then
1805 # sed_convert_to_cache_statements does not depend on the module.
1806 modcachevar_assignment='modcache_\1[$1]='
1807 func_init_sed_convert_to_cache_statements
1810 # func_cache_lookup_module module
1812 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1813 # of its relevant data in a cache in the memory of the processing shell. If
1814 # already cached, it does not look it up again, thus saving file access time.
1816 # - module non-empty string
1817 # Output if $have_associative:
1818 # - modcache_cached[$module] set to yes
1819 # - modcache_description[$module] ==
1820 # - modcache_status[$module] \ set to the field's value, minus the
1821 # - ... / final newline,
1822 # - modcache_maintainer[$module] == or unset if the field's value is empty
1823 # Output if ! $have_associative:
1824 # - cachevar a shell variable name
1825 # - ${cachevar}_cached set to $module
1826 # - ${cachevar}_description ==
1827 # - ${cachevar}_status \ set to the field's value, minus the
1828 # - ... / final newline,
1829 # - ${cachevar}_maintainer == or unset if the field's value is empty
1830 # - ${cachevar}_description_set ==
1831 # - ${cachevar}_status_set \ set to non-empty if the field's value
1832 # - ... / is non-empty,
1833 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1834 func_cache_lookup_module ()
1836 if $have_associative; then
1837 eval 'cached=${modcache_cached[$1]}'
1840 eval "cached=\"\$${cachevar}_cached\""
1842 if test -z "$cached"; then
1843 # Not found in cache. Look it up on the file system.
1844 func_lookup_file "modules/$1"
1845 if $have_associative; then
1846 eval 'modcache_cached[$1]=yes'
1848 eval "${cachevar}_cached=\"\$1\""
1850 if ! $have_associative; then
1851 # sed_convert_to_cache_statements depends on the module.
1852 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1853 func_init_sed_convert_to_cache_statements
1855 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1856 eval "$cache_statements"
1858 if ! $have_associative; then
1859 if test "$1" != "$cached"; then
1860 func_fatal_error "cache variable collision between $1 and $cached"
1868 # func_get_description module
1870 # - local_gnulib_dir from --local-dir
1871 # - modcache true or false, from --cache-modules/--no-cache-modules
1872 func_get_description ()
1874 if ! $modcache; then
1875 func_lookup_file "modules/$1"
1876 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1878 func_cache_lookup_module "$1"
1879 # Output the field's value, including the final newline (if any).
1880 if $have_associative; then
1881 if eval 'test -n "${modcache_description[$1]+set}"'; then
1882 eval 'echo "${modcache_description[$1]}"'
1885 eval "field_set=\"\$${cachevar}_description_set\""
1886 if test -n "$field_set"; then
1887 eval "field_value=\"\$${cachevar}_description\""
1888 echo "${field_value}"
1894 # func_get_comment module
1896 # - local_gnulib_dir from --local-dir
1897 # - modcache true or false, from --cache-modules/--no-cache-modules
1900 if ! $modcache; then
1901 func_lookup_file "modules/$1"
1902 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1904 func_cache_lookup_module "$1"
1905 # Output the field's value, including the final newline (if any).
1906 if $have_associative; then
1907 if eval 'test -n "${modcache_comment[$1]+set}"'; then
1908 eval 'echo "${modcache_comment[$1]}"'
1911 eval "field_set=\"\$${cachevar}_comment_set\""
1912 if test -n "$field_set"; then
1913 eval "field_value=\"\$${cachevar}_comment\""
1914 echo "${field_value}"
1920 # func_get_status module
1922 # - local_gnulib_dir from --local-dir
1923 # - modcache true or false, from --cache-modules/--no-cache-modules
1926 if ! $modcache; then
1927 func_lookup_file "modules/$1"
1928 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1930 func_cache_lookup_module "$1"
1931 # Output the field's value, including the final newline (if any).
1932 if $have_associative; then
1933 if eval 'test -n "${modcache_status[$1]+set}"'; then
1934 eval 'echo "${modcache_status[$1]}"'
1937 eval "field_set=\"\$${cachevar}_status_set\""
1938 if test -n "$field_set"; then
1939 eval "field_value=\"\$${cachevar}_status\""
1940 echo "${field_value}"
1946 # func_get_notice module
1948 # - local_gnulib_dir from --local-dir
1949 # - modcache true or false, from --cache-modules/--no-cache-modules
1952 if ! $modcache; then
1953 func_lookup_file "modules/$1"
1954 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1956 func_cache_lookup_module "$1"
1957 # Output the field's value, including the final newline (if any).
1958 if $have_associative; then
1959 if eval 'test -n "${modcache_notice[$1]+set}"'; then
1960 eval 'echo "${modcache_notice[$1]}"'
1963 eval "field_set=\"\$${cachevar}_notice_set\""
1964 if test -n "$field_set"; then
1965 eval "field_value=\"\$${cachevar}_notice\""
1966 echo "${field_value}"
1972 # func_get_applicability module
1974 # - local_gnulib_dir from --local-dir
1975 # - modcache true or false, from --cache-modules/--no-cache-modules
1976 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1977 func_get_applicability ()
1979 if ! $modcache; then
1980 func_lookup_file "modules/$1"
1981 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1983 func_cache_lookup_module "$1"
1984 # Get the field's value, without the final newline.
1985 if $have_associative; then
1986 eval 'my_applicability="${modcache_applicability[$1]}"'
1988 eval "my_applicability=\"\$${cachevar}_applicability\""
1991 if test -n "$my_applicability"; then
1992 echo $my_applicability
1994 # The default is 'main' or 'tests', depending on the module's name.
1996 *-tests) echo "tests";;
2002 # func_get_filelist module
2004 # - local_gnulib_dir from --local-dir
2005 # - modcache true or false, from --cache-modules/--no-cache-modules
2006 func_get_filelist ()
2008 if ! $modcache; then
2009 func_lookup_file "modules/$1"
2010 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2012 func_cache_lookup_module "$1"
2013 # Output the field's value, including the final newline (if any).
2014 if $have_associative; then
2015 if eval 'test -n "${modcache_files[$1]+set}"'; then
2016 eval 'echo "${modcache_files[$1]}"'
2019 eval "field_set=\"\$${cachevar}_files_set\""
2020 if test -n "$field_set"; then
2021 eval "field_value=\"\$${cachevar}_files\""
2022 echo "${field_value}"
2027 echo m4/gnulib-common.m4
2028 case "$autoconf_minversion" in
2035 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2036 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2037 # elements starting with prefix and ending with suffix are considered.
2038 # Processing: removed_prefix and removed_suffix are removed from each element,
2039 # added_prefix and added_suffix are added to each element.
2040 # prefix, suffix should not contain shell-special characters.
2041 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2042 # added_prefix, added_suffix should not contain the characters \|&.
2043 func_filter_filelist ()
2045 if test "$2" != "$nl" \
2046 || { $fast_func_append \
2047 && { test -z "$6" || $fast_func_remove_prefix; } \
2048 && { test -z "$7" || $fast_func_remove_suffix; }; \
2052 # Do not quote possibly-empty parameters in case patterns,
2053 # AIX and HP-UX ksh won't match them if they are empty.
2056 if test -n "$6"; then
2057 func_remove_prefix fff "$6"
2059 if test -n "$7"; then
2060 func_remove_suffix fff "$7"
2063 if test -z "$ffflist"; then
2066 func_append ffflist "$2${fff}"
2072 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2073 ffflist=`for fff in $3; do
2075 $4*$5) echo "$fff" ;;
2077 done | sed -e "$sed_fff_filter"`
2079 eval "$1=\"\$ffflist\""
2082 # func_get_dependencies module
2084 # - local_gnulib_dir from --local-dir
2085 # - modcache true or false, from --cache-modules/--no-cache-modules
2086 func_get_dependencies ()
2088 # ${module}-tests implicitly depends on ${module}, if that module exists.
2092 func_remove_suffix fgd1 '-tests'
2093 if func_exists_module "$fgd1"; then
2098 # Then the explicit dependencies listed in the module description.
2099 { if ! $modcache; then
2100 func_lookup_file "modules/$1"
2101 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2103 func_cache_lookup_module "$1"
2104 # Output the field's value, including the final newline (if any).
2105 if $have_associative; then
2106 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2107 eval 'echo "${modcache_dependson[$1]}"'
2110 eval "field_set=\"\$${cachevar}_dependson_set\""
2111 if test -n "$field_set"; then
2112 eval "field_value=\"\$${cachevar}_dependson\""
2113 echo "${field_value}"
2121 # func_get_autoconf_early_snippet module
2123 # - local_gnulib_dir from --local-dir
2124 # - modcache true or false, from --cache-modules/--no-cache-modules
2125 func_get_autoconf_early_snippet ()
2127 if ! $modcache; then
2128 func_lookup_file "modules/$1"
2129 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2131 func_cache_lookup_module "$1"
2132 # Output the field's value, including the final newline (if any).
2133 if $have_associative; then
2134 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2135 eval 'echo "${modcache_configureac_early[$1]}"'
2138 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2139 if test -n "$field_set"; then
2140 eval "field_value=\"\$${cachevar}_configureac_early\""
2141 echo "${field_value}"
2147 # func_get_autoconf_snippet module
2149 # - local_gnulib_dir from --local-dir
2150 # - modcache true or false, from --cache-modules/--no-cache-modules
2151 func_get_autoconf_snippet ()
2153 if ! $modcache; then
2154 func_lookup_file "modules/$1"
2155 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2157 func_cache_lookup_module "$1"
2158 # Output the field's value, including the final newline (if any).
2159 if $have_associative; then
2160 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2161 eval 'echo "${modcache_configureac[$1]}"'
2164 eval "field_set=\"\$${cachevar}_configureac_set\""
2165 if test -n "$field_set"; then
2166 eval "field_value=\"\$${cachevar}_configureac\""
2167 echo "${field_value}"
2173 # func_get_automake_snippet_conditional module
2174 # returns the part of the Makefile.am snippet that can be put inside Automake
2177 # - local_gnulib_dir from --local-dir
2178 # - modcache true or false, from --cache-modules/--no-cache-modules
2179 func_get_automake_snippet_conditional ()
2181 if ! $modcache; then
2182 func_lookup_file "modules/$1"
2183 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2185 func_cache_lookup_module "$1"
2186 # Output the field's value, including the final newline (if any).
2187 if $have_associative; then
2188 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2189 eval 'echo "${modcache_makefile[$1]}"'
2192 eval "field_set=\"\$${cachevar}_makefile_set\""
2193 if test -n "$field_set"; then
2194 eval "field_value=\"\$${cachevar}_makefile\""
2195 echo "${field_value}"
2201 # func_get_automake_snippet_unconditional module
2202 # returns the part of the Makefile.am snippet that must stay outside of
2203 # Automake conditionals.
2205 # - local_gnulib_dir from --local-dir
2206 # - modcache true or false, from --cache-modules/--no-cache-modules
2207 func_get_automake_snippet_unconditional ()
2211 # *-tests module live in tests/, not lib/.
2212 # Synthesize an EXTRA_DIST augmentation.
2213 all_files=`func_get_filelist $1`
2214 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2215 extra_files="$tests_files"
2216 if test -n "$extra_files"; then
2217 echo "EXTRA_DIST +=" $extra_files
2222 # Synthesize an EXTRA_DIST augmentation.
2223 sed_combine_lines='/\\$/{
2230 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2231 already_mentioned_files=` \
2232 { if ! $modcache; then
2233 func_lookup_file "modules/$1"
2234 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2236 func_cache_lookup_module "$1"
2237 if $have_associative; then
2238 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2239 eval 'echo "${modcache_makefile[$1]}"'
2242 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2243 if test -n "$field_set"; then
2244 eval 'field_value="$'"${cachevar}"'_makefile"'
2245 echo "${field_value}"
2250 | sed -e "$sed_combine_lines" \
2251 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2252 all_files=`func_get_filelist $1`
2253 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2254 # Remove $already_mentioned_files from $lib_files.
2255 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2256 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2257 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2258 if test -n "$extra_files"; then
2259 echo "EXTRA_DIST +=" $extra_files
2262 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2263 # This is necessary so that automake can generate the right list of
2265 # A possible approach would be to use autom4te --trace of the redefined
2266 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2267 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2268 # inside autoconf's built-in macros are not missed).
2269 # But it's simpler and more robust to do it here, based on the file list.
2270 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2271 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2272 # automake will generate a useless dependency; this is harmless.
2274 relocatable-prog-wrapper) ;;
2277 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2278 if test -n "$extra_files"; then
2279 echo "EXTRA_lib_SOURCES +=" $extra_files
2284 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2285 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2286 if test -n "$buildaux_files"; then
2287 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2288 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2291 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2292 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2293 if test -n "$top_files"; then
2294 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2295 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2302 # func_get_automake_snippet module
2304 # - local_gnulib_dir from --local-dir
2305 # - modcache true or false, from --cache-modules/--no-cache-modules
2306 func_get_automake_snippet ()
2308 func_get_automake_snippet_conditional "$1"
2309 func_get_automake_snippet_unconditional "$1"
2312 # func_get_include_directive module
2314 # - local_gnulib_dir from --local-dir
2315 # - modcache true or false, from --cache-modules/--no-cache-modules
2316 func_get_include_directive ()
2319 if ! $modcache; then
2320 func_lookup_file "modules/$1"
2321 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2323 func_cache_lookup_module "$1"
2324 # Output the field's value, including the final newline (if any).
2325 if $have_associative; then
2326 if eval 'test -n "${modcache_include[$1]+set}"'; then
2327 eval 'echo "${modcache_include[$1]}"'
2330 eval "field_set=\"\$${cachevar}_include_set\""
2331 if test -n "$field_set"; then
2332 eval "field_value=\"\$${cachevar}_include\""
2333 echo "${field_value}"
2337 } | sed -e 's/^\(["<]\)/#include \1/'
2340 # func_get_link_directive module
2342 # - local_gnulib_dir from --local-dir
2343 # - modcache true or false, from --cache-modules/--no-cache-modules
2344 func_get_link_directive ()
2346 if ! $modcache; then
2347 func_lookup_file "modules/$1"
2348 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2350 func_cache_lookup_module "$1"
2351 # Output the field's value, including the final newline (if any).
2352 if $have_associative; then
2353 if eval 'test -n "${modcache_link[$1]+set}"'; then
2354 eval 'echo "${modcache_link[$1]}"'
2357 eval "field_set=\"\$${cachevar}_link_set\""
2358 if test -n "$field_set"; then
2359 eval "field_value=\"\$${cachevar}_link\""
2360 echo "${field_value}"
2366 # func_get_license module
2368 # - local_gnulib_dir from --local-dir
2369 # - modcache true or false, from --cache-modules/--no-cache-modules
2373 if ! $modcache; then
2374 func_lookup_file "modules/$1"
2375 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2377 func_cache_lookup_module "$1"
2378 # Output the field's value, including the final newline (if any).
2379 if $have_associative; then
2380 if eval 'test -n "${modcache_license[$1]+set}"'; then
2381 eval 'echo "${modcache_license[$1]}"'
2384 eval "field_set=\"\$${cachevar}_license_set\""
2385 if test -n "$field_set"; then
2386 eval "field_value=\"\$${cachevar}_license\""
2387 echo "${field_value}"
2391 # The default is GPL.
2393 } | sed -e 's,^ *$,,' | sed -e 1q
2396 # func_get_maintainer module
2398 # - local_gnulib_dir from --local-dir
2399 # - modcache true or false, from --cache-modules/--no-cache-modules
2400 func_get_maintainer ()
2402 if ! $modcache; then
2403 func_lookup_file "modules/$1"
2404 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2406 func_cache_lookup_module "$1"
2407 # Output the field's value, including the final newline (if any).
2408 if $have_associative; then
2409 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2410 eval 'echo "${modcache_maintainer[$1]}"'
2413 eval "field_set=\"\$${cachevar}_maintainer_set\""
2414 if test -n "$field_set"; then
2415 eval "field_value=\"\$${cachevar}_maintainer\""
2416 echo "${field_value}"
2422 # func_get_tests_module module
2424 # - local_gnulib_dir from --local-dir
2425 func_get_tests_module ()
2427 # The naming convention for tests modules is hardwired: ${module}-tests.
2428 if test -f "$gnulib_dir/modules/$1"-tests \
2429 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2430 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2435 # func_acceptable module
2436 # tests whether a module is acceptable.
2438 # - avoidlist list of modules to avoid
2441 for avoid in $avoidlist; do
2442 if test "$avoid" = "$1"; then
2449 # sed expression to keep the first 32 characters of each line.
2450 sed_first_32_chars='s/^\(................................\).*/\1/'
2452 # func_module_shellfunc_name module
2453 # computes the shell function name that will contain the m4 macros for the module.
2455 # - macro_prefix prefix to use
2457 # - shellfunc shell function name
2458 func_module_shellfunc_name ()
2462 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2464 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2468 # func_module_shellvar_name module
2469 # computes the shell variable name the will be set to true once the m4 macros
2470 # for the module have been executed.
2472 # - shellvar shell variable name
2473 func_module_shellvar_name ()
2477 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2479 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2483 # func_module_conditional_name module
2484 # computes the automake conditional name for the module.
2486 # - conditional name of automake conditional
2487 func_module_conditional_name ()
2491 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2493 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2497 # func_uncond_add_module B
2498 # notes the presence of B as an unconditional module.
2500 # func_conddep_add_module A B cond
2501 # notes the presence of a conditional dependency from module A to module B,
2502 # subject to the condition that A is enabled and cond is true.
2504 # func_cond_module_p B
2505 # tests whether module B is conditional.
2507 # func_cond_module_condition A B
2508 # returns the condition when B should be enabled as a dependency of A, once the
2509 # m4 code for A has been executed.
2510 # Output: - condition
2512 if $have_associative; then
2513 declare -A conddep_isuncond
2514 declare -A conddep_dependers
2515 declare -A conddep_condition
2516 func_uncond_add_module ()
2518 eval 'conddep_isuncond[$1]=true'
2519 eval 'unset conddep_dependers[$1]'
2521 func_conddep_add_module ()
2523 eval 'isuncond="${conddep_isuncond[$2]}"'
2524 if test -z "$isuncond"; then
2525 # No unconditional dependency to B known at this point.
2526 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2527 eval 'conddep_condition[$1---$2]="$3"'
2530 func_cond_module_p ()
2532 eval 'previous_dependers="${conddep_dependers[$1]}"'
2533 test -n "$previous_dependers"
2535 func_cond_module_condition ()
2537 eval 'condition="${conddep_condition[$1---$2]}"'
2540 func_uncond_add_module ()
2544 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2548 eval 'conddep_isuncond_'"$suffix"'=true'
2549 eval 'unset conddep_dependers_'"$suffix"
2551 func_conddep_add_module ()
2555 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2559 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2560 if test -z "$isuncond"; then
2561 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2562 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2563 eval 'conddep_condition_'"$suffix"'="$3"'
2566 func_cond_module_p ()
2570 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2574 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2575 test -n "$previous_dependers"
2577 func_cond_module_condition ()
2579 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2580 eval 'condition="${conddep_condition_'"$suffix"'}"'
2584 sed_dependencies_without_conditions='s/ *\[.*//'
2586 # func_modules_transitive_closure
2588 # - local_gnulib_dir from --local-dir
2589 # - modcache true or false, from --cache-modules/--no-cache-modules
2590 # - modules list of specified modules
2591 # - inctests true if tests should be included, blank otherwise
2592 # - incobsolete true if obsolete modules among dependencies should be
2593 # included, blank otherwise
2594 # - inc_cxx_tests true if C++ interoperability tests should be included,
2596 # - inc_longrunning_tests true if long-runnings tests should be included,
2598 # - inc_privileged_tests true if tests that require root privileges should be
2599 # included, blank otherwise
2600 # - inc_unportable_tests true if tests that fail on some platforms should be
2601 # included, blank otherwise
2602 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2603 # the unit tests of the specified modules should be
2604 # included, blank otherwise
2605 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2606 # the unit tests of the dependencies should be
2607 # included, blank otherwise
2608 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2610 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2612 # - excl_privileged_tests true if tests that require root privileges should be
2613 # excluded, blank otherwise
2614 # - excl_unportable_tests true if tests that fail on some platforms should be
2615 # excluded, blank otherwise
2616 # - avoidlist list of modules to avoid
2617 # - cond_dependencies true if conditional dependencies shall be supported,
2619 # - tmp pathname of a temporary directory
2621 # - modules list of modules, including dependencies
2622 # - conddep_dependers, conddep_condition information about conditionally
2624 func_modules_transitive_closure ()
2626 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2627 # In order to process every module only once (for speed), process an "input
2628 # list" of modules, producing an "output list" of modules. During each round,
2629 # more modules can be queued in the input list. Once a module on the input
2630 # list has been processed, it is added to the "handled list", so we can avoid
2631 # to process it again.
2633 inmodules="$modules"
2635 fmtc_inc_all_tests="$inc_all_direct_tests"
2636 if test "$cond_dependencies" = true; then
2637 for module in $inmodules; do
2639 if test -n "$module"; then
2640 if func_acceptable $module; then
2641 func_uncond_add_module $module
2646 while test -n "$inmodules"; do
2647 inmodules_this_round="$inmodules"
2648 inmodules= # Accumulator, queue for next round
2649 for module in $inmodules_this_round; do
2651 if test -n "$module"; then
2652 if func_acceptable $module; then
2653 func_append outmodules " $module"
2654 if test "$cond_dependencies" = true; then
2655 if func_get_automake_snippet_conditional $module | grep '^if ' > /dev/null; then
2656 # A module whose Makefile.am snippet contains a reference to an
2657 # automake conditional. If we were to use it conditionally, we
2658 # would get an error
2659 # configure: error: conditional "..." was never defined.
2660 # because automake 1.11.1 does not handle nested conditionals
2661 # correctly. As a workaround, make the module unconditional.
2662 func_uncond_add_module $module
2664 if func_cond_module_p $module; then
2670 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2671 # Duplicate dependencies are harmless, but Jim wants a warning.
2672 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2673 if test -n "$duplicated_deps"; then
2674 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2676 if test -n "$inctests"; then
2677 testsmodule=`func_get_tests_module $module`
2678 if test -n "$testsmodule"; then
2679 deps="$deps $testsmodule"
2682 for dep in $deps; do
2683 # Determine whether to include the dependency or tests module.
2685 for word in `func_get_status $dep`; do
2688 test -n "$incobsolete" \
2692 test -z "$excl_cxx_tests" \
2694 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2698 test -z "$excl_longrunning_tests" \
2700 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2704 test -z "$excl_privileged_tests" \
2706 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2710 test -z "$excl_unportable_tests" \
2712 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2716 test -n "$fmtc_inc_all_tests" \
2722 func_append inmodules " $dep"
2723 if test "$cond_dependencies" = true; then
2724 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2725 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2728 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2729 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2731 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2732 if test "$condition" = true; then
2735 if test -n "$condition"; then
2736 func_conddep_add_module "$module" "$dep" "$condition"
2738 if $conditional; then
2739 func_conddep_add_module "$module" "$dep" true
2741 func_uncond_add_module "$dep"
2750 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2751 # Remove $handledmodules from $inmodules.
2752 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2753 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2754 fmtc_inc_all_tests="$inc_all_indirect_tests"
2756 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2757 rm -f "$tmp"/queued-modules
2760 # func_show_module_list
2762 # - specified_modules list of specified modules (one per line, sorted)
2763 # - modules complete list of modules (one per line, sorted)
2764 # - tmp pathname of a temporary directory
2765 func_show_module_list ()
2771 # Assume xterm compatible escape sequences.
2772 bold_on=`printf '\x1b[1m'`
2773 bold_off=`printf '\x1b[0m'`
2778 echo "Module list with included dependencies (indented):"
2779 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2780 echo "$modules" | sed -e '/^$/d' \
2781 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2782 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2785 # func_modules_transitive_closure_separately
2786 # Determine main module list and tests-related module list separately.
2787 # The main module list is the transitive closure of the specified modules,
2788 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2789 # is specified, it will consist only of LGPLed source.
2790 # The tests-related module list is the transitive closure of the specified
2791 # modules, including tests modules, minus the main module list excluding
2792 # modules of applicability 'all'. Its lib/* sources (brought in through
2793 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2794 # source, even if --lgpl is specified.
2796 # - local_gnulib_dir from --local-dir
2797 # - modcache true or false, from --cache-modules/--no-cache-modules
2798 # - specified_modules list of specified modules
2799 # - inctests true if tests should be included, blank otherwise
2800 # - incobsolete true if obsolete modules among dependencies should be
2801 # included, blank otherwise
2802 # - inc_cxx_tests true if C++ interoperability tests should be included,
2804 # - inc_longrunning_tests true if long-runnings tests should be included,
2806 # - inc_privileged_tests true if tests that require root privileges should be
2807 # included, blank otherwise
2808 # - inc_unportable_tests true if tests that fail on some platforms should be
2809 # included, blank otherwise
2810 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2811 # the unit tests of the specified modules should be
2812 # included, blank otherwise
2813 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2814 # the unit tests of the dependencies should be
2815 # included, blank otherwise
2816 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2818 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2820 # - excl_privileged_tests true if tests that require root privileges should be
2821 # excluded, blank otherwise
2822 # - excl_unportable_tests true if tests that fail on some platforms should be
2823 # excluded, blank otherwise
2824 # - avoidlist list of modules to avoid
2825 # - cond_dependencies true if conditional dependencies shall be supported,
2827 # - tmp pathname of a temporary directory
2829 # - main_modules list of modules, including dependencies
2830 # - testsrelated_modules list of tests-related modules, including dependencies
2831 # - conddep_dependers, conddep_condition information about conditionally
2833 func_modules_transitive_closure_separately ()
2835 # Determine main module list.
2836 saved_inctests="$inctests"
2838 modules="$specified_modules"
2839 func_modules_transitive_closure
2840 main_modules="$modules"
2841 inctests="$saved_inctests"
2842 if test $verbose -ge 1; then
2843 echo "Main module list:"
2844 echo "$main_modules" | sed -e 's/^/ /'
2846 # Determine tests-related module list.
2847 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2848 testsrelated_modules=`for module in $main_modules; do
2849 if test \`func_get_applicability $module\` = main; then
2853 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2854 if test $verbose -ge 1; then
2855 echo "Tests-related module list:"
2856 echo "$testsrelated_modules" | sed -e 's/^/ /'
2860 # func_determine_use_libtests
2861 # Determines whether a $testsbase/libtests.a is needed.
2863 # - local_gnulib_dir from --local-dir
2864 # - modcache true or false, from --cache-modules/--no-cache-modules
2865 # - testsrelated_modules list of tests-related modules, including dependencies
2867 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2868 func_determine_use_libtests ()
2871 for module in $testsrelated_modules; do
2872 func_verify_nontests_module
2873 if test -n "$module"; then
2874 all_files=`func_get_filelist $module`
2875 # Test whether some file in $all_files lies in lib/.
2876 for f in $all_files; do
2888 # func_modules_add_dummy
2890 # - local_gnulib_dir from --local-dir
2891 # - modcache true or false, from --cache-modules/--no-cache-modules
2892 # - modules list of modules, including dependencies
2894 # - modules list of modules, including 'dummy' if needed
2895 func_modules_add_dummy ()
2897 # Determine whether any module provides a lib_SOURCES augmentation.
2899 sed_remove_backslash_newline=':a
2906 for module in $modules; do
2907 func_verify_nontests_module
2908 if test -n "$module"; then
2909 # Extract the value of "lib_SOURCES += ...".
2910 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2911 # Ignore .h files since they are not compiled.
2915 have_lib_SOURCES=yes
2922 # Add the dummy module, to make sure the library will be non-empty.
2923 if test -z "$have_lib_SOURCES"; then
2924 if func_acceptable "dummy"; then
2925 func_append modules " dummy"
2930 # func_modules_add_dummy_separately
2932 # - local_gnulib_dir from --local-dir
2933 # - modcache true or false, from --cache-modules/--no-cache-modules
2934 # - main_modules list of modules, including dependencies
2935 # - testsrelated_modules list of tests-related modules, including dependencies
2936 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2938 # - main_modules list of modules, including 'dummy' if needed
2939 # - testsrelated_modules list of tests-related modules, including 'dummy' if
2941 func_modules_add_dummy_separately ()
2943 # Add the dummy module to the main module list if needed.
2944 modules="$main_modules"
2945 func_modules_add_dummy
2946 main_modules="$modules"
2948 # Add the dummy module to the tests-related module list if needed.
2949 if $use_libtests; then
2950 modules="$testsrelated_modules"
2951 func_modules_add_dummy
2952 testsrelated_modules="$modules"
2956 # func_modules_notice
2958 # - local_gnulib_dir from --local-dir
2959 # - modcache true or false, from --cache-modules/--no-cache-modules
2960 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2961 # - modules list of modules, including dependencies
2962 func_modules_notice ()
2964 if test $verbose -ge -1; then
2965 for module in $modules; do
2967 if test -n "$module"; then
2968 msg=`func_get_notice $module`
2969 if test -n "$msg"; then
2970 echo "Notice from module $module:"
2971 echo "$msg" | sed -e 's/^/ /'
2978 # func_modules_to_filelist
2980 # - local_gnulib_dir from --local-dir
2981 # - modcache true or false, from --cache-modules/--no-cache-modules
2982 # - modules list of modules, including dependencies
2984 # - files list of files
2985 func_modules_to_filelist ()
2988 for module in $modules; do
2990 if test -n "$module"; then
2991 fs=`func_get_filelist $module`
2992 func_append files " $fs"
2995 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2998 # func_modules_to_filelist_separately
2999 # Determine the final file lists.
3000 # They must be computed separately, because files in lib/* go into
3001 # $sourcebase/ if they are in the main file list but into $testsbase/
3002 # if they are in the tests-related file list. Furthermore lib/dummy.c
3005 # - local_gnulib_dir from --local-dir
3006 # - modcache true or false, from --cache-modules/--no-cache-modules
3007 # - main_modules list of modules, including dependencies
3008 # - testsrelated_modules list of tests-related modules, including dependencies
3009 func_modules_to_filelist_separately ()
3011 # Determine final main file list.
3012 modules="$main_modules"
3013 func_modules_to_filelist
3015 # Determine final tests-related file list.
3016 modules="$testsrelated_modules"
3017 func_modules_to_filelist
3018 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3019 # Merge both file lists.
3020 sed_remove_empty_lines='/^$/d'
3021 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3022 if test $verbose -ge 0; then
3024 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3025 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3029 # func_compute_include_guard_prefix
3030 # Determine include_guard_prefix.
3032 # - macro_prefix prefix of gl_LIBOBJS macros to use
3034 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3035 # - sed_replace_include_guard_prefix
3036 # sed expression for resolving ${gl_include_guard_prefix}
3037 func_compute_include_guard_prefix ()
3039 if test "$macro_prefix" = gl; then
3040 include_guard_prefix='GL'
3042 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3044 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3047 # func_execute_command command [args...]
3048 # Executes a command.
3049 # Uses also the variables
3050 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3051 func_execute_command ()
3053 if test $verbose -ge 0; then
3057 # Commands like automake produce output to stderr even when they succeed.
3058 # Turn this output off if the command succeeds.
3059 "$@" > "$tmp"/cmdout 2>&1
3061 if test $cmdret = 0; then
3065 cat "$tmp"/cmdout 1>&2
3072 # func_dest_tmpfilename file
3073 # determines the name of a temporary file (file is relative to destdir).
3075 # - destdir target directory
3076 # - doit : if actions shall be executed, false if only to be printed
3077 # - tmp pathname of a temporary directory
3079 # - tmpfile absolute filename of the temporary file
3080 func_dest_tmpfilename ()
3083 # Put the new contents of $file in a file in the same directory (needed
3084 # to guarantee that an 'mv' to "$destdir/$file" works).
3085 tmpfile="$destdir/$1.tmp"
3087 # Put the new contents of $file in a file in a temporary directory
3088 # (because the directory of "$file" might not exist).
3089 tmpfile="$tmp"/`basename "$1"`.tmp
3094 # copies a file from gnulib into the destination directory. The destination
3095 # is known to not exist.
3097 # - destdir target directory
3098 # - local_gnulib_dir from --local-dir
3099 # - modcache true or false, from --cache-modules/--no-cache-modules
3100 # - f the original file name
3101 # - lookedup_file name of the merged (combined) file
3102 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3103 # - g the rewritten file name
3104 # - tmpfile absolute filename of the temporary file
3105 # - doit : if actions shall be executed, false if only to be printed
3106 # - symbolic true if files should be symlinked, copied otherwise
3107 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3112 echo "Copying file $g"
3113 if { test -n "$symbolic" \
3114 || { test -n "$lsymbolic" \
3115 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3116 && test -z "$lookedup_tmp" \
3117 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
3118 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3120 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3128 # copies a file from gnulib into the destination directory. The destination
3129 # is known to exist.
3131 # - destdir target directory
3132 # - local_gnulib_dir from --local-dir
3133 # - modcache true or false, from --cache-modules/--no-cache-modules
3134 # - f the original file name
3135 # - lookedup_file name of the merged (combined) file
3136 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3137 # - g the rewritten file name
3138 # - tmpfile absolute filename of the temporary file
3139 # - doit : if actions shall be executed, false if only to be printed
3140 # - symbolic true if files should be symlinked, copied otherwise
3141 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3143 # - already_present nonempty if the file should already exist, empty otherwise
3146 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
3147 : # The file has not changed.
3151 if test -n "$already_present"; then
3152 echo "Updating file $g (backup in ${g}~)"
3154 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3156 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3157 if { test -n "$symbolic" \
3158 || { test -n "$lsymbolic" \
3159 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3160 && test -z "$lookedup_tmp" \
3161 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
3162 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3164 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3167 if test -n "$already_present"; then
3168 echo "Update file $g (backup in ${g}~)"
3170 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3176 # func_emit_lib_Makefile_am
3177 # emits the contents of library makefile to standard output.
3179 # - local_gnulib_dir from --local-dir
3180 # - modcache true or false, from --cache-modules/--no-cache-modules
3181 # - modules list of modules, including dependencies
3182 # - libname library name
3183 # - pobase directory relative to destdir where to place *.po files
3184 # - auxdir directory relative to destdir where to place build aux files
3185 # - makefile_name from --makefile-name
3186 # - libtool true if libtool will be used, false or blank otherwise
3187 # - macro_prefix prefix of gl_LIBOBJS macros to use
3188 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3189 # - witness_c_macro from --witness-c-macro
3190 # - actioncmd (optional) command that will reproduce this invocation
3191 # - for_test true if creating a package for testing, false otherwise
3192 # - sed_replace_include_guard_prefix
3193 # sed expression for resolving ${gl_include_guard_prefix}
3194 # - destfile filename relative to destdir of makefile being generated
3196 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3197 # list of edits to be done to Makefile.am variables
3199 # - uses_subdirs nonempty if object files in subdirs exist
3200 func_emit_lib_Makefile_am ()
3202 # When creating an includable Makefile.am snippet, augment variables with
3203 # += instead of assigning them.
3204 if test -n "$makefile_name"; then
3209 if test "$libtool" = true; then
3212 sed_eliminate_LDFLAGS="$sed_noop"
3216 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3219 # When creating a package for testing: Attempt to provoke failures,
3220 # especially link errors, already during "make" rather than during
3221 # "make check", because "make check" is not possible in a cross-compiling
3222 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3223 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3225 sed_transform_check_PROGRAMS="$sed_noop"
3227 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3228 echo "## Process this file with automake to produce Makefile.in."
3229 func_emit_copyright_notice
3230 if test -n "$actioncmd"; then
3231 # The maximum line length (excluding the terminating newline) of any file
3232 # that is to be preprocessed by config.status is 3070. config.status uses
3233 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3234 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3235 len=`echo "$actioncmd" | wc -c`
3236 if test -n "$len" && test "$len" -le 3000; then
3237 echo "# Reproduce by: $actioncmd"
3243 for module in $modules; do
3244 func_verify_nontests_module
3245 if test -n "$module"; then
3247 func_get_automake_snippet_conditional "$module" |
3249 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3250 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3251 -e "$sed_eliminate_LDFLAGS" \
3252 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3253 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3254 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3255 -e "$sed_transform_check_PROGRAMS" \
3256 -e "$sed_replace_include_guard_prefix"
3257 if test "$module" = 'alloca'; then
3258 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3259 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3261 } > "$tmp"/amsnippet1
3263 func_get_automake_snippet_unconditional "$module" |
3264 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3265 } > "$tmp"/amsnippet2
3266 # Skip the contents if it's entirely empty.
3267 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3268 echo "## begin gnulib module $module"
3270 if test "$cond_dependencies" = true; then
3271 if func_cond_module_p "$module"; then
3272 func_module_conditional_name "$module"
3273 echo "if $conditional"
3276 cat "$tmp"/amsnippet1
3277 if test "$cond_dependencies" = true; then
3278 if func_cond_module_p "$module"; then
3282 cat "$tmp"/amsnippet2
3283 echo "## end gnulib module $module"
3286 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3287 # Test whether there are some source files in subdirectories.
3288 for f in `func_get_filelist "$module"`; do
3298 } > "$tmp"/allsnippets
3299 if test -z "$makefile_name"; then
3300 # If there are source files in subdirectories, prevent collision of the
3301 # object files (example: hash.c and libxml/hash.c).
3303 if test -n "$uses_subdirs"; then
3304 subdir_options=' subdir-objects'
3306 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
3309 if test -z "$makefile_name"; then
3311 echo "noinst_HEADERS ="
3312 echo "noinst_LIBRARIES ="
3313 echo "noinst_LTLIBRARIES ="
3314 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3315 # if you specify pkgdata_DATA to empty. This is a workaround.
3316 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3317 echo "pkgdata_DATA ="
3320 echo "BUILT_SOURCES ="
3323 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3324 if test -z "$makefile_name"; then
3325 echo "MOSTLYCLEANDIRS ="
3327 echo "DISTCLEANFILES ="
3328 echo "MAINTAINERCLEANFILES ="
3330 # Execute edits that apply to the Makefile.am being generated.
3332 while test $edit != $makefile_am_edits; do
3333 edit=`expr $edit + 1`
3334 eval dir=\"\$makefile_am_edit${edit}_dir\"
3335 eval var=\"\$makefile_am_edit${edit}_var\"
3336 eval val=\"\$makefile_am_edit${edit}_val\"
3337 if test -n "$var"; then
3338 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3339 echo "${var} += ${val}"
3340 eval "makefile_am_edit${edit}_var="
3344 if test -n "$witness_c_macro"; then
3345 cppflags_part1=" -D$witness_c_macro=1"
3350 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3354 if test -z "$makefile_name"; then
3356 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3359 if test -n "$cppflags_part1$cppflags_part2"; then
3361 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3365 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3366 || { test -n "$makefile_name" \
3367 && test -f "$sourcebase/Makefile.am" \
3368 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3370 # One of the snippets or the user's Makefile.am already specifies an
3371 # installation location for the library. Don't confuse automake by saying
3372 # it should not be installed.
3375 # By default, the generated library should not be installed.
3376 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3379 echo "${libname}_${libext}_SOURCES ="
3380 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3381 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3382 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3383 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3384 echo "EXTRA_${libname}_${libext}_SOURCES ="
3385 if test "$libtool" = true; then
3386 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3387 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3388 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3389 # the link dependencies of all modules.
3390 for module in $modules; do
3391 func_verify_nontests_module
3392 if test -n "$module"; then
3393 func_get_link_directive "$module"
3396 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3397 | LC_ALL=C sort -u \
3398 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3401 if test -n "$pobase"; then
3402 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3405 cat "$tmp"/allsnippets \
3406 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3408 echo "mostlyclean-local: mostlyclean-generic"
3409 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3410 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3411 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3415 rm -f "$tmp"/allsnippets
3418 # func_emit_po_Makevars
3419 # emits the contents of po/ makefile parameterization to standard output.
3421 # - local_gnulib_dir from --local-dir
3422 # - modcache true or false, from --cache-modules/--no-cache-modules
3423 # - sourcebase directory relative to destdir where to place source code
3424 # - pobase directory relative to destdir where to place *.po files
3425 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3426 func_emit_po_Makevars ()
3428 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3429 func_emit_copyright_notice
3431 echo "# Usually the message domain is the same as the package name."
3432 echo "# But here it has a '-gnulib' suffix."
3433 echo "DOMAIN = ${po_domain}-gnulib"
3435 echo "# These two variables depend on the location of this directory."
3436 echo "subdir = ${pobase}"
3437 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3440 # These options get passed to xgettext.
3441 XGETTEXT_OPTIONS = \
3442 --keyword=_ --flag=_:1:pass-c-format \
3443 --keyword=N_ --flag=N_:1:pass-c-format \
3444 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3445 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3446 --flag=error:3:c-format --flag=error_at_line:5:c-format
3448 # This is the copyright holder that gets inserted into the header of the
3449 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3450 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3452 # This is the email address or URL to which the translators shall report
3453 # bugs in the untranslated strings:
3454 # - Strings which are not entire sentences, see the maintainer guidelines
3455 # in the GNU gettext documentation, section 'Preparing Strings'.
3456 # - Strings which use unclear terms or require additional context to be
3458 # - Strings which make invalid assumptions about notation of date, time or
3460 # - Pluralisation problems.
3461 # - Incorrect English spelling.
3462 # - Incorrect formatting.
3463 # It can be your email address, or a mailing list address where translators
3464 # can write to without being subscribed, or the URL of a web page through
3465 # which the translators can contact you.
3466 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3468 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3469 # message catalogs shall be used. It is usually empty.
3470 EXTRA_LOCALE_CATEGORIES =
3472 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3473 # context. Possible values are "yes" and "no". Set this to yes if the
3474 # package uses functions taking also a message context, like pgettext(), or
3475 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3480 # func_emit_po_POTFILES_in
3481 # emits the file list to be passed to xgettext to standard output.
3483 # - local_gnulib_dir from --local-dir
3484 # - modcache true or false, from --cache-modules/--no-cache-modules
3485 # - sourcebase directory relative to destdir where to place source code
3486 # - files list of new files
3487 func_emit_po_POTFILES_in ()
3489 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3490 func_emit_copyright_notice
3492 echo "# List of files which contain translatable strings."
3493 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3496 # func_emit_tests_Makefile_am witness_macro
3497 # emits the contents of tests makefile to standard output.
3499 # - local_gnulib_dir from --local-dir
3500 # - modcache true or false, from --cache-modules/--no-cache-modules
3501 # - modules list of modules, including dependencies
3502 # - libname library name
3503 # - auxdir directory relative to destdir where to place build aux files
3504 # - makefile_name from --makefile-name
3505 # - libtool true if libtool will be used, false or blank otherwise
3506 # - sourcebase relative directory containing lib source code
3507 # - m4base relative directory containing autoconf macros
3508 # - testsbase relative directory containing unit test code
3509 # - macro_prefix prefix of gl_LIBOBJS macros to use
3510 # - witness_c_macro from --witness-c-macro
3511 # - for_test true if creating a package for testing, false otherwise
3512 # - single_configure true if a single configure file should be generated,
3513 # false for a separate configure file for the tests
3514 # - use_libtests true if a libtests.a should be built, false otherwise
3515 # - sed_replace_include_guard_prefix
3516 # sed expression for resolving ${gl_include_guard_prefix}
3517 # - destfile filename relative to destdir of makefile being generated
3519 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3520 # list of edits to be done to Makefile.am variables
3522 # - uses_subdirs nonempty if object files in subdirs exist
3523 func_emit_tests_Makefile_am ()
3526 if test "$libtool" = true; then
3528 sed_eliminate_LDFLAGS="$sed_noop"
3531 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3534 # When creating a package for testing: Attempt to provoke failures,
3535 # especially link errors, already during "make" rather than during
3536 # "make check", because "make check" is not possible in a cross-compiling
3537 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3538 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3540 sed_transform_check_PROGRAMS="$sed_noop"
3542 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3543 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3544 echo "## Process this file with automake to produce Makefile.in."
3545 func_emit_copyright_notice
3549 for module in $modules; do
3550 if $for_test && ! $single_configure; then
3551 func_verify_tests_module
3555 if test -n "$module"; then
3557 func_get_automake_snippet "$module" |
3559 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3560 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3561 -e "$sed_eliminate_LDFLAGS" \
3562 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3563 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3564 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3565 -e "$sed_transform_check_PROGRAMS" \
3566 -e "$sed_replace_include_guard_prefix"
3567 if $use_libtests && test "$module" = 'alloca'; then
3568 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3569 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3571 } > "$tmp"/amsnippet
3572 # Skip the contents if it's entirely empty.
3573 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3574 # Mention long-running tests at the end.
3576 for word in `func_get_status "$module"`; do
3577 if test "$word" = 'longrunning-test'; then
3582 { echo "## begin gnulib module $module"
3584 cat "$tmp"/amsnippet
3585 echo "## end gnulib module $module"
3589 rm -f "$tmp"/amsnippet
3590 # Test whether there are some source files in subdirectories.
3591 for f in `func_get_filelist "$module"`; do
3593 lib/*/*.c | tests/*/*.c)
3601 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3602 # Generate dependencies here, since it eases the debugging of test failures.
3603 # If there are source files in subdirectories, prevent collision of the
3604 # object files (example: hash.c and libxml/hash.c).
3606 if test -n "$uses_subdirs"; then
3607 subdir_options=' subdir-objects'
3609 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3611 if $for_test && ! $single_configure; then
3612 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3615 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3616 # variable is needed to avoid an error from automake:
3617 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3620 echo "XFAIL_TESTS ="
3621 echo "TESTS_ENVIRONMENT ="
3622 echo "noinst_PROGRAMS ="
3623 if ! $for_test; then
3624 echo "check_PROGRAMS ="
3626 echo "noinst_HEADERS ="
3627 echo "noinst_LIBRARIES ="
3628 if $use_libtests; then
3630 echo "noinst_LIBRARIES += libtests.a"
3632 echo "check_LIBRARIES = libtests.a"
3635 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3636 # if you specify pkgdata_DATA to empty. This is a workaround.
3637 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3638 echo "pkgdata_DATA ="
3641 echo "BUILT_SOURCES ="
3643 echo "MOSTLYCLEANFILES = core *.stackdump"
3644 echo "MOSTLYCLEANDIRS ="
3646 echo "DISTCLEANFILES ="
3647 echo "MAINTAINERCLEANFILES ="
3648 # Execute edits that apply to the Makefile.am being generated.
3650 while test $edit != $makefile_am_edits; do
3651 edit=`expr $edit + 1`
3652 eval dir=\"\$makefile_am_edit${edit}_dir\"
3653 eval var=\"\$makefile_am_edit${edit}_var\"
3654 eval val=\"\$makefile_am_edit${edit}_val\"
3655 if test -n "$var"; then
3656 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3657 echo "${var} += ${val}"
3658 eval "makefile_am_edit${edit}_var="
3663 echo "AM_CPPFLAGS = \\"
3665 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3667 if test -n "$witness_c_macro"; then
3668 echo " -D$witness_c_macro=1 \\"
3670 if test -n "${witness_macro}"; then
3671 echo " -D@${witness_macro}@=1 \\"
3673 echo " -I. -I\$(srcdir) \\"
3674 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3675 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3677 local_ldadd_before=''
3678 local_ldadd_after=''
3679 if $use_libtests; then
3680 # All test programs need to be linked with libtests.a.
3681 # It needs to be passed to the linker before ${libname}.${libext}, since
3682 # the tests-related modules depend on the main modules.
3683 # It also needs to be passed to the linker after ${libname}.${libext}
3684 # because the latter might contain incomplete modules (such as the 'error'
3685 # module whose dependency to 'progname' is voluntarily omitted).
3686 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3688 local_ldadd_before=' libtests.a'
3689 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3691 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3693 if $use_libtests; then
3694 echo "libtests_a_SOURCES ="
3695 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3696 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3697 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3698 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3699 echo "EXTRA_libtests_a_SOURCES ="
3700 # The circular dependency in LDADD requires this.
3701 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3704 # Many test scripts use ${EXEEXT} or ${srcdir}.
3705 # EXEEXT is defined by AC_PROG_CC through autoconf.
3706 # srcdir is defined by autoconf and automake.
3707 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3709 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3710 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3711 echo "# Clean up after Solaris cc."
3713 echo " rm -rf SunWS_cache"
3715 echo "mostlyclean-local: mostlyclean-generic"
3716 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3717 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3718 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3722 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3725 # func_emit_initmacro_start macro_prefix
3726 # emits the first few statements of the gl_INIT macro to standard output.
3727 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3728 func_emit_initmacro_start ()
3730 macro_prefix_arg="$1"
3731 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3732 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3733 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3734 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3736 # Furthermore it avoids an automake error like this when a Makefile.am
3737 # that uses pieces of gnulib also uses $(LIBOBJ):
3738 # automatically discovered file `error.c' should not be explicitly mentioned
3739 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3740 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3741 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3742 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3743 # automatically discovered file `error.c' should not be explicitly mentioned
3744 # We let automake know about the files to be distributed through the
3745 # EXTRA_lib_SOURCES variable.
3746 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3747 # Create data variables for checking the presence of files that are mentioned
3748 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3749 # because we want the check to happen when the configure file is created,
3750 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3751 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3752 # in which to expect them.
3753 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3754 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3758 # func_emit_initmacro_end macro_prefix
3759 # emits the last few statements of the gl_INIT macro to standard output.
3760 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3761 func_emit_initmacro_end ()
3763 macro_prefix_arg="$1"
3764 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3765 # The check is performed only when autoconf is run from the directory where
3766 # the configure.ac resides; if it is run from a different directory, the
3768 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3769 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3770 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3771 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3772 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3776 echo " m4_if(m4_sysval, [0], [],"
3777 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3779 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3780 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3781 echo " m4_popdef([AC_LIBSOURCES])"
3782 echo " m4_popdef([AC_REPLACE_FUNCS])"
3783 echo " m4_popdef([AC_LIBOBJ])"
3784 echo " AC_CONFIG_COMMANDS_PRE(["
3785 echo " ${macro_prefix_arg}_libobjs="
3786 echo " ${macro_prefix_arg}_ltlibobjs="
3787 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3788 echo " # Remove the extension."
3789 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3790 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3791 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3792 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3795 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3796 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3800 # func_emit_initmacro_done macro_prefix sourcebase
3801 # emits a few statements after the gl_INIT macro to standard output.
3802 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3803 # - sourcebase directory relative to destdir where to place source code
3804 func_emit_initmacro_done ()
3806 macro_prefix_arg="$1"
3809 echo "# Like AC_LIBOBJ, except that the module name goes"
3810 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3811 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3812 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3813 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3816 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3817 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3818 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3819 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3820 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3823 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3824 echo "# expected is derived from the gnulib-tool parameterization,"
3825 echo "# and alloca is special cased (for the alloca-opt module)."
3826 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3827 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3828 echo " m4_foreach([_gl_NAME], [\$1], ["
3829 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3830 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3831 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3837 # func_emit_autoconf_snippet indentation
3838 # emits the autoconf snippet of a module.
3840 # - local_gnulib_dir from --local-dir
3841 # - modcache true or false, from --cache-modules/--no-cache-modules
3842 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3843 # - module the module name
3844 # - toplevel true or false. 'false' means a subordinate use of
3846 # - disable_libtool true or false. It tells whether to disable libtool
3847 # handling even if it has been specified through the
3848 # command line options.
3849 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3851 # - indentation spaces to prepend on each line
3852 func_emit_autoconf_snippet ()
3854 if { case $module in
3855 gnumakefile | maintainer-makefile)
3856 # These modules are meant to be used only in the top-level directory.
3862 func_get_autoconf_snippet "$module" \
3863 | sed -e '/^$/d;' -e "s/^/$indentation/" \
3864 -e "$sed_replace_build_aux" \
3865 | { if $disable_libtool; then
3866 sed -e 's/\$gl_cond_libtool/false/g' \
3867 -e 's/gl_libdeps/gltests_libdeps/g' \
3868 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3873 | { if $disable_gettext; then
3874 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
3879 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
3880 echo 'changequote(,)dnl'
3881 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3882 echo 'changequote([, ])dnl'
3883 echo 'AC_SUBST([LTALLOCA])'
3888 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
3889 # collects and emit the autoconf snippets of a set of modules.
3891 # - local_gnulib_dir from --local-dir
3892 # - modcache true or false, from --cache-modules/--no-cache-modules
3893 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3894 # - modules the list of modules.
3895 # - verifier one of func_verify_module, func_verify_nontests_module,
3896 # func_verify_tests_module. It selects the subset of
3897 # $modules to consider.
3898 # - toplevel true or false. 'false' means a subordinate use of
3900 # - disable_libtool true or false. It tells whether to disable libtool
3901 # handling even if it has been specified through the
3902 # command line options.
3903 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3905 func_emit_autoconf_snippets ()
3909 disable_libtool="$4"
3910 disable_gettext="$5"
3911 if test "$cond_dependencies" = true; then
3912 # Emit the autoconf code for the unconditional modules.
3913 for module in $1; do
3915 if test -n "$module"; then
3916 if func_cond_module_p "$module"; then
3919 func_emit_autoconf_snippet " "
3923 # Initialize the shell variables indicating that the modules are enabled.
3924 for module in $1; do
3926 if test -n "$module"; then
3927 if func_cond_module_p "$module"; then
3928 func_module_shellvar_name "$module"
3929 echo " $shellvar=false"
3933 # Emit the autoconf code for the conditional modules, each in a separate
3934 # function. This makes it possible to support cycles among conditional
3936 for module in $1; do
3938 if test -n "$module"; then
3939 if func_cond_module_p "$module"; then
3940 func_module_shellfunc_name "$module"
3941 func_module_shellvar_name "$module"
3942 echo " $shellfunc ()"
3944 echo " if ! \$$shellvar; then"
3945 func_emit_autoconf_snippet " "
3946 echo " $shellvar=true"
3947 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3948 for dep in $deps; do
3949 if func_cond_module_p "$dep"; then
3950 func_module_shellfunc_name "$dep"
3951 func_cond_module_condition "$module" "$dep"
3952 if test "$condition" != true; then
3953 echo ' if $condition; then'
3960 # The autoconf code for $dep has already been emitted above and
3961 # therefore is already executed when this function is run.
3970 # Emit the dependencies from the unconditional to the conditional modules.
3971 for module in $1; do
3973 if test -n "$module"; then
3974 if func_cond_module_p "$module"; then
3977 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3978 for dep in $deps; do
3979 if func_cond_module_p "$dep"; then
3980 func_module_shellfunc_name "$dep"
3981 func_cond_module_condition "$module" "$dep"
3982 if test "$condition" != true; then
3983 echo " if $condition; then"
3990 # The autoconf code for $dep has already been emitted above and
3991 # therefore is already executed when this code is run.
3998 # Define the Automake conditionals.
3999 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4000 for module in $1; do
4002 if test -n "$module"; then
4003 if func_cond_module_p "$module"; then
4004 func_module_conditional_name "$module"
4005 func_module_shellvar_name "$module"
4006 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4011 # Ignore the conditions, and enable all modules unconditionally.
4012 for module in $1; do
4014 if test -n "$module"; then
4015 func_emit_autoconf_snippet " "
4021 # func_import modules
4022 # Uses also the variables
4023 # - mode import or add-import or remove-import or update
4024 # - destdir target directory
4025 # - local_gnulib_dir from --local-dir
4026 # - modcache true or false, from --cache-modules/--no-cache-modules
4027 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4028 # - libname library name
4029 # - supplied_libname true if --lib was given, blank otherwise
4030 # - sourcebase directory relative to destdir where to place source code
4031 # - m4base directory relative to destdir where to place *.m4 macros
4032 # - pobase directory relative to destdir where to place *.po files
4033 # - docbase directory relative to destdir where to place doc files
4034 # - testsbase directory relative to destdir where to place unit test code
4035 # - auxdir directory relative to destdir where to place build aux files
4036 # - inctests true if --with-tests was given, blank otherwise
4037 # - incobsolete true if --with-obsolete was given, blank otherwise
4038 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4039 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4041 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4043 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4045 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4046 # - avoidlist list of modules to avoid, from --avoid
4047 # - cond_dependencies true if --conditional-dependencies was given, false if
4048 # --no-conditional-dependencies was given, blank otherwise
4049 # - lgpl yes or a number if library's license shall be LGPL,
4051 # - makefile_name from --makefile-name
4052 # - libtool true if --libtool was given, false if --no-libtool was
4053 # given, blank otherwise
4054 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4055 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4056 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4057 # - witness_c_macro from --witness-c-macro
4058 # - vc_files true if --vc-files was given, false if --no-vc-files was
4059 # given, blank otherwise
4060 # - autoconf_minversion minimum supported autoconf version
4061 # - doit : if actions shall be executed, false if only to be printed
4062 # - symbolic true if files should be symlinked, copied otherwise
4063 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4065 # - do_copyrights true if copyright notices in files should be replaced,
4069 # Get the cached settings.
4070 # In 'import' mode, we read them only for the purpose of knowing the old
4071 # installed file list, and don't use them as defaults.
4072 cached_local_gnulib_dir=
4073 cached_specified_modules=
4075 cached_inc_cxx_tests=
4076 cached_inc_longrunning_tests=
4077 cached_inc_privileged_tests=
4078 cached_inc_unportable_tests=
4079 cached_inc_all_tests=
4089 cached_makefile_name=
4090 cached_cond_dependencies=
4092 cached_macro_prefix=
4094 cached_witness_c_macro=
4097 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4098 cached_libtool=false
4104 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
4114 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4116 /gl_WITH_OBSOLETE/ {
4117 s,^.*$,cached_incobsolete=true,p
4119 /gl_WITH_CXX_TESTS/ {
4120 s,^.*$,cached_inc_cxx_tests=true,p
4122 /gl_WITH_LONGRUNNING_TESTS/ {
4123 s,^.*$,cached_inc_longrunning_tests=true,p
4125 /gl_WITH_PRIVILEGED_TESTS/ {
4126 s,^.*$,cached_inc_privileged_tests=true,p
4128 /gl_WITH_UNPORTABLE_TESTS/ {
4129 s,^.*$,cached_inc_unportable_tests=true,p
4131 /gl_WITH_ALL_TESTS/ {
4132 s,^.*$,cached_inc_all_tests=true,p
4135 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4138 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4141 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4144 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4147 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4150 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4153 s,^.*$,cached_inctests=true,p
4156 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4159 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4162 s,^.*$,cached_lgpl=yes,p
4164 /gl_MAKEFILE_NAME(/ {
4165 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4167 /gl_CONDITIONAL_DEPENDENCIES/ {
4168 s,^.*$,cached_cond_dependencies=true,p
4171 s,^.*$,cached_libtool=true,p
4173 /gl_MACRO_PREFIX(/ {
4174 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4177 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4179 /gl_WITNESS_C_MACRO(/ {
4180 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4183 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4185 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4186 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4191 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4192 s,^.*$,cached_files=",p
4205 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4209 if test "$mode" = import; then
4210 # In 'import' mode, the new set of specified modules overrides the cached
4211 # set of modules. Ignore the cached settings.
4212 specified_modules="$1"
4214 # Merge the cached settings with the specified ones.
4215 # The m4base must be the same as expected from the pathname.
4216 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4217 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4219 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
4220 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4221 if test -z "$local_gnulib_dir"; then
4222 if test -n "$cached_local_gnulib_dir"; then
4225 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4227 case "$cached_local_gnulib_dir" in
4229 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4231 func_relconcat "$destdir" "$cached_local_gnulib_dir"
4232 local_gnulib_dir="$relconcat" ;;
4239 # Append the cached and the specified module names. So that
4240 # "gnulib-tool --add-import foo" means to add the module foo.
4241 specified_modules="$cached_specified_modules $1"
4244 # Take the cached module names, minus the specified module names.
4246 if $have_associative; then
4247 # Use an associative array, for O(N) worst-case run time.
4248 declare -A to_remove
4250 eval 'to_remove[$m]=yes'
4252 for module in $cached_specified_modules; do
4253 if eval 'test -z "${to_remove[$module]}"'; then
4254 func_append specified_modules "$module "
4258 # This loop has O(N²) worst-case run time.
4259 for module in $cached_specified_modules; do
4262 if test "$m" = "$module"; then
4267 if test -z "$to_remove"; then
4268 func_append specified_modules "$module "
4274 # Take the cached module names. There are no specified module names.
4275 specified_modules="$cached_specified_modules"
4278 # Included obsolete modules among the dependencies if specified either way.
4279 if test -z "$incobsolete"; then
4280 incobsolete="$cached_incobsolete"
4282 # Included special kinds of tests modules among the dependencies if specified
4284 if test -z "$inc_cxx_tests"; then
4285 inc_cxx_tests="$cached_inc_cxx_tests"
4287 if test -z "$inc_longrunning_tests"; then
4288 inc_longrunning_tests="$cached_inc_longrunning_tests"
4290 if test -z "$inc_privileged_tests"; then
4291 inc_privileged_tests="$cached_inc_privileged_tests"
4293 if test -z "$inc_unportable_tests"; then
4294 inc_unportable_tests="$cached_inc_unportable_tests"
4296 if test -z "$inc_all_tests"; then
4297 inc_all_tests="$cached_inc_all_tests"
4299 # Append the cached and the specified avoidlist. This is probably better
4300 # than dropping the cached one when --avoid is specified at least once.
4301 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4302 avoidlist=`echo $avoidlist`
4304 # The sourcebase defaults to the cached one.
4305 if test -z "$sourcebase"; then
4306 sourcebase="$cached_sourcebase"
4307 if test -z "$sourcebase"; then
4308 func_fatal_error "missing --source-base option"
4311 # The pobase defaults to the cached one.
4312 if test -z "$pobase"; then
4313 pobase="$cached_pobase"
4315 # The docbase defaults to the cached one.
4316 if test -z "$docbase"; then
4317 docbase="$cached_docbase"
4318 if test -z "$docbase"; then
4319 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."
4322 # The testsbase defaults to the cached one.
4323 if test -z "$testsbase"; then
4324 testsbase="$cached_testsbase"
4325 if test -z "$testsbase"; then
4326 func_fatal_error "missing --tests-base option"
4329 # Require the tests if specified either way.
4330 if test -z "$inctests"; then
4331 inctests="$cached_inctests"
4333 # The libname defaults to the cached one.
4334 if test -z "$supplied_libname"; then
4335 libname="$cached_libname"
4336 if test -z "$libname"; then
4337 func_fatal_error "missing --lib option"
4340 # Require LGPL if specified either way.
4341 if test -z "$lgpl"; then
4344 # The makefile_name defaults to the cached one.
4345 if test -z "$makefile_name"; then
4346 makefile_name="$cached_makefile_name"
4348 # Use conditional dependencies if specified either way.
4349 if test -z "$cond_dependencies"; then
4350 cond_dependencies="$cached_cond_dependencies"
4352 # Use libtool if specified either way, or if guessed.
4353 if test -z "$libtool"; then
4354 if test -n "$cached_m4base"; then
4355 libtool="$cached_libtool"
4357 libtool="$guessed_libtool"
4360 # The macro_prefix defaults to the cached one.
4361 if test -z "$macro_prefix"; then
4362 macro_prefix="$cached_macro_prefix"
4363 if test -z "$macro_prefix"; then
4364 func_fatal_error "missing --macro-prefix option"
4367 # The po_domain defaults to the cached one.
4368 if test -z "$po_domain"; then
4369 po_domain="$cached_po_domain"
4371 # The witness_c_macro defaults to the cached one.
4372 if test -z "$witness_c_macro"; then
4373 witness_c_macro="$cached_witness_c_macro"
4375 # The vc_files defaults to the cached one.
4376 if test -z "$vc_files"; then
4377 vc_files="$cached_vc_files"
4379 # Ensure constraints.
4380 if test "$cond_dependencies" = true && test -n "$inctests"; then
4381 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4385 # --without-*-tests options are not supported here.
4387 excl_longrunning_tests=
4388 excl_privileged_tests=
4389 excl_unportable_tests=
4391 # Canonicalize the list of specified modules.
4392 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4394 # Include all kinds of tests modules if --with-all-tests was specified.
4395 inc_all_direct_tests="$inc_all_tests"
4396 inc_all_indirect_tests="$inc_all_tests"
4398 # Determine final module list.
4399 modules="$specified_modules"
4400 func_modules_transitive_closure
4401 if test $verbose -ge 0; then
4402 func_show_module_list
4404 final_modules="$modules"
4406 # Determine main module list and tests-related module list separately.
4407 func_modules_transitive_closure_separately
4409 # Determine whether a $testsbase/libtests.a is needed.
4410 func_determine_use_libtests
4412 # Add the dummy module to the main module list or to the tests-related module
4414 func_modules_add_dummy_separately
4416 # If --lgpl, verify that the licenses of modules are compatible.
4417 if test -n "$lgpl"; then
4418 license_incompatibilities=
4419 for module in $main_modules; do
4420 license=`func_get_license $module`
4422 'GPLed build tool') ;;
4423 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4428 LGPL | LGPLv2+ | LGPLv3+) ;;
4429 *) func_append license_incompatibilities "$module $license$nl" ;;
4435 *) func_append license_incompatibilities "$module $license$nl" ;;
4438 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4443 if test -n "$license_incompatibilities"; then
4444 # Format the license incompatibilities as a table.
4445 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4446 s,^\(.................................................[^ ]*\) *, \1 ,'
4447 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4448 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4452 # Show banner notice of every module.
4453 modules="$main_modules"
4456 # Determine script to apply to imported library files.
4457 sed_transform_lib_file=
4458 for module in $main_modules; do
4459 if test $module = config-h; then
4460 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4461 sed_transform_lib_file=$sed_transform_lib_file'
4462 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4467 sed_transform_main_lib_file="$sed_transform_lib_file"
4468 if test -n "$do_copyrights"; then
4469 if test -n "$lgpl"; then
4473 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4474 s/GNU General/GNU Lesser General/g
4475 s/General Public License/Lesser General Public License/g
4476 s/Lesser Lesser General Public License/Lesser General Public License/g
4480 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4481 s/GNU General/GNU Lesser General/g
4482 s/General Public License/Lesser General Public License/g
4483 s/Lesser Lesser General Public License/Lesser General Public License/g
4485 s/version [23]\([ ,]\)/version 2.1\1/g
4488 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4492 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4493 s/GNU Lesser General/GNU General/g
4494 s/Lesser General Public License/General Public License/g
4496 s/GNU Library General/GNU General/g
4497 s/Library General Public License/General Public License/g
4499 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4504 # Determine script to apply to auxiliary files that go into $auxdir/.
4505 sed_transform_build_aux_file=
4506 if test -n "$do_copyrights"; then
4508 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4509 s/GNU Lesser General/GNU General/g
4510 s/Lesser General Public License/General Public License/g
4512 s/GNU Library General/GNU General/g
4513 s/Library General Public License/General Public License/g
4515 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4519 # Determine script to apply to library files that go into $testsbase/.
4520 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4521 if test -n "$do_copyrights"; then
4523 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4524 s/GNU Lesser General/GNU General/g
4525 s/Lesser General Public License/General Public License/g
4527 s/GNU Library General/GNU General/g
4528 s/Library General Public License/General Public License/g
4530 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4534 # Determine the final file lists.
4535 func_modules_to_filelist_separately
4538 || func_fatal_error "refusing to do nothing"
4540 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4541 new_files="$files m4/gnulib-tool.m4"
4542 old_files="$cached_files"
4543 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4544 func_append old_files " m4/gnulib-tool.m4"
4547 rewritten='%REWRITTEN%'
4548 sed_rewrite_old_files="\
4549 s,^build-aux/,$rewritten$auxdir/,
4550 s,^doc/,$rewritten$cached_docbase/,
4551 s,^lib/,$rewritten$cached_sourcebase/,
4552 s,^m4/,$rewritten$cached_m4base/,
4553 s,^tests/,$rewritten$cached_testsbase/,
4554 s,^tests=lib/,$rewritten$cached_testsbase/,
4557 sed_rewrite_new_files="\
4558 s,^build-aux/,$rewritten$auxdir/,
4559 s,^doc/,$rewritten$docbase/,
4560 s,^lib/,$rewritten$sourcebase/,
4561 s,^m4/,$rewritten$m4base/,
4562 s,^tests/,$rewritten$testsbase/,
4563 s,^tests=lib/,$rewritten$testsbase/,
4567 # Create directories.
4568 { echo "$sourcebase"
4570 if test -n "$pobase"; then
4573 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4574 if test -n "$docfiles"; then
4577 if test -n "$inctests"; then
4581 for f in $files; do echo $f; done \
4582 | sed -e "$sed_rewrite_new_files" \
4583 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4586 { # Rearrange file descriptors. Needed because "while ... done < ..."
4587 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4588 exec 5<&0 < "$tmp"/dirs
4590 if test ! -d "$destdir/$d"; then
4592 echo "Creating directory $destdir/$d"
4593 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4595 echo "Create directory $destdir/$d"
4602 # Copy files or make symbolic links. Remove obsolete files.
4606 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4607 # representing the files according to the last gnulib-tool invocation.
4608 for f in $old_files; do echo $f; done \
4609 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4612 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4613 # representing the files after this gnulib-tool invocation.
4614 for f in $new_files; do echo $f; done \
4615 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4618 # First the files that are in old-files, but not in new-files:
4619 sed_take_first_column='s,'"$delimiter"'.*,,'
4620 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4621 # Remove the file. Do nothing if the user already removed it.
4622 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4624 echo "Removing file $g (backup in ${g}~)"
4625 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4627 echo "Remove file $g (backup in ${g}~)"
4629 func_append removed_files "$g$nl"
4632 # func_add_or_update handles a file that ought to be present afterwards.
4634 # - f the original file name
4635 # - g the rewritten file name
4636 # - already_present nonempty if the file should already exist, empty
4638 func_add_or_update ()
4642 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4644 func_dest_tmpfilename "$g"
4645 func_lookup_file "$f"
4646 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4647 if test -n "$sed_transform_main_lib_file"; then
4650 sed -e "$sed_transform_main_lib_file" \
4651 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4655 if test -n "$sed_transform_build_aux_file"; then
4658 sed -e "$sed_transform_build_aux_file" \
4659 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4663 if test -n "$sed_transform_testsrelated_lib_file"; then
4666 sed -e "$sed_transform_testsrelated_lib_file" \
4667 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4671 if test -f "$destdir/$g"; then
4672 # The file already exists.
4676 # Don't protest if the file should be there but isn't: it happens
4677 # frequently that developers don't put autogenerated files under version control.
4679 func_append added_files "$g$nl"
4683 # Then the files that are in new-files, but not in old-files:
4684 sed_take_last_column='s,^.*'"$delimiter"',,'
4686 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4687 | sed -e "$sed_take_last_column" \
4688 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4689 { # Rearrange file descriptors. Needed because "while ... done < ..."
4690 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4691 exec 5<&0 < "$tmp"/added-files
4697 # Then the files that are in new-files and in old-files:
4698 already_present=true
4699 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4700 | sed -e "$sed_take_last_column" \
4701 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4702 { # Rearrange file descriptors. Needed because "while ... done < ..."
4703 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4704 exec 5<&0 < "$tmp"/kept-files
4711 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4712 actioncmd="gnulib-tool --import"
4713 func_append actioncmd " --dir=$destdir"
4714 if test -n "$local_gnulib_dir"; then
4715 func_append actioncmd " --local-dir=$local_gnulib_dir"
4717 func_append actioncmd " --lib=$libname"
4718 func_append actioncmd " --source-base=$sourcebase"
4719 func_append actioncmd " --m4-base=$m4base"
4720 if test -n "$pobase"; then
4721 func_append actioncmd " --po-base=$pobase"
4723 func_append actioncmd " --doc-base=$docbase"
4724 func_append actioncmd " --tests-base=$testsbase"
4725 func_append actioncmd " --aux-dir=$auxdir"
4726 if test -n "$inctests"; then
4727 func_append actioncmd " --with-tests"
4729 if test -n "$incobsolete"; then
4730 func_append actioncmd " --with-obsolete"
4732 if test -n "$inc_cxx_tests"; then
4733 func_append actioncmd " --with-c++-tests"
4735 if test -n "$inc_longrunning_tests"; then
4736 func_append actioncmd " --with-longrunning-tests"
4738 if test -n "$inc_privileged_tests"; then
4739 func_append actioncmd " --with-privileged-tests"
4741 if test -n "$inc_unportable_tests"; then
4742 func_append actioncmd " --with-unportable-tests"
4744 if test -n "$inc_all_tests"; then
4745 func_append actioncmd " --with-all-tests"
4747 for module in $avoidlist; do
4748 func_append actioncmd " --avoid=$module"
4750 if test -n "$lgpl"; then
4751 if test "$lgpl" = yes; then
4752 func_append actioncmd " --lgpl"
4754 func_append actioncmd " --lgpl=$lgpl"
4757 if test -n "$makefile_name"; then
4758 func_append actioncmd " --makefile-name=$makefile_name"
4760 if test "$cond_dependencies" = true; then
4761 func_append actioncmd " --conditional-dependencies"
4763 func_append actioncmd " --no-conditional-dependencies"
4765 if test "$libtool" = true; then
4766 func_append actioncmd " --libtool"
4768 func_append actioncmd " --no-libtool"
4770 func_append actioncmd " --macro-prefix=$macro_prefix"
4771 if test -n "$po_domain"; then
4772 func_append actioncmd " --po-domain=$po_domain"
4774 if test -n "$witness_c_macro"; then
4775 func_append actioncmd " --witness-c-macro=$witness_c_macro"
4777 if test -n "$vc_files"; then
4778 if test "$vc_files" = true; then
4779 func_append actioncmd " --vc-files"
4781 func_append actioncmd " --no-vc-files"
4784 func_append actioncmd " `echo $specified_modules`"
4786 # Determine include_guard_prefix.
4787 func_compute_include_guard_prefix
4789 # Default the makefile name to Makefile.am.
4790 if test -n "$makefile_name"; then
4791 makefile_am=$makefile_name
4793 makefile_am=Makefile.am
4796 # Create normal Makefile.ams.
4799 # Setup list of Makefile.am edits that are to be performed afterwards.
4800 # Some of these edits apply to files that we will generate; others are
4801 # under the responsibility of the developer.
4803 # func_note_Makefile_am_edit dir var value
4804 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4806 func_note_Makefile_am_edit ()
4808 makefile_am_edits=`expr $makefile_am_edits + 1`
4809 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4810 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4811 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4813 if test "$makefile_am" = Makefile.am; then
4814 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4815 sourcebase_base=`basename "$sourcebase"`
4816 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4818 if test -n "$pobase"; then
4819 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4820 pobase_base=`basename "$pobase"`
4821 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4823 if test -n "$inctests"; then
4824 if test "$makefile_am" = Makefile.am; then
4825 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4826 testsbase_base=`basename "$testsbase"`
4827 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4830 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4832 # Find the first parent directory of $m4base that contains or will contain
4834 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4836 sed_butlast='s,[^/][^/]*//*$,,'
4837 dir1="${m4base}/"; dir2=""
4838 while test -n "$dir1" \
4839 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4840 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4841 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4842 || { test -n "$inctests" \
4843 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4844 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4845 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4846 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4848 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4851 # Create library makefile.
4852 func_dest_tmpfilename $sourcebase/$makefile_am
4853 destfile="$sourcebase/$makefile_am"
4854 modules="$main_modules"
4855 func_emit_lib_Makefile_am > "$tmpfile"
4856 if test -f "$destdir"/$sourcebase/$makefile_am; then
4857 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4861 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4862 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4863 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4865 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4871 echo "Creating $sourcebase/$makefile_am"
4872 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4874 echo "Create $sourcebase/$makefile_am"
4877 func_append added_files "$sourcebase/$makefile_am$nl"
4880 # Create po/ directory.
4881 if test -n "$pobase"; then
4882 # Create po makefile and auxiliary files.
4883 for file in Makefile.in.in remove-potcdate.sin; do
4884 func_dest_tmpfilename $pobase/$file
4885 func_lookup_file build-aux/po/$file
4886 cat "$lookedup_file" > "$tmpfile"
4887 if test -f "$destdir"/$pobase/$file; then
4888 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4892 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4893 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4894 mv -f "$tmpfile" "$destdir"/$pobase/$file
4896 echo "Update $pobase/$file (backup in $pobase/$file~)"
4902 echo "Creating $pobase/$file"
4903 mv -f "$tmpfile" "$destdir"/$pobase/$file
4905 echo "Create $pobase/$file"
4908 func_append added_files "$pobase/$file$nl"
4911 # Create po makefile parameterization, part 1.
4912 func_dest_tmpfilename $pobase/Makevars
4913 func_emit_po_Makevars > "$tmpfile"
4914 if test -f "$destdir"/$pobase/Makevars; then
4915 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4919 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4920 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4921 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4923 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4929 echo "Creating $pobase/Makevars"
4930 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4932 echo "Create $pobase/Makevars"
4935 func_append added_files "$pobase/Makevars$nl"
4937 # Create po makefile parameterization, part 2.
4938 func_dest_tmpfilename $pobase/POTFILES.in
4939 func_emit_po_POTFILES_in > "$tmpfile"
4940 if test -f "$destdir"/$pobase/POTFILES.in; then
4941 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4945 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4946 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4947 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4949 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4955 echo "Creating $pobase/POTFILES.in"
4956 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4958 echo "Create $pobase/POTFILES.in"
4961 func_append added_files "$pobase/POTFILES.in$nl"
4964 TP_URL="http://translationproject.org/latest/"
4965 TP_RSYNC_URI="translationproject.org::tp/latest/"
4967 echo "Fetching gnulib PO files from $TP_URL"
4968 (cd "$destdir"/$pobase \
4969 && { # Prefer rsync over wget if it is available, since it consumes
4970 # less network bandwidth, due to compression.
4971 if type rsync 2>/dev/null | grep / > /dev/null; then
4972 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4974 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4979 echo "Fetch gnulib PO files from $TP_URL"
4981 # Create po/LINGUAS.
4983 func_dest_tmpfilename $pobase/LINGUAS
4984 (cd "$destdir"/$pobase \
4985 && { echo '# Set of available languages.'
4986 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4989 if test -f "$destdir"/$pobase/LINGUAS; then
4990 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4993 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4994 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4995 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4998 echo "Creating $pobase/LINGUAS"
4999 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5000 func_append added_files "$pobase/LINGUAS$nl"
5003 if test -f "$destdir"/$pobase/LINGUAS; then
5004 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5006 echo "Create $pobase/LINGUAS"
5011 # Create m4/gnulib-cache.m4.
5012 func_dest_tmpfilename $m4base/gnulib-cache.m4
5014 func_emit_copyright_notice
5016 echo "# This file represents the specification of how gnulib-tool is used."
5017 echo "# It acts as a cache: It is written and read by gnulib-tool."
5018 echo "# In projects that use version control, this file is meant to be put under"
5019 echo "# version control, like the configure.ac and various Makefile.am files."
5022 echo "# Specification in the form of a command-line invocation:"
5025 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5026 # Store the local_gnulib_dir relative to destdir.
5027 case "$local_gnulib_dir" in
5029 relative_local_gnulib_dir="$local_gnulib_dir" ;;
5032 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
5034 # destdir, local_gnulib_dir are both relative.
5035 func_relativize "$destdir" "$local_gnulib_dir"
5036 relative_local_gnulib_dir="$reldir" ;;
5039 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
5041 echo "$specified_modules" | sed -e 's/^/ /g'
5043 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5044 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5045 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5046 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5047 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5048 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5049 echo "gl_AVOID([$avoidlist])"
5050 echo "gl_SOURCE_BASE([$sourcebase])"
5051 echo "gl_M4_BASE([$m4base])"
5052 echo "gl_PO_BASE([$pobase])"
5053 echo "gl_DOC_BASE([$docbase])"
5054 echo "gl_TESTS_BASE([$testsbase])"
5055 test -z "$inctests" || echo "gl_WITH_TESTS"
5056 echo "gl_LIB([$libname])"
5057 if test -n "$lgpl"; then
5058 if test "$lgpl" = yes; then
5061 echo "gl_LGPL([$lgpl])"
5064 echo "gl_MAKEFILE_NAME([$makefile_name])"
5065 if test "$cond_dependencies" = true; then
5066 echo "gl_CONDITIONAL_DEPENDENCIES"
5068 if test "$libtool" = true; then
5071 echo "gl_MACRO_PREFIX([$macro_prefix])"
5072 echo "gl_PO_DOMAIN([$po_domain])"
5073 echo "gl_WITNESS_C_DOMAIN([$witness_c_macro])"
5074 if test -n "$vc_files"; then
5075 echo "gl_VC_FILES([$vc_files])"
5078 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5079 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
5083 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5084 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5085 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5087 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5091 echo "# gnulib-cache.m4 ends here"
5098 echo "Creating $m4base/gnulib-cache.m4"
5099 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5101 echo "Create $m4base/gnulib-cache.m4"
5107 # Create m4/gnulib-comp.m4.
5108 func_dest_tmpfilename $m4base/gnulib-comp.m4
5110 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5111 func_emit_copyright_notice
5113 echo "# This file represents the compiled summary of the specification in"
5114 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5115 echo "# to be invoked from configure.ac."
5116 echo "# In projects that use version control, this file can be treated like"
5117 echo "# other built files."
5120 echo "# This macro should be invoked from $configure_ac, in the section"
5121 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5122 echo "# any checks for libraries, header files, types and library functions."
5123 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5125 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5126 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5127 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5128 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5129 echo " AC_REQUIRE([AC_PROG_RANLIB])"
5130 if test -n "$uses_subdirs"; then
5131 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5133 for module in $final_modules; do
5135 if test -n "$module"; then
5136 echo "# Code from module $module:"
5137 func_get_autoconf_early_snippet "$module"
5140 | sed -e '/^$/d;' -e 's/^/ /'
5143 echo "# This macro should be invoked from $configure_ac, in the section"
5144 echo "# \"Check for header files, types and library functions\"."
5145 echo "AC_DEFUN([${macro_prefix}_INIT],"
5147 if test "$libtool" = true; then
5148 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5149 echo " gl_cond_libtool=true"
5151 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5152 echo " gl_cond_libtool=false"
5154 echo " gl_ltlibdeps="
5156 if test "$auxdir" != "build-aux"; then
5157 sed_replace_build_aux='
5159 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5160 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5164 sed_replace_build_aux="$sed_noop"
5166 echo " gl_m4_base='$m4base'"
5167 func_emit_initmacro_start $macro_prefix
5168 echo " gl_source_base='$sourcebase'"
5169 if test -n "$witness_c_macro"; then
5170 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5172 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
5173 if test -n "$witness_c_macro"; then
5174 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5176 echo " # End of code from modules"
5177 func_emit_initmacro_end $macro_prefix
5178 echo " gltests_libdeps="
5179 echo " gltests_ltlibdeps="
5180 func_emit_initmacro_start ${macro_prefix}tests
5181 echo " gl_source_base='$testsbase'"
5182 # Define a tests witness macro that depends on the package.
5183 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5184 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5185 echo "changequote(,)dnl"
5186 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"
5187 echo "changequote([, ])dnl"
5188 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5189 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5190 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5191 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
5192 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5193 func_emit_initmacro_end ${macro_prefix}tests
5194 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5195 # created using libtool, because libtool already handles the dependencies.
5196 if test "$libtool" != true; then
5197 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5198 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5199 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5200 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5201 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5203 if $use_libtests; then
5204 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5205 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5208 func_emit_initmacro_done $macro_prefix $sourcebase
5209 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5211 echo "# This macro records the list of files which have been installed by"
5212 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5213 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5214 echo "$files" | sed -e 's,^, ,'
5217 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5218 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
5222 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5223 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5224 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5226 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5230 echo "# gnulib-comp.m4 ends here"
5237 echo "Creating $m4base/gnulib-comp.m4"
5238 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5240 echo "Create $m4base/gnulib-comp.m4"
5246 if test -n "$inctests"; then
5247 # Create tests makefile.
5248 func_dest_tmpfilename $testsbase/$makefile_am
5249 destfile="$testsbase/$makefile_am"
5250 modules="$testsrelated_modules"
5251 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5252 if test -f "$destdir"/$testsbase/$makefile_am; then
5253 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
5257 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5258 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5259 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5261 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5267 echo "Creating $testsbase/$makefile_am"
5268 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5270 echo "Create $testsbase/$makefile_am"
5273 func_append added_files "$testsbase/$makefile_am$nl"
5277 if test "$vc_files" != false; then
5278 # Update the .cvsignore and .gitignore files.
5279 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5280 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5281 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5282 echo "$m4base/|A|gnulib-comp.m4"
5283 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5284 { # Rearrange file descriptors. Needed because "while ... done < ..."
5285 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5286 exec 5<&0 < "$tmp"/fileset-changes
5287 func_update_ignorelist ()
5290 if test "$ignore" = .gitignore; then
5291 # In a .gitignore file, "foo" applies to the current directory and all
5292 # subdirectories, whereas "/foo" applies to the current directory only.
5295 doubly_escaped_anchor='\\/'
5299 doubly_escaped_anchor=''
5301 if test -f "$destdir/$dir$ignore"; then
5302 if test -n "$dir_added" || test -n "$dir_removed"; then
5303 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5304 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5305 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5306 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5307 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
5309 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5311 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5312 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5313 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5314 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5315 } > "$tmp"/sed-ignore-removed
5316 { cat "$destdir/$dir$ignore"~
5317 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5318 } | sed -f "$tmp"/sed-ignore-removed \
5319 > "$destdir/$dir$ignore"
5321 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5326 if test -n "$dir_added"; then
5328 echo "Creating $destdir/$dir$ignore"
5330 if test "$ignore" = .cvsignore; then
5332 # Automake generates Makefile rules that create .dirstamp files.
5335 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5336 } > "$destdir/$dir$ignore"
5338 echo "Create $destdir/$dir$ignore"
5348 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5349 func_update_ignorelist .cvsignore
5351 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5352 func_update_ignorelist .gitignore
5359 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5360 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5361 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5362 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5363 if test "$next_dir" != "$last_dir"; then
5364 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5365 last_dir="$next_dir"
5370 A) func_append last_dir_added "$file$nl";;
5371 R) func_append last_dir_removed "$file$nl";;
5374 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5381 echo "You may need to add #include directives for the following .h files."
5382 # Intersect $specified_modules and $main_modules
5383 # (since $specified_modules is not necessarily of subset of $main_modules
5384 # - some may have been skipped through --avoid, and since the elements of
5385 # $main_modules but not in $specified_modules can go away without explicit
5386 # notice - through changes in the module dependencies).
5387 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5388 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5389 # First the #include <...> directives without #ifs, sorted for convenience,
5390 # then the #include "..." directives without #ifs, sorted for convenience,
5391 # then the #include directives that are surrounded by #ifs. Not sorted.
5392 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5393 include_directive=`func_get_include_directive "$module"`
5394 case "$nl$include_directive" in
5396 echo "$include_directive" 1>&5
5399 echo "$include_directive" | grep -v 'include "' 1>&6
5400 echo "$include_directive" | grep 'include "' 1>&7
5403 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5405 LC_ALL=C sort -u "$tmp"/include-angles
5406 LC_ALL=C sort -u "$tmp"/include-quotes
5407 cat "$tmp"/include-if
5408 ) | sed -e '/^$/d' -e 's/^/ /'
5409 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5411 for module in $main_modules; do
5412 func_get_link_directive "$module"
5414 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5415 if test `wc -l < "$tmp"/link` != 0; then
5417 echo "You may need to use the following Makefile variables when linking."
5418 echo "Use them in <program>_LDADD when linking a program, or"
5419 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5425 echo "Don't forget to"
5426 if test "$makefile_am" = Makefile.am; then
5427 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5429 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5431 if test -n "$pobase"; then
5432 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5434 if test -n "$inctests"; then
5435 if test "$makefile_am" = Makefile.am; then
5436 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5438 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5442 while test $edit != $makefile_am_edits; do
5443 edit=`expr $edit + 1`
5444 eval dir=\"\$makefile_am_edit${edit}_dir\"
5445 eval var=\"\$makefile_am_edit${edit}_var\"
5446 eval val=\"\$makefile_am_edit${edit}_val\"
5447 if test -n "$var"; then
5448 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5451 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
5452 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5455 # func_create_testdir testdir modules
5457 # - local_gnulib_dir from --local-dir
5458 # - modcache true or false, from --cache-modules/--no-cache-modules
5459 # - auxdir directory relative to destdir where to place build aux files
5460 # - inctests true if tests should be included, blank otherwise
5461 # - incobsolete true if obsolete modules among dependencies should be
5462 # included, blank otherwise
5463 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5465 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5467 # - excl_privileged_tests true if tests that require root privileges should be
5468 # excluded, blank otherwise
5469 # - excl_unportable_tests true if tests that fail on some platforms should be
5470 # excluded, blank otherwise
5471 # - single_configure true if a single configure file should be generated,
5472 # false for a separate configure file for the tests
5473 # - avoidlist list of modules to avoid
5474 # - cond_dependencies true if --conditional-dependencies was given, false if
5475 # --no-conditional-dependencies was given, blank otherwise
5476 # - libtool true if --libtool was given, false if --no-libtool was
5477 # given, blank otherwise
5478 # - symbolic true if files should be symlinked, copied otherwise
5479 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
5481 func_create_testdir ()
5485 if test -z "$modules"; then
5486 # All modules together.
5487 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5488 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5489 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5490 modules=`func_all_modules`
5491 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5493 specified_modules="$modules"
5495 # Canonicalize the list of specified modules.
5496 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5498 # Unlike in func_import, here we want to include all kinds of tests for the
5499 # directly specified modules, but not for dependencies.
5500 inc_all_direct_tests=true
5501 inc_all_indirect_tests="$inc_all_tests"
5503 # Check that the license of every module is consistent with the license of
5505 saved_inctests="$inctests"
5506 # When computing transitive closures, don't consider $module to depend on
5507 # $module-tests. Need this becauses tests are implicitly GPL and may depend
5508 # on GPL modules - therefore we don't want a warning in this case.
5510 for requested_module in $specified_modules; do
5511 requested_license=`func_get_license "$requested_module"`
5512 if test "$requested_license" != GPL; then
5513 # Here we use func_modules_transitive_closure, not just
5514 # func_get_dependencies, so that we also detect weird situations like
5515 # an LGPL module which depends on a GPLed build tool module which depends
5517 modules="$requested_module"
5518 func_modules_transitive_closure
5519 for module in $modules; do
5520 license=`func_get_license "$module"`
5522 'GPLed build tool') ;;
5523 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5525 case "$requested_license" in
5528 GPLv2+ | LGPLv2+) ;;
5529 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5535 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5541 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5550 inctests="$saved_inctests"
5552 # Subdirectory names.
5563 # Determine final module list.
5564 modules="$specified_modules"
5565 func_modules_transitive_closure
5566 if test $verbose -ge 0; then
5567 func_show_module_list
5569 final_modules="$modules"
5571 if $single_configure; then
5572 # Determine main module list and tests-related module list separately.
5573 func_modules_transitive_closure_separately
5576 if $single_configure; then
5577 # Determine whether a $testsbase/libtests.a is needed.
5578 func_determine_use_libtests
5581 # Add the dummy module if needed.
5582 if $single_configure; then
5583 func_modules_add_dummy_separately
5585 func_modules_add_dummy
5588 # Show banner notice of every module.
5589 if $single_configure; then
5590 modules="$main_modules"
5596 # Determine final file list.
5597 if $single_configure; then
5598 func_modules_to_filelist_separately
5600 func_modules_to_filelist
5601 if test $verbose -ge 0; then
5603 echo "$files" | sed -e 's/^/ /'
5606 # Add files for which the copy in gnulib is newer than the one that
5607 # "automake --add-missing --copy" would provide.
5608 files="$files build-aux/config.guess"
5609 files="$files build-aux/config.sub"
5610 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5612 rewritten='%REWRITTEN%'
5613 sed_rewrite_files="\
5614 s,^build-aux/,$rewritten$auxdir/,
5615 s,^doc/,$rewritten$docbase/,
5616 s,^lib/,$rewritten$sourcebase/,
5617 s,^m4/,$rewritten$m4base/,
5618 s,^tests/,$rewritten$testsbase/,
5619 s,^tests=lib/,$rewritten$testsbase/,
5623 # Create directories.
5624 for f in $files; do echo $f; done \
5625 | sed -e "$sed_rewrite_files" \
5626 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5627 | LC_ALL=C sort -u \
5629 { # Rearrange file descriptors. Needed because "while ... done < ..."
5630 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5631 exec 5<&0 < "$tmp"/dirs
5633 mkdir -p "$testdir/$d"
5638 # Copy files or make symbolic links.
5640 for f in $files; do echo $f; done \
5641 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5644 { # Rearrange file descriptors. Needed because "while ... done < ..."
5645 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5646 exec 5<&0 < "$tmp"/files
5649 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5651 func_lookup_file "$f"
5652 if test -n "$lookedup_tmp"; then
5653 cp -p "$lookedup_file" "$testdir/$g"
5655 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5656 if { test -n "$symbolic" \
5657 || { test -n "$lsymbolic" \
5658 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5659 func_ln "$lookedup_file" "$testdir/$g"
5661 cp -p "$lookedup_file" "$testdir/$g"
5668 # Determine include_guard_prefix.
5669 func_compute_include_guard_prefix
5671 # Create Makefile.ams that are for testing.
5674 # No special edits are needed.
5677 # Create $sourcebase/Makefile.am.
5678 mkdir -p "$testdir/$sourcebase"
5679 destfile="$sourcebase/Makefile.am"
5680 if $single_configure; then
5681 modules="$main_modules"
5683 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5684 any_uses_subdirs="$uses_subdirs"
5686 # Create $m4base/Makefile.am.
5687 mkdir -p "$testdir/$m4base"
5688 (echo "## Process this file with automake to produce Makefile.in."
5694 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5697 ) > "$testdir/$m4base/Makefile.am"
5699 subdirs="$sourcebase $m4base"
5700 subdirs_with_configure_ac=""
5702 if false && test -f "$testdir"/$m4base/gettext.m4; then
5703 # Avoid stupid error message from automake:
5704 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5705 mkdir -p "$testdir/po"
5706 (echo "## Process this file with automake to produce Makefile.in."
5707 ) > "$testdir/po/Makefile.am"
5708 func_append subdirs " po"
5711 if test -n "$inctests"; then
5712 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5713 if $single_configure; then
5714 # Create $testsbase/Makefile.am.
5715 destfile="$testsbase/Makefile.am"
5716 modules="$testsrelated_modules"
5717 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
5719 # Viewed from the $testsbase subdirectory, $auxdir is different.
5720 saved_auxdir="$auxdir"
5721 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5722 # Create $testsbase/Makefile.am.
5724 destfile="$testsbase/Makefile.am"
5725 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5726 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5727 # Create $testsbase/configure.ac.
5728 (echo "# Process this file with autoconf to produce a configure script."
5729 echo "AC_INIT([dummy], [0])"
5730 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5731 echo "AM_INIT_AUTOMAKE"
5733 echo "AC_CONFIG_HEADERS([config.h])"
5736 echo "AC_PROG_INSTALL"
5737 echo "AC_PROG_MAKE_SET"
5738 echo "AC_PROG_RANLIB"
5740 if test -n "$uses_subdirs"; then
5741 echo "AM_PROG_CC_C_O"
5744 for module in $modules; do
5746 if test -n "$module"; then
5748 gnumakefile | maintainer-makefile)
5749 # These modules are meant to be used only in the top-level directory.
5752 func_get_autoconf_early_snippet "$module"
5757 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5758 if test "$libtool" = true; then
5759 echo "LT_INIT([win32-dll])"
5760 echo "LT_LANG([C++])"
5761 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5762 echo "gl_cond_libtool=true"
5764 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5765 echo "gl_cond_libtool=false"
5767 echo "gl_ltlibdeps="
5769 # Wrap the set of autoconf snippets into an autoconf macro that is then
5770 # invoked. This is needed because autoconf does not support AC_REQUIRE
5772 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5773 # but we want the AC_REQUIRE to have its normal meaning (provide one
5774 # expansion of the required macro before the current point, and only one
5776 echo "AC_DEFUN([gl_INIT], ["
5777 sed_replace_build_aux='
5779 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5780 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5783 echo "gl_m4_base='../$m4base'"
5784 func_emit_initmacro_start $macro_prefix
5785 # We don't have explicit ordering constraints between the various
5786 # autoconf snippets. It's cleanest to put those of the library before
5787 # those of the tests.
5788 echo "gl_source_base='../$sourcebase'"
5789 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
5790 echo "gl_source_base='.'"
5791 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
5792 func_emit_initmacro_end $macro_prefix
5793 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5794 # created using libtool, because libtool already handles the dependencies.
5795 if test "$libtool" != true; then
5796 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5797 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5798 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5799 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5800 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5803 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5807 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5808 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5809 echo "AH_TOP([#include \"../config.h\"])"
5811 echo "AC_CONFIG_FILES([Makefile])"
5813 ) > "$testdir/$testsbase/configure.ac"
5814 auxdir="$saved_auxdir"
5815 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5817 func_append subdirs " $testsbase"
5820 # Create Makefile.am.
5821 (echo "## Process this file with automake to produce Makefile.in."
5823 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5825 echo "SUBDIRS = $subdirs"
5827 echo "ACLOCAL_AMFLAGS = -I $m4base"
5828 ) > "$testdir/Makefile.am"
5830 # Create configure.ac.
5831 (echo "# Process this file with autoconf to produce a configure script."
5832 echo "AC_INIT([dummy], [0])"
5833 if test "$auxdir" != "."; then
5834 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5836 echo "AM_INIT_AUTOMAKE"
5838 echo "AC_CONFIG_HEADERS([config.h])"
5841 echo "AC_PROG_INSTALL"
5842 echo "AC_PROG_MAKE_SET"
5844 echo "# For autobuild."
5845 echo "AC_CANONICAL_BUILD"
5846 echo "AC_CANONICAL_HOST"
5848 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5849 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5850 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5851 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5853 echo "AC_PROG_RANLIB"
5855 if test -n "$any_uses_subdirs"; then
5856 echo "AM_PROG_CC_C_O"
5859 for module in $final_modules; do
5860 if $single_configure; then
5863 func_verify_nontests_module
5865 if test -n "$module"; then
5866 func_get_autoconf_early_snippet "$module"
5869 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5870 if test "$libtool" = true; then
5871 echo "LT_INIT([win32-dll])"
5872 echo "LT_LANG([C++])"
5873 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5874 echo "gl_cond_libtool=true"
5876 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5877 echo "gl_cond_libtool=false"
5879 echo "gl_ltlibdeps="
5881 # Wrap the set of autoconf snippets into an autoconf macro that is then
5882 # invoked. This is needed because autoconf does not support AC_REQUIRE
5884 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5885 # but we want the AC_REQUIRE to have its normal meaning (provide one
5886 # expansion of the required macro before the current point, and only one
5888 echo "AC_DEFUN([gl_INIT], ["
5889 if test "$auxdir" != "build-aux"; then
5890 sed_replace_build_aux='
5892 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5893 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5897 sed_replace_build_aux="$sed_noop"
5899 echo "gl_m4_base='$m4base'"
5900 func_emit_initmacro_start $macro_prefix
5901 echo "gl_source_base='$sourcebase'"
5902 if $single_configure; then
5903 func_emit_autoconf_snippets "$main_modules" func_verify_module true false false
5905 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
5907 func_emit_initmacro_end $macro_prefix
5908 if $single_configure; then
5909 echo " gltests_libdeps="
5910 echo " gltests_ltlibdeps="
5911 func_emit_initmacro_start ${macro_prefix}tests
5912 echo " gl_source_base='$testsbase'"
5913 # Define a tests witness macro.
5914 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
5915 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5916 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5917 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5918 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true false false
5919 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5920 func_emit_initmacro_end ${macro_prefix}tests
5922 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5923 # created using libtool, because libtool already handles the dependencies.
5924 if test "$libtool" != true; then
5925 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5926 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5927 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5928 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5929 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5931 if $single_configure; then
5932 if $use_libtests; then
5933 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5934 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5938 func_emit_initmacro_done $macro_prefix $sourcebase
5939 if $single_configure; then
5940 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5945 if test -n "$subdirs_with_configure_ac"; then
5946 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5948 makefiles="Makefile"
5949 for d in $subdirs; do
5950 # For subdirs that have a configure.ac by their own, it's the subdir's
5951 # configure.ac which creates the subdir's Makefile.am, not this one.
5952 case " $subdirs_with_configure_ac " in
5954 *) func_append makefiles " $d/Makefile" ;;
5957 echo "AC_CONFIG_FILES([$makefiles])"
5959 ) > "$testdir/configure.ac"
5961 # Create autogenerated files.
5963 # Do not use "${AUTORECONF} --force --install", because it may invoke
5964 # autopoint, which brings in older versions of some of our .m4 files.
5965 if test -f $m4base/gettext.m4; then
5966 func_execute_command ${AUTOPOINT} --force || func_exit 1
5967 for f in $m4base/*.m4~; do
5969 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5973 if test "$libtool" = true; then
5974 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5976 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5977 if ! test -d build-aux; then
5978 func_execute_command mkdir build-aux || func_exit 1
5980 func_execute_command ${AUTOCONF} || func_exit 1
5981 func_execute_command ${AUTOHEADER} || func_exit 1
5982 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5984 if test -n "$inctests" && ! $single_configure; then
5985 # Create autogenerated files.
5986 (cd "$testdir/$testsbase" || func_exit 1
5987 # Do not use "${AUTORECONF} --force --install", because it may invoke
5988 # autopoint, which brings in older versions of some of our .m4 files.
5989 if test -f ../$m4base/gettext.m4; then
5990 func_execute_command ${AUTOPOINT} --force || func_exit 1
5991 for f in ../$m4base/*.m4~; do
5993 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5997 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5998 if ! test -d ../build-aux; then
5999 func_execute_command mkdir ../build-aux
6001 func_execute_command ${AUTOCONF} || func_exit 1
6002 func_execute_command ${AUTOHEADER} || func_exit 1
6003 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6006 # Need to run configure and make once, to create built files that are to be
6007 # distributed (such as parse-datetime.c).
6008 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6009 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6010 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6011 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6012 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6013 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6014 # such $(FOO_H) because they don't refer to distributed files.
6015 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6016 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6017 | sed -e "$sed_remove_make_variables"`
6018 distributed_built_sources=`for file in $built_sources; do
6019 case "$cleaned_files" in
6024 tests_distributed_built_sources=
6025 if test -n "$inctests"; then
6026 # Likewise for built files in the $testsbase directory.
6027 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6028 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6029 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6030 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6031 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6032 | sed -e "$sed_remove_make_variables"`
6033 tests_distributed_built_sources=`for file in $tests_built_sources; do
6034 case "$tests_cleaned_files" in
6040 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6042 ./configure || func_exit 1
6043 if test -n "$distributed_built_sources"; then
6045 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6046 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6051 if test -n "$tests_distributed_built_sources"; then
6053 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6054 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6059 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6066 # func_create_megatestdir megatestdir allmodules
6068 # - local_gnulib_dir from --local-dir
6069 # - modcache true or false, from --cache-modules/--no-cache-modules
6070 # - auxdir directory relative to destdir where to place build aux files
6071 func_create_megatestdir ()
6075 if test -z "$allmodules"; then
6076 allmodules=`func_all_modules`
6080 # First, all modules one by one.
6081 for onemodule in $allmodules; do
6082 func_create_testdir "$megatestdir/$onemodule" $onemodule
6083 func_append megasubdirs "$onemodule "
6085 # Then, all modules all together.
6086 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6087 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6088 func_create_testdir "$megatestdir/ALL" "$allmodules"
6089 func_append megasubdirs "ALL"
6092 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
6093 vc_witness="$gnulib_dir/CVS/Entries"; \
6095 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6097 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6098 | sed -e 's,January,01,' -e 's,Jan,01,' \
6099 -e 's,February,02,' -e 's,Feb,02,' \
6100 -e 's,March,03,' -e 's,Mar,03,' \
6101 -e 's,April,04,' -e 's,Apr,04,' \
6103 -e 's,June,06,' -e 's,Jun,06,' \
6104 -e 's,July,07,' -e 's,Jul,07,' \
6105 -e 's,August,08,' -e 's,Aug,08,' \
6106 -e 's,September,09,' -e 's,Sep,09,' \
6107 -e 's,October,10,' -e 's,Oct,10,' \
6108 -e 's,November,11,' -e 's,Nov,11,' \
6109 -e 's,December,12,' -e 's,Dec,12,' \
6110 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6111 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6113 echo "CVSDATE=$cvsdate"
6114 echo ": \${MAKE=make}"
6115 echo "test -d logs || mkdir logs"
6116 echo "for module in $megasubdirs; do"
6117 echo " echo \"Working on module \$module...\""
6118 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6119 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6122 echo " : autobuild project... \$module"
6123 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6124 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6125 echo " : autobuild hostname... \`hostname\`"
6126 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6128 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6130 ) > "$megatestdir/do-autobuild"
6131 chmod a+x "$megatestdir/do-autobuild"
6133 # Create Makefile.am.
6134 (echo "## Process this file with automake to produce Makefile.in."
6136 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
6138 echo "SUBDIRS = $megasubdirs"
6140 echo "EXTRA_DIST = do-autobuild"
6141 ) > "$megatestdir/Makefile.am"
6143 # Create configure.ac.
6144 (echo "# Process this file with autoconf to produce a configure script."
6145 echo "AC_INIT([dummy], [0])"
6146 if test "$auxdir" != "."; then
6147 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6149 echo "AM_INIT_AUTOMAKE"
6151 echo "AC_PROG_MAKE_SET"
6153 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6154 echo "AC_CONFIG_FILES([Makefile])"
6156 ) > "$megatestdir/configure.ac"
6158 # Create autogenerated files.
6160 # Do not use "${AUTORECONF} --install", because autoreconf operates
6161 # recursively, but the subdirectories are already finished, therefore
6162 # calling autoreconf here would only waste lots of CPU time.
6163 func_execute_command ${ACLOCAL} || func_exit 1
6164 func_execute_command mkdir build-aux
6165 func_execute_command ${AUTOCONF} || func_exit 1
6166 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6172 func_fatal_error "no mode specified" ;;
6179 # sed expression that converts a literal to a basic regular expression.
6180 # Needs to handle . [ \ * ^ $.
6181 sed_literal_to_basic_regex='s/\\/\\\\/g
6187 if test -f "$gnulib_dir/$filename" \
6188 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
6189 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6190 filename_line_regex='^'"$filename_anywhere_regex"'$'
6193 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6194 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
6195 (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$,,')
6198 | func_sanitize_modulelist \
6201 for module in $module_candidates; do
6202 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6207 func_warning "file $filename does not exist"
6212 import | add-import | remove-import | update )
6215 if test -z "$destdir"; then
6218 test -d "$destdir" \
6219 || func_fatal_error "destination directory does not exist: $destdir"
6221 # Prefer configure.ac to configure.in.
6222 if test -f "$destdir"/configure.ac; then
6223 configure_ac="$destdir/configure.ac"
6225 if test -f "$destdir"/configure.in; then
6226 configure_ac="$destdir/configure.in"
6228 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6232 # Analyze configure.ac.
6234 guessed_libtool=false
6239 /AC_CONFIG_AUX_DIR/ {
6240 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6242 /A[CM]_PROG_LIBTOOL/ {
6243 s,^.*$,guessed_libtool=true,p
6245 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6247 if test -z "$auxdir"; then
6248 auxdir="$guessed_auxdir"
6251 # Determine where to apply func_import.
6252 if test "$mode" = import; then
6253 # Apply func_import to a particular gnulib directory.
6254 # The command line contains the complete specification; don't look at
6255 # the contents of gnulib-cache.m4.
6256 test -n "$supplied_libname" || supplied_libname=true
6257 test -n "$sourcebase" || sourcebase="lib"
6258 test -n "$m4base" || m4base="m4"
6259 test -n "$docbase" || docbase="doc"
6260 test -n "$testsbase" || testsbase="tests"
6261 test -n "$macro_prefix" || macro_prefix="gl"
6264 if test -n "$m4base"; then
6265 # Apply func_import to a particular gnulib directory.
6266 # Any number of additional modules can be given.
6267 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6268 # First use of gnulib in the given m4base.
6269 test -n "$supplied_libname" || supplied_libname=true
6270 test -n "$sourcebase" || sourcebase="lib"
6271 test -n "$docbase" || docbase="doc"
6272 test -n "$testsbase" || testsbase="tests"
6273 test -n "$macro_prefix" || macro_prefix="gl"
6277 # Apply func_import to all gnulib directories.
6278 # To get this list of directories, look at Makefile.am. (Not at
6279 # configure, because it may be omitted from version control. Also,
6280 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6284 if test -f "$destdir"/Makefile.am; then
6285 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6287 for arg in $aclocal_amflags; do
6288 if test -n "$m4dir_is_next"; then
6289 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6293 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6294 func_append m4dirs " $arg"
6295 m4dirs_count=`expr $m4dirs_count + 1`
6301 if test "X$arg" = "X-I"; then
6309 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6310 if test -f "$destdir"/aclocal.m4; then
6311 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6312 sedexpr2='s,^[^/]*$,.,'
6313 sedexpr3='s,/[^/]*$,,'
6314 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6315 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6316 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6319 if test $m4dirs_count = 0; then
6320 # First use of gnulib in a package.
6321 # Any number of additional modules can be given.
6322 test -n "$supplied_libname" || supplied_libname=true
6323 test -n "$sourcebase" || sourcebase="lib"
6325 test -n "$docbase" || docbase="doc"
6326 test -n "$testsbase" || testsbase="tests"
6327 test -n "$macro_prefix" || macro_prefix="gl"
6330 if test $m4dirs_count = 1; then
6331 # There's only one use of gnulib here. Assume the user means it.
6332 # Any number of additional modules can be given.
6333 for m4base in $m4dirs; do
6337 # Ambiguous - guess what the user meant.
6338 if test $# = 0; then
6339 # No further arguments. Guess the user wants to update all of them.
6340 for m4base in $m4dirs; do
6341 # Perform func_import in a subshell, so that variable values
6343 # local_gnulib_dir, incobsolete, inc_cxx_tests,
6344 # inc_longrunning_tests, inc_privileged_tests,
6345 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6346 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6347 # makefile_name, libtool, macro_prefix, po_domain,
6348 # witness_c_macro, vc_files
6349 # don't propagate from one directory to another.
6350 (func_import) || func_exit 1
6354 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6363 if test -z "$destdir"; then
6364 func_fatal_error "please specify --dir option"
6367 test -d "$destdir" \
6368 || func_fatal_error "could not create destination directory"
6369 test -n "$auxdir" || auxdir="build-aux"
6370 func_create_testdir "$destdir" "$*"
6373 create-megatestdir )
6374 if test -z "$destdir"; then
6375 func_fatal_error "please specify --dir option"
6377 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6378 test -n "$auxdir" || auxdir="build-aux"
6379 func_create_megatestdir "$destdir" "$*"
6383 test -n "$destdir" || destdir=testdir$$
6384 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6385 test -n "$auxdir" || auxdir="build-aux"
6386 func_create_testdir "$destdir" "$*"
6390 ../configure || func_exit 1
6391 $MAKE || func_exit 1
6392 $MAKE check || func_exit 1
6393 $MAKE distclean || func_exit 1
6394 remaining=`find . -type f -print`
6395 if test -n "$remaining"; then
6396 echo "Remaining files:" $remaining 1>&2
6397 echo "gnulib-tool: *** Stop." 1>&2
6406 test -n "$destdir" || destdir=testdir$$
6407 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6408 test -n "$auxdir" || auxdir="build-aux"
6409 func_create_megatestdir "$destdir" "$*"
6417 remaining=`find . -type f -print`
6418 if test -n "$remaining"; then
6419 echo "Remaining files:" $remaining 1>&2
6420 echo "gnulib-tool: *** Stop." 1>&2
6428 extract-description )
6432 if test -n "$module"; then
6433 func_get_description "$module"
6442 if test -n "$module"; then
6443 func_get_comment "$module"
6452 if test -n "$module"; then
6453 func_get_status "$module"
6462 if test -n "$module"; then
6463 func_get_notice "$module"
6468 extract-applicability )
6472 if test -n "$module"; then
6473 func_get_applicability "$module"
6482 if test -n "$module"; then
6483 func_get_filelist "$module"
6488 extract-dependencies )
6492 if test -n "$module"; then
6493 func_get_dependencies "$module"
6498 extract-autoconf-snippet )
6502 if test -n "$module"; then
6503 func_get_autoconf_snippet "$module"
6508 extract-automake-snippet )
6512 if test -n "$module"; then
6513 func_get_automake_snippet "$module"
6518 extract-include-directive )
6522 if test -n "$module"; then
6523 func_get_include_directive "$module"
6528 extract-link-directive )
6532 if test -n "$module"; then
6533 func_get_link_directive "$module"
6542 if test -n "$module"; then
6543 func_get_license "$module"
6548 extract-maintainer )
6552 if test -n "$module"; then
6553 func_get_maintainer "$module"
6558 extract-tests-module )
6562 if test -n "$module"; then
6563 func_get_tests_module "$module"
6569 # Verify the number of arguments.
6570 if test $# -lt 1 || test $# -gt 2; then
6571 func_fatal_error "invalid number of arguments for --$mode"
6574 # The first argument is the file to be copied.
6576 # Verify the file exists.
6577 func_lookup_file "$f"
6579 # The second argument is the destination; either a directory ot a file.
6580 # It defaults to the current directory.
6582 test -n "$dest" || dest='.'
6583 test -n "$sourcebase" || sourcebase="lib"
6584 test -n "$m4base" || m4base="m4"
6585 test -n "$docbase" || docbase="doc"
6586 test -n "$testsbase" || testsbase="tests"
6587 test -n "$auxdir" || auxdir="build-aux"
6588 rewritten='%REWRITTEN%'
6589 sed_rewrite_files="\
6590 s,^build-aux/,$rewritten$auxdir/,
6591 s,^doc/,$rewritten$docbase/,
6592 s,^lib/,$rewritten$sourcebase/,
6593 s,^m4/,$rewritten$m4base/,
6594 s,^tests/,$rewritten$testsbase/,
6597 if test -d "$dest"; then
6599 g=`echo "$f" | sed -e "$sed_rewrite_files"`
6601 destdir=`dirname "$dest"`
6602 g=`basename "$dest"`
6605 # Create the directory for destfile.
6606 d=`dirname "$destdir/$g"`
6608 if test -n "$d" && test ! -d "$d"; then
6609 mkdir -p "$d" || func_fatal_error "failed"
6613 func_dest_tmpfilename "$g"
6614 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
6615 already_present=true
6616 if test -f "$destdir/$g"; then
6617 # The file already exists.
6621 # Don't protest if the file should be there but isn't: it happens
6622 # frequently that developers don't put autogenerated files under version
6630 func_fatal_error "unknown operation mode --$mode" ;;
6634 # Undo the effect of the previous 'trap' command. Some shellology:
6635 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6636 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6637 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6638 # 128 + signal number and is set before the trap-registered command is run.
6640 trap 'func_exit $?' 1 2 3 13 15
6645 # indent-tabs-mode: nil
6646 # whitespace-check-buffer-indent: nil