3 # Copyright (C) 2002-2010 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.
126 # This use of bold display can be removed on 2011-01-01.
131 # Assume xterm compatible escape sequences.
132 bold_on=`printf '\x1b[1m'`
133 bold_off=`printf '\x1b[0m'`
139 Usage: gnulib-tool --list
140 gnulib-tool --find filename${bold_on}
141 gnulib-tool --import [module1 ... moduleN]
142 gnulib-tool --add-import [module1 ... moduleN]
143 gnulib-tool --remove-import [module1 ... moduleN]${bold_off}
145 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
146 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
147 gnulib-tool --test --dir=directory module1 ... moduleN
148 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
149 gnulib-tool --extract-description module
150 gnulib-tool --extract-comment module
151 gnulib-tool --extract-status module
152 gnulib-tool --extract-notice module
153 gnulib-tool --extract-applicability module
154 gnulib-tool --extract-filelist module
155 gnulib-tool --extract-dependencies module
156 gnulib-tool --extract-autoconf-snippet module
157 gnulib-tool --extract-automake-snippet module
158 gnulib-tool --extract-include-directive module
159 gnulib-tool --extract-link-directive module
160 gnulib-tool --extract-license module
161 gnulib-tool --extract-maintainer module
162 gnulib-tool --extract-tests-module module
163 gnulib-tool --copy-file file [destination]
166 --list print the available module names
167 --find find the modules which contain the specified file${bold_on}
168 --import import the given modules into the current package
169 --add-import augment the list of imports from gnulib into the
170 current package, by adding the given modules;
171 if no modules are specified, update the current
172 package from the current gnulib
173 --remove-import reduce the list of imports from gnulib into the
174 current package, by removing the given modules${bold_off}
175 --update update the current package, restore files omitted
177 --create-testdir create a scratch package with the given modules
178 --create-megatestdir create a mega scratch package with the given modules
179 one by one and all together
180 --test test the combination of the given modules
181 (recommended to use CC=\"gcc -Wall\" here)
182 --megatest test the given modules one by one and all together
183 (recommended to use CC=\"gcc -Wall\" here)
184 --extract-description extract the description
185 --extract-comment extract the comment
186 --extract-status extract the status (obsolete etc.)
187 --extract-notice extract the notice or banner
188 --extract-applicability extract the applicability
189 --extract-filelist extract the list of files
190 --extract-dependencies extract the dependencies
191 --extract-autoconf-snippet extract the snippet for configure.ac
192 --extract-automake-snippet extract the snippet for library makefile
193 --extract-include-directive extract the #include directive
194 --extract-link-directive extract the linker directive
195 --extract-license report the license terms of the source files
197 --extract-maintainer report the maintainer(s) inside gnulib
198 --extract-tests-module report the unit test module, if it exists
199 --copy-file copy a file that is not part of any module
202 --dir=DIRECTORY Specify the target directory.
203 For --import, this specifies where your
204 configure.ac can be found. Defaults to current
206 --local-dir=DIRECTORY Specify a local override directory where to look
207 up files before looking in gnulib's directory.
208 --cache-modules Enable module caching optimization.
209 --no-cache-modules Disable module caching optimization.
210 --verbose Increase verbosity. May be repeated.
211 --quiet Decrease verbosity. May be repeated.
213 Options for --import, --update:
214 --dry-run Only print what would have been done.
216 Options for --import, --create-[mega]testdir, --[mega]test:
217 --with-tests Include unit tests for the included modules.
218 --with-obsolete Include obsolete modules when they occur among the
219 dependencies. By default, dependencies to obsolete
221 --with-c++-tests Include even unit tests for C++ interoperability.
222 --with-longrunning-tests
223 Include even unit tests that are long-runners.
224 --with-privileged-tests
225 Include even unit tests that require root
227 --with-unportable-tests
228 Include even unit tests that fail on some platforms.
229 --with-all-tests Include all kinds of problematic unit tests.
230 --avoid=MODULE Avoid including the given MODULE. Useful if you
231 have code that provides equivalent functionality.
232 This option can be repeated.
233 --libtool Use libtool rules.
234 --no-libtool Don't use libtool rules.
236 Options for --import:
237 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
238 --source-base=DIRECTORY
239 Directory relative to --dir where source code is
240 placed (default \"lib\").
241 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
242 placed (default \"m4\").
243 --po-base=DIRECTORY Directory relative to --dir where *.po files are
244 placed (default \"po\").
245 --doc-base=DIRECTORY Directory relative to --dir where doc files are
246 placed (default \"doc\").
247 --tests-base=DIRECTORY
248 Directory relative to --dir where unit tests are
249 placed (default \"tests\").
250 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
251 tools are placed (default \"build-aux\").
252 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
253 Also modify license template from GPL to LGPL.
254 The version number of the LGPL can be specified;
255 the default is currently LGPLv3.
256 --makefile-name=NAME Name of makefile in automake syntax in the
257 source-base and tests-base directories
258 (default \"Makefile.am\").
259 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
260 'gl_INIT'. Default is 'gl'.
261 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
262 the package name. A suffix '-gnulib' is appended.
263 --vc-files Update version control related files.
264 --no-vc-files Don't update version control related files
265 (.gitignore and/or .cvsignore).
266 --no-changelog Don't update or create ChangeLog files.
268 Options for --create-[mega]testdir, --[mega]test:
269 --without-c++-tests Exclude unit tests for C++ interoperability.
270 --without-longrunning-tests
271 Exclude unit tests that are long-runners.
272 --without-privileged-tests
273 Exclude unit tests that require root privileges.
274 --without-unportable-tests
275 Exclude unit tests that fail on some platforms.
277 Options for --import, --update, --create-[mega]testdir, --[mega]test:
278 -s, --symbolic, --symlink Make symbolic links instead of copying files.
279 --local-symlink Make symbolic links instead of copying files, only
280 for files from the local override directory.
282 Options for --import, --update:
283 -S, --more-symlinks Make symbolic links instead of copying files, and
284 don't replace copyright notices.
286 Report bugs to <bug-gnulib@gnu.org>."
290 # outputs to stdout the --version message.
294 if test -d "$gnulib_dir"/.git \
295 && (git --version) >/dev/null 2>/dev/null \
296 && (date --version) >/dev/null 2>/dev/null; then
297 # gnulib checked out from git.
298 sed_extract_first_date='/^Date/{
302 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
303 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
304 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
305 date=`echo "$date" | sed -e "$sed_year_before_time"`
306 # Use GNU date to compute the time in GMT.
307 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
308 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
310 if test -d "$gnulib_dir"/CVS \
311 && (cvs --version) >/dev/null 2>/dev/null; then
312 # gnulib checked out from CVS.
313 sed_extract_first_date='/^date: /{
314 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
317 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
319 # gnulib copy without versioning information.
320 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
324 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
326 gnulib-tool (GNU $package $date)$version
327 Copyright (C) $year Free Software Foundation, Inc.
328 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
329 This is free software: you are free to change and redistribute it.
330 There is NO WARRANTY, to the extent permitted by law.
332 Written by" "Bruno Haible" "and" "Simon Josefsson"
335 # func_emit_copyright_notice
336 # outputs to stdout a header for a generated file.
337 func_emit_copyright_notice ()
339 sed -n -e '/Copyright/ {
342 }' < "$self_abspathname"
344 echo "# This file is free software, distributed under the terms of the GNU"
345 echo "# General Public License. As a special exception to the GNU General"
346 echo "# Public License, this file may be distributed as part of a program"
347 echo "# that contains a configuration script generated by Autoconf, under"
348 echo "# the same distribution terms as the rest of that program."
350 echo "# Generated by gnulib-tool."
354 # exits with a given status.
355 # This function needs to be used, rather than 'exit', when a 'trap' handler is
356 # in effect that refers to $?.
363 # locates the directory where the gnulib repository lives
365 # - progname name of this program
367 # - self_abspathname absolute pathname of gnulib-tool
368 # - gnulib_dir absolute pathname of gnulib repository
372 /*) self_abspathname="$progname" ;;
373 */*) self_abspathname=`pwd`/"$progname" ;;
376 # Iterate through the elements of $PATH.
377 # We use IFS=: instead of
378 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
379 # because the latter does not work when some PATH element contains spaces.
380 # We use a canonicalized $pathx instead of $PATH, because empty PATH
381 # elements are by definition equivalent to '.', however field splitting
382 # according to IFS=: loses empty fields in many shells:
383 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
384 # beginning, at the end, and in the middle),
385 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
386 # at the beginning and at the end,
387 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
388 # Solaris lose empty fields at the end.
389 # The 'case' statement is an optimization, to avoid evaluating the
390 # explicit canonicalization command when $PATH contains no empty fields.
392 if test "${PATH_SEPARATOR+set}" != set; then
393 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
394 # contains only /bin. Note that ksh looks also at the FPATH variable,
395 # so we have to set that as well for the test.
397 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
398 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
399 || PATH_SEPARATOR=';'
402 if test "$PATH_SEPARATOR" = ";"; then
403 # On Windows, programs are searched in "." before $PATH.
406 # On Unix, we have to convert empty PATH elements to ".".
410 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
415 IFS="$PATH_SEPARATOR"
419 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
420 self_abspathname="$d/$progname"
425 if test -z "$self_abspathname"; then
426 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
430 while test -h "$self_abspathname"; do
431 # Resolve symbolic link.
432 linkval=`func_readlink "$self_abspathname"`
433 test -n "$linkval" || break
435 /* ) self_abspathname="$linkval" ;;
436 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
439 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
443 # creates a temporary directory.
445 # - progname name of this program
447 # - tmp pathname of freshly created temporary directory
450 # Use the environment variable TMPDIR, falling back to /tmp. This allows
451 # users to specify a different temporary directory, for example, if their
452 # /tmp is filled up or too small.
455 # Use the mktemp program if available. If not available, hide the error
457 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
458 test -n "$tmp" && test -d "$tmp"
461 # Use a simple mkdir command. It is guaranteed to fail if the directory
462 # already exists. $RANDOM is bash specific and expands to empty in shells
463 # other than bash, ksh and zsh. Its use does not increase security;
464 # rather, it minimizes the probability of failure in a very cluttered /tmp
466 tmp=$TMPDIR/gl$$-$RANDOM
467 (umask 077 && mkdir "$tmp")
470 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
475 # func_append var value
476 # appends the given value to the shell variable var.
477 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
478 # Use bash's += operator. It reduces complexity of appending repeatedly to
479 # a single variable from O(n^2) to O(n).
484 fast_func_append=true
488 eval "$1=\"\$$1\$2\""
490 fast_func_append=false
493 # func_remove_prefix var prefix
494 # removes the given prefix from the value of the shell variable var.
495 # var should be the name of a shell variable.
496 # Its value should not contain a newline and not start or end with whitespace.
497 # prefix should not contain the characters "$`\{}[]^|.
498 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
499 func_remove_prefix ()
503 fast_func_remove_prefix=true
505 func_remove_prefix ()
507 eval "value=\"\$$1\""
511 sed_escape_dots='s/\([.]\)/\\\1/g'
512 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
515 value=`echo "$value" | sed -e "s|^${prefix}||"`
516 eval "$1=\"\$value\""
518 fast_func_remove_prefix=false
521 # func_remove_suffix var suffix
522 # removes the given suffix from the value of the shell variable var.
523 # var should be the name of a shell variable.
524 # Its value should not contain a newline and not start or end with whitespace.
525 # suffix should not contain the characters "$`\{}[]^|.
526 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
527 func_remove_suffix ()
531 fast_func_remove_suffix=true
533 func_remove_suffix ()
535 eval "value=\"\$$1\""
539 sed_escape_dots='s/\([.]\)/\\\1/g'
540 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
543 value=`echo "$value" | sed -e "s|${suffix}\$||"`
544 eval "$1=\"\$value\""
546 fast_func_remove_suffix=false
549 # func_fatal_error message
550 # outputs to stderr a fatal error message, and terminates the program.
552 # - progname name of this program
555 echo "$progname: *** $1" 1>&2
556 echo "$progname: *** Stop." 1>&2
560 # func_warning message
561 # Outputs to stderr a warning message,
564 echo "gnulib-tool: warning: $1" 1>&2
567 # func_readlink SYMLINK
568 # outputs the target of the given symlink.
569 if (type -p readlink) > /dev/null 2>&1; then
572 # Use the readlink program from GNU coreutils.
578 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
579 # would do the wrong thing if the link target contains " -> ".
580 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
584 # func_relativize DIR1 DIR2
585 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
587 # - DIR1 relative pathname, relative to the current directory
588 # - DIR2 relative pathname, relative to the current directory
590 # - reldir relative pathname of DIR2, relative to DIR1
596 sed_first='s,^\([^/]*\)/.*$,\1,'
597 sed_rest='s,^[^/]*/*,,'
598 sed_last='s,^.*/\([^/]*\)$,\1,'
599 sed_butlast='s,/*[^/]*$,,'
600 while test -n "$dir1"; do
601 first=`echo "$dir1" | sed -e "$sed_first"`
602 if test "$first" != "."; then
603 if test "$first" = ".."; then
604 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
605 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
607 first2=`echo "$dir2" | sed -e "$sed_first"`
608 if test "$first2" = "$first"; then
609 dir2=`echo "$dir2" | sed -e "$sed_rest"`
613 dir0="$dir0"/"$first"
616 dir1=`echo "$dir1" | sed -e "$sed_rest"`
621 # func_relconcat DIR1 DIR2
622 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
624 # - DIR1 relative pathname, relative to the current directory
625 # - DIR2 relative pathname, relative to DIR1
627 # - relconcat DIR1/DIR2, relative to the current directory
632 sed_first='s,^\([^/]*\)/.*$,\1,'
633 sed_rest='s,^[^/]*/*,,'
634 sed_last='s,^.*/\([^/]*\)$,\1,'
635 sed_butlast='s,/*[^/]*$,,'
637 first=`echo "$dir2" | sed -e "$sed_first"`
638 if test "$first" = "."; then
639 dir2=`echo "$dir2" | sed -e "$sed_rest"`
640 if test -z "$dir2"; then
645 last=`echo "$dir1" | sed -e "$sed_last"`
646 while test "$last" = "."; do
647 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
648 last=`echo "$dir1" | sed -e "$sed_last"`
650 if test -z "$dir1"; then
654 if test "$first" = ".."; then
655 if test "$last" = ".."; then
656 relconcat="$dir1/$dir2"
659 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
660 dir2=`echo "$dir2" | sed -e "$sed_rest"`
661 if test -z "$dir1"; then
665 if test -z "$dir2"; then
670 relconcat="$dir1/$dir2"
678 # Like ln -s, except that SRC is given relative to the current directory (or
679 # absolute), not given relative to the directory of DEST.
685 *) # SRC is relative.
688 ln -s "`pwd`/$1" "$2" ;;
689 *) # DEST is relative too.
690 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
691 test -n "$ln_destdir" || ln_destdir="."
692 func_relativize "$ln_destdir" "$1"
700 # func_ln_if_changed SRC DEST
701 # Like func_ln, but avoids munging timestamps if the link is correct.
702 func_ln_if_changed ()
704 if test $# -ne 2; then
705 echo "usage: func_ln_if_changed SRC DEST" >&2
707 ln_target=`func_readlink "$2"`
708 if test -h "$2" && test "$1" = "$ln_target"; then
716 # Ensure an 'echo' command that
717 # 1. does not interpret backslashes and
718 # 2. does not print an error message "broken pipe" when writing into a pipe
721 # Test cases for problem 1:
722 # echo '\n' | wc -l prints 1 when OK, 2 when KO
723 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
724 # Test cases for problem 2:
725 # echo hi | true frequently prints
726 # "bash: echo: write error: Broken pipe"
727 # to standard error in bash 3.2.
729 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
730 # BSD echo interprets '-n' as an option, which is also not desirable).
731 # Nowadays the problem occurs in 4 situations:
732 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
733 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
734 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
735 # - in zsh, when sh-emulation is not set,
736 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
737 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
738 # - in Solaris /bin/sh and OSF/1 /bin/sh.
739 # We try the following workarounds:
740 # - for all: respawn using $CONFIG_SHELL if that is set and works.
741 # - for bash >= 2.04: unset the shell option xpg_echo.
742 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
743 # - for bash < 2.0: define echo to a function that uses cat of a here document.
744 # - for zsh: turn sh-emulation on.
745 # - for ksh: alias echo to 'print -r'.
746 # - for ksh: alias echo to a function that uses cat of a here document.
747 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
748 # the ksh workaround.
749 # - otherwise: respawn using /bin/sh and rely on the workarounds.
750 # When respawning, we pass --no-reexec as first argument, so as to avoid
751 # turning this script into a fork bomb in unlucky situations.
753 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
754 # the 'printf' built-in. See
755 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
756 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
757 # The workaround is: define echo to a function that uses the printf built-in.
759 if echo '\t' | grep t > /dev/null; then
760 have_echo=yes # Lucky!
762 # Try the workarounds.
763 # Respawn using $CONFIG_SHELL if that is set and works.
764 if test -z "$have_echo" \
765 && test "X$1" != "X--no-reexec" \
766 && test -n "$CONFIG_SHELL" \
767 && test -f "$CONFIG_SHELL" \
768 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
769 exec $CONFIG_SHELL "$0" --no-reexec "$@"
772 # For bash >= 2.04: unset the shell option xpg_echo.
773 if test -z "$have_echo" \
774 && test -n "$BASH_VERSION" \
775 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
779 # For bash >= 2.0: define echo to a function that uses the printf built-in.
780 # For bash < 2.0: define echo to a function that uses cat of a here document.
781 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
782 # Also handle problem 2, specific to bash 3.2, here.
783 if { test -z "$have_echo" \
784 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
786 && test -n "$BASH_VERSION"; then \
787 if type printf 2>/dev/null | grep / > /dev/null; then
788 # 'printf' is not a shell built-in.
796 # 'printf' is a shell built-in.
802 if echo '\t' | grep t > /dev/null; then
806 # For zsh: turn sh-emulation on.
807 if test -z "$have_echo" \
808 && test -n "$ZSH_VERSION" \
809 && (emulate sh) >/dev/null 2>&1; then
812 # For ksh: alias echo to 'print -r'.
813 if test -z "$have_echo" \
814 && (type print) >/dev/null 2>&1; then
815 # A 'print' command exists.
816 if type print 2>/dev/null | grep / > /dev/null; then
819 # 'print' is a shell built-in.
820 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
821 # 'print' is the ksh shell built-in.
822 alias echo='print -r'
826 if test -z "$have_echo" \
827 && echo '\t' | grep t > /dev/null; then
830 # For ksh: alias echo to a function that uses cat of a here document.
831 # The ksh manual page says:
832 # "Aliasing is performed when scripts are read, not while they are executed.
833 # Therefore, for an alias to take effect, the alias definition command has
834 # to be executed before the command which references the alias is read."
835 # Because of this, we have to play strange tricks with have_echo, to ensure
836 # that the top-level statement containing the test starts after the 'alias'
838 if test -z "$have_echo"; then
845 if (alias echo=bsd_echo) 2>/dev/null; then
846 alias echo=bsd_echo 2>/dev/null
849 if test -z "$have_echo" \
850 && echo '\t' | grep t > /dev/null; then
853 if test -z "$have_echo"; then
854 if (alias echo=bsd_echo) 2>/dev/null; then
855 unalias echo 2>/dev/null
858 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
859 if test -z "$have_echo" \
860 && test "X$1" != "X--no-reexec" \
861 && test -f /bin/ksh; then
862 exec /bin/ksh "$0" --no-reexec "$@"
865 # Otherwise: respawn using /bin/sh.
866 if test -z "$have_echo" \
867 && test "X$1" != "X--no-reexec" \
868 && test -f /bin/sh; then
869 exec /bin/sh "$0" --no-reexec "$@"
872 if test -z "$have_echo"; then
873 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
875 if echo '\t' | grep t > /dev/null; then
878 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
880 if test "X$1" = "X--no-reexec"; then
884 # Command-line option processing.
885 # Removes the OPTIONS from the arguments. Sets the variables:
886 # - mode list or import or add-import or remove-import or update
887 # or create-testdir or create-megatestdir
888 # - destdir from --dir
889 # - local_gnulib_dir from --local-dir
890 # - modcache true or false, from --cache-modules/--no-cache-modules
891 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
892 # - libname, supplied_libname from --lib
893 # - sourcebase from --source-base
894 # - m4base from --m4-base
895 # - pobase from --po-base
896 # - docbase from --doc-base
897 # - testsbase from --tests-base
898 # - auxdir from --aux-dir
899 # - inctests true if --with-tests was given, blank otherwise
900 # - incobsolete true if --with-obsolete was given, blank otherwise
901 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
902 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
904 # - inc_privileged_tests true if --with-privileged-tests was given, blank
906 # - inc_unportable_tests true if --with-unportable-tests was given, blank
908 # - inc_all_tests true if --with-all-tests was given, blank otherwise
909 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
910 # - excl_longrunning_tests true if --without-longrunning-tests was given,
912 # - excl_privileged_tests true if --without-privileged-tests was given, blank
914 # - excl_unportable_tests true if --without-unportable-tests was given, blank
916 # - avoidlist list of modules to avoid, from --avoid
917 # - lgpl yes or a number if --lgpl was given, blank otherwise
918 # - makefile_name from --makefile-name
919 # - libtool true if --libtool was given, false if --no-libtool was
920 # given, blank otherwise
921 # - macro_prefix from --macro-prefix
922 # - po_domain from --po-domain
923 # - vc_files true if --vc-files was given, false if --no-vc-files was
924 # given, blank otherwise
925 # - autoconf_minversion minimum supported autoconf version
926 # - do_changelog false if --no-changelog was given, : otherwise
927 # - doit : if actions shall be executed, false if only to be printed
928 # - symbolic true if --symlink or --more-symlinks was given, blank
930 # - lsymbolic true if --local-symlink was given, blank otherwise
931 # - do_copyrights blank if --more-symlinks was given, true otherwise
949 inc_longrunning_tests=
950 inc_privileged_tests=
951 inc_unportable_tests=
954 excl_longrunning_tests=
955 excl_privileged_tests=
956 excl_unportable_tests=
972 while test $# -gt 0; do
977 --find | --fin | --fi | --f )
980 --import | --impor | --impo | --imp | --im | --i )
983 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
986 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
989 --update | --updat | --upda | --upd | --up | --u )
992 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
995 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
996 mode=create-megatestdir
998 --test | --tes | --te | --t )
1001 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1005 mode=`echo "X$1" | sed -e 's/^X--//'`
1007 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
1012 if test $# = 0; then
1013 func_fatal_error "missing argument for --dir"
1018 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1022 if test $# = 0; then
1023 func_fatal_error "missing argument for --local-dir"
1028 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1030 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1033 --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 )
1036 --verbose | --verbos | --verbo | --verb )
1037 verbose=`expr $verbose + 1`
1039 --quiet | --quie | --qui | --qu | --q )
1040 verbose=`expr $verbose - 1`
1044 if test $# = 0; then
1045 func_fatal_error "missing argument for --lib"
1048 supplied_libname=true
1051 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1052 supplied_libname=true
1056 if test $# = 0; then
1057 func_fatal_error "missing argument for --source-base"
1062 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1066 if test $# = 0; then
1067 func_fatal_error "missing argument for --m4-base"
1072 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1076 if test $# = 0; then
1077 func_fatal_error "missing argument for --po-base"
1082 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1086 if test $# = 0; then
1087 func_fatal_error "missing argument for --doc-base"
1092 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1096 if test $# = 0; then
1097 func_fatal_error "missing argument for --tests-base"
1102 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1106 if test $# = 0; then
1107 func_fatal_error "missing argument for --aux-dir"
1112 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1114 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1117 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1120 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1123 --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)
1124 inc_longrunning_tests=true
1126 --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)
1127 inc_privileged_tests=true
1129 --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)
1130 inc_unportable_tests=true
1132 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1135 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1138 --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)
1139 excl_longrunning_tests=true
1141 --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)
1142 excl_privileged_tests=true
1144 --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)
1145 excl_unportable_tests=true
1149 if test $# = 0; then
1150 func_fatal_error "missing argument for --avoid"
1152 func_append avoidlist " $1"
1155 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1156 func_append avoidlist " $arg"
1162 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1165 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1171 if test $# = 0; then
1172 func_fatal_error "missing argument for --makefile-name"
1177 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1187 if test $# = 0; then
1188 func_fatal_error "missing argument for --macro-prefix"
1193 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1197 if test $# = 0; then
1198 func_fatal_error "missing argument for --po-domain"
1203 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1211 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1217 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1220 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1223 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1227 --help | --hel | --he | --h )
1230 --version | --versio | --versi | --vers )
1234 # Stop option processing
1238 echo "gnulib-tool: unknown option $1" 1>&2
1239 echo "Try 'gnulib-tool --help' for more information." 1>&2
1246 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1247 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1248 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests"; then
1249 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1250 echo "Try 'gnulib-tool --help' for more information." 1>&2
1254 # This code helps migrating from --import to --add-import or --update. It can
1255 # be removed on 2012-01-01.
1256 if test "$mode" = import && test $# = 0; then
1257 echo "gnulib-tool: cowardly refusing to erase the module list." 1>&2
1258 echo "The meaning of the option '--import' has changed." 1>&2
1259 echo "See the documentation at" 1>&2
1260 echo "<http://www.gnu.org/software/gnulib/manual/html_node/Modified-imports.html>." 1>&2
1261 echo "For updating to a newer version of gnulib, use" 1>&2
1262 echo " gnulib-tool --add-import" 1>&2
1263 echo "For restoring files that were omitted from version control, use" 1>&2
1264 echo " gnulib-tool --update" 1>&2
1267 if test "$mode" = update; then
1268 if test $# != 0; then
1269 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1270 echo "Try 'gnulib-tool --help' for more information." 1>&2
1271 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1272 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1275 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1276 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1277 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1278 || test -n "$inctests" || test -n "$incobsolete" \
1279 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1280 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1281 || test -n "$inc_all_tests" \
1282 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1283 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1284 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1285 || test -n "$macro_prefix" || test -n "$po_domain" \
1286 || test -n "$vc_files"; then
1287 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1288 echo "Try 'gnulib-tool --help' for more information." 1>&2
1289 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1290 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1295 if test -n "$pobase" && test -z "$po_domain"; then
1296 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1297 echo "Try 'gnulib-tool --help' for more information." 1>&2
1300 if test -z "$pobase" && test -n "$po_domain"; then
1301 func_warning "--po-domain has no effect without a --po-base option"
1304 # Determine the minimum supported autoconf version from the project's
1306 DEFAULT_AUTOCONF_MINVERSION="2.59"
1307 autoconf_minversion=
1309 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1310 && test -n "$destdir"; then
1311 if test -f "$destdir"/configure.ac; then
1312 configure_ac="$destdir/configure.ac"
1314 if test -f "$destdir"/configure.in; then
1315 configure_ac="$destdir/configure.in"
1319 if test -f configure.ac; then
1320 configure_ac="configure.ac"
1322 if test -f configure.in; then
1323 configure_ac="configure.in"
1327 if test -n "$configure_ac"; then
1328 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1329 # because when some m4 files are omitted from a version control repository,
1330 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1331 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1332 # autom4te: m4 failed with exit status: 1
1339 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1341 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1342 if test -n "$prereqs"; then
1343 autoconf_minversion=`
1344 for version in $prereqs; do echo $version; done |
1345 LC_ALL=C sort -nru | sed -e 1q
1349 if test -z "$autoconf_minversion"; then
1350 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1352 case "$autoconf_minversion" in
1353 1.* | 2.[0-4]* | 2.5[0-8]*)
1354 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1357 # Remove trailing slashes from the directory names. This is necessary for
1358 # m4base (to avoid an error in func_import) and optional for the others.
1359 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1360 case "$local_gnulib_dir" in
1361 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1363 case "$sourcebase" in
1364 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1367 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1370 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1373 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1375 case "$testsbase" in
1376 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1379 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1385 trap 'exit_status=$?
1386 if test "$signal" != 0; then
1387 echo "caught signal $signal" >&2
1390 exit $exit_status' 0
1391 for signal in 1 2 3 13 15; do
1392 trap '{ signal='$signal'; func_exit 1; }' $signal
1396 # Note: The 'eval' silences stderr output in dash.
1397 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1398 # Zsh 4 and Bash 4 have associative arrays.
1399 have_associative=true
1401 # For other shells, use 'eval' with computed shell variable names.
1402 have_associative=false
1405 # func_lookup_file file
1406 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1409 # - local_gnulib_dir from --local-dir
1411 # - lookedup_file name of the merged (combined) file
1412 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1416 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1417 lookedup_file="$local_gnulib_dir/$lkfile"
1420 if test -f "$gnulib_dir/$lkfile"; then
1421 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1422 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1423 rm -f "$tmp/$lkbase"
1424 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1425 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1426 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1427 lookedup_file="$tmp/$lkbase"
1430 lookedup_file="$gnulib_dir/$lkfile"
1434 func_fatal_error "file $gnulib_dir/$lkfile not found"
1439 # func_sanitize_modulelist
1440 # receives a list of possible module names on standard input, one per line.
1441 # It removes those which are just file names unrelated to modules, and outputs
1442 # the resulting list to standard output, one per line.
1443 func_sanitize_modulelist ()
1445 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1446 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1447 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1448 -e '/^README$/d' -e '/\/README$/d' \
1449 -e '/^TEMPLATE$/d' \
1450 -e '/^TEMPLATE-EXTENDED$/d' \
1451 -e '/^TEMPLATE-TESTS$/d' \
1458 # - local_gnulib_dir from --local-dir
1461 # Filter out metainformation files like README, which are not modules.
1462 # Filter out unit test modules; they can be retrieved through
1463 # --extract-tests-module if desired.
1465 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1466 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1467 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1470 | func_sanitize_modulelist \
1471 | sed -e '/-tests$/d' \
1475 # func_exists_module module
1476 # tests whether a module, given by name, exists
1478 # - local_gnulib_dir from --local-dir
1479 func_exists_module ()
1481 { test -f "$gnulib_dir/modules/$1" \
1482 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1483 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1484 && test "CVS" != "$1" \
1485 && test "ChangeLog" != "$1" \
1486 && test "COPYING" != "$1" \
1487 && test "README" != "$1" \
1488 && test "TEMPLATE" != "$1" \
1489 && test "TEMPLATE-EXTENDED" != "$1" \
1490 && test "TEMPLATE-TESTS" != "$1"
1493 # func_verify_module
1494 # verifies a module name
1496 # - local_gnulib_dir from --local-dir
1497 # - module module name argument
1498 func_verify_module ()
1500 if func_exists_module "$module"; then
1501 # OK, $module is a correct module name.
1502 # Verify that building the module description with 'patch' succeeds.
1503 func_lookup_file "modules/$module"
1505 func_warning "module $module doesn't exist"
1510 # func_verify_nontests_module
1511 # verifies a module name, excluding tests modules
1513 # - local_gnulib_dir from --local-dir
1514 # - module module name argument
1515 func_verify_nontests_module ()
1518 *-tests ) module= ;;
1519 * ) func_verify_module ;;
1523 # func_verify_tests_module
1524 # verifies a module name, considering only tests modules
1526 # - local_gnulib_dir from --local-dir
1527 # - module module name argument
1528 func_verify_tests_module ()
1531 *-tests ) func_verify_module ;;
1536 # Suffix of a sed expression that extracts a particular field from a
1537 # module description.
1538 # A field starts with a line that contains a keyword, such as 'Description',
1539 # followed by a colon and optional whitespace. All following lines, up to
1540 # the next field (or end of file if there is none) form the contents of the
1542 # An absent field is equivalent to a field with empty contents.
1543 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1544 sed_extract_prog=':[ ]*$/ {
1547 s/^Description:[ ]*$//
1551 s/^Applicability:[ ]*$//
1553 s/^Depends-on:[ ]*$//
1554 s/^configure\.ac-early:[ ]*$//
1555 s/^configure\.ac:[ ]*$//
1556 s/^Makefile\.am:[ ]*$//
1560 s/^Maintainer:[ ]*$//
1567 # Piece of a sed expression that converts a field header line to a shell
1569 # NOTE: Keep this in sync with sed_extract_prog above!
1570 sed_extract_field_header='
1571 s/^Description:[ ]*$/description/
1572 s/^Comment:[ ]*$/comment/
1573 s/^Status:[ ]*$/status/
1574 s/^Notice:[ ]*$/notice/
1575 s/^Applicability:[ ]*$/applicability/
1576 s/^Files:[ ]*$/files/
1577 s/^Depends-on:[ ]*$/dependson/
1578 s/^configure\.ac-early:[ ]*$/configureac_early/
1579 s/^configure\.ac:[ ]*$/configureac/
1580 s/^Makefile\.am:[ ]*$/makefile/
1581 s/^Include:[ ]*$/include/
1583 s/^License:[ ]*$/license/
1584 s/^Maintainer:[ ]*$/maintainer/'
1588 if $have_associative; then
1590 # Declare the associative arrays.
1591 declare -A modcache_cached
1592 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1593 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1594 eval "$declare_script"
1598 # func_cache_var module
1599 # computes the cache variable name corresponding to $module.
1600 # Note: This computation can map different module names to the same
1601 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1602 # to protect against this case.
1604 # - cachevar a shell variable name
1605 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1606 # Bash 2.0 and newer, ksh, and zsh support the syntax
1607 # ${param//pattern/replacement}
1608 # as a shorthand for
1609 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1610 # Note: The 'eval' above silences stderr output in dash.
1613 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1620 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1629 # func_init_sed_convert_to_cache_statements
1631 # - modcachevar_assignment
1633 # - sed_convert_to_cache_statements
1634 func_init_sed_convert_to_cache_statements ()
1636 # 'sed' script that turns a module description into shell script
1637 # assignments, suitable to be eval'ed. All active characters are escaped.
1640 # Some module's description
1645 # modcache_description[$1]=\
1646 # 'Some module'"'"'s description
1648 # modcache_files[$1]=\
1651 # c_MODULE_description_set=set; c_MODULE_description=\
1652 # 'Some module'"'"'s description
1654 # c_MODULE_files_set=set; c_MODULE_files=\
1656 # The script consists of two parts:
1657 # 1) Ignore the lines before the first field header.
1658 # 2) A loop, treating non-field-header lines by escaping single quotes
1659 # and adding a closing quote in the last line,
1660 sed_convert_to_cache_statements="
1662 # Here we have not yet seen a field header.
1664 # See if the current line contains a field header.
1667 ${sed_extract_field_header}
1670 # No field header. Ignore the line.
1672 # Read the next line. Upon EOF, just exit.
1677 # The current line contains a field header.
1679 # Turn it into the beginning of an assignment.
1680 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1682 # Move it to the hold space. Don't print it yet,
1683 # because we want no assignment if the field is empty.
1686 # Read the next line.
1687 # Upon EOF, the field was empty. Print no assignment. Just exit.
1690 # See if the current line contains a field header.
1693 ${sed_extract_field_header}
1694 # If it is, the previous field was empty. Print no assignment.
1697 # Not a field header.
1699 # Print the previous line, held in the hold space.
1704 # Transform single quotes.
1707 # Prepend a single quote.
1712 # Move it to the hold space.
1715 # Read the next line.
1722 # See if the current line contains a field header.
1725 ${sed_extract_field_header}
1728 # Print the previous line, held in the hold space.
1733 # Transform single quotes.
1740 # Print the previous line, held in the hold space, with a single quote
1741 # to end the assignment.
1751 # Print the previous line, held in the hold space, with a single quote
1752 # to end the assignment.
1759 if ! $sed_comments; then
1761 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1762 | sed -e 's/^ *//' -e 's/^#.*//'`
1766 if $have_associative; then
1767 # sed_convert_to_cache_statements does not depend on the module.
1768 modcachevar_assignment='modcache_\1[$1]='
1769 func_init_sed_convert_to_cache_statements
1772 # func_cache_lookup_module module
1774 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1775 # of its relevant data in a cache in the memory of the processing shell. If
1776 # already cached, it does not look it up again, thus saving file access time.
1778 # - module non-empty string
1779 # Output if $have_associative:
1780 # - modcache_cached[$module] set to yes
1781 # - modcache_description[$module] ==
1782 # - modcache_status[$module] \ set to the field's value, minus the
1783 # - ... / final newline,
1784 # - modcache_maintainer[$module] == or unset if the field's value is empty
1785 # Output if ! $have_associative:
1786 # - cachevar a shell variable name
1787 # - ${cachevar}_cached set to $module
1788 # - ${cachevar}_description ==
1789 # - ${cachevar}_status \ set to the field's value, minus the
1790 # - ... / final newline,
1791 # - ${cachevar}_maintainer == or unset if the field's value is empty
1792 # - ${cachevar}_description_set ==
1793 # - ${cachevar}_status_set \ set to non-empty if the field's value
1794 # - ... / is non-empty,
1795 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1796 func_cache_lookup_module ()
1798 if $have_associative; then
1799 cached=${modcache_cached[$1]}
1802 eval "cached=\"\$${cachevar}_cached\""
1804 if test -z "$cached"; then
1805 # Not found in cache. Look it up on the file system.
1806 func_lookup_file "modules/$1"
1807 if $have_associative; then
1808 modcache_cached[$1]=yes
1810 eval "${cachevar}_cached=\"\$1\""
1812 if ! $have_associative; then
1813 # sed_convert_to_cache_statements depends on the module.
1814 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1815 func_init_sed_convert_to_cache_statements
1817 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1818 eval "$cache_statements"
1820 if ! $have_associative; then
1821 if test "$1" != "$cached"; then
1822 func_fatal_error "cache variable collision between $1 and $cached"
1830 # func_get_description module
1832 # - local_gnulib_dir from --local-dir
1833 # - modcache true or false, from --cache-modules/--no-cache-modules
1834 func_get_description ()
1836 if ! $modcache; then
1837 func_lookup_file "modules/$1"
1838 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1840 func_cache_lookup_module "$1"
1841 # Output the field's value, including the final newline (if any).
1842 if $have_associative; then
1843 if test -n "${modcache_description[$1]+set}"; then
1844 echo "${modcache_description[$1]}"
1847 eval "field_set=\"\$${cachevar}_description_set\""
1848 if test -n "$field_set"; then
1849 eval "field_value=\"\$${cachevar}_description\""
1850 echo "${field_value}"
1856 # func_get_comment module
1858 # - local_gnulib_dir from --local-dir
1859 # - modcache true or false, from --cache-modules/--no-cache-modules
1862 if ! $modcache; then
1863 func_lookup_file "modules/$1"
1864 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1866 func_cache_lookup_module "$1"
1867 # Output the field's value, including the final newline (if any).
1868 if $have_associative; then
1869 if test -n "${modcache_comment[$1]+set}"; then
1870 echo "${modcache_comment[$1]}"
1873 eval "field_set=\"\$${cachevar}_comment_set\""
1874 if test -n "$field_set"; then
1875 eval "field_value=\"\$${cachevar}_comment\""
1876 echo "${field_value}"
1882 # func_get_status module
1884 # - local_gnulib_dir from --local-dir
1885 # - modcache true or false, from --cache-modules/--no-cache-modules
1888 if ! $modcache; then
1889 func_lookup_file "modules/$1"
1890 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1892 func_cache_lookup_module "$1"
1893 # Output the field's value, including the final newline (if any).
1894 if $have_associative; then
1895 if test -n "${modcache_status[$1]+set}"; then
1896 echo "${modcache_status[$1]}"
1899 eval "field_set=\"\$${cachevar}_status_set\""
1900 if test -n "$field_set"; then
1901 eval "field_value=\"\$${cachevar}_status\""
1902 echo "${field_value}"
1908 # func_get_notice module
1910 # - local_gnulib_dir from --local-dir
1911 # - modcache true or false, from --cache-modules/--no-cache-modules
1914 if ! $modcache; then
1915 func_lookup_file "modules/$1"
1916 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1918 func_cache_lookup_module "$1"
1919 # Output the field's value, including the final newline (if any).
1920 if $have_associative; then
1921 if test -n "${modcache_notice[$1]+set}"; then
1922 echo "${modcache_notice[$1]}"
1925 eval "field_set=\"\$${cachevar}_notice_set\""
1926 if test -n "$field_set"; then
1927 eval "field_value=\"\$${cachevar}_notice\""
1928 echo "${field_value}"
1934 # func_get_applicability module
1936 # - local_gnulib_dir from --local-dir
1937 # - modcache true or false, from --cache-modules/--no-cache-modules
1938 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1939 func_get_applicability ()
1941 if ! $modcache; then
1942 func_lookup_file "modules/$1"
1943 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1945 func_cache_lookup_module "$1"
1946 # Get the field's value, without the final newline.
1947 if $have_associative; then
1948 my_applicability="${modcache_applicability[$1]}"
1950 eval "my_applicability=\"\$${cachevar}_applicability\""
1953 if test -n "$my_applicability"; then
1954 echo $my_applicability
1956 # The default is 'main' or 'tests', depending on the module's name.
1958 *-tests) echo "tests";;
1964 # func_get_filelist module
1966 # - local_gnulib_dir from --local-dir
1967 # - modcache true or false, from --cache-modules/--no-cache-modules
1968 func_get_filelist ()
1970 if ! $modcache; then
1971 func_lookup_file "modules/$1"
1972 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1974 func_cache_lookup_module "$1"
1975 # Output the field's value, including the final newline (if any).
1976 if $have_associative; then
1977 if test -n "${modcache_files[$1]+set}"; then
1978 echo "${modcache_files[$1]}"
1981 eval "field_set=\"\$${cachevar}_files_set\""
1982 if test -n "$field_set"; then
1983 eval "field_value=\"\$${cachevar}_files\""
1984 echo "${field_value}"
1989 echo m4/gnulib-common.m4
1990 case "$autoconf_minversion" in
1997 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1998 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1999 # elements starting with prefix and ending with suffix are considered.
2000 # Processing: removed_prefix and removed_suffix are removed from each element,
2001 # added_prefix and added_suffix are added to each element.
2002 # prefix, suffix should not contain shell-special characters.
2003 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2004 # added_prefix, added_suffix should not contain the characters \|&.
2005 func_filter_filelist ()
2007 if test "$2" != "$nl" \
2008 || { $fast_func_append \
2009 && { test -z "$6" || $fast_func_remove_prefix; } \
2010 && { test -z "$7" || $fast_func_remove_suffix; }; \
2014 # Do not quote possibly-empty parameters in case patterns,
2015 # AIX and HP-UX ksh won't match them if they are empty.
2018 if test -n "$6"; then
2019 func_remove_prefix fff "$6"
2021 if test -n "$7"; then
2022 func_remove_suffix fff "$7"
2025 if test -z "$ffflist"; then
2028 func_append ffflist "$2${fff}"
2034 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2035 ffflist=`for fff in $3; do
2037 $4*$5) echo "$fff" ;;
2039 done | sed -e "$sed_fff_filter"`
2041 eval "$1=\"\$ffflist\""
2044 # func_get_dependencies module
2046 # - local_gnulib_dir from --local-dir
2047 # - modcache true or false, from --cache-modules/--no-cache-modules
2048 func_get_dependencies ()
2050 # ${module}-tests implicitly depends on ${module}, if that module exists.
2054 func_remove_suffix fgd1 '-tests'
2055 if func_exists_module "$fgd1"; then
2060 # Then the explicit dependencies listed in the module description.
2061 if ! $modcache; then
2062 func_lookup_file "modules/$1"
2063 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2065 func_cache_lookup_module "$1"
2066 # Output the field's value, including the final newline (if any).
2067 if $have_associative; then
2068 if test -n "${modcache_dependson[$1]+set}"; then
2069 echo "${modcache_dependson[$1]}"
2072 eval "field_set=\"\$${cachevar}_dependson_set\""
2073 if test -n "$field_set"; then
2074 eval "field_value=\"\$${cachevar}_dependson\""
2075 echo "${field_value}"
2081 # func_get_autoconf_early_snippet module
2083 # - local_gnulib_dir from --local-dir
2084 # - modcache true or false, from --cache-modules/--no-cache-modules
2085 func_get_autoconf_early_snippet ()
2087 if ! $modcache; then
2088 func_lookup_file "modules/$1"
2089 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2091 func_cache_lookup_module "$1"
2092 # Output the field's value, including the final newline (if any).
2093 if $have_associative; then
2094 if test -n "${modcache_configureac_early[$1]+set}"; then
2095 echo "${modcache_configureac_early[$1]}"
2098 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2099 if test -n "$field_set"; then
2100 eval "field_value=\"\$${cachevar}_configureac_early\""
2101 echo "${field_value}"
2107 # func_get_autoconf_snippet module
2109 # - local_gnulib_dir from --local-dir
2110 # - modcache true or false, from --cache-modules/--no-cache-modules
2111 func_get_autoconf_snippet ()
2113 if ! $modcache; then
2114 func_lookup_file "modules/$1"
2115 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2117 func_cache_lookup_module "$1"
2118 # Output the field's value, including the final newline (if any).
2119 if $have_associative; then
2120 if test -n "${modcache_configureac[$1]+set}"; then
2121 echo "${modcache_configureac[$1]}"
2124 eval "field_set=\"\$${cachevar}_configureac_set\""
2125 if test -n "$field_set"; then
2126 eval "field_value=\"\$${cachevar}_configureac\""
2127 echo "${field_value}"
2133 # func_get_automake_snippet module
2135 # - local_gnulib_dir from --local-dir
2136 # - modcache true or false, from --cache-modules/--no-cache-modules
2137 func_get_automake_snippet ()
2139 if ! $modcache; then
2140 func_lookup_file "modules/$1"
2141 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2143 func_cache_lookup_module "$1"
2144 # Output the field's value, including the final newline (if any).
2145 if $have_associative; then
2146 if test -n "${modcache_makefile[$1]+set}"; then
2147 echo "${modcache_makefile[$1]}"
2150 eval "field_set=\"\$${cachevar}_makefile_set\""
2151 if test -n "$field_set"; then
2152 eval "field_value=\"\$${cachevar}_makefile\""
2153 echo "${field_value}"
2159 # *-tests module live in tests/, not lib/.
2160 # Synthesize an EXTRA_DIST augmentation.
2161 all_files=`func_get_filelist $1`
2162 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2163 extra_files="$tests_files"
2164 if test -n "$extra_files"; then
2165 echo "EXTRA_DIST +=" $extra_files
2170 # Synthesize an EXTRA_DIST augmentation.
2171 sed_combine_lines='/\\$/{
2178 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2179 already_mentioned_files=` \
2180 { if ! $modcache; then
2181 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2183 if $have_associative; then
2184 if test -n "${modcache_makefile[$1]+set}"; then
2185 echo "${modcache_makefile[$1]}"
2188 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2189 if test -n "$field_set"; then
2190 eval 'field_value="$'"${cachevar}"'_makefile"'
2191 echo "${field_value}"
2196 | sed -e "$sed_combine_lines" \
2197 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2198 all_files=`func_get_filelist $1`
2199 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2200 # Remove $already_mentioned_files from $lib_files.
2201 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2202 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2203 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2204 if test -n "$extra_files"; then
2205 echo "EXTRA_DIST +=" $extra_files
2208 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2209 # This is necessary so that automake can generate the right list of
2211 # A possible approach would be to use autom4te --trace of the redefined
2212 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2213 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2214 # inside autoconf's built-in macros are not missed).
2215 # But it's simpler and more robust to do it here, based on the file list.
2216 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2217 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2218 # automake will generate a useless dependency; this is harmless.
2220 relocatable-prog-wrapper) ;;
2222 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2223 if test -n "$extra_files"; then
2224 echo "EXTRA_lib_SOURCES +=" $extra_files
2229 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2230 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2231 if test -n "$buildaux_files"; then
2232 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2233 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2236 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2237 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2238 if test -n "$top_files"; then
2239 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2240 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2247 # func_get_include_directive module
2249 # - local_gnulib_dir from --local-dir
2250 # - modcache true or false, from --cache-modules/--no-cache-modules
2251 func_get_include_directive ()
2254 if ! $modcache; then
2255 func_lookup_file "modules/$1"
2256 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2258 func_cache_lookup_module "$1"
2259 # Output the field's value, including the final newline (if any).
2260 if $have_associative; then
2261 if test -n "${modcache_include[$1]+set}"; then
2262 echo "${modcache_include[$1]}"
2265 eval "field_set=\"\$${cachevar}_include_set\""
2266 if test -n "$field_set"; then
2267 eval "field_value=\"\$${cachevar}_include\""
2268 echo "${field_value}"
2272 } | sed -e 's/^\(["<]\)/#include \1/'
2275 # func_get_link_directive module
2277 # - local_gnulib_dir from --local-dir
2278 # - modcache true or false, from --cache-modules/--no-cache-modules
2279 func_get_link_directive ()
2281 if ! $modcache; then
2282 func_lookup_file "modules/$1"
2283 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2285 func_cache_lookup_module "$1"
2286 # Output the field's value, including the final newline (if any).
2287 if $have_associative; then
2288 if test -n "${modcache_link[$1]+set}"; then
2289 echo "${modcache_link[$1]}"
2292 eval "field_set=\"\$${cachevar}_link_set\""
2293 if test -n "$field_set"; then
2294 eval "field_value=\"\$${cachevar}_link\""
2295 echo "${field_value}"
2301 # func_get_license module
2303 # - local_gnulib_dir from --local-dir
2304 # - modcache true or false, from --cache-modules/--no-cache-modules
2308 if ! $modcache; then
2309 func_lookup_file "modules/$1"
2310 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2312 func_cache_lookup_module "$1"
2313 # Output the field's value, including the final newline (if any).
2314 if $have_associative; then
2315 if test -n "${modcache_license[$1]+set}"; then
2316 echo "${modcache_license[$1]}"
2319 eval "field_set=\"\$${cachevar}_license_set\""
2320 if test -n "$field_set"; then
2321 eval "field_value=\"\$${cachevar}_license\""
2322 echo "${field_value}"
2326 # The default is GPL.
2328 } | sed -e 's,^ *$,,' | sed -e 1q
2331 # func_get_maintainer module
2333 # - local_gnulib_dir from --local-dir
2334 # - modcache true or false, from --cache-modules/--no-cache-modules
2335 func_get_maintainer ()
2337 if ! $modcache; then
2338 func_lookup_file "modules/$1"
2339 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2341 func_cache_lookup_module "$1"
2342 # Output the field's value, including the final newline (if any).
2343 if $have_associative; then
2344 if test -n "${modcache_maintainer[$1]+set}"; then
2345 echo "${modcache_maintainer[$1]}"
2348 eval "field_set=\"\$${cachevar}_maintainer_set\""
2349 if test -n "$field_set"; then
2350 eval "field_value=\"\$${cachevar}_maintainer\""
2351 echo "${field_value}"
2357 # func_get_tests_module module
2359 # - local_gnulib_dir from --local-dir
2360 func_get_tests_module ()
2362 # The naming convention for tests modules is hardwired: ${module}-tests.
2363 if test -f "$gnulib_dir/modules/$1"-tests \
2364 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2365 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2370 # func_acceptable module
2371 # tests whether a module is acceptable.
2373 # - avoidlist list of modules to avoid
2376 for avoid in $avoidlist; do
2377 if test "$avoid" = "$1"; then
2384 # func_modules_transitive_closure
2386 # - local_gnulib_dir from --local-dir
2387 # - modcache true or false, from --cache-modules/--no-cache-modules
2388 # - modules list of specified modules
2389 # - inctests true if tests should be included, blank otherwise
2390 # - incobsolete true if obsolete modules among dependencies should be
2391 # included, blank otherwise
2392 # - inc_cxx_tests true if C++ interoperability tests should be included,
2394 # - inc_longrunning_tests true if long-runnings tests should be included,
2396 # - inc_privileged_tests true if tests that require root privileges should be
2397 # included, blank otherwise
2398 # - inc_unportable_tests true if tests that fail on some platforms should be
2399 # included, blank otherwise
2400 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2401 # the unit tests of the specified modules should be
2402 # included, blank otherwise
2403 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2404 # the unit tests of the dependencies should be
2405 # included, blank otherwise
2406 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2408 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2410 # - excl_privileged_tests true if tests that require root privileges should be
2411 # excluded, blank otherwise
2412 # - excl_unportable_tests true if tests that fail on some platforms should be
2413 # excluded, blank otherwise
2414 # - avoidlist list of modules to avoid
2415 # - tmp pathname of a temporary directory
2417 # - modules list of modules, including dependencies
2418 func_modules_transitive_closure ()
2420 # In order to process every module only once (for speed), process an "input
2421 # list" of modules, producing an "output list" of modules. During each round,
2422 # more modules can be queued in the input list. Once a module on the input
2423 # list has been processed, it is added to the "handled list", so we can avoid
2424 # to process it again.
2426 inmodules="$modules"
2428 fmtc_inc_all_tests="$inc_all_direct_tests"
2429 while test -n "$inmodules"; do
2430 inmodules_this_round="$inmodules"
2431 inmodules= # Accumulator, queue for next round
2432 for module in $inmodules_this_round; do
2434 if test -n "$module"; then
2435 if func_acceptable $module; then
2436 func_append outmodules " $module"
2437 deps=`func_get_dependencies $module`
2438 # Duplicate dependencies are harmless, but Jim wants a warning.
2439 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2440 if test -n "$duplicated_deps"; then
2441 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2443 if test -n "$inctests"; then
2444 testsmodule=`func_get_tests_module $module`
2445 if test -n "$testsmodule"; then
2446 deps="$deps $testsmodule"
2449 for dep in $deps; do
2450 # Determine whether to include the dependency or tests module.
2452 for word in `func_get_status $dep`; do
2455 test -n "$incobsolete" \
2459 test -z "$excl_cxx_tests" \
2461 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2465 test -z "$excl_longrunning_tests" \
2467 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2471 test -z "$excl_privileged_tests" \
2473 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2477 test -z "$excl_unportable_tests" \
2479 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2483 test -n "$fmtc_inc_all_tests" \
2489 func_append inmodules " $dep"
2495 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2496 # Remove $handledmodules from $inmodules.
2497 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2498 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2499 fmtc_inc_all_tests="$inc_all_indirect_tests"
2501 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2502 rm -f "$tmp"/queued-modules
2505 # func_show_module_list
2507 # - specified_modules list of specified modules (one per line, sorted)
2508 # - modules complete list of modules (one per line, sorted)
2509 # - tmp pathname of a temporary directory
2510 func_show_module_list ()
2516 # Assume xterm compatible escape sequences.
2517 bold_on=`printf '\x1b[1m'`
2518 bold_off=`printf '\x1b[0m'`
2523 echo "Module list with included dependencies (indented):"
2524 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2525 echo "$modules" | sed -e '/^$/d' \
2526 | LC_ALL=C join -t '|' -a 2 "$tmp"/specified-modules - \
2527 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2530 # func_modules_add_dummy
2532 # - local_gnulib_dir from --local-dir
2533 # - modcache true or false, from --cache-modules/--no-cache-modules
2534 # - modules list of modules, including dependencies
2536 # - modules list of modules, including 'dummy' if needed
2537 func_modules_add_dummy ()
2539 # Determine whether any module provides a lib_SOURCES augmentation.
2541 sed_remove_backslash_newline=':a
2548 for module in $modules; do
2549 func_verify_nontests_module
2550 if test -n "$module"; then
2551 # Extract the value of "lib_SOURCES += ...".
2552 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2553 # Ignore .h files since they are not compiled.
2557 have_lib_SOURCES=yes
2564 # Add the dummy module, to make sure the library will be non-empty.
2565 if test -z "$have_lib_SOURCES"; then
2566 if func_acceptable "dummy"; then
2567 func_append modules " dummy"
2572 # func_modules_notice
2574 # - local_gnulib_dir from --local-dir
2575 # - modcache true or false, from --cache-modules/--no-cache-modules
2576 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2577 # - modules list of modules, including dependencies
2578 func_modules_notice ()
2580 if test $verbose -ge -1; then
2581 for module in $modules; do
2583 if test -n "$module"; then
2584 msg=`func_get_notice $module`
2585 if test -n "$msg"; then
2586 echo "Notice from module $module:"
2587 echo "$msg" | sed -e 's/^/ /'
2594 # func_modules_to_filelist
2596 # - local_gnulib_dir from --local-dir
2597 # - modcache true or false, from --cache-modules/--no-cache-modules
2598 # - modules list of modules, including dependencies
2600 # - files list of files
2601 func_modules_to_filelist ()
2604 for module in $modules; do
2606 if test -n "$module"; then
2607 fs=`func_get_filelist $module`
2608 func_append files " $fs"
2611 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2614 # func_execute_command command [args...]
2615 # Executes a command.
2616 # Uses also the variables
2617 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2618 func_execute_command ()
2620 if test $verbose -ge 0; then
2624 # Commands like automake produce output to stderr even when they succeed.
2625 # Turn this output off if the command succeeds.
2626 "$@" > "$tmp"/cmdout 2>&1
2628 if test $cmdret = 0; then
2632 cat "$tmp"/cmdout 1>&2
2639 # func_dest_tmpfilename file
2640 # determines the name of a temporary file (file is relative to destdir).
2642 # - destdir target directory
2643 # - doit : if actions shall be executed, false if only to be printed
2644 # - tmp pathname of a temporary directory
2646 # - tmpfile absolute filename of the temporary file
2647 func_dest_tmpfilename ()
2650 # Put the new contents of $file in a file in the same directory (needed
2651 # to guarantee that an 'mv' to "$destdir/$file" works).
2652 tmpfile="$destdir/$1.tmp"
2654 # Put the new contents of $file in a file in a temporary directory
2655 # (because the directory of "$file" might not exist).
2656 tmpfile="$tmp"/`basename "$1"`.tmp
2661 # copies a file from gnulib into the destination directory. The destination
2662 # is known to not exist.
2664 # - destdir target directory
2665 # - local_gnulib_dir from --local-dir
2666 # - modcache true or false, from --cache-modules/--no-cache-modules
2667 # - f the original file name
2668 # - lookedup_file name of the merged (combined) file
2669 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2670 # - g the rewritten file name
2671 # - tmpfile absolute filename of the temporary file
2672 # - doit : if actions shall be executed, false if only to be printed
2673 # - symbolic true if files should be symlinked, copied otherwise
2674 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2679 echo "Copying file $g"
2680 if { test -n "$symbolic" \
2681 || { test -n "$lsymbolic" \
2682 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2683 && test -z "$lookedup_tmp" \
2684 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2685 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2687 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2695 # copies a file from gnulib into the destination directory. The destination
2696 # is known to exist.
2698 # - destdir target directory
2699 # - local_gnulib_dir from --local-dir
2700 # - modcache true or false, from --cache-modules/--no-cache-modules
2701 # - f the original file name
2702 # - lookedup_file name of the merged (combined) file
2703 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2704 # - g the rewritten file name
2705 # - tmpfile absolute filename of the temporary file
2706 # - doit : if actions shall be executed, false if only to be printed
2707 # - symbolic true if files should be symlinked, copied otherwise
2708 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2710 # - already_present nonempty if the file should already exist, empty otherwise
2713 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2714 : # The file has not changed.
2718 if test -n "$already_present"; then
2719 echo "Updating file $g (backup in ${g}~)"
2721 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2723 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2724 if { test -n "$symbolic" \
2725 || { test -n "$lsymbolic" \
2726 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2727 && test -z "$lookedup_tmp" \
2728 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2729 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2731 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2734 if test -n "$already_present"; then
2735 echo "Update file $g (backup in ${g}~)"
2737 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2743 # func_emit_lib_Makefile_am
2744 # emits the contents of library makefile to standard output.
2746 # - local_gnulib_dir from --local-dir
2747 # - modcache true or false, from --cache-modules/--no-cache-modules
2748 # - modules list of modules, including dependencies
2749 # - libname library name
2750 # - pobase directory relative to destdir where to place *.po files
2751 # - auxdir directory relative to destdir where to place build aux files
2752 # - makefile_name from --makefile-name
2753 # - libtool true if libtool will be used, false or blank otherwise
2754 # - macro_prefix prefix of gl_LIBOBJS macros to use
2755 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2756 # - actioncmd (optional) command that will reproduce this invocation
2757 # - for_test true if creating a package for testing, false otherwise
2758 # - destfile filename relative to destdir of makefile being generated
2760 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2761 # list of edits to be done to Makefile.am variables
2763 # - uses_subdirs nonempty if object files in subdirs exist
2764 func_emit_lib_Makefile_am ()
2766 # When creating an includable Makefile.am snippet, augment variables with
2767 # += instead of assigning them.
2768 if test -n "$makefile_name"; then
2773 if test "$libtool" = true; then
2776 sed_eliminate_LDFLAGS="$sed_noop"
2780 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2783 # When creating a package for testing: Attempt to provoke failures,
2784 # especially link errors, already during "make" rather than during
2785 # "make check", because "make check" is not possible in a cross-compiling
2786 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2787 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2789 sed_transform_check_PROGRAMS="$sed_noop"
2791 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2792 echo "## Process this file with automake to produce Makefile.in."
2793 func_emit_copyright_notice
2794 if test -n "$actioncmd"; then
2795 # The maximum line length (excluding the terminating newline) of any file
2796 # that is to be preprocessed by config.status is 3070. config.status uses
2797 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2798 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2799 len=`echo "$actioncmd" | wc -c`
2800 if test -n "$len" && test "$len" -le 3000; then
2801 echo "# Reproduce by: $actioncmd"
2807 for module in $modules; do
2808 func_verify_nontests_module
2809 if test -n "$module"; then
2811 func_get_automake_snippet "$module" |
2813 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2814 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2815 -e "$sed_eliminate_LDFLAGS" \
2816 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2817 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2818 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2819 -e "$sed_transform_check_PROGRAMS"
2820 if test "$module" = 'alloca'; then
2821 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2822 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2824 } > "$tmp"/amsnippet
2825 # Skip the contents if it's entirely empty.
2826 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2827 echo "## begin gnulib module $module"
2829 cat "$tmp"/amsnippet
2830 echo "## end gnulib module $module"
2833 rm -f "$tmp"/amsnippet
2834 # Test whether there are some source files in subdirectories.
2835 for f in `func_get_filelist "$module"`; do
2845 } > "$tmp"/allsnippets
2846 if test -z "$makefile_name"; then
2847 # If there are source files in subdirectories, prevent collision of the
2848 # object files (example: hash.c and libxml/hash.c).
2850 if test -n "$uses_subdirs"; then
2851 subdir_options=' subdir-objects'
2853 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2856 if test -z "$makefile_name"; then
2858 echo "noinst_HEADERS ="
2859 echo "noinst_LIBRARIES ="
2860 echo "noinst_LTLIBRARIES ="
2861 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2862 # if you specify pkgdata_DATA to empty. This is a workaround.
2863 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2864 echo "pkgdata_DATA ="
2867 echo "BUILT_SOURCES ="
2870 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2871 if test -z "$makefile_name"; then
2872 echo "MOSTLYCLEANDIRS ="
2874 echo "DISTCLEANFILES ="
2875 echo "MAINTAINERCLEANFILES ="
2877 # Execute edits that apply to the Makefile.am being generated.
2879 while test $edit != $makefile_am_edits; do
2880 edit=`expr $edit + 1`
2881 eval dir=\"\$makefile_am_edit${edit}_dir\"
2882 eval var=\"\$makefile_am_edit${edit}_var\"
2883 eval val=\"\$makefile_am_edit${edit}_val\"
2884 if test -n "$var"; then
2885 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2886 echo "${var} += ${val}"
2887 eval "makefile_am_edit${edit}_var="
2891 if test -z "$makefile_name"; then
2894 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
2896 echo "AM_CPPFLAGS ="
2901 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2902 || { test -n "$makefile_name" \
2903 && test -f "$sourcebase/Makefile.am" \
2904 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2906 # One of the snippets or the user's Makefile.am already specifies an
2907 # installation location for the library. Don't confuse automake by saying
2908 # it should not be installed.
2911 # By default, the generated library should not be installed.
2912 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2915 echo "${libname}_${libext}_SOURCES ="
2916 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2917 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2918 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2919 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2920 echo "EXTRA_${libname}_${libext}_SOURCES ="
2921 if test "$libtool" = true; then
2922 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2925 if test -n "$pobase"; then
2926 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2929 cat "$tmp"/allsnippets \
2930 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2932 echo "mostlyclean-local: mostlyclean-generic"
2933 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2934 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2935 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2939 rm -f "$tmp"/allsnippets
2942 # func_emit_po_Makevars
2943 # emits the contents of po/ makefile parameterization to standard output.
2945 # - local_gnulib_dir from --local-dir
2946 # - modcache true or false, from --cache-modules/--no-cache-modules
2947 # - sourcebase directory relative to destdir where to place source code
2948 # - pobase directory relative to destdir where to place *.po files
2949 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2950 func_emit_po_Makevars ()
2952 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2953 func_emit_copyright_notice
2955 echo "# Usually the message domain is the same as the package name."
2956 echo "# But here it has a '-gnulib' suffix."
2957 echo "DOMAIN = ${po_domain}-gnulib"
2959 echo "# These two variables depend on the location of this directory."
2960 echo "subdir = ${pobase}"
2961 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2964 # These options get passed to xgettext.
2965 XGETTEXT_OPTIONS = \
2966 --keyword=_ --flag=_:1:pass-c-format \
2967 --keyword=N_ --flag=N_:1:pass-c-format \
2968 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2969 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2970 --flag=error:3:c-format --flag=error_at_line:5:c-format
2972 # This is the copyright holder that gets inserted into the header of the
2973 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2974 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2976 # This is the email address or URL to which the translators shall report
2977 # bugs in the untranslated strings:
2978 # - Strings which are not entire sentences, see the maintainer guidelines
2979 # in the GNU gettext documentation, section 'Preparing Strings'.
2980 # - Strings which use unclear terms or require additional context to be
2982 # - Strings which make invalid assumptions about notation of date, time or
2984 # - Pluralisation problems.
2985 # - Incorrect English spelling.
2986 # - Incorrect formatting.
2987 # It can be your email address, or a mailing list address where translators
2988 # can write to without being subscribed, or the URL of a web page through
2989 # which the translators can contact you.
2990 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2992 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2993 # message catalogs shall be used. It is usually empty.
2994 EXTRA_LOCALE_CATEGORIES =
2996 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2997 # context. Possible values are "yes" and "no". Set this to yes if the
2998 # package uses functions taking also a message context, like pgettext(), or
2999 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3004 # func_emit_po_POTFILES_in
3005 # emits the file list to be passed to xgettext to standard output.
3007 # - local_gnulib_dir from --local-dir
3008 # - modcache true or false, from --cache-modules/--no-cache-modules
3009 # - sourcebase directory relative to destdir where to place source code
3010 # - files list of new files
3011 func_emit_po_POTFILES_in ()
3013 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3014 func_emit_copyright_notice
3016 echo "# List of files which contain translatable strings."
3017 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3020 # func_emit_tests_Makefile_am witness_macro
3021 # emits the contents of tests makefile to standard output.
3023 # - local_gnulib_dir from --local-dir
3024 # - modcache true or false, from --cache-modules/--no-cache-modules
3025 # - modules list of modules, including dependencies
3026 # - libname library name
3027 # - auxdir directory relative to destdir where to place build aux files
3028 # - makefile_name from --makefile-name
3029 # - libtool true if libtool will be used, false or blank otherwise
3030 # - sourcebase relative directory containing lib source code
3031 # - m4base relative directory containing autoconf macros
3032 # - testsbase relative directory containing unit test code
3033 # - macro_prefix prefix of gl_LIBOBJS macros to use
3034 # - for_test true if creating a package for testing, false otherwise
3035 # - use_libtests true if a libtests.a should be built, false otherwise
3036 # - destfile filename relative to destdir of makefile being generated
3038 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3039 # list of edits to be done to Makefile.am variables
3041 # - uses_subdirs nonempty if object files in subdirs exist
3042 func_emit_tests_Makefile_am ()
3045 if test "$libtool" = true; then
3047 sed_eliminate_LDFLAGS="$sed_noop"
3050 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3053 # When creating a package for testing: Attempt to provoke failures,
3054 # especially link errors, already during "make" rather than during
3055 # "make check", because "make check" is not possible in a cross-compiling
3056 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3057 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3059 sed_transform_check_PROGRAMS="$sed_noop"
3061 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3062 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3063 echo "## Process this file with automake to produce Makefile.in."
3064 func_emit_copyright_notice
3068 for module in $modules; do
3070 func_verify_tests_module
3074 if test -n "$module"; then
3076 func_get_automake_snippet "$module" |
3078 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3079 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3080 -e "$sed_eliminate_LDFLAGS" \
3081 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3082 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3083 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3084 -e "$sed_transform_check_PROGRAMS"
3085 if $use_libtests && test "$module" = 'alloca'; then
3086 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3087 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3089 } > "$tmp"/amsnippet
3090 # Skip the contents if it's entirely empty.
3091 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3092 # Mention long-running tests at the end.
3094 for word in `func_get_status "$module"`; do
3095 if test "$word" = 'longrunning-test'; then
3100 { echo "## begin gnulib module $module"
3102 cat "$tmp"/amsnippet
3103 echo "## end gnulib module $module"
3107 rm -f "$tmp"/amsnippet
3108 # Test whether there are some source files in subdirectories.
3109 for f in `func_get_filelist "$module"`; do
3111 lib/*/*.c | tests/*/*.c)
3119 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3120 # Generate dependencies here, since it eases the debugging of test failures.
3121 # If there are source files in subdirectories, prevent collision of the
3122 # object files (example: hash.c and libxml/hash.c).
3124 if test -n "$uses_subdirs"; then
3125 subdir_options=' subdir-objects'
3127 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3130 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3133 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3134 # variable is needed to avoid an error from automake:
3135 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3138 echo "XFAIL_TESTS ="
3139 echo "TESTS_ENVIRONMENT ="
3140 echo "noinst_PROGRAMS ="
3141 if ! $for_test; then
3142 echo "check_PROGRAMS ="
3144 echo "noinst_HEADERS ="
3145 echo "noinst_LIBRARIES ="
3146 if $use_libtests; then
3148 echo "noinst_LIBRARIES += libtests.a"
3150 echo "check_LIBRARIES = libtests.a"
3153 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3154 # if you specify pkgdata_DATA to empty. This is a workaround.
3155 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3156 echo "pkgdata_DATA ="
3159 echo "BUILT_SOURCES ="
3161 echo "MOSTLYCLEANFILES = core *.stackdump"
3162 echo "MOSTLYCLEANDIRS ="
3164 echo "DISTCLEANFILES ="
3165 echo "MAINTAINERCLEANFILES ="
3166 # Execute edits that apply to the Makefile.am being generated.
3168 while test $edit != $makefile_am_edits; do
3169 edit=`expr $edit + 1`
3170 eval dir=\"\$makefile_am_edit${edit}_dir\"
3171 eval var=\"\$makefile_am_edit${edit}_var\"
3172 eval val=\"\$makefile_am_edit${edit}_val\"
3173 if test -n "$var"; then
3174 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3175 echo "${var} += ${val}"
3176 eval "makefile_am_edit${edit}_var="
3181 echo "AM_CPPFLAGS = \\"
3183 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3185 if test -n "${witness_macro}"; then
3186 echo " -D@${witness_macro}@=1 \\"
3188 echo " -I. -I\$(srcdir) \\"
3189 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3190 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3192 local_ldadd_before=''
3193 local_ldadd_after=''
3194 if $use_libtests; then
3195 # All test programs need to be linked with libtests.a.
3196 # It needs to be passed to the linker before ${libname}.${libext}, since
3197 # the tests-related modules depend on the main modules.
3198 # It also needs to be passed to the linker after ${libname}.${libext}
3199 # because the latter might contain incomplete modules (such as the 'error'
3200 # module whose dependency to 'progname' is voluntarily omitted).
3201 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3203 local_ldadd_before=' libtests.a'
3204 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3206 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3208 if $use_libtests; then
3209 echo "libtests_a_SOURCES ="
3210 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3211 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3212 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3213 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3214 echo "EXTRA_libtests_a_SOURCES ="
3215 # The circular dependency in LDADD requires this.
3216 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3219 # Many test scripts use ${EXEEXT} or ${srcdir}.
3220 # EXEEXT is defined by AC_PROG_CC through autoconf.
3221 # srcdir is defined by autoconf and automake.
3222 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3224 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3225 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3226 echo "# Clean up after Solaris cc."
3228 echo " rm -rf SunWS_cache"
3230 echo "mostlyclean-local: mostlyclean-generic"
3231 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3232 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3233 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3237 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3240 # func_emit_initmacro_start macro_prefix
3241 # emits the first few statements of the gl_INIT macro to standard output.
3242 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3243 func_emit_initmacro_start ()
3245 macro_prefix_arg="$1"
3246 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3247 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3248 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3249 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3251 # Furthermore it avoids an automake error like this when a Makefile.am
3252 # that uses pieces of gnulib also uses $(LIBOBJ):
3253 # automatically discovered file `error.c' should not be explicitly mentioned
3254 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3255 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3256 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3257 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3258 # automatically discovered file `error.c' should not be explicitly mentioned
3259 # We let automake know about the files to be distributed through the
3260 # EXTRA_lib_SOURCES variable.
3261 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3262 # Create data variables for checking the presence of files that are mentioned
3263 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3264 # because we want the check to happen when the configure file is created,
3265 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3266 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3267 # in which to expect them.
3268 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3269 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3273 # func_emit_initmacro_end macro_prefix
3274 # emits the last few statements of the gl_INIT macro to standard output.
3275 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3276 func_emit_initmacro_end ()
3278 macro_prefix_arg="$1"
3279 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3280 # The check is performed only when autoconf is run from the directory where
3281 # the configure.ac resides; if it is run from a different directory, the
3283 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3284 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3285 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3286 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3287 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3291 echo " m4_if(m4_sysval, [0], [],"
3292 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3294 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3295 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3296 echo " m4_popdef([AC_LIBSOURCES])"
3297 echo " m4_popdef([AC_REPLACE_FUNCS])"
3298 echo " m4_popdef([AC_LIBOBJ])"
3299 echo " AC_CONFIG_COMMANDS_PRE(["
3300 echo " ${macro_prefix_arg}_libobjs="
3301 echo " ${macro_prefix_arg}_ltlibobjs="
3302 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3303 echo " # Remove the extension."
3304 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3305 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3306 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3307 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3310 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3311 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3315 # func_emit_initmacro_done macro_prefix sourcebase
3316 # emits a few statements after the gl_INIT macro to standard output.
3317 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3318 # - sourcebase directory relative to destdir where to place source code
3319 func_emit_initmacro_done ()
3321 macro_prefix_arg="$1"
3324 echo "# Like AC_LIBOBJ, except that the module name goes"
3325 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3326 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3327 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3328 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3331 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3332 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3333 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3334 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3335 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3338 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3339 echo "# expected is derived from the gnulib-tool parameterization,"
3340 echo "# and alloca is special cased (for the alloca-opt module)."
3341 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3342 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3343 echo " m4_foreach([_gl_NAME], [\$1], ["
3344 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3345 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3346 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3352 # func_import modules
3353 # Uses also the variables
3354 # - mode import or add-import or remove-import or update
3355 # - destdir target directory
3356 # - local_gnulib_dir from --local-dir
3357 # - modcache true or false, from --cache-modules/--no-cache-modules
3358 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3359 # - libname library name
3360 # - supplied_libname true if --lib was given, blank otherwise
3361 # - sourcebase directory relative to destdir where to place source code
3362 # - m4base directory relative to destdir where to place *.m4 macros
3363 # - pobase directory relative to destdir where to place *.po files
3364 # - docbase directory relative to destdir where to place doc files
3365 # - testsbase directory relative to destdir where to place unit test code
3366 # - auxdir directory relative to destdir where to place build aux files
3367 # - inctests true if --with-tests was given, blank otherwise
3368 # - incobsolete true if --with-obsolete was given, blank otherwise
3369 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3370 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3372 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3374 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3376 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3377 # - avoidlist list of modules to avoid, from --avoid
3378 # - lgpl yes or a number if library's license shall be LGPL,
3380 # - makefile_name from --makefile-name
3381 # - libtool true if --libtool was given, false if --no-libtool was
3382 # given, blank otherwise
3383 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3384 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3385 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3386 # - vc_files true if --vc-files was given, false if --no-vc-files was
3387 # given, blank otherwise
3388 # - autoconf_minversion minimum supported autoconf version
3389 # - doit : if actions shall be executed, false if only to be printed
3390 # - symbolic true if files should be symlinked, copied otherwise
3391 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3393 # - do_copyrights true if copyright notices in files should be replaced,
3397 # Get the cached settings.
3398 # In 'import' mode, we read them only for the purpose of knowing the old
3399 # installed file list, and don't use them as defaults.
3400 cached_local_gnulib_dir=
3401 cached_specified_modules=
3403 cached_inc_cxx_tests=
3404 cached_inc_longrunning_tests=
3405 cached_inc_privileged_tests=
3406 cached_inc_unportable_tests=
3407 cached_inc_all_tests=
3417 cached_makefile_name=
3419 cached_macro_prefix=
3423 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3424 cached_libtool=false
3430 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3440 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3442 /gl_WITH_OBSOLETE/ {
3443 s,^.*$,cached_incobsolete=true,p
3445 /gl_WITH_CXX_TESTS/ {
3446 s,^.*$,cached_inc_cxx_tests=true,p
3448 /gl_WITH_LONGRUNNING_TESTS/ {
3449 s,^.*$,cached_inc_longrunning_tests=true,p
3451 /gl_WITH_PRIVILEGED_TESTS/ {
3452 s,^.*$,cached_inc_privileged_tests=true,p
3454 /gl_WITH_UNPORTABLE_TESTS/ {
3455 s,^.*$,cached_inc_unportable_tests=true,p
3457 /gl_WITH_ALL_TESTS/ {
3458 s,^.*$,cached_inc_all_tests=true,p
3461 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3464 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3467 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3470 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3473 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3476 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3479 s,^.*$,cached_inctests=true,p
3482 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3485 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3488 s,^.*$,cached_lgpl=yes,p
3490 /gl_MAKEFILE_NAME(/ {
3491 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3494 s,^.*$,cached_libtool=true,p
3496 /gl_MACRO_PREFIX(/ {
3497 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3500 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3503 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3505 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3506 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3511 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3512 s,^.*$,cached_files=",p
3525 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3529 if test "$mode" = import; then
3530 # In 'import' mode, the new set of specified modules overrides the cached
3531 # set of modules. Ignore the cached settings.
3532 specified_modules="$1"
3534 # Merge the cached settings with the specified ones.
3535 # The m4base must be the same as expected from the pathname.
3536 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3537 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3539 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3540 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3541 if test -z "$local_gnulib_dir"; then
3542 if test -n "$cached_local_gnulib_dir"; then
3545 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3547 case "$cached_local_gnulib_dir" in
3549 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3551 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3552 local_gnulib_dir="$relconcat" ;;
3559 # Append the cached and the specified module names. So that
3560 # "gnulib-tool --add-import foo" means to add the module foo.
3561 specified_modules="$cached_specified_modules $1"
3564 # Take the cached module names, minus the specified module names.
3566 if $have_associative; then
3567 # Use an associative array, for O(N) worst-case run time.
3568 declare -A to_remove
3572 for module in $cached_specified_modules; do
3573 if test -z "${to_remove[$module]}"; then
3574 func_append specified_modules "$module "
3578 # This loop has O(N²) worst-case run time.
3579 for module in $cached_specified_modules; do
3582 if test "$m" = "$module"; then
3587 if test -z "$to_remove"; then
3588 func_append specified_modules "$module "
3594 # Take the cached module names. There are no specified module names.
3595 specified_modules="$cached_specified_modules"
3598 # Included obsolete modules among the dependencies if specified either way.
3599 if test -z "$incobsolete"; then
3600 incobsolete="$cached_incobsolete"
3602 # Included special kinds of tests modules among the dependencies if specified
3604 if test -z "$inc_cxx_tests"; then
3605 inc_cxx_tests="$cached_inc_cxx_tests"
3607 if test -z "$inc_longrunning_tests"; then
3608 inc_longrunning_tests="$cached_inc_longrunning_tests"
3610 if test -z "$inc_privileged_tests"; then
3611 inc_privileged_tests="$cached_inc_privileged_tests"
3613 if test -z "$inc_unportable_tests"; then
3614 inc_unportable_tests="$cached_inc_unportable_tests"
3616 if test -z "$inc_all_tests"; then
3617 inc_all_tests="$cached_inc_all_tests"
3619 # Append the cached and the specified avoidlist. This is probably better
3620 # than dropping the cached one when --avoid is specified at least once.
3621 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3622 avoidlist=`echo $avoidlist`
3624 # The sourcebase defaults to the cached one.
3625 if test -z "$sourcebase"; then
3626 sourcebase="$cached_sourcebase"
3627 if test -z "$sourcebase"; then
3628 func_fatal_error "missing --source-base option"
3631 # The pobase defaults to the cached one.
3632 if test -z "$pobase"; then
3633 pobase="$cached_pobase"
3635 # The docbase defaults to the cached one.
3636 if test -z "$docbase"; then
3637 docbase="$cached_docbase"
3638 if test -z "$docbase"; then
3639 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."
3642 # The testsbase defaults to the cached one.
3643 if test -z "$testsbase"; then
3644 testsbase="$cached_testsbase"
3645 if test -z "$testsbase"; then
3646 func_fatal_error "missing --tests-base option"
3649 # Require the tests if specified either way.
3650 if test -z "$inctests"; then
3651 inctests="$cached_inctests"
3653 # The libname defaults to the cached one.
3654 if test -z "$supplied_libname"; then
3655 libname="$cached_libname"
3656 if test -z "$libname"; then
3657 func_fatal_error "missing --lib option"
3660 # Require LGPL if specified either way.
3661 if test -z "$lgpl"; then
3664 # The makefile_name defaults to the cached one.
3665 if test -z "$makefile_name"; then
3666 makefile_name="$cached_makefile_name"
3668 # Use libtool if specified either way, or if guessed.
3669 if test -z "$libtool"; then
3670 if test -n "$cached_m4base"; then
3671 libtool="$cached_libtool"
3673 libtool="$guessed_libtool"
3676 # The macro_prefix defaults to the cached one.
3677 if test -z "$macro_prefix"; then
3678 macro_prefix="$cached_macro_prefix"
3679 if test -z "$macro_prefix"; then
3680 func_fatal_error "missing --macro-prefix option"
3683 # The po_domain defaults to the cached one.
3684 if test -z "$po_domain"; then
3685 po_domain="$cached_po_domain"
3687 # The vc_files defaults to the cached one.
3688 if test -z "$vc_files"; then
3689 vc_files="$cached_vc_files"
3692 # --without-*-tests options are not supported here.
3694 excl_longrunning_tests=
3695 excl_privileged_tests=
3696 excl_unportable_tests=
3698 # Canonicalize the list of specified modules.
3699 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3701 # Include all kinds of tests modules if --with-all-tests was specified.
3702 inc_all_direct_tests="$inc_all_tests"
3703 inc_all_indirect_tests="$inc_all_tests"
3705 # Determine final module list.
3706 modules="$specified_modules"
3707 func_modules_transitive_closure
3708 if test $verbose -ge 0; then
3709 func_show_module_list
3711 final_modules="$modules"
3713 # Determine main module list and tests-related module list separately.
3714 # The main module list is the transitive closure of the specified modules,
3715 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3716 # is specified, it will consist only of LGPLed source.
3717 # The tests-related module list is the transitive closure of the specified
3718 # modules, including tests modules, minus the main module list excluding
3719 # modules of applicability 'all'. Its lib/* sources (brought in through
3720 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3721 # source, even if --lgpl is specified.
3722 # Determine main module list.
3723 saved_inctests="$inctests"
3725 modules="$specified_modules"
3726 func_modules_transitive_closure
3727 main_modules="$modules"
3728 inctests="$saved_inctests"
3729 if test $verbose -ge 1; then
3730 echo "Main module list:"
3731 echo "$main_modules" | sed -e 's/^/ /'
3733 # Determine tests-related module list.
3734 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3735 testsrelated_modules=`for module in $main_modules; do
3736 if test \`func_get_applicability $module\` = main; then
3740 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3741 if test $verbose -ge 1; then
3742 echo "Tests-related module list:"
3743 echo "$testsrelated_modules" | sed -e 's/^/ /'
3746 # Add the dummy module to the main module list if needed.
3747 modules="$main_modules"
3748 func_modules_add_dummy
3749 main_modules="$modules"
3751 # Determine whether a $testsbase/libtests.a is needed.
3753 for module in $testsrelated_modules; do
3754 func_verify_nontests_module
3755 if test -n "$module"; then
3756 all_files=`func_get_filelist $module`
3757 # Test whether some file in $all_files lies in lib/.
3758 for f in $all_files; do
3769 # Add the dummy module to the tests-related module list if needed.
3770 if $use_libtests; then
3771 modules="$testsrelated_modules"
3772 func_modules_add_dummy
3773 testsrelated_modules="$modules"
3776 # If --lgpl, verify that the licenses of modules are compatible.
3777 if test -n "$lgpl"; then
3778 license_incompatibilities=
3779 for module in $main_modules; do
3780 license=`func_get_license $module`
3782 'GPLed build tool') ;;
3783 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3788 LGPL | LGPLv2+ | LGPLv3+) ;;
3789 *) func_append license_incompatibilities "$module $license$nl" ;;
3795 *) func_append license_incompatibilities "$module $license$nl" ;;
3798 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3803 if test -n "$license_incompatibilities"; then
3804 # Format the license incompatibilities as a table.
3805 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3806 s,^\(.................................................[^ ]*\) *, \1 ,'
3807 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3808 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3812 # Show banner notice of every module.
3813 modules="$main_modules"
3816 # Determine script to apply to imported library files.
3817 sed_transform_lib_file=
3818 for module in $main_modules; do
3819 if test $module = config-h; then
3820 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3821 sed_transform_lib_file=$sed_transform_lib_file'
3822 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3827 sed_transform_main_lib_file="$sed_transform_lib_file"
3828 if test -n "$do_copyrights"; then
3829 if test -n "$lgpl"; then
3833 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3834 s/GNU General/GNU Lesser General/g
3838 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3839 s/GNU General/GNU Lesser General/g
3840 s/version [23]\([ ,]\)/version 2.1\1/g
3843 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3847 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3848 s/GNU Lesser General/GNU General/g
3849 s/GNU Library General/GNU General/g
3850 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3855 # Determine script to apply to auxiliary files that go into $auxdir/.
3856 sed_transform_build_aux_file=
3857 if test -n "$do_copyrights"; then
3859 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3860 s/GNU Lesser General/GNU General/g
3861 s/GNU Library General/GNU General/g
3862 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3866 # Determine script to apply to library files that go into $testsbase/.
3867 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3868 if test -n "$do_copyrights"; then
3870 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3871 s/GNU Lesser General/GNU General/g
3872 s/GNU Library General/GNU General/g
3873 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3877 # Determine the final file lists.
3878 # They must be computed separately, because files in lib/* go into
3879 # $sourcebase/ if they are in the main file list but into $testsbase/
3880 # if they are in the tests-related file list. Furthermore lib/dummy.c
3882 # Determine final main file list.
3883 modules="$main_modules"
3884 func_modules_to_filelist
3886 # Determine final tests-related file list.
3887 modules="$testsrelated_modules"
3888 func_modules_to_filelist
3889 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3890 # Merge both file lists.
3891 sed_remove_empty_lines='/^$/d'
3892 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3893 if test $verbose -ge 0; then
3895 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3896 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3900 || func_fatal_error "refusing to do nothing"
3902 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3903 new_files="$files m4/gnulib-tool.m4"
3904 old_files="$cached_files"
3905 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3906 func_append old_files " m4/gnulib-tool.m4"
3909 rewritten='%REWRITTEN%'
3910 sed_rewrite_old_files="\
3911 s,^build-aux/,$rewritten$auxdir/,
3912 s,^doc/,$rewritten$cached_docbase/,
3913 s,^lib/,$rewritten$cached_sourcebase/,
3914 s,^m4/,$rewritten$cached_m4base/,
3915 s,^tests/,$rewritten$cached_testsbase/,
3916 s,^tests=lib/,$rewritten$cached_testsbase/,
3919 sed_rewrite_new_files="\
3920 s,^build-aux/,$rewritten$auxdir/,
3921 s,^doc/,$rewritten$docbase/,
3922 s,^lib/,$rewritten$sourcebase/,
3923 s,^m4/,$rewritten$m4base/,
3924 s,^tests/,$rewritten$testsbase/,
3925 s,^tests=lib/,$rewritten$testsbase/,
3929 # Create directories.
3930 { echo "$sourcebase"
3932 if test -n "$pobase"; then
3935 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3936 if test -n "$docfiles"; then
3939 if test -n "$inctests"; then
3943 for f in $files; do echo $f; done \
3944 | sed -e "$sed_rewrite_new_files" \
3945 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3948 { # Rearrange file descriptors. Needed because "while ... done < ..."
3949 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3950 exec 5<&0 < "$tmp"/dirs
3952 if test ! -d "$destdir/$d"; then
3954 echo "Creating directory $destdir/$d"
3955 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3957 echo "Create directory $destdir/$d"
3964 # Copy files or make symbolic links. Remove obsolete files.
3968 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3969 # representing the files according to the last gnulib-tool invocation.
3970 for f in $old_files; do echo $f; done \
3971 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3974 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3975 # representing the files after this gnulib-tool invocation.
3976 for f in $new_files; do echo $f; done \
3977 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3980 # First the files that are in old-files, but not in new-files:
3981 sed_take_first_column='s,'"$delimiter"'.*,,'
3982 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3983 # Remove the file. Do nothing if the user already removed it.
3984 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3986 echo "Removing file $g (backup in ${g}~)"
3987 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3989 echo "Remove file $g (backup in ${g}~)"
3991 func_append removed_files "$g$nl"
3994 # func_add_or_update handles a file that ought to be present afterwards.
3996 # - f the original file name
3997 # - g the rewritten file name
3998 # - already_present nonempty if the file should already exist, empty
4000 func_add_or_update ()
4004 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4006 func_dest_tmpfilename "$g"
4007 func_lookup_file "$f"
4008 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4009 if test -n "$sed_transform_main_lib_file"; then
4012 sed -e "$sed_transform_main_lib_file" \
4013 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4017 if test -n "$sed_transform_build_aux_file"; then
4020 sed -e "$sed_transform_build_aux_file" \
4021 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4025 if test -n "$sed_transform_testsrelated_lib_file"; then
4028 sed -e "$sed_transform_testsrelated_lib_file" \
4029 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4033 if test -f "$destdir/$g"; then
4034 # The file already exists.
4038 # Don't protest if the file should be there but isn't: it happens
4039 # frequently that developers don't put autogenerated files under version control.
4041 func_append added_files "$g$nl"
4045 # Then the files that are in new-files, but not in old-files:
4046 sed_take_last_column='s,^.*'"$delimiter"',,'
4048 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4049 | sed -e "$sed_take_last_column" \
4050 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4051 { # Rearrange file descriptors. Needed because "while ... done < ..."
4052 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4053 exec 5<&0 < "$tmp"/added-files
4059 # Then the files that are in new-files and in old-files:
4060 already_present=true
4061 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4062 | sed -e "$sed_take_last_column" \
4063 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4064 { # Rearrange file descriptors. Needed because "while ... done < ..."
4065 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4066 exec 5<&0 < "$tmp"/kept-files
4073 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4074 actioncmd="gnulib-tool --import"
4075 func_append actioncmd " --dir=$destdir"
4076 if test -n "$local_gnulib_dir"; then
4077 func_append actioncmd " --local-dir=$local_gnulib_dir"
4079 func_append actioncmd " --lib=$libname"
4080 func_append actioncmd " --source-base=$sourcebase"
4081 func_append actioncmd " --m4-base=$m4base"
4082 if test -n "$pobase"; then
4083 func_append actioncmd " --po-base=$pobase"
4085 func_append actioncmd " --doc-base=$docbase"
4086 func_append actioncmd " --tests-base=$testsbase"
4087 func_append actioncmd " --aux-dir=$auxdir"
4088 if test -n "$inctests"; then
4089 func_append actioncmd " --with-tests"
4091 if test -n "$incobsolete"; then
4092 func_append actioncmd " --with-obsolete"
4094 if test -n "$inc_cxx_tests"; then
4095 func_append actioncmd " --with-c++-tests"
4097 if test -n "$inc_longrunning_tests"; then
4098 func_append actioncmd " --with-longrunning-tests"
4100 if test -n "$inc_privileged_tests"; then
4101 func_append actioncmd " --with-privileged-tests"
4103 if test -n "$inc_unportable_tests"; then
4104 func_append actioncmd " --with-unportable-tests"
4106 if test -n "$inc_all_tests"; then
4107 func_append actioncmd " --with-all-tests"
4109 for module in $avoidlist; do
4110 func_append actioncmd " --avoid=$module"
4112 if test -n "$lgpl"; then
4113 if test "$lgpl" = yes; then
4114 func_append actioncmd " --lgpl"
4116 func_append actioncmd " --lgpl=$lgpl"
4119 if test -n "$makefile_name"; then
4120 func_append actioncmd " --makefile-name=$makefile_name"
4122 if test "$libtool" = true; then
4123 func_append actioncmd " --libtool"
4125 func_append actioncmd " --no-libtool"
4127 func_append actioncmd " --macro-prefix=$macro_prefix"
4128 if test -n "$po_domain"; then
4129 func_append actioncmd " --po-domain=$po_domain"
4131 if test -n "$vc_files"; then
4132 if test "$vc_files" = true; then
4133 func_append actioncmd " --vc-files"
4135 func_append actioncmd " --no-vc-files"
4138 func_append actioncmd " `echo $specified_modules`"
4140 # Default the makefile name to Makefile.am.
4141 if test -n "$makefile_name"; then
4142 makefile_am=$makefile_name
4144 makefile_am=Makefile.am
4147 # Create normal Makefile.ams.
4150 # Setup list of Makefile.am edits that are to be performed afterwards.
4151 # Some of these edits apply to files that we will generate; others are
4152 # under the responsibility of the developer.
4154 # func_note_Makefile_am_edit dir var value
4155 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4157 func_note_Makefile_am_edit ()
4159 makefile_am_edits=`expr $makefile_am_edits + 1`
4160 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4161 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4162 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4164 if test "$makefile_am" = Makefile.am; then
4165 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4166 sourcebase_base=`basename "$sourcebase"`
4167 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4169 if test -n "$pobase"; then
4170 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4171 pobase_base=`basename "$pobase"`
4172 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4174 if test -n "$inctests"; then
4175 if test "$makefile_am" = Makefile.am; then
4176 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4177 testsbase_base=`basename "$testsbase"`
4178 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4181 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4183 # Find the first parent directory of $m4base that contains or will contain
4185 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4187 sed_butlast='s,[^/][^/]*//*$,,'
4188 dir1="${m4base}/"; dir2=""
4189 while test -n "$dir1" \
4190 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4191 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4192 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4193 || { test -n "$inctests" \
4194 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4195 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4196 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4197 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4199 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4202 # Create library makefile.
4203 func_dest_tmpfilename $sourcebase/$makefile_am
4204 destfile="$sourcebase/$makefile_am"
4205 modules="$main_modules"
4206 func_emit_lib_Makefile_am > "$tmpfile"
4207 if test -f "$destdir"/$sourcebase/$makefile_am; then
4208 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4212 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4213 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4214 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4216 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4222 echo "Creating $sourcebase/$makefile_am"
4223 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4225 echo "Create $sourcebase/$makefile_am"
4228 func_append added_files "$sourcebase/$makefile_am$nl"
4231 # Create po/ directory.
4232 if test -n "$pobase"; then
4233 # Create po makefile and auxiliary files.
4234 for file in Makefile.in.in remove-potcdate.sin; do
4235 func_dest_tmpfilename $pobase/$file
4236 func_lookup_file build-aux/po/$file
4237 cat "$lookedup_file" > "$tmpfile"
4238 if test -f "$destdir"/$pobase/$file; then
4239 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4243 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4244 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4245 mv -f "$tmpfile" "$destdir"/$pobase/$file
4247 echo "Update $pobase/$file (backup in $pobase/$file~)"
4253 echo "Creating $pobase/$file"
4254 mv -f "$tmpfile" "$destdir"/$pobase/$file
4256 echo "Create $pobase/$file"
4259 func_append added_files "$pobase/$file$nl"
4262 # Create po makefile parameterization, part 1.
4263 func_dest_tmpfilename $pobase/Makevars
4264 func_emit_po_Makevars > "$tmpfile"
4265 if test -f "$destdir"/$pobase/Makevars; then
4266 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4270 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4271 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4272 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4274 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4280 echo "Creating $pobase/Makevars"
4281 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4283 echo "Create $pobase/Makevars"
4286 func_append added_files "$pobase/Makevars$nl"
4288 # Create po makefile parameterization, part 2.
4289 func_dest_tmpfilename $pobase/POTFILES.in
4290 func_emit_po_POTFILES_in > "$tmpfile"
4291 if test -f "$destdir"/$pobase/POTFILES.in; then
4292 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4296 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4297 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4298 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4300 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4306 echo "Creating $pobase/POTFILES.in"
4307 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4309 echo "Create $pobase/POTFILES.in"
4312 func_append added_files "$pobase/POTFILES.in$nl"
4315 TP_URL="http://translationproject.org/latest/"
4316 TP_RSYNC_URI="translationproject.org::tp/latest/"
4318 echo "Fetching gnulib PO files from $TP_URL"
4319 (cd "$destdir"/$pobase \
4320 && { # Prefer rsync over wget if it is available, since it consumes
4321 # less network bandwidth, due to compression.
4322 if type rsync 2>/dev/null | grep / > /dev/null; then
4323 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4325 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4330 echo "Fetch gnulib PO files from $TP_URL"
4332 # Create po/LINGUAS.
4334 func_dest_tmpfilename $pobase/LINGUAS
4335 (cd "$destdir"/$pobase \
4336 && { echo '# Set of available languages.'
4337 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4340 if test -f "$destdir"/$pobase/LINGUAS; then
4341 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4344 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4345 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4346 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4349 echo "Creating $pobase/LINGUAS"
4350 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4351 func_append added_files "$pobase/LINGUAS$nl"
4354 if test -f "$destdir"/$pobase/LINGUAS; then
4355 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4357 echo "Create $pobase/LINGUAS"
4362 # Create m4/gnulib-cache.m4.
4363 func_dest_tmpfilename $m4base/gnulib-cache.m4
4365 func_emit_copyright_notice
4367 echo "# This file represents the specification of how gnulib-tool is used."
4368 echo "# It acts as a cache: It is written and read by gnulib-tool."
4369 echo "# In projects that use version control, this file is meant to be put under"
4370 echo "# version control, like the configure.ac and various Makefile.am files."
4373 echo "# Specification in the form of a command-line invocation:"
4376 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4377 # Store the local_gnulib_dir relative to destdir.
4378 case "$local_gnulib_dir" in
4380 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4383 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4385 # destdir, local_gnulib_dir are both relative.
4386 func_relativize "$destdir" "$local_gnulib_dir"
4387 relative_local_gnulib_dir="$reldir" ;;
4390 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4392 echo "$specified_modules" | sed -e 's/^/ /g'
4394 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4395 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4396 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4397 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4398 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4399 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4400 echo "gl_AVOID([$avoidlist])"
4401 echo "gl_SOURCE_BASE([$sourcebase])"
4402 echo "gl_M4_BASE([$m4base])"
4403 echo "gl_PO_BASE([$pobase])"
4404 echo "gl_DOC_BASE([$docbase])"
4405 echo "gl_TESTS_BASE([$testsbase])"
4406 test -z "$inctests" || echo "gl_WITH_TESTS"
4407 echo "gl_LIB([$libname])"
4408 if test -n "$lgpl"; then
4409 if test "$lgpl" = yes; then
4412 echo "gl_LGPL([$lgpl])"
4415 echo "gl_MAKEFILE_NAME([$makefile_name])"
4416 if test "$libtool" = true; then
4419 echo "gl_MACRO_PREFIX([$macro_prefix])"
4420 echo "gl_PO_DOMAIN([$po_domain])"
4421 if test -n "$vc_files"; then
4422 echo "gl_VC_FILES([$vc_files])"
4425 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4426 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4430 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4431 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4432 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4434 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4438 echo "# gnulib-cache.m4 ends here"
4445 echo "Creating $m4base/gnulib-cache.m4"
4446 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4448 echo "Create $m4base/gnulib-cache.m4"
4454 # Create m4/gnulib-comp.m4.
4455 func_dest_tmpfilename $m4base/gnulib-comp.m4
4457 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4458 func_emit_copyright_notice
4460 echo "# This file represents the compiled summary of the specification in"
4461 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4462 echo "# to be invoked from configure.ac."
4463 echo "# In projects that use version control, this file can be treated like"
4464 echo "# other built files."
4467 echo "# This macro should be invoked from $configure_ac, in the section"
4468 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4469 echo "# any checks for libraries, header files, types and library functions."
4470 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4472 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4473 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4474 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4475 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4476 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4477 if test -n "$uses_subdirs"; then
4478 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4480 for module in $final_modules; do
4482 if test -n "$module"; then
4483 echo "# Code from module $module:"
4484 func_get_autoconf_early_snippet "$module"
4487 | sed -e '/^$/d;' -e 's/^/ /'
4490 echo "# This macro should be invoked from $configure_ac, in the section"
4491 echo "# \"Check for header files, types and library functions\"."
4492 echo "AC_DEFUN([${macro_prefix}_INIT],"
4494 if test "$libtool" = true; then
4495 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4496 echo " gl_cond_libtool=true"
4498 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4499 echo " gl_cond_libtool=false"
4501 echo " gl_ltlibdeps="
4503 if test "$auxdir" != "build-aux"; then
4504 sed_replace_build_aux='
4506 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4507 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4511 sed_replace_build_aux="$sed_noop"
4513 echo " gl_m4_base='$m4base'"
4514 func_emit_initmacro_start $macro_prefix
4515 echo " gl_source_base='$sourcebase'"
4516 for module in $main_modules; do
4518 if test -n "$module"; then
4519 echo " # Code from module $module:"
4520 func_get_autoconf_snippet "$module" \
4521 | sed -e '/^$/d;' -e 's/^/ /' \
4522 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4523 -e "$sed_replace_build_aux"
4524 if test "$module" = 'alloca' && test "$libtool" = true; then
4525 echo 'changequote(,)dnl'
4526 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4527 echo 'changequote([, ])dnl'
4528 echo 'AC_SUBST([LTALLOCA])'
4532 echo " # End of code from modules"
4533 func_emit_initmacro_end $macro_prefix
4534 echo " gltests_libdeps="
4535 echo " gltests_ltlibdeps="
4536 func_emit_initmacro_start ${macro_prefix}tests
4537 echo " gl_source_base='$testsbase'"
4538 # Define a tests witness macro that depends on the package.
4539 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4540 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4541 echo "changequote(,)dnl"
4542 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"
4543 echo "changequote([, ])dnl"
4544 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4545 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4546 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4547 for module in $testsrelated_modules; do
4549 if test -n "$module"; then
4550 func_get_autoconf_snippet "$module" \
4551 | sed -e '/^$/d;' -e 's/^/ /' \
4552 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4553 -e "$sed_replace_build_aux" \
4554 -e 's/\$gl_cond_libtool/false/g' \
4555 -e 's/gl_libdeps/gltests_libdeps/g' \
4556 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4559 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4560 func_emit_initmacro_end ${macro_prefix}tests
4561 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4562 # created using libtool, because libtool already handles the dependencies.
4563 if test "$libtool" != true; then
4564 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4565 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4566 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4567 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4568 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4570 if $use_libtests; then
4571 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4572 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4575 func_emit_initmacro_done $macro_prefix $sourcebase
4576 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4578 echo "# This macro records the list of files which have been installed by"
4579 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4580 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4581 echo "$files" | sed -e 's,^, ,'
4584 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4585 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4589 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4590 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4591 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4593 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4597 echo "# gnulib-comp.m4 ends here"
4604 echo "Creating $m4base/gnulib-comp.m4"
4605 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4607 echo "Create $m4base/gnulib-comp.m4"
4613 if test -n "$inctests"; then
4614 # Create tests makefile.
4615 func_dest_tmpfilename $testsbase/$makefile_am
4616 destfile="$testsbase/$makefile_am"
4617 modules="$testsrelated_modules"
4618 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4619 if test -f "$destdir"/$testsbase/$makefile_am; then
4620 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4624 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4625 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4626 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4628 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4634 echo "Creating $testsbase/$makefile_am"
4635 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4637 echo "Create $testsbase/$makefile_am"
4640 func_append added_files "$testsbase/$makefile_am$nl"
4644 if test "$vc_files" != false; then
4645 # Update the .cvsignore and .gitignore files.
4646 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4647 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4648 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4649 echo "$m4base/|A|gnulib-comp.m4"
4650 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4651 { # Rearrange file descriptors. Needed because "while ... done < ..."
4652 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4653 exec 5<&0 < "$tmp"/fileset-changes
4654 func_update_ignorelist ()
4657 if test "$ignore" = .gitignore; then
4658 # In a .gitignore file, "foo" applies to the current directory and all
4659 # subdirectories, whereas "/foo" applies to the current directory only.
4662 doubly_escaped_anchor='\\/'
4666 doubly_escaped_anchor=''
4668 if test -f "$destdir/$dir$ignore"; then
4669 if test -n "$dir_added" || test -n "$dir_removed"; then
4670 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4671 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4672 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4673 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4674 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4676 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4678 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4679 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4680 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4681 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4682 } > "$tmp"/sed-ignore-removed
4683 { cat "$destdir/$dir$ignore"~
4684 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4685 } | sed -f "$tmp"/sed-ignore-removed \
4686 > "$destdir/$dir$ignore"
4688 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4693 if test -n "$dir_added"; then
4695 echo "Creating $destdir/$dir$ignore"
4697 if test "$ignore" = .cvsignore; then
4699 # Automake generates Makefile rules that create .dirstamp files.
4702 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4703 } > "$destdir/$dir$ignore"
4705 echo "Create $destdir/$dir$ignore"
4715 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4716 func_update_ignorelist .cvsignore
4718 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4719 func_update_ignorelist .gitignore
4726 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4727 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4728 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4729 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4730 if test "$next_dir" != "$last_dir"; then
4731 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4732 last_dir="$next_dir"
4737 A) func_append last_dir_added "$file$nl";;
4738 R) func_append last_dir_removed "$file$nl";;
4741 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4748 echo "You may need to add #include directives for the following .h files."
4749 # Intersect $specified_modules and $main_modules
4750 # (since $specified_modules is not necessarily of subset of $main_modules
4751 # - some may have been skipped through --avoid, and since the elements of
4752 # $main_modules but not in $specified_modules can go away without explicit
4753 # notice - through changes in the module dependencies).
4754 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4755 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4756 # First the #include <...> directives without #ifs, sorted for convenience,
4757 # then the #include "..." directives without #ifs, sorted for convenience,
4758 # then the #include directives that are surrounded by #ifs. Not sorted.
4759 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4760 include_directive=`func_get_include_directive "$module"`
4761 case "$nl$include_directive" in
4763 echo "$include_directive" 1>&5
4766 echo "$include_directive" | grep -v 'include "' 1>&6
4767 echo "$include_directive" | grep 'include "' 1>&7
4770 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4772 LC_ALL=C sort -u "$tmp"/include-angles
4773 LC_ALL=C sort -u "$tmp"/include-quotes
4774 cat "$tmp"/include-if
4775 ) | sed -e '/^$/d' -e 's/^/ /'
4776 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4778 for module in $main_modules; do
4779 func_get_link_directive "$module"
4781 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4782 if test `wc -l < "$tmp"/link` != 0; then
4784 echo "You may need to use the following Makefile variables when linking."
4785 echo "Use them in <program>_LDADD when linking a program, or"
4786 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4792 echo "Don't forget to"
4793 if test "$makefile_am" = Makefile.am; then
4794 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4796 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4798 if test -n "$pobase"; then
4799 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4801 if test -n "$inctests"; then
4802 if test "$makefile_am" = Makefile.am; then
4803 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4805 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4809 while test $edit != $makefile_am_edits; do
4810 edit=`expr $edit + 1`
4811 eval dir=\"\$makefile_am_edit${edit}_dir\"
4812 eval var=\"\$makefile_am_edit${edit}_var\"
4813 eval val=\"\$makefile_am_edit${edit}_val\"
4814 if test -n "$var"; then
4815 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4818 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4819 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4822 # func_create_testdir testdir modules
4824 # - local_gnulib_dir from --local-dir
4825 # - modcache true or false, from --cache-modules/--no-cache-modules
4826 # - auxdir directory relative to destdir where to place build aux files
4827 # - inctests true if tests should be included, blank otherwise
4828 # - incobsolete true if obsolete modules among dependencies should be
4829 # included, blank otherwise
4830 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
4832 # - excl_longrunning_tests true if long-runnings tests should be excluded,
4834 # - excl_privileged_tests true if tests that require root privileges should be
4835 # excluded, blank otherwise
4836 # - excl_unportable_tests true if tests that fail on some platforms should be
4837 # excluded, blank otherwise
4838 # - avoidlist list of modules to avoid
4839 # - libtool true if --libtool was given, false if --no-libtool was
4840 # given, blank otherwise
4841 # - symbolic true if files should be symlinked, copied otherwise
4842 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4844 func_create_testdir ()
4848 if test -z "$modules"; then
4849 # All modules together.
4850 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4851 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4852 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4853 modules=`func_all_modules`
4854 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4856 specified_modules="$modules"
4858 # Canonicalize the list of specified modules.
4859 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4861 # Unlike in func_import, here we want to include all kinds of tests for the
4862 # directly specified modules, but not for dependencies.
4863 inc_all_direct_tests=true
4864 inc_all_indirect_tests="$inc_all_tests"
4866 # Check that the license of every module is consistent with the license of
4868 saved_inctests="$inctests"
4869 # When computing transitive closures, don't consider $module to depend on
4870 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4871 # on GPL modules - therefore we don't want a warning in this case.
4873 for requested_module in $specified_modules; do
4874 requested_license=`func_get_license "$requested_module"`
4875 if test "$requested_license" != GPL; then
4876 # Here we use func_modules_transitive_closure, not just
4877 # func_get_dependencies, so that we also detect weird situations like
4878 # an LGPL module which depends on a GPLed build tool module which depends
4880 modules="$requested_module"
4881 func_modules_transitive_closure
4882 for module in $modules; do
4883 license=`func_get_license "$module"`
4885 'GPLed build tool') ;;
4886 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4888 case "$requested_license" in
4891 GPLv2+ | LGPLv2+) ;;
4892 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4898 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4904 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4913 inctests="$saved_inctests"
4915 # Subdirectory names.
4925 # Determine final module list.
4926 modules="$specified_modules"
4927 func_modules_transitive_closure
4928 if test $verbose -ge 0; then
4929 func_show_module_list
4932 # Add the dummy module if needed.
4933 func_modules_add_dummy
4935 # Show banner notice of every module.
4938 # Determine final file list.
4939 func_modules_to_filelist
4940 if test $verbose -ge 0; then
4942 echo "$files" | sed -e 's/^/ /'
4945 rewritten='%REWRITTEN%'
4946 sed_rewrite_files="\
4947 s,^build-aux/,$rewritten$auxdir/,
4948 s,^doc/,$rewritten$docbase/,
4949 s,^lib/,$rewritten$sourcebase/,
4950 s,^m4/,$rewritten$m4base/,
4951 s,^tests/,$rewritten$testsbase/,
4955 # Create directories.
4956 for f in $files; do echo $f; done \
4957 | sed -e "$sed_rewrite_files" \
4958 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4959 | LC_ALL=C sort -u \
4961 { # Rearrange file descriptors. Needed because "while ... done < ..."
4962 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4963 exec 5<&0 < "$tmp"/dirs
4965 mkdir -p "$testdir/$d"
4970 # Copy files or make symbolic links.
4972 for f in $files; do echo $f; done \
4973 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4976 { # Rearrange file descriptors. Needed because "while ... done < ..."
4977 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4978 exec 5<&0 < "$tmp"/files
4980 func_lookup_file "$f"
4981 if test -n "$lookedup_tmp"; then
4982 cp -p "$lookedup_file" "$testdir/$g"
4984 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4985 if { test -n "$symbolic" \
4986 || { test -n "$lsymbolic" \
4987 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4988 func_ln "$lookedup_file" "$testdir/$g"
4990 cp -p "$lookedup_file" "$testdir/$g"
4997 # Create Makefile.ams that are for testing.
5000 # No special edits are needed.
5003 # Create $sourcebase/Makefile.am.
5004 mkdir -p "$testdir/$sourcebase"
5005 destfile="$sourcebase/Makefile.am"
5006 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5007 any_uses_subdirs="$uses_subdirs"
5009 # Create $m4base/Makefile.am.
5010 mkdir -p "$testdir/$m4base"
5011 (echo "## Process this file with automake to produce Makefile.in."
5017 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5020 ) > "$testdir/$m4base/Makefile.am"
5022 subdirs="$sourcebase $m4base"
5023 subdirs_with_configure_ac=""
5025 if false && test -f "$testdir"/$m4base/gettext.m4; then
5026 # Avoid stupid error message from automake:
5027 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5028 mkdir -p "$testdir/po"
5029 (echo "## Process this file with automake to produce Makefile.in."
5030 ) > "$testdir/po/Makefile.am"
5031 func_append subdirs " po"
5034 if test -n "$inctests"; then
5035 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5036 # Viewed from the $testsbase subdirectory, $auxdir is different.
5037 saved_auxdir="$auxdir"
5038 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5039 # Create $testsbase/Makefile.am.
5041 destfile="$testsbase/Makefile.am"
5042 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5043 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5044 # Create $testsbase/configure.ac.
5045 (echo "# Process this file with autoconf to produce a configure script."
5046 echo "AC_INIT([dummy], [0])"
5047 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5048 echo "AM_INIT_AUTOMAKE"
5050 echo "AC_CONFIG_HEADERS([config.h])"
5053 echo "AC_PROG_INSTALL"
5054 echo "AC_PROG_MAKE_SET"
5055 echo "AC_PROG_RANLIB"
5057 if test -n "$uses_subdirs"; then
5058 echo "AM_PROG_CC_C_O"
5061 for module in $modules; do
5063 if test -n "$module"; then
5065 gnumakefile | maintainer-makefile)
5066 # These modules are meant to be used only in the top-level directory.
5069 func_get_autoconf_early_snippet "$module"
5074 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5075 if test "$libtool" = true; then
5076 echo "LT_INIT([win32-dll])"
5077 echo "LT_LANG([C++])"
5078 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5079 echo "gl_cond_libtool=true"
5081 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5082 echo "gl_cond_libtool=false"
5084 echo "gl_ltlibdeps="
5086 # Wrap the set of autoconf snippets into an autoconf macro that is then
5087 # invoked. This is needed because autoconf does not support AC_REQUIRE
5089 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5090 # but we want the AC_REQUIRE to have its normal meaning (provide one
5091 # expansion of the required macro before the current point, and only one
5093 echo "AC_DEFUN([gl_INIT], ["
5094 sed_replace_build_aux='
5096 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5097 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5100 echo "gl_m4_base='../$m4base'"
5101 func_emit_initmacro_start $macro_prefix
5102 # We don't have explicit ordering constraints between the various
5103 # autoconf snippets. It's cleanest to put those of the library before
5104 # those of the tests.
5105 echo "gl_source_base='../$sourcebase'"
5106 for module in $modules; do
5107 func_verify_nontests_module
5108 if test -n "$module"; then
5110 gnumakefile | maintainer-makefile)
5111 # These modules are meant to be used only in the top-level directory.
5114 func_get_autoconf_snippet "$module" \
5115 | sed -e "$sed_replace_build_aux"
5120 echo "gl_source_base='.'"
5121 for module in $modules; do
5122 func_verify_tests_module
5123 if test -n "$module"; then
5124 func_get_autoconf_snippet "$module" \
5125 | sed -e "$sed_replace_build_aux"
5128 func_emit_initmacro_end $macro_prefix
5129 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5130 # created using libtool, because libtool already handles the dependencies.
5131 if test "$libtool" != true; then
5132 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5133 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5134 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5135 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5136 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5139 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5143 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5144 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5145 echo "AH_TOP([#include \"../config.h\"])"
5147 echo "AC_CONFIG_FILES([Makefile])"
5149 ) > "$testdir/$testsbase/configure.ac"
5150 auxdir="$saved_auxdir"
5151 func_append subdirs " $testsbase"
5152 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5155 # Create Makefile.am.
5156 (echo "## Process this file with automake to produce Makefile.in."
5158 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5160 echo "SUBDIRS = $subdirs"
5162 echo "ACLOCAL_AMFLAGS = -I $m4base"
5163 ) > "$testdir/Makefile.am"
5165 # Create configure.ac.
5166 (echo "# Process this file with autoconf to produce a configure script."
5167 echo "AC_INIT([dummy], [0])"
5168 if test "$auxdir" != "."; then
5169 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5171 echo "AM_INIT_AUTOMAKE"
5173 echo "AC_CONFIG_HEADERS([config.h])"
5176 echo "AC_PROG_INSTALL"
5177 echo "AC_PROG_MAKE_SET"
5179 echo "# For autobuild."
5180 echo "AC_CANONICAL_BUILD"
5181 echo "AC_CANONICAL_HOST"
5183 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5184 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5185 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5186 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5188 echo "AC_PROG_RANLIB"
5190 if test -n "$any_uses_subdirs"; then
5191 echo "AM_PROG_CC_C_O"
5194 for module in $modules; do
5195 func_verify_nontests_module
5196 if test -n "$module"; then
5197 func_get_autoconf_early_snippet "$module"
5200 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5201 if test "$libtool" = true; then
5202 echo "LT_INIT([win32-dll])"
5203 echo "LT_LANG([C++])"
5204 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5205 echo "gl_cond_libtool=true"
5207 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5208 echo "gl_cond_libtool=false"
5210 echo "gl_ltlibdeps="
5212 # Wrap the set of autoconf snippets into an autoconf macro that is then
5213 # invoked. This is needed because autoconf does not support AC_REQUIRE
5215 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5216 # but we want the AC_REQUIRE to have its normal meaning (provide one
5217 # expansion of the required macro before the current point, and only one
5219 echo "AC_DEFUN([gl_INIT], ["
5220 if test "$auxdir" != "build-aux"; then
5221 sed_replace_build_aux='
5223 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5224 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5228 sed_replace_build_aux="$sed_noop"
5230 echo "gl_m4_base='$m4base'"
5231 func_emit_initmacro_start $macro_prefix
5232 echo "gl_source_base='$sourcebase'"
5233 for module in $modules; do
5234 func_verify_nontests_module
5235 if test -n "$module"; then
5236 func_get_autoconf_snippet "$module" \
5237 | sed -e "$sed_replace_build_aux"
5240 func_emit_initmacro_end $macro_prefix
5241 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5242 # created using libtool, because libtool already handles the dependencies.
5243 if test "$libtool" != true; then
5244 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5245 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5246 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5247 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5248 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5251 func_emit_initmacro_done $macro_prefix $sourcebase
5255 if test -n "$subdirs_with_configure_ac"; then
5256 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5258 makefiles="Makefile"
5259 for d in $subdirs; do
5260 # For subdirs that have a configure.ac by their own, it's the subdir's
5261 # configure.ac which creates the subdir's Makefile.am, not this one.
5262 case " $subdirs_with_configure_ac " in
5264 *) func_append makefiles " $d/Makefile" ;;
5267 echo "AC_CONFIG_FILES([$makefiles])"
5269 ) > "$testdir/configure.ac"
5271 # Create autogenerated files.
5273 # Do not use "${AUTORECONF} --force --install", because it may invoke
5274 # autopoint, which brings in older versions of some of our .m4 files.
5275 if test -f $m4base/gettext.m4; then
5276 func_execute_command ${AUTOPOINT} --force || func_exit 1
5277 for f in $m4base/*.m4~; do
5279 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5283 if test "$libtool" = true; then
5284 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5286 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5287 if ! test -d build-aux; then
5288 func_execute_command mkdir build-aux || func_exit 1
5290 func_execute_command ${AUTOCONF} || func_exit 1
5291 func_execute_command ${AUTOHEADER} || func_exit 1
5292 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5294 if test -n "$inctests"; then
5295 # Create autogenerated files.
5296 (cd "$testdir/$testsbase" || func_exit 1
5297 # Do not use "${AUTORECONF} --force --install", because it may invoke
5298 # autopoint, which brings in older versions of some of our .m4 files.
5299 if test -f ../$m4base/gettext.m4; then
5300 func_execute_command ${AUTOPOINT} --force || func_exit 1
5301 for f in ../$m4base/*.m4~; do
5303 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5307 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5308 if ! test -d ../build-aux; then
5309 func_execute_command mkdir ../build-aux
5311 func_execute_command ${AUTOCONF} || func_exit 1
5312 func_execute_command ${AUTOHEADER} || func_exit 1
5313 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5316 # Need to run configure and make once, to create built files that are to be
5317 # distributed (such as getdate.c).
5318 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5319 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5320 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5321 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5322 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5323 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5324 # such $(FOO_H) because they don't refer to distributed files.
5325 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5326 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5327 | sed -e "$sed_remove_make_variables"`
5328 distributed_built_sources=`for file in $built_sources; do
5329 case "$cleaned_files" in
5334 tests_distributed_built_sources=
5335 if test -n "$inctests"; then
5336 # Likewise for built files in the $testsbase directory.
5337 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5338 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5339 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5340 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5341 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5342 | sed -e "$sed_remove_make_variables"`
5343 tests_distributed_built_sources=`for file in $tests_built_sources; do
5344 case "$tests_cleaned_files" in
5350 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5352 ./configure || func_exit 1
5353 if test -n "$distributed_built_sources"; then
5355 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5356 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5361 if test -n "$tests_distributed_built_sources"; then
5363 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5364 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5369 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5376 # func_create_megatestdir megatestdir allmodules
5378 # - local_gnulib_dir from --local-dir
5379 # - modcache true or false, from --cache-modules/--no-cache-modules
5380 # - auxdir directory relative to destdir where to place build aux files
5381 func_create_megatestdir ()
5385 if test -z "$allmodules"; then
5386 allmodules=`func_all_modules`
5390 # First, all modules one by one.
5391 for onemodule in $allmodules; do
5392 func_create_testdir "$megatestdir/$onemodule" $onemodule
5393 func_append megasubdirs "$onemodule "
5395 # Then, all modules all together.
5396 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5397 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5398 func_create_testdir "$megatestdir/ALL" "$allmodules"
5399 func_append megasubdirs "ALL"
5402 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5403 vc_witness="$gnulib_dir/CVS/Entries"; \
5405 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5407 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5408 | sed -e 's,January,01,' -e 's,Jan,01,' \
5409 -e 's,February,02,' -e 's,Feb,02,' \
5410 -e 's,March,03,' -e 's,Mar,03,' \
5411 -e 's,April,04,' -e 's,Apr,04,' \
5413 -e 's,June,06,' -e 's,Jun,06,' \
5414 -e 's,July,07,' -e 's,Jul,07,' \
5415 -e 's,August,08,' -e 's,Aug,08,' \
5416 -e 's,September,09,' -e 's,Sep,09,' \
5417 -e 's,October,10,' -e 's,Oct,10,' \
5418 -e 's,November,11,' -e 's,Nov,11,' \
5419 -e 's,December,12,' -e 's,Dec,12,' \
5420 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5421 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5423 echo "CVSDATE=$cvsdate"
5424 echo ": \${MAKE=make}"
5425 echo "test -d logs || mkdir logs"
5426 echo "for module in $megasubdirs; do"
5427 echo " echo \"Working on module \$module...\""
5428 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5429 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5432 echo " : autobuild project... \$module"
5433 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5434 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5435 echo " : autobuild hostname... \`hostname\`"
5436 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5438 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5440 ) > "$megatestdir/do-autobuild"
5441 chmod a+x "$megatestdir/do-autobuild"
5443 # Create Makefile.am.
5444 (echo "## Process this file with automake to produce Makefile.in."
5446 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5448 echo "SUBDIRS = $megasubdirs"
5450 echo "EXTRA_DIST = do-autobuild"
5451 ) > "$megatestdir/Makefile.am"
5453 # Create configure.ac.
5454 (echo "# Process this file with autoconf to produce a configure script."
5455 echo "AC_INIT([dummy], [0])"
5456 if test "$auxdir" != "."; then
5457 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5459 echo "AM_INIT_AUTOMAKE"
5461 echo "AC_PROG_MAKE_SET"
5463 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5464 echo "AC_CONFIG_FILES([Makefile])"
5466 ) > "$megatestdir/configure.ac"
5468 # Create autogenerated files.
5470 # Do not use "${AUTORECONF} --install", because autoreconf operates
5471 # recursively, but the subdirectories are already finished, therefore
5472 # calling autoreconf here would only waste lots of CPU time.
5473 func_execute_command ${ACLOCAL} || func_exit 1
5474 func_execute_command mkdir build-aux
5475 func_execute_command ${AUTOCONF} || func_exit 1
5476 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5482 func_fatal_error "no mode specified" ;;
5489 # sed expression that converts a literal to a basic regular expression.
5490 # Needs to handle . [ \ * ^ $.
5491 sed_literal_to_basic_regex='s/\\/\\\\/g
5497 if test -f "$gnulib_dir/$filename" \
5498 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5499 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5500 filename_line_regex='^'"$filename_anywhere_regex"'$'
5503 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5504 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5505 (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$,,')
5508 | func_sanitize_modulelist \
5511 for module in $module_candidates; do
5512 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5517 func_warning "file $filename does not exist"
5522 import | add-import | remove-import | update )
5525 if test -z "$destdir"; then
5528 test -d "$destdir" \
5529 || func_fatal_error "destination directory does not exist: $destdir"
5531 # Prefer configure.ac to configure.in.
5532 if test -f "$destdir"/configure.ac; then
5533 configure_ac="$destdir/configure.ac"
5535 if test -f "$destdir"/configure.in; then
5536 configure_ac="$destdir/configure.in"
5538 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5542 # Analyze configure.ac.
5544 guessed_libtool=false
5549 /AC_CONFIG_AUX_DIR/ {
5550 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5552 /A[CM]_PROG_LIBTOOL/ {
5553 s,^.*$,guessed_libtool=true,p
5555 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5557 if test -z "$auxdir"; then
5558 auxdir="$guessed_auxdir"
5561 # Determine where to apply func_import.
5562 if test "$mode" = import; then
5563 # Apply func_import to a particular gnulib directory.
5564 # The command line contains the complete specification; don't look at
5565 # the contents of gnulib-cache.m4.
5566 test -n "$supplied_libname" || supplied_libname=true
5567 test -n "$sourcebase" || sourcebase="lib"
5568 test -n "$m4base" || m4base="m4"
5569 test -n "$docbase" || docbase="doc"
5570 test -n "$testsbase" || testsbase="tests"
5571 test -n "$macro_prefix" || macro_prefix="gl"
5574 if test -n "$m4base"; then
5575 # Apply func_import to a particular gnulib directory.
5576 # Any number of additional modules can be given.
5577 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5578 # First use of gnulib in the given m4base.
5579 test -n "$supplied_libname" || supplied_libname=true
5580 test -n "$sourcebase" || sourcebase="lib"
5581 test -n "$docbase" || docbase="doc"
5582 test -n "$testsbase" || testsbase="tests"
5583 test -n "$macro_prefix" || macro_prefix="gl"
5587 # Apply func_import to all gnulib directories.
5588 # To get this list of directories, look at Makefile.am. (Not at
5589 # configure, because it may be omitted from version control. Also,
5590 # don't run "find $destdir -name gnulib-cache.m4", as it might be
5594 if test -f "$destdir"/Makefile.am; then
5595 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5597 for arg in $aclocal_amflags; do
5598 if test -n "$m4dir_is_next"; then
5599 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5603 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5604 func_append m4dirs " $arg"
5605 m4dirs_count=`expr $m4dirs_count + 1`
5611 if test "X$arg" = "X-I"; then
5619 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5620 if test -f "$destdir"/aclocal.m4; then
5621 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5622 sedexpr2='s,^[^/]*$,.,'
5623 sedexpr3='s,/[^/]*$,,'
5624 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5625 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
5626 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
5629 if test $m4dirs_count = 0; then
5630 # First use of gnulib in a package.
5631 # Any number of additional modules can be given.
5632 test -n "$supplied_libname" || supplied_libname=true
5633 test -n "$sourcebase" || sourcebase="lib"
5635 test -n "$docbase" || docbase="doc"
5636 test -n "$testsbase" || testsbase="tests"
5637 test -n "$macro_prefix" || macro_prefix="gl"
5640 if test $m4dirs_count = 1; then
5641 # There's only one use of gnulib here. Assume the user means it.
5642 # Any number of additional modules can be given.
5643 for m4base in $m4dirs; do
5647 # Ambiguous - guess what the user meant.
5648 if test $# = 0; then
5649 # No further arguments. Guess the user wants to update all of them.
5650 for m4base in $m4dirs; do
5651 # Perform func_import in a subshell, so that variable values
5653 # local_gnulib_dir, incobsolete, inc_cxx_tests,
5654 # inc_longrunning_tests, inc_privileged_tests,
5655 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
5656 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
5657 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5658 # don't propagate from one directory to another.
5659 (func_import) || func_exit 1
5663 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5672 if test -z "$destdir"; then
5673 func_fatal_error "please specify --dir option"
5676 test -d "$destdir" \
5677 || func_fatal_error "could not create destination directory"
5678 test -n "$auxdir" || auxdir="build-aux"
5679 func_create_testdir "$destdir" "$*"
5682 create-megatestdir )
5683 if test -z "$destdir"; then
5684 func_fatal_error "please specify --dir option"
5686 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5687 test -n "$auxdir" || auxdir="build-aux"
5688 func_create_megatestdir "$destdir" "$*"
5692 test -n "$destdir" || destdir=testdir$$
5693 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5694 test -n "$auxdir" || auxdir="build-aux"
5695 func_create_testdir "$destdir" "$*"
5699 ../configure || func_exit 1
5700 $MAKE || func_exit 1
5701 $MAKE check || func_exit 1
5702 $MAKE distclean || func_exit 1
5703 remaining=`find . -type f -print`
5704 if test -n "$remaining"; then
5705 echo "Remaining files:" $remaining 1>&2
5706 echo "gnulib-tool: *** Stop." 1>&2
5715 test -n "$destdir" || destdir=testdir$$
5716 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5717 test -n "$auxdir" || auxdir="build-aux"
5718 func_create_megatestdir "$destdir" "$*"
5726 remaining=`find . -type f -print`
5727 if test -n "$remaining"; then
5728 echo "Remaining files:" $remaining 1>&2
5729 echo "gnulib-tool: *** Stop." 1>&2
5737 extract-description )
5741 if test -n "$module"; then
5742 func_get_description "$module"
5751 if test -n "$module"; then
5752 func_get_comment "$module"
5761 if test -n "$module"; then
5762 func_get_status "$module"
5771 if test -n "$module"; then
5772 func_get_notice "$module"
5777 extract-applicability )
5781 if test -n "$module"; then
5782 func_get_applicability "$module"
5791 if test -n "$module"; then
5792 func_get_filelist "$module"
5797 extract-dependencies )
5801 if test -n "$module"; then
5802 func_get_dependencies "$module"
5807 extract-autoconf-snippet )
5811 if test -n "$module"; then
5812 func_get_autoconf_snippet "$module"
5817 extract-automake-snippet )
5821 if test -n "$module"; then
5822 func_get_automake_snippet "$module"
5827 extract-include-directive )
5831 if test -n "$module"; then
5832 func_get_include_directive "$module"
5837 extract-link-directive )
5841 if test -n "$module"; then
5842 func_get_link_directive "$module"
5851 if test -n "$module"; then
5852 func_get_license "$module"
5857 extract-maintainer )
5861 if test -n "$module"; then
5862 func_get_maintainer "$module"
5867 extract-tests-module )
5871 if test -n "$module"; then
5872 func_get_tests_module "$module"
5878 # Verify the number of arguments.
5879 if test $# -lt 1 || test $# -gt 2; then
5880 func_fatal_error "invalid number of arguments for --$mode"
5883 # The first argument is the file to be copied.
5885 # Verify the file exists.
5886 func_lookup_file "$f"
5888 # The second argument is the destination; either a directory ot a file.
5889 # It defaults to the current directory.
5891 test -n "$dest" || dest='.'
5892 test -n "$sourcebase" || sourcebase="lib"
5893 test -n "$m4base" || m4base="m4"
5894 test -n "$docbase" || docbase="doc"
5895 test -n "$testsbase" || testsbase="tests"
5896 test -n "$auxdir" || auxdir="build-aux"
5897 rewritten='%REWRITTEN%'
5898 sed_rewrite_files="\
5899 s,^build-aux/,$rewritten$auxdir/,
5900 s,^doc/,$rewritten$docbase/,
5901 s,^lib/,$rewritten$sourcebase/,
5902 s,^m4/,$rewritten$m4base/,
5903 s,^tests/,$rewritten$testsbase/,
5906 if test -d "$dest"; then
5908 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5910 destdir=`dirname "$dest"`
5911 g=`basename "$dest"`
5914 # Create the directory for destfile.
5915 d=`dirname "$destdir/$g"`
5917 if test -n "$d" && test ! -d "$d"; then
5918 mkdir -p "$d" || func_fatal_error "failed"
5922 func_dest_tmpfilename "$g"
5923 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5924 already_present=true
5925 if test -f "$destdir/$g"; then
5926 # The file already exists.
5930 # Don't protest if the file should be there but isn't: it happens
5931 # frequently that developers don't put autogenerated files under version
5939 func_fatal_error "unknown operation mode --$mode" ;;
5943 # Undo the effect of the previous 'trap' command. Some shellology:
5944 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5945 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5946 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5947 # 128 + signal number and is set before the trap-registered command is run.
5949 trap 'func_exit $?' 1 2 3 13 15
5954 # indent-tabs-mode: nil
5955 # whitespace-check-buffer-indent: nil