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 # (The GNU autoconf doc says that sed comments are not portable, but does
113 # not say which 'sed' versions are affected.)
114 if echo fo | sed -e 's/f/g/
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
123 # outputs to stdout the --help usage message.
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
131 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
132 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
133 gnulib-tool --test --dir=directory module1 ... moduleN
134 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
135 gnulib-tool --extract-description module
136 gnulib-tool --extract-comment module
137 gnulib-tool --extract-status module
138 gnulib-tool --extract-notice module
139 gnulib-tool --extract-applicability module
140 gnulib-tool --extract-filelist module
141 gnulib-tool --extract-dependencies module
142 gnulib-tool --extract-autoconf-snippet module
143 gnulib-tool --extract-automake-snippet module
144 gnulib-tool --extract-include-directive module
145 gnulib-tool --extract-link-directive module
146 gnulib-tool --extract-license module
147 gnulib-tool --extract-maintainer module
148 gnulib-tool --extract-tests-module module
149 gnulib-tool --copy-file file [destination]
152 --list print the available module names
153 --find find the modules which contain the specified file
154 --import import the given modules into the current package;
155 if no modules are specified, update the current
156 package from the current gnulib
157 --update update the current package, restore files omitted
159 --create-testdir create a scratch package with the given modules
160 --create-megatestdir create a mega scratch package with the given modules
161 one by one and all together
162 --test test the combination of the given modules
163 (recommended to use CC=\"gcc -Wall\" here)
164 --megatest test the given modules one by one and all together
165 (recommended to use CC=\"gcc -Wall\" here)
166 --extract-description extract the description
167 --extract-comment extract the comment
168 --extract-status extract the status (obsolete etc.)
169 --extract-notice extract the notice or banner
170 --extract-applicability extract the applicability
171 --extract-filelist extract the list of files
172 --extract-dependencies extract the dependencies
173 --extract-autoconf-snippet extract the snippet for configure.ac
174 --extract-automake-snippet extract the snippet for library makefile
175 --extract-include-directive extract the #include directive
176 --extract-link-directive extract the linker directive
177 --extract-license report the license terms of the source files
179 --extract-maintainer report the maintainer(s) inside gnulib
180 --extract-tests-module report the unit test module, if it exists
181 --copy-file copy a file that is not part of any module
184 --dir=DIRECTORY Specify the target directory.
185 For --import, this specifies where your
186 configure.ac can be found. Defaults to current
188 --local-dir=DIRECTORY Specify a local override directory where to look
189 up files before looking in gnulib's directory.
190 --cache-modules Enable module caching optimization.
191 --no-cache-modules Disable module caching optimization.
192 --verbose Increase verbosity. May be repeated.
193 --quiet Decrease verbosity. May be repeated.
195 Options for --import, --update:
196 --dry-run Only print what would have been done.
198 Options for --import, --create-[mega]testdir, --[mega]test:
199 --with-tests Include unit tests for the included modules.
200 --with-obsolete Include obsolete modules when they occur among the
201 dependencies. By default, dependencies to obsolete
203 --with-c++-tests Include even unit tests for C++ interoperability.
204 --with-longrunning-tests
205 Include even unit tests that are long-runners.
206 --with-privileged-tests
207 Include even unit tests that require root
209 --with-unportable-tests
210 Include even unit tests that fail on some platforms.
211 --with-all-tests Include all kinds of problematic unit tests.
212 --avoid=MODULE Avoid including the given MODULE. Useful if you
213 have code that provides equivalent functionality.
214 This option can be repeated.
215 --libtool Use libtool rules.
216 --no-libtool Don't use libtool rules.
218 Options for --import:
219 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
220 --source-base=DIRECTORY
221 Directory relative to --dir where source code is
222 placed (default \"lib\").
223 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
224 placed (default \"m4\").
225 --po-base=DIRECTORY Directory relative to --dir where *.po files are
226 placed (default \"po\").
227 --doc-base=DIRECTORY Directory relative to --dir where doc files are
228 placed (default \"doc\").
229 --tests-base=DIRECTORY
230 Directory relative to --dir where unit tests are
231 placed (default \"tests\").
232 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
233 tools are placed (default \"build-aux\").
234 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
235 Also modify license template from GPL to LGPL.
236 The version number of the LGPL can be specified;
237 the default is currently LGPLv3.
238 --makefile-name=NAME Name of makefile in automake syntax in the
239 source-base and tests-base directories
240 (default \"Makefile.am\").
241 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
242 'gl_INIT'. Default is 'gl'.
243 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
244 the package name. A suffix '-gnulib' is appended.
245 --vc-files Update version control related files.
246 --no-vc-files Don't update version control related files
247 (.gitignore and/or .cvsignore).
248 --no-changelog Don't update or create ChangeLog files.
250 Options for --create-[mega]testdir, --[mega]test:
251 --without-c++-tests Exclude unit tests for C++ interoperability.
252 --without-longrunning-tests
253 Exclude unit tests that are long-runners.
254 --without-privileged-tests
255 Exclude unit tests that require root privileges.
256 --without-unportable-tests
257 Exclude unit tests that fail on some platforms.
259 Options for --import, --update, --create-[mega]testdir, --[mega]test:
260 -s, --symbolic, --symlink Make symbolic links instead of copying files.
261 --local-symlink Make symbolic links instead of copying files, only
262 for files from the local override directory.
264 Options for --import, --update:
265 -S, --more-symlinks Make symbolic links instead of copying files, and
266 don't replace copyright notices.
268 Report bugs to <bug-gnulib@gnu.org>."
272 # outputs to stdout the --version message.
276 if test -d "$gnulib_dir"/.git \
277 && (git --version) >/dev/null 2>/dev/null \
278 && (date --version) >/dev/null 2>/dev/null; then
279 # gnulib checked out from git.
280 sed_extract_first_date='/^Date/{
284 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
285 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
286 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
287 date=`echo "$date" | sed -e "$sed_year_before_time"`
288 # Use GNU date to compute the time in GMT.
289 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
290 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
292 if test -d "$gnulib_dir"/CVS \
293 && (cvs --version) >/dev/null 2>/dev/null; then
294 # gnulib checked out from CVS.
295 sed_extract_first_date='/^date: /{
296 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
299 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
301 # gnulib copy without versioning information.
302 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
306 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
308 gnulib-tool (GNU $package $date)$version
309 Copyright (C) $year Free Software Foundation, Inc.
310 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
311 This is free software: you are free to change and redistribute it.
312 There is NO WARRANTY, to the extent permitted by law.
314 Written by" "Bruno Haible" "and" "Simon Josefsson"
317 # func_emit_copyright_notice
318 # outputs to stdout a header for a generated file.
319 func_emit_copyright_notice ()
321 sed -n -e '/Copyright/ {
324 }' < "$self_abspathname"
326 echo "# This file is free software, distributed under the terms of the GNU"
327 echo "# General Public License. As a special exception to the GNU General"
328 echo "# Public License, this file may be distributed as part of a program"
329 echo "# that contains a configuration script generated by Autoconf, under"
330 echo "# the same distribution terms as the rest of that program."
332 echo "# Generated by gnulib-tool."
336 # exits with a given status.
337 # This function needs to be used, rather than 'exit', when a 'trap' handler is
338 # in effect that refers to $?.
345 # locates the directory where the gnulib repository lives
347 # - progname name of this program
349 # - self_abspathname absolute pathname of gnulib-tool
350 # - gnulib_dir absolute pathname of gnulib repository
354 /*) self_abspathname="$progname" ;;
355 */*) self_abspathname=`pwd`/"$progname" ;;
358 # Iterate through the elements of $PATH.
359 # We use IFS=: instead of
360 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
361 # because the latter does not work when some PATH element contains spaces.
362 # We use a canonicalized $pathx instead of $PATH, because empty PATH
363 # elements are by definition equivalent to '.', however field splitting
364 # according to IFS=: loses empty fields in many shells:
365 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
366 # beginning, at the end, and in the middle),
367 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
368 # at the beginning and at the end,
369 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
370 # Solaris lose empty fields at the end.
371 # The 'case' statement is an optimization, to avoid evaluating the
372 # explicit canonicalization command when $PATH contains no empty fields.
374 if test "${PATH_SEPARATOR+set}" != set; then
376 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
377 chmod +x "$tmp"/conf.sh
378 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
385 if test "$PATH_SEPARATOR" = ";"; then
386 # On Windows, programs are searched in "." before $PATH.
389 # On Unix, we have to convert empty PATH elements to ".".
393 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
398 IFS="$PATH_SEPARATOR"
402 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
403 self_abspathname="$d/$progname"
408 if test -z "$self_abspathname"; then
409 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
413 while test -h "$self_abspathname"; do
414 # Resolve symbolic link.
415 linkval=`func_readlink "$self_abspathname"`
416 test -n "$linkval" || break
418 /* ) self_abspathname="$linkval" ;;
419 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
422 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
426 # creates a temporary directory.
428 # - progname name of this program
430 # - tmp pathname of freshly created temporary directory
433 # Use the environment variable TMPDIR, falling back to /tmp. This allows
434 # users to specify a different temporary directory, for example, if their
435 # /tmp is filled up or too small.
438 # Use the mktemp program if available. If not available, hide the error
440 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
441 test -n "$tmp" && test -d "$tmp"
444 # Use a simple mkdir command. It is guaranteed to fail if the directory
445 # already exists. $RANDOM is bash specific and expands to empty in shells
446 # other than bash, ksh and zsh. Its use does not increase security;
447 # rather, it minimizes the probability of failure in a very cluttered /tmp
449 tmp=$TMPDIR/gl$$-$RANDOM
450 (umask 077 && mkdir "$tmp")
453 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
458 # func_append var value
459 # appends the given value to the shell variable var.
460 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
461 # Use bash's += operator. It reduces complexity of appending repeatedly to
462 # a single variable from O(n^2) to O(n).
467 fast_func_append=true
471 eval "$1=\"\$$1\$2\""
473 fast_func_append=false
476 # func_remove_prefix var prefix
477 # removes the given prefix from the value of the shell variable var.
478 # var should be the name of a shell variable.
479 # Its value should not contain a newline and not start or end with whitespace.
480 # prefix should not contain the characters "$`\{}[]^|.
481 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
482 func_remove_prefix ()
486 fast_func_remove_prefix=true
488 func_remove_prefix ()
490 eval "value=\"\$$1\""
494 sed_escape_dots='s/\([.]\)/\\\1/g'
495 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
498 value=`echo "$value" | sed -e "s|^${prefix}||"`
499 eval "$1=\"\$value\""
501 fast_func_remove_prefix=false
504 # func_remove_suffix var suffix
505 # removes the given suffix from the value of the shell variable var.
506 # var should be the name of a shell variable.
507 # Its value should not contain a newline and not start or end with whitespace.
508 # suffix should not contain the characters "$`\{}[]^|.
509 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
510 func_remove_suffix ()
514 fast_func_remove_suffix=true
516 func_remove_suffix ()
518 eval "value=\"\$$1\""
522 sed_escape_dots='s/\([.]\)/\\\1/g'
523 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
526 value=`echo "$value" | sed -e "s|${suffix}\$||"`
527 eval "$1=\"\$value\""
529 fast_func_remove_suffix=false
532 # func_fatal_error message
533 # outputs to stderr a fatal error message, and terminates the program.
535 # - progname name of this program
538 echo "$progname: *** $1" 1>&2
539 echo "$progname: *** Stop." 1>&2
543 # func_warning message
544 # Outputs to stderr a warning message,
547 echo "gnulib-tool: warning: $1" 1>&2
550 # func_readlink SYMLINK
551 # outputs the target of the given symlink.
552 if (type -p readlink) > /dev/null 2>&1; then
555 # Use the readlink program from GNU coreutils.
561 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
562 # would do the wrong thing if the link target contains " -> ".
563 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
567 # func_relativize DIR1 DIR2
568 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
570 # - DIR1 relative pathname, relative to the current directory
571 # - DIR2 relative pathname, relative to the current directory
573 # - reldir relative pathname of DIR2, relative to DIR1
579 sed_first='s,^\([^/]*\)/.*$,\1,'
580 sed_rest='s,^[^/]*/*,,'
581 sed_last='s,^.*/\([^/]*\)$,\1,'
582 sed_butlast='s,/*[^/]*$,,'
583 while test -n "$dir1"; do
584 first=`echo "$dir1" | sed -e "$sed_first"`
585 if test "$first" != "."; then
586 if test "$first" = ".."; then
587 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
588 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
590 first2=`echo "$dir2" | sed -e "$sed_first"`
591 if test "$first2" = "$first"; then
592 dir2=`echo "$dir2" | sed -e "$sed_rest"`
596 dir0="$dir0"/"$first"
599 dir1=`echo "$dir1" | sed -e "$sed_rest"`
604 # func_relconcat DIR1 DIR2
605 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
607 # - DIR1 relative pathname, relative to the current directory
608 # - DIR2 relative pathname, relative to DIR1
610 # - relconcat DIR1/DIR2, relative to the current directory
615 sed_first='s,^\([^/]*\)/.*$,\1,'
616 sed_rest='s,^[^/]*/*,,'
617 sed_last='s,^.*/\([^/]*\)$,\1,'
618 sed_butlast='s,/*[^/]*$,,'
620 first=`echo "$dir2" | sed -e "$sed_first"`
621 if test "$first" = "."; then
622 dir2=`echo "$dir2" | sed -e "$sed_rest"`
623 if test -z "$dir2"; then
628 last=`echo "$dir1" | sed -e "$sed_last"`
629 while test "$last" = "."; do
630 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
631 last=`echo "$dir1" | sed -e "$sed_last"`
633 if test -z "$dir1"; then
637 if test "$first" = ".."; then
638 if test "$last" = ".."; then
639 relconcat="$dir1/$dir2"
642 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
643 dir2=`echo "$dir2" | sed -e "$sed_rest"`
644 if test -z "$dir1"; then
648 if test -z "$dir2"; then
653 relconcat="$dir1/$dir2"
661 # Like ln -s, except that SRC is given relative to the current directory (or
662 # absolute), not given relative to the directory of DEST.
668 *) # SRC is relative.
671 ln -s "`pwd`/$1" "$2" ;;
672 *) # DEST is relative too.
673 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
674 test -n "$ln_destdir" || ln_destdir="."
675 func_relativize "$ln_destdir" "$1"
683 # func_ln_if_changed SRC DEST
684 # Like func_ln, but avoids munging timestamps if the link is correct.
685 func_ln_if_changed ()
687 if test $# -ne 2; then
688 echo "usage: func_ln_if_changed SRC DEST" >&2
690 ln_target=`func_readlink "$2"`
691 if test -h "$2" && test "$1" = "$ln_target"; then
699 # Ensure an 'echo' command that
700 # 1. does not interpret backslashes and
701 # 2. does not print an error message "broken pipe" when writing into a pipe
704 # Test cases for problem 1:
705 # echo '\n' | wc -l prints 1 when OK, 2 when KO
706 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
707 # Test cases for problem 2:
708 # echo hi | true frequently prints
709 # "bash: echo: write error: Broken pipe"
710 # to standard error in bash 3.2.
712 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
713 # BSD echo interprets '-n' as an option, which is also not desirable).
714 # Nowadays the problem occurs in 4 situations:
715 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
716 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
717 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
718 # - in zsh, when sh-emulation is not set,
719 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
720 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
721 # - in Solaris /bin/sh and OSF/1 /bin/sh.
722 # We try the following workarounds:
723 # - for all: respawn using $CONFIG_SHELL if that is set and works.
724 # - for bash >= 2.04: unset the shell option xpg_echo.
725 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
726 # - for bash < 2.0: define echo to a function that uses cat of a here document.
727 # - for zsh: turn sh-emulation on.
728 # - for ksh: alias echo to 'print -r'.
729 # - for ksh: alias echo to a function that uses cat of a here document.
730 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
731 # the ksh workaround.
732 # - otherwise: respawn using /bin/sh and rely on the workarounds.
733 # When respawning, we pass --no-reexec as first argument, so as to avoid
734 # turning this script into a fork bomb in unlucky situations.
736 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
737 # the 'printf' built-in. See
738 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
739 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
740 # The workaround is: define echo to a function that uses the printf built-in.
742 if echo '\t' | grep t > /dev/null; then
743 have_echo=yes # Lucky!
745 # Try the workarounds.
746 # Respawn using $CONFIG_SHELL if that is set and works.
747 if test -z "$have_echo" \
748 && test "X$1" != "X--no-reexec" \
749 && test -n "$CONFIG_SHELL" \
750 && test -f "$CONFIG_SHELL" \
751 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
752 exec $CONFIG_SHELL "$0" --no-reexec "$@"
755 # For bash >= 2.04: unset the shell option xpg_echo.
756 if test -z "$have_echo" \
757 && test -n "$BASH_VERSION" \
758 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
762 # For bash >= 2.0: define echo to a function that uses the printf built-in.
763 # For bash < 2.0: define echo to a function that uses cat of a here document.
764 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
765 # Also handle problem 2, specific to bash 3.2, here.
766 if { test -z "$have_echo" \
767 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
769 && test -n "$BASH_VERSION"; then \
770 if type printf 2>/dev/null | grep / > /dev/null; then
771 # 'printf' is not a shell built-in.
779 # 'printf' is a shell built-in.
785 if echo '\t' | grep t > /dev/null; then
789 # For zsh: turn sh-emulation on.
790 if test -z "$have_echo" \
791 && test -n "$ZSH_VERSION" \
792 && (emulate sh) >/dev/null 2>&1; then
795 # For ksh: alias echo to 'print -r'.
796 if test -z "$have_echo" \
797 && (type print) >/dev/null 2>&1; then
798 # A 'print' command exists.
799 if type print 2>/dev/null | grep / > /dev/null; then
802 # 'print' is a shell built-in.
803 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
804 # 'print' is the ksh shell built-in.
805 alias echo='print -r'
809 if test -z "$have_echo" \
810 && echo '\t' | grep t > /dev/null; then
813 # For ksh: alias echo to a function that uses cat of a here document.
814 # The ksh manual page says:
815 # "Aliasing is performed when scripts are read, not while they are executed.
816 # Therefore, for an alias to take effect, the alias definition command has
817 # to be executed before the command which references the alias is read."
818 # Because of this, we have to play strange tricks with have_echo, to ensure
819 # that the top-level statement containing the test starts after the 'alias'
821 if test -z "$have_echo"; then
828 alias echo=bsd_echo 2>/dev/null
830 if test -z "$have_echo" \
831 && echo '\t' | grep t > /dev/null; then
834 if test -z "$have_echo"; then
835 unalias echo 2>/dev/null
837 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
838 if test -z "$have_echo" \
839 && test "X$1" != "X--no-reexec" \
840 && test -f /bin/ksh; then
841 exec /bin/ksh "$0" --no-reexec "$@"
844 # Otherwise: respawn using /bin/sh.
845 if test -z "$have_echo" \
846 && test "X$1" != "X--no-reexec" \
847 && test -f /bin/sh; then
848 exec /bin/sh "$0" --no-reexec "$@"
851 if test -z "$have_echo"; then
852 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
854 if echo '\t' | grep t > /dev/null; then
857 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
859 if test "X$1" = "X--no-reexec"; then
863 # Command-line option processing.
864 # Removes the OPTIONS from the arguments. Sets the variables:
865 # - mode list or import or create-testdir or create-megatestdir
866 # - destdir from --dir
867 # - local_gnulib_dir from --local-dir
868 # - modcache true or false, from --cache-modules/--no-cache-modules
869 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
870 # - libname, supplied_libname from --lib
871 # - sourcebase from --source-base
872 # - m4base from --m4-base
873 # - pobase from --po-base
874 # - docbase from --doc-base
875 # - testsbase from --tests-base
876 # - auxdir from --aux-dir
877 # - inctests true if --with-tests was given, blank otherwise
878 # - incobsolete true if --with-obsolete was given, blank otherwise
879 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
880 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
882 # - inc_privileged_tests true if --with-privileged-tests was given, blank
884 # - inc_unportable_tests true if --with-unportable-tests was given, blank
886 # - inc_all_tests true if --with-all-tests was given, blank otherwise
887 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
888 # - excl_longrunning_tests true if --without-longrunning-tests was given,
890 # - excl_privileged_tests true if --without-privileged-tests was given, blank
892 # - excl_unportable_tests true if --without-unportable-tests was given, blank
894 # - avoidlist list of modules to avoid, from --avoid
895 # - lgpl yes or a number if --lgpl was given, blank otherwise
896 # - makefile_name from --makefile-name
897 # - libtool true if --libtool was given, false if --no-libtool was
898 # given, blank otherwise
899 # - macro_prefix from --macro-prefix
900 # - po_domain from --po-domain
901 # - vc_files true if --vc-files was given, false if --no-vc-files was
902 # given, blank otherwise
903 # - autoconf_minversion minimum supported autoconf version
904 # - do_changelog false if --no-changelog was given, : otherwise
905 # - doit : if actions shall be executed, false if only to be printed
906 # - symbolic true if --symlink or --more-symlinks was given, blank
908 # - lsymbolic true if --local-symlink was given, blank otherwise
909 # - do_copyrights blank if --more-symlinks was given, true otherwise
927 inc_longrunning_tests=
928 inc_privileged_tests=
929 inc_unportable_tests=
932 excl_longrunning_tests=
933 excl_privileged_tests=
934 excl_unportable_tests=
950 while test $# -gt 0; do
955 --find | --fin | --fi | --f )
958 --import | --impor | --impo | --imp | --im | --i )
961 --update | --updat | --upda | --upd | --up | --u )
964 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
967 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
968 mode=create-megatestdir
970 --test | --tes | --te | --t )
973 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
977 mode=`echo "X$1" | sed -e 's/^X--//'`
979 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
985 func_fatal_error "missing argument for --dir"
990 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
995 func_fatal_error "missing argument for --local-dir"
1000 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1002 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1005 --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 )
1008 --verbose | --verbos | --verbo | --verb )
1009 verbose=`expr $verbose + 1`
1011 --quiet | --quie | --qui | --qu | --q )
1012 verbose=`expr $verbose - 1`
1016 if test $# = 0; then
1017 func_fatal_error "missing argument for --lib"
1020 supplied_libname=true
1023 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1024 supplied_libname=true
1028 if test $# = 0; then
1029 func_fatal_error "missing argument for --source-base"
1034 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1038 if test $# = 0; then
1039 func_fatal_error "missing argument for --m4-base"
1044 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1048 if test $# = 0; then
1049 func_fatal_error "missing argument for --po-base"
1054 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1058 if test $# = 0; then
1059 func_fatal_error "missing argument for --doc-base"
1064 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1068 if test $# = 0; then
1069 func_fatal_error "missing argument for --tests-base"
1074 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1078 if test $# = 0; then
1079 func_fatal_error "missing argument for --aux-dir"
1084 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1086 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1089 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1092 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1095 --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)
1096 inc_longrunning_tests=true
1098 --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)
1099 inc_privileged_tests=true
1101 --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)
1102 inc_unportable_tests=true
1104 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1107 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1110 --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)
1111 excl_longrunning_tests=true
1113 --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)
1114 excl_privileged_tests=true
1116 --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)
1117 excl_unportable_tests=true
1121 if test $# = 0; then
1122 func_fatal_error "missing argument for --avoid"
1124 func_append avoidlist " $1"
1127 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1128 func_append avoidlist " $arg"
1134 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1137 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1143 if test $# = 0; then
1144 func_fatal_error "missing argument for --makefile-name"
1149 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1159 if test $# = 0; then
1160 func_fatal_error "missing argument for --macro-prefix"
1165 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1169 if test $# = 0; then
1170 func_fatal_error "missing argument for --po-domain"
1175 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1183 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1189 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1192 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1195 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1199 --help | --hel | --he | --h )
1202 --version | --versio | --versi | --vers )
1206 # Stop option processing
1210 echo "gnulib-tool: unknown option $1" 1>&2
1211 echo "Try 'gnulib-tool --help' for more information." 1>&2
1218 if test "$mode" = import; then
1219 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1220 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests"; then
1221 echo "gnulib-tool: invalid options for 'import' mode" 1>&2
1222 echo "Try 'gnulib-tool --help' for more information." 1>&2
1226 if test "$mode" = update; then
1227 if test $# != 0; then
1228 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1229 echo "Try 'gnulib-tool --help' for more information." 1>&2
1230 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1231 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1234 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1235 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1236 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1237 || test -n "$inctests" || test -n "$incobsolete" \
1238 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1239 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1240 || test -n "$inc_all_tests" \
1241 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1242 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1243 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1244 || test -n "$macro_prefix" || test -n "$po_domain" \
1245 || test -n "$vc_files"; then
1246 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1247 echo "Try 'gnulib-tool --help' for more information." 1>&2
1248 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1249 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1254 if test -n "$pobase" && test -z "$po_domain"; then
1255 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1256 echo "Try 'gnulib-tool --help' for more information." 1>&2
1259 if test -z "$pobase" && test -n "$po_domain"; then
1260 func_warning "--po-domain has no effect without a --po-base option"
1263 # Determine the minimum supported autoconf version from the project's
1265 DEFAULT_AUTOCONF_MINVERSION="2.59"
1266 autoconf_minversion=
1268 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1269 if test -f "$destdir"/configure.ac; then
1270 configure_ac="$destdir/configure.ac"
1272 if test -f "$destdir"/configure.in; then
1273 configure_ac="$destdir/configure.in"
1277 if test -f configure.ac; then
1278 configure_ac="configure.ac"
1280 if test -f configure.in; then
1281 configure_ac="configure.in"
1285 if test -n "$configure_ac"; then
1286 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1287 # because when some m4 files are omitted from a CVS repository,
1288 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1289 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1290 # autom4te: m4 failed with exit status: 1
1297 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1299 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1300 if test -n "$prereqs"; then
1301 autoconf_minversion=`
1302 for version in $prereqs; do echo $version; done |
1303 LC_ALL=C sort -nru | sed -e 1q
1307 if test -z "$autoconf_minversion"; then
1308 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1310 case "$autoconf_minversion" in
1311 1.* | 2.[0-4]* | 2.5[0-8]*)
1312 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1315 # Remove trailing slashes from the directory names. This is necessary for
1316 # m4base (to avoid an error in func_import) and optional for the others.
1317 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1318 case "$local_gnulib_dir" in
1319 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1321 case "$sourcebase" in
1322 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1325 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1328 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1331 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1333 case "$testsbase" in
1334 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1337 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1343 trap 'exit_status=$?
1344 if test "$signal" != 0; then
1345 echo "caught signal $signal" >&2
1348 exit $exit_status' 0
1349 for signal in 1 2 3 13 15; do
1350 trap '{ signal='$signal'; func_exit 1; }' $signal
1354 # func_lookup_file file
1355 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1358 # - local_gnulib_dir from --local-dir
1360 # - lookedup_file name of the merged (combined) file
1361 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1365 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1366 lookedup_file="$local_gnulib_dir/$lkfile"
1369 if test -f "$gnulib_dir/$lkfile"; then
1370 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1371 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1372 rm -f "$tmp/$lkbase"
1373 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1374 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1375 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1376 lookedup_file="$tmp/$lkbase"
1379 lookedup_file="$gnulib_dir/$lkfile"
1383 func_fatal_error "file $gnulib_dir/$lkfile not found"
1388 # func_sanitize_modulelist
1389 # receives a list of possible module names on standard input, one per line.
1390 # It removes those which are just file names unrelated to modules, and outputs
1391 # the resulting list to standard output, one per line.
1392 func_sanitize_modulelist ()
1394 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1395 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1396 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1397 -e '/^README$/d' -e '/\/README$/d' \
1398 -e '/^TEMPLATE$/d' \
1399 -e '/^TEMPLATE-EXTENDED$/d' \
1400 -e '/^TEMPLATE-TESTS$/d' \
1407 # - local_gnulib_dir from --local-dir
1410 # Filter out metainformation files like README, which are not modules.
1411 # Filter out unit test modules; they can be retrieved through
1412 # --extract-tests-module if desired.
1414 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1415 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1416 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1419 | func_sanitize_modulelist \
1420 | sed -e '/-tests$/d' \
1424 # func_exists_module module
1425 # tests whether a module, given by name, exists
1427 # - local_gnulib_dir from --local-dir
1428 func_exists_module ()
1430 { test -f "$gnulib_dir/modules/$1" \
1431 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1432 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1433 && test "CVS" != "$1" \
1434 && test "ChangeLog" != "$1" \
1435 && test "COPYING" != "$1" \
1436 && test "README" != "$1" \
1437 && test "TEMPLATE" != "$1" \
1438 && test "TEMPLATE-EXTENDED" != "$1" \
1439 && test "TEMPLATE-TESTS" != "$1"
1442 # func_verify_module
1443 # verifies a module name
1445 # - local_gnulib_dir from --local-dir
1446 # - module module name argument
1447 func_verify_module ()
1449 if func_exists_module "$module"; then
1450 # OK, $module is a correct module name.
1451 # Verify that building the module description with 'patch' succeeds.
1452 func_lookup_file "modules/$module"
1454 func_warning "module $module doesn't exist"
1459 # func_verify_nontests_module
1460 # verifies a module name, excluding tests modules
1462 # - local_gnulib_dir from --local-dir
1463 # - module module name argument
1464 func_verify_nontests_module ()
1467 *-tests ) module= ;;
1468 * ) func_verify_module ;;
1472 # func_verify_tests_module
1473 # verifies a module name, considering only tests modules
1475 # - local_gnulib_dir from --local-dir
1476 # - module module name argument
1477 func_verify_tests_module ()
1480 *-tests ) func_verify_module ;;
1485 # Suffix of a sed expression that extracts a particular field from a
1486 # module description.
1487 # A field starts with a line that contains a keyword, such as 'Description',
1488 # followed by a colon and optional whitespace. All following lines, up to
1489 # the next field (or end of file if there is none) form the contents of the
1491 # An absent field is equivalent to a field with empty contents.
1492 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1493 sed_extract_prog=':[ ]*$/ {
1496 s/^Description:[ ]*$//
1500 s/^Applicability:[ ]*$//
1502 s/^Depends-on:[ ]*$//
1503 s/^configure\.ac-early:[ ]*$//
1504 s/^configure\.ac:[ ]*$//
1505 s/^Makefile\.am:[ ]*$//
1509 s/^Maintainer:[ ]*$//
1516 # Piece of a sed expression that converts a field header line to a shell
1518 # NOTE: Keep this in sync with sed_extract_prog above!
1519 sed_extract_field_header='
1520 s/^Description:[ ]*$/description/
1521 s/^Comment:[ ]*$/comment/
1522 s/^Status:[ ]*$/status/
1523 s/^Notice:[ ]*$/notice/
1524 s/^Applicability:[ ]*$/applicability/
1525 s/^Files:[ ]*$/files/
1526 s/^Depends-on:[ ]*$/dependson/
1527 s/^configure\.ac-early:[ ]*$/configureac_early/
1528 s/^configure\.ac:[ ]*$/configureac/
1529 s/^Makefile\.am:[ ]*$/makefile/
1530 s/^Include:[ ]*$/include/
1532 s/^License:[ ]*$/license/
1533 s/^Maintainer:[ ]*$/maintainer/'
1537 # Note: The 'eval' silences stderr output in dash.
1538 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1539 # Zsh 4 and Bash 4 have associative arrays.
1540 have_associative=true
1542 # For other shells, use 'eval' with computed shell variable names.
1543 have_associative=false
1546 if $have_associative; then
1548 # Declare the associative arrays.
1549 declare -A modcache_cached
1550 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1551 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1552 eval "$declare_script"
1556 # func_cache_var module
1557 # computes the cache variable name corresponding to $module.
1558 # Note: This computation can map different module names to the same
1559 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1560 # to protect against this case.
1562 # - cachevar a shell variable name
1563 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1564 # Bash 2.0 and newer, ksh, and zsh support the syntax
1565 # ${param//pattern/replacement}
1566 # as a shorthand for
1567 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1568 # Note: The 'eval' above silences stderr output in dash.
1571 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1578 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1587 # func_init_sed_convert_to_cache_statements
1589 # - modcachevar_assignment
1591 # - sed_convert_to_cache_statements
1592 func_init_sed_convert_to_cache_statements ()
1594 # 'sed' script that turns a module description into shell script
1595 # assignments, suitable to be eval'ed. All active characters are escaped.
1598 # Some module's description
1603 # modcache_description[$1]=\
1604 # 'Some module'"'"'s description
1606 # modcache_files[$1]=\
1609 # c_MODULE_description_set=set; c_MODULE_description=\
1610 # 'Some module'"'"'s description
1612 # c_MODULE_files_set=set; c_MODULE_files=\
1614 # The script consists of two parts:
1615 # 1) Ignore the lines before the first field header.
1616 # 2) A loop, treating non-field-header lines by escaping single quotes
1617 # and adding a closing quote in the last line,
1618 sed_convert_to_cache_statements="
1620 # Here we have not yet seen a field header.
1622 # See if the current line contains a field header.
1625 ${sed_extract_field_header}
1628 # No field header. Ignore the line.
1630 # Read the next line. Upon EOF, just exit.
1635 # The current line contains a field header.
1637 # Turn it into the beginning of an assignment.
1638 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1640 # Move it to the hold space. Don't print it yet,
1641 # because we want no assignment if the field is empty.
1644 # Read the next line.
1645 # Upon EOF, the field was empty. Print no assignment. Just exit.
1648 # See if the current line contains a field header.
1651 ${sed_extract_field_header}
1652 # If it is, the previous field was empty. Print no assignment.
1655 # Not a field header.
1657 # Print the previous line, held in the hold space.
1662 # Transform single quotes.
1665 # Prepend a single quote.
1670 # Move it to the hold space.
1673 # Read the next line.
1680 # See if the current line contains a field header.
1683 ${sed_extract_field_header}
1686 # Print the previous line, held in the hold space.
1691 # Transform single quotes.
1698 # Print the previous line, held in the hold space, with a single quote
1699 # to end the assignment.
1709 # Print the previous line, held in the hold space, with a single quote
1710 # to end the assignment.
1717 if ! $sed_comments; then
1719 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1720 | sed -e 's/^ *//' -e 's/^#.*//'`
1724 if $have_associative; then
1725 # sed_convert_to_cache_statements does not depend on the module.
1726 modcachevar_assignment='modcache_\1[$1]='
1727 func_init_sed_convert_to_cache_statements
1730 # func_cache_lookup_module module
1732 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1733 # of its relevant data in a cache in the memory of the processing shell. If
1734 # already cached, it does not look it up again, thus saving file access time.
1736 # - module non-empty string
1737 # Output if $have_associative:
1738 # - modcache_cached[$module] set to yes
1739 # - modcache_description[$module] ==
1740 # - modcache_status[$module] \ set to the field's value, minus the
1741 # - ... / final newline,
1742 # - modcache_maintainer[$module] == or unset if the field's value is empty
1743 # Output if ! $have_associative:
1744 # - cachevar a shell variable name
1745 # - ${cachevar}_cached set to $module
1746 # - ${cachevar}_description ==
1747 # - ${cachevar}_status \ set to the field's value, minus the
1748 # - ... / final newline,
1749 # - ${cachevar}_maintainer == or unset if the field's value is empty
1750 # - ${cachevar}_description_set ==
1751 # - ${cachevar}_status_set \ set to non-empty if the field's value
1752 # - ... / is non-empty,
1753 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1754 func_cache_lookup_module ()
1756 if $have_associative; then
1757 cached=${modcache_cached[$1]}
1760 eval "cached=\"\$${cachevar}_cached\""
1762 if test -z "$cached"; then
1763 # Not found in cache. Look it up on the file system.
1764 func_lookup_file "modules/$1"
1765 if $have_associative; then
1766 modcache_cached[$1]=yes
1768 eval "${cachevar}_cached=\"\$1\""
1770 if ! $have_associative; then
1771 # sed_convert_to_cache_statements depends on the module.
1772 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1773 func_init_sed_convert_to_cache_statements
1775 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1776 eval "$cache_statements"
1778 if ! $have_associative; then
1779 if test "$1" != "$cached"; then
1780 func_fatal_error "cache variable collision between $1 and $cached"
1788 # func_get_description module
1790 # - local_gnulib_dir from --local-dir
1791 # - modcache true or false, from --cache-modules/--no-cache-modules
1792 func_get_description ()
1794 if ! $modcache; then
1795 func_lookup_file "modules/$1"
1796 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1798 func_cache_lookup_module "$1"
1799 # Output the field's value, including the final newline (if any).
1800 if $have_associative; then
1801 if test -n "${modcache_description[$1]+set}"; then
1802 echo "${modcache_description[$1]}"
1805 eval "field_set=\"\$${cachevar}_description_set\""
1806 if test -n "$field_set"; then
1807 eval "field_value=\"\$${cachevar}_description\""
1808 echo "${field_value}"
1814 # func_get_comment module
1816 # - local_gnulib_dir from --local-dir
1817 # - modcache true or false, from --cache-modules/--no-cache-modules
1820 if ! $modcache; then
1821 func_lookup_file "modules/$1"
1822 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1824 func_cache_lookup_module "$1"
1825 # Output the field's value, including the final newline (if any).
1826 if $have_associative; then
1827 if test -n "${modcache_comment[$1]+set}"; then
1828 echo "${modcache_comment[$1]}"
1831 eval "field_set=\"\$${cachevar}_comment_set\""
1832 if test -n "$field_set"; then
1833 eval "field_value=\"\$${cachevar}_comment\""
1834 echo "${field_value}"
1840 # func_get_status module
1842 # - local_gnulib_dir from --local-dir
1843 # - modcache true or false, from --cache-modules/--no-cache-modules
1846 if ! $modcache; then
1847 func_lookup_file "modules/$1"
1848 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1850 func_cache_lookup_module "$1"
1851 # Output the field's value, including the final newline (if any).
1852 if $have_associative; then
1853 if test -n "${modcache_status[$1]+set}"; then
1854 echo "${modcache_status[$1]}"
1857 eval "field_set=\"\$${cachevar}_status_set\""
1858 if test -n "$field_set"; then
1859 eval "field_value=\"\$${cachevar}_status\""
1860 echo "${field_value}"
1866 # func_get_notice module
1868 # - local_gnulib_dir from --local-dir
1869 # - modcache true or false, from --cache-modules/--no-cache-modules
1872 if ! $modcache; then
1873 func_lookup_file "modules/$1"
1874 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1876 func_cache_lookup_module "$1"
1877 # Output the field's value, including the final newline (if any).
1878 if $have_associative; then
1879 if test -n "${modcache_notice[$1]+set}"; then
1880 echo "${modcache_notice[$1]}"
1883 eval "field_set=\"\$${cachevar}_notice_set\""
1884 if test -n "$field_set"; then
1885 eval "field_value=\"\$${cachevar}_notice\""
1886 echo "${field_value}"
1892 # func_get_applicability module
1894 # - local_gnulib_dir from --local-dir
1895 # - modcache true or false, from --cache-modules/--no-cache-modules
1896 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1897 func_get_applicability ()
1899 if ! $modcache; then
1900 func_lookup_file "modules/$1"
1901 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1903 func_cache_lookup_module "$1"
1904 # Get the field's value, without the final newline.
1905 if $have_associative; then
1906 my_applicability="${modcache_applicability[$1]}"
1908 eval "my_applicability=\"\$${cachevar}_applicability\""
1911 if test -n "$my_applicability"; then
1912 echo $my_applicability
1914 # The default is 'main' or 'tests', depending on the module's name.
1916 *-tests) echo "tests";;
1922 # func_get_filelist module
1924 # - local_gnulib_dir from --local-dir
1925 # - modcache true or false, from --cache-modules/--no-cache-modules
1926 func_get_filelist ()
1928 if ! $modcache; then
1929 func_lookup_file "modules/$1"
1930 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1932 func_cache_lookup_module "$1"
1933 # Output the field's value, including the final newline (if any).
1934 if $have_associative; then
1935 if test -n "${modcache_files[$1]+set}"; then
1936 echo "${modcache_files[$1]}"
1939 eval "field_set=\"\$${cachevar}_files_set\""
1940 if test -n "$field_set"; then
1941 eval "field_value=\"\$${cachevar}_files\""
1942 echo "${field_value}"
1947 echo m4/gnulib-common.m4
1948 case "$autoconf_minversion" in
1955 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1956 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1957 # elements starting with prefix and ending with suffix are considered.
1958 # Processing: removed_prefix and removed_suffix are removed from each element,
1959 # added_prefix and added_suffix are added to each element.
1960 # prefix, suffix should not contain shell-special characters.
1961 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1962 # added_prefix, added_suffix should not contain the characters \|&.
1963 func_filter_filelist ()
1965 if test "$2" != "$nl" \
1966 || { $fast_func_append \
1967 && { test -z "$6" || $fast_func_remove_prefix; } \
1968 && { test -z "$7" || $fast_func_remove_suffix; }; \
1972 # Do not quote possibly-empty parameters in case patterns,
1973 # AIX and HP-UX ksh won't match them if they are empty.
1976 if test -n "$6"; then
1977 func_remove_prefix fff "$6"
1979 if test -n "$7"; then
1980 func_remove_suffix fff "$7"
1983 if test -z "$ffflist"; then
1986 func_append ffflist "$2${fff}"
1992 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1993 ffflist=`for fff in $3; do
1995 $4*$5) echo "$fff" ;;
1997 done | sed -e "$sed_fff_filter"`
1999 eval "$1=\"\$ffflist\""
2002 # func_get_dependencies module
2004 # - local_gnulib_dir from --local-dir
2005 # - modcache true or false, from --cache-modules/--no-cache-modules
2006 func_get_dependencies ()
2008 # ${module}-tests implicitly depends on ${module}, if that module exists.
2012 func_remove_suffix fgd1 '-tests'
2013 if func_exists_module "$fgd1"; then
2018 # Then the explicit dependencies listed in the module description.
2019 if ! $modcache; then
2020 func_lookup_file "modules/$1"
2021 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2023 func_cache_lookup_module "$1"
2024 # Output the field's value, including the final newline (if any).
2025 if $have_associative; then
2026 if test -n "${modcache_dependson[$1]+set}"; then
2027 echo "${modcache_dependson[$1]}"
2030 eval "field_set=\"\$${cachevar}_dependson_set\""
2031 if test -n "$field_set"; then
2032 eval "field_value=\"\$${cachevar}_dependson\""
2033 echo "${field_value}"
2039 # func_get_autoconf_early_snippet module
2041 # - local_gnulib_dir from --local-dir
2042 # - modcache true or false, from --cache-modules/--no-cache-modules
2043 func_get_autoconf_early_snippet ()
2045 if ! $modcache; then
2046 func_lookup_file "modules/$1"
2047 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2049 func_cache_lookup_module "$1"
2050 # Output the field's value, including the final newline (if any).
2051 if $have_associative; then
2052 if test -n "${modcache_configureac_early[$1]+set}"; then
2053 echo "${modcache_configureac_early[$1]}"
2056 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2057 if test -n "$field_set"; then
2058 eval "field_value=\"\$${cachevar}_configureac_early\""
2059 echo "${field_value}"
2065 # func_get_autoconf_snippet module
2067 # - local_gnulib_dir from --local-dir
2068 # - modcache true or false, from --cache-modules/--no-cache-modules
2069 func_get_autoconf_snippet ()
2071 if ! $modcache; then
2072 func_lookup_file "modules/$1"
2073 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2075 func_cache_lookup_module "$1"
2076 # Output the field's value, including the final newline (if any).
2077 if $have_associative; then
2078 if test -n "${modcache_configureac[$1]+set}"; then
2079 echo "${modcache_configureac[$1]}"
2082 eval "field_set=\"\$${cachevar}_configureac_set\""
2083 if test -n "$field_set"; then
2084 eval "field_value=\"\$${cachevar}_configureac\""
2085 echo "${field_value}"
2091 # func_get_automake_snippet module
2093 # - local_gnulib_dir from --local-dir
2094 # - modcache true or false, from --cache-modules/--no-cache-modules
2095 func_get_automake_snippet ()
2097 if ! $modcache; then
2098 func_lookup_file "modules/$1"
2099 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2101 func_cache_lookup_module "$1"
2102 # Output the field's value, including the final newline (if any).
2103 if $have_associative; then
2104 if test -n "${modcache_makefile[$1]+set}"; then
2105 echo "${modcache_makefile[$1]}"
2108 eval "field_set=\"\$${cachevar}_makefile_set\""
2109 if test -n "$field_set"; then
2110 eval "field_value=\"\$${cachevar}_makefile\""
2111 echo "${field_value}"
2117 # *-tests module live in tests/, not lib/.
2118 # Synthesize an EXTRA_DIST augmentation.
2119 all_files=`func_get_filelist $1`
2120 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2121 extra_files="$tests_files"
2122 if test -n "$extra_files"; then
2123 echo "EXTRA_DIST +=" $extra_files
2128 # Synthesize an EXTRA_DIST augmentation.
2129 sed_combine_lines='/\\$/{
2136 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2137 already_mentioned_files=` \
2138 { if ! $modcache; then
2139 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2141 if $have_associative; then
2142 if test -n "${modcache_makefile[$1]+set}"; then
2143 echo "${modcache_makefile[$1]}"
2146 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2147 if test -n "$field_set"; then
2148 eval 'field_value="$'"${cachevar}"'_makefile"'
2149 echo "${field_value}"
2154 | sed -e "$sed_combine_lines" \
2155 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2156 all_files=`func_get_filelist $1`
2157 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2158 # Remove $already_mentioned_files from $lib_files.
2159 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2160 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2161 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2162 if test -n "$extra_files"; then
2163 echo "EXTRA_DIST +=" $extra_files
2166 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2167 # This is necessary so that automake can generate the right list of
2169 # A possible approach would be to use autom4te --trace of the redefined
2170 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2171 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2172 # inside autoconf's built-in macros are not missed).
2173 # But it's simpler and more robust to do it here, based on the file list.
2174 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2175 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2176 # automake will generate a useless dependency; this is harmless.
2178 relocatable-prog-wrapper) ;;
2180 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2181 if test -n "$extra_files"; then
2182 echo "EXTRA_lib_SOURCES +=" $extra_files
2187 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2188 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2189 if test -n "$buildaux_files"; then
2190 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2191 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2194 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2195 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2196 if test -n "$top_files"; then
2197 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2198 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2205 # func_get_include_directive module
2207 # - local_gnulib_dir from --local-dir
2208 # - modcache true or false, from --cache-modules/--no-cache-modules
2209 func_get_include_directive ()
2212 if ! $modcache; then
2213 func_lookup_file "modules/$1"
2214 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2216 func_cache_lookup_module "$1"
2217 # Output the field's value, including the final newline (if any).
2218 if $have_associative; then
2219 if test -n "${modcache_include[$1]+set}"; then
2220 echo "${modcache_include[$1]}"
2223 eval "field_set=\"\$${cachevar}_include_set\""
2224 if test -n "$field_set"; then
2225 eval "field_value=\"\$${cachevar}_include\""
2226 echo "${field_value}"
2230 } | sed -e 's/^\(["<]\)/#include \1/'
2233 # func_get_link_directive module
2235 # - local_gnulib_dir from --local-dir
2236 # - modcache true or false, from --cache-modules/--no-cache-modules
2237 func_get_link_directive ()
2239 if ! $modcache; then
2240 func_lookup_file "modules/$1"
2241 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2243 func_cache_lookup_module "$1"
2244 # Output the field's value, including the final newline (if any).
2245 if $have_associative; then
2246 if test -n "${modcache_link[$1]+set}"; then
2247 echo "${modcache_link[$1]}"
2250 eval "field_set=\"\$${cachevar}_link_set\""
2251 if test -n "$field_set"; then
2252 eval "field_value=\"\$${cachevar}_link\""
2253 echo "${field_value}"
2259 # func_get_license module
2261 # - local_gnulib_dir from --local-dir
2262 # - modcache true or false, from --cache-modules/--no-cache-modules
2266 if ! $modcache; then
2267 func_lookup_file "modules/$1"
2268 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2270 func_cache_lookup_module "$1"
2271 # Output the field's value, including the final newline (if any).
2272 if $have_associative; then
2273 if test -n "${modcache_license[$1]+set}"; then
2274 echo "${modcache_license[$1]}"
2277 eval "field_set=\"\$${cachevar}_license_set\""
2278 if test -n "$field_set"; then
2279 eval "field_value=\"\$${cachevar}_license\""
2280 echo "${field_value}"
2284 # The default is GPL.
2286 } | sed -e 's,^ *$,,' | sed -e 1q
2289 # func_get_maintainer module
2291 # - local_gnulib_dir from --local-dir
2292 # - modcache true or false, from --cache-modules/--no-cache-modules
2293 func_get_maintainer ()
2295 if ! $modcache; then
2296 func_lookup_file "modules/$1"
2297 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2299 func_cache_lookup_module "$1"
2300 # Output the field's value, including the final newline (if any).
2301 if $have_associative; then
2302 if test -n "${modcache_maintainer[$1]+set}"; then
2303 echo "${modcache_maintainer[$1]}"
2306 eval "field_set=\"\$${cachevar}_maintainer_set\""
2307 if test -n "$field_set"; then
2308 eval "field_value=\"\$${cachevar}_maintainer\""
2309 echo "${field_value}"
2315 # func_get_tests_module module
2317 # - local_gnulib_dir from --local-dir
2318 func_get_tests_module ()
2320 # The naming convention for tests modules is hardwired: ${module}-tests.
2321 if test -f "$gnulib_dir/modules/$1"-tests \
2322 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2323 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2328 # func_acceptable module
2329 # tests whether a module is acceptable.
2331 # - avoidlist list of modules to avoid
2334 for avoid in $avoidlist; do
2335 if test "$avoid" = "$1"; then
2342 # func_modules_transitive_closure
2344 # - local_gnulib_dir from --local-dir
2345 # - modcache true or false, from --cache-modules/--no-cache-modules
2346 # - modules list of specified modules
2347 # - inctests true if tests should be included, blank otherwise
2348 # - incobsolete true if obsolete modules among dependencies should be
2349 # included, blank otherwise
2350 # - inc_cxx_tests true if C++ interoperability tests should be included,
2352 # - inc_longrunning_tests true if long-runnings tests should be included,
2354 # - inc_privileged_tests true if tests that require root privileges should be
2355 # included, blank otherwise
2356 # - inc_unportable_tests true if tests that fail on some platforms should be
2357 # included, blank otherwise
2358 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2359 # the unit tests of the specified modules should be
2360 # included, blank otherwise
2361 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2362 # the unit tests of the dependencies should be
2363 # included, blank otherwise
2364 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2366 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2368 # - excl_privileged_tests true if tests that require root privileges should be
2369 # excluded, blank otherwise
2370 # - excl_unportable_tests true if tests that fail on some platforms should be
2371 # excluded, blank otherwise
2372 # - avoidlist list of modules to avoid
2373 # - tmp pathname of a temporary directory
2375 # - modules list of modules, including dependencies
2376 func_modules_transitive_closure ()
2378 # In order to process every module only once (for speed), process an "input
2379 # list" of modules, producing an "output list" of modules. During each round,
2380 # more modules can be queued in the input list. Once a module on the input
2381 # list has been processed, it is added to the "handled list", so we can avoid
2382 # to process it again.
2384 inmodules="$modules"
2386 fmtc_inc_all_tests="$inc_all_direct_tests"
2387 while test -n "$inmodules"; do
2388 inmodules_this_round="$inmodules"
2389 inmodules= # Accumulator, queue for next round
2390 for module in $inmodules_this_round; do
2392 if test -n "$module"; then
2393 if func_acceptable $module; then
2394 func_append outmodules " $module"
2395 deps=`func_get_dependencies $module`
2396 # Duplicate dependencies are harmless, but Jim wants a warning.
2397 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2398 if test -n "$duplicated_deps"; then
2399 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2401 if test -n "$inctests"; then
2402 testsmodule=`func_get_tests_module $module`
2403 if test -n "$testsmodule"; then
2404 deps="$deps $testsmodule"
2407 for dep in $deps; do
2408 # Determine whether to include the dependency or tests module.
2410 for word in `func_get_status $dep`; do
2413 test -n "$incobsolete" \
2417 test -z "$excl_cxx_tests" \
2419 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2423 test -z "$excl_longrunning_tests" \
2425 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2429 test -z "$excl_privileged_tests" \
2431 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2435 test -z "$excl_unportable_tests" \
2437 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2441 test -n "$fmtc_inc_all_tests" \
2447 func_append inmodules " $dep"
2453 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2454 # Remove $handledmodules from $inmodules.
2455 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2456 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2457 fmtc_inc_all_tests="$inc_all_indirect_tests"
2459 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2460 rm -f "$tmp"/queued-modules
2463 # func_show_module_list
2465 # - specified_modules list of specified modules (one per line, sorted)
2466 # - modules complete list of modules (one per line, sorted)
2467 # - tmp pathname of a temporary directory
2468 func_show_module_list ()
2474 # Assume xterm compatible escape sequences.
2475 bold_on=`printf '\x1b[1m'`
2476 bold_off=`printf '\x1b[0m'`
2481 echo "Module list with included dependencies (indented):"
2482 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2483 echo "$modules" | sed -e '/^$/d' \
2484 | LC_ALL=C join -t '|' -a 2 "$tmp"/specified-modules - \
2485 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2488 # func_modules_add_dummy
2490 # - local_gnulib_dir from --local-dir
2491 # - modcache true or false, from --cache-modules/--no-cache-modules
2492 # - modules list of modules, including dependencies
2494 # - modules list of modules, including 'dummy' if needed
2495 func_modules_add_dummy ()
2497 # Determine whether any module provides a lib_SOURCES augmentation.
2499 sed_remove_backslash_newline=':a
2506 for module in $modules; do
2507 func_verify_nontests_module
2508 if test -n "$module"; then
2509 # Extract the value of "lib_SOURCES += ...".
2510 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2511 # Ignore .h files since they are not compiled.
2515 have_lib_SOURCES=yes
2522 # Add the dummy module, to make sure the library will be non-empty.
2523 if test -z "$have_lib_SOURCES"; then
2524 if func_acceptable "dummy"; then
2525 func_append modules " dummy"
2530 # func_modules_notice
2532 # - local_gnulib_dir from --local-dir
2533 # - modcache true or false, from --cache-modules/--no-cache-modules
2534 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2535 # - modules list of modules, including dependencies
2536 func_modules_notice ()
2538 if test $verbose -ge -1; then
2539 for module in $modules; do
2541 if test -n "$module"; then
2542 msg=`func_get_notice $module`
2543 if test -n "$msg"; then
2544 echo "Notice from module $module:"
2545 echo "$msg" | sed -e 's/^/ /'
2552 # func_modules_to_filelist
2554 # - local_gnulib_dir from --local-dir
2555 # - modcache true or false, from --cache-modules/--no-cache-modules
2556 # - modules list of modules, including dependencies
2558 # - files list of files
2559 func_modules_to_filelist ()
2562 for module in $modules; do
2564 if test -n "$module"; then
2565 fs=`func_get_filelist $module`
2566 func_append files " $fs"
2569 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2572 # func_execute_command command [args...]
2573 # Executes a command.
2574 # Uses also the variables
2575 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2576 func_execute_command ()
2578 if test $verbose -ge 0; then
2582 # Commands like automake produce output to stderr even when they succeed.
2583 # Turn this output off if the command succeeds.
2584 "$@" > "$tmp"/cmdout 2>&1
2586 if test $cmdret = 0; then
2590 cat "$tmp"/cmdout 1>&2
2597 # func_dest_tmpfilename file
2598 # determines the name of a temporary file (file is relative to destdir).
2600 # - destdir target directory
2601 # - doit : if actions shall be executed, false if only to be printed
2602 # - tmp pathname of a temporary directory
2604 # - tmpfile absolute filename of the temporary file
2605 func_dest_tmpfilename ()
2608 # Put the new contents of $file in a file in the same directory (needed
2609 # to guarantee that an 'mv' to "$destdir/$file" works).
2610 tmpfile="$destdir/$1.tmp"
2612 # Put the new contents of $file in a file in a temporary directory
2613 # (because the directory of "$file" might not exist).
2614 tmpfile="$tmp"/`basename "$1"`.tmp
2619 # copies a file from gnulib into the destination directory. The destination
2620 # is known to not exist.
2622 # - destdir target directory
2623 # - local_gnulib_dir from --local-dir
2624 # - modcache true or false, from --cache-modules/--no-cache-modules
2625 # - f the original file name
2626 # - lookedup_file name of the merged (combined) file
2627 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2628 # - g the rewritten file name
2629 # - tmpfile absolute filename of the temporary file
2630 # - doit : if actions shall be executed, false if only to be printed
2631 # - symbolic true if files should be symlinked, copied otherwise
2632 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2637 echo "Copying file $g"
2638 if { test -n "$symbolic" \
2639 || { test -n "$lsymbolic" \
2640 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2641 && test -z "$lookedup_tmp" \
2642 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2643 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2645 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2653 # copies a file from gnulib into the destination directory. The destination
2654 # is known to exist.
2656 # - destdir target directory
2657 # - local_gnulib_dir from --local-dir
2658 # - modcache true or false, from --cache-modules/--no-cache-modules
2659 # - f the original file name
2660 # - lookedup_file name of the merged (combined) file
2661 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2662 # - g the rewritten file name
2663 # - tmpfile absolute filename of the temporary file
2664 # - doit : if actions shall be executed, false if only to be printed
2665 # - symbolic true if files should be symlinked, copied otherwise
2666 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2668 # - already_present nonempty if the file should already exist, empty otherwise
2671 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2672 : # The file has not changed.
2676 if test -n "$already_present"; then
2677 echo "Updating file $g (backup in ${g}~)"
2679 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2681 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2682 if { test -n "$symbolic" \
2683 || { test -n "$lsymbolic" \
2684 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2685 && test -z "$lookedup_tmp" \
2686 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2687 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2689 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2692 if test -n "$already_present"; then
2693 echo "Update file $g (backup in ${g}~)"
2695 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2701 # func_emit_lib_Makefile_am
2702 # emits the contents of library makefile to standard output.
2704 # - local_gnulib_dir from --local-dir
2705 # - modcache true or false, from --cache-modules/--no-cache-modules
2706 # - modules list of modules, including dependencies
2707 # - libname library name
2708 # - pobase directory relative to destdir where to place *.po files
2709 # - auxdir directory relative to destdir where to place build aux files
2710 # - makefile_name from --makefile-name
2711 # - libtool true if libtool will be used, false or blank otherwise
2712 # - macro_prefix prefix of gl_LIBOBJS macros to use
2713 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2714 # - actioncmd (optional) command that will reproduce this invocation
2715 # - for_test true if creating a package for testing, false otherwise
2716 # - destfile filename relative to destdir of makefile being generated
2718 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2719 # list of edits to be done to Makefile.am variables
2721 # - uses_subdirs nonempty if object files in subdirs exist
2722 func_emit_lib_Makefile_am ()
2724 # When creating an includable Makefile.am snippet, augment variables with
2725 # += instead of assigning them.
2726 if test -n "$makefile_name"; then
2731 if test "$libtool" = true; then
2734 sed_eliminate_LDFLAGS="$sed_noop"
2738 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2741 # When creating a package for testing: Attempt to provoke failures,
2742 # especially link errors, already during "make" rather than during
2743 # "make check", because "make check" is not possible in a cross-compiling
2744 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2745 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2747 sed_transform_check_PROGRAMS="$sed_noop"
2749 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2750 echo "## Process this file with automake to produce Makefile.in."
2751 func_emit_copyright_notice
2752 if test -n "$actioncmd"; then
2753 # The maximum line length (excluding the terminating newline) of any file
2754 # that is to be preprocessed by config.status is 3070. config.status uses
2755 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2756 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2757 len=`echo "$actioncmd" | wc -c`
2758 if test -n "$len" && test "$len" -le 3000; then
2759 echo "# Reproduce by: $actioncmd"
2765 for module in $modules; do
2766 func_verify_nontests_module
2767 if test -n "$module"; then
2769 func_get_automake_snippet "$module" |
2771 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2772 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2773 -e "$sed_eliminate_LDFLAGS" \
2774 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2775 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2776 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2777 -e "$sed_transform_check_PROGRAMS"
2778 if test "$module" = 'alloca'; then
2779 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2780 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2782 } > "$tmp"/amsnippet
2783 # Skip the contents if it's entirely empty.
2784 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2785 echo "## begin gnulib module $module"
2787 cat "$tmp"/amsnippet
2788 echo "## end gnulib module $module"
2791 rm -f "$tmp"/amsnippet
2792 # Test whether there are some source files in subdirectories.
2793 for f in `func_get_filelist "$module"`; do
2803 } > "$tmp"/allsnippets
2804 if test -z "$makefile_name"; then
2805 # If there are source files in subdirectories, prevent collision of the
2806 # object files (example: hash.c and libxml/hash.c).
2808 if test -n "$uses_subdirs"; then
2809 subdir_options=' subdir-objects'
2811 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2814 if test -z "$makefile_name"; then
2816 echo "noinst_HEADERS ="
2817 echo "noinst_LIBRARIES ="
2818 echo "noinst_LTLIBRARIES ="
2819 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2820 # if you specify pkgdata_DATA to empty. This is a workaround.
2821 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2822 echo "pkgdata_DATA ="
2825 echo "BUILT_SOURCES ="
2828 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2829 if test -z "$makefile_name"; then
2830 echo "MOSTLYCLEANDIRS ="
2832 echo "DISTCLEANFILES ="
2833 echo "MAINTAINERCLEANFILES ="
2835 # Execute edits that apply to the Makefile.am being generated.
2837 while test $edit != $makefile_am_edits; do
2838 edit=`expr $edit + 1`
2839 eval dir=\"\$makefile_am_edit${edit}_dir\"
2840 eval var=\"\$makefile_am_edit${edit}_var\"
2841 eval val=\"\$makefile_am_edit${edit}_val\"
2842 if test -n "$var"; then
2843 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2844 echo "${var} += ${val}"
2845 eval "makefile_am_edit${edit}_var="
2849 if test -z "$makefile_name"; then
2852 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
2854 echo "AM_CPPFLAGS ="
2859 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2860 || { test -n "$makefile_name" \
2861 && test -f "$sourcebase/Makefile.am" \
2862 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2864 # One of the snippets or the user's Makefile.am already specifies an
2865 # installation location for the library. Don't confuse automake by saying
2866 # it should not be installed.
2869 # By default, the generated library should not be installed.
2870 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2873 echo "${libname}_${libext}_SOURCES ="
2874 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2875 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2876 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2877 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2878 echo "EXTRA_${libname}_${libext}_SOURCES ="
2879 if test "$libtool" = true; then
2880 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2883 if test -n "$pobase"; then
2884 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2887 cat "$tmp"/allsnippets \
2888 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2890 echo "mostlyclean-local: mostlyclean-generic"
2891 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2892 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2893 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2897 rm -f "$tmp"/allsnippets
2900 # func_emit_po_Makevars
2901 # emits the contents of po/ makefile parameterization to standard output.
2903 # - local_gnulib_dir from --local-dir
2904 # - modcache true or false, from --cache-modules/--no-cache-modules
2905 # - sourcebase directory relative to destdir where to place source code
2906 # - pobase directory relative to destdir where to place *.po files
2907 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2908 func_emit_po_Makevars ()
2910 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2911 func_emit_copyright_notice
2913 echo "# Usually the message domain is the same as the package name."
2914 echo "# But here it has a '-gnulib' suffix."
2915 echo "DOMAIN = ${po_domain}-gnulib"
2917 echo "# These two variables depend on the location of this directory."
2918 echo "subdir = ${pobase}"
2919 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2922 # These options get passed to xgettext.
2923 XGETTEXT_OPTIONS = \
2924 --keyword=_ --flag=_:1:pass-c-format \
2925 --keyword=N_ --flag=N_:1:pass-c-format \
2926 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2927 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2928 --flag=error:3:c-format --flag=error_at_line:5:c-format
2930 # This is the copyright holder that gets inserted into the header of the
2931 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2932 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2934 # This is the email address or URL to which the translators shall report
2935 # bugs in the untranslated strings:
2936 # - Strings which are not entire sentences, see the maintainer guidelines
2937 # in the GNU gettext documentation, section 'Preparing Strings'.
2938 # - Strings which use unclear terms or require additional context to be
2940 # - Strings which make invalid assumptions about notation of date, time or
2942 # - Pluralisation problems.
2943 # - Incorrect English spelling.
2944 # - Incorrect formatting.
2945 # It can be your email address, or a mailing list address where translators
2946 # can write to without being subscribed, or the URL of a web page through
2947 # which the translators can contact you.
2948 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2950 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2951 # message catalogs shall be used. It is usually empty.
2952 EXTRA_LOCALE_CATEGORIES =
2954 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2955 # context. Possible values are "yes" and "no". Set this to yes if the
2956 # package uses functions taking also a message context, like pgettext(), or
2957 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2962 # func_emit_po_POTFILES_in
2963 # emits the file list to be passed to xgettext to standard output.
2965 # - local_gnulib_dir from --local-dir
2966 # - modcache true or false, from --cache-modules/--no-cache-modules
2967 # - sourcebase directory relative to destdir where to place source code
2968 # - files list of new files
2969 func_emit_po_POTFILES_in ()
2971 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2972 func_emit_copyright_notice
2974 echo "# List of files which contain translatable strings."
2975 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2978 # func_emit_tests_Makefile_am witness_macro
2979 # emits the contents of tests makefile to standard output.
2981 # - local_gnulib_dir from --local-dir
2982 # - modcache true or false, from --cache-modules/--no-cache-modules
2983 # - modules list of modules, including dependencies
2984 # - libname library name
2985 # - auxdir directory relative to destdir where to place build aux files
2986 # - makefile_name from --makefile-name
2987 # - libtool true if libtool will be used, false or blank otherwise
2988 # - sourcebase relative directory containing lib source code
2989 # - m4base relative directory containing autoconf macros
2990 # - testsbase relative directory containing unit test code
2991 # - macro_prefix prefix of gl_LIBOBJS macros to use
2992 # - for_test true if creating a package for testing, false otherwise
2993 # - use_libtests true if a libtests.a should be built, false otherwise
2994 # - destfile filename relative to destdir of makefile being generated
2996 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2997 # list of edits to be done to Makefile.am variables
2999 # - uses_subdirs nonempty if object files in subdirs exist
3000 func_emit_tests_Makefile_am ()
3003 if test "$libtool" = true; then
3005 sed_eliminate_LDFLAGS="$sed_noop"
3008 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3011 # When creating a package for testing: Attempt to provoke failures,
3012 # especially link errors, already during "make" rather than during
3013 # "make check", because "make check" is not possible in a cross-compiling
3014 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3015 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3017 sed_transform_check_PROGRAMS="$sed_noop"
3019 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3020 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3021 echo "## Process this file with automake to produce Makefile.in."
3022 func_emit_copyright_notice
3026 for module in $modules; do
3028 func_verify_tests_module
3032 if test -n "$module"; then
3034 func_get_automake_snippet "$module" |
3036 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3037 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3038 -e "$sed_eliminate_LDFLAGS" \
3039 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3040 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3041 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3042 -e "$sed_transform_check_PROGRAMS"
3043 if $use_libtests && test "$module" = 'alloca'; then
3044 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3045 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3047 } > "$tmp"/amsnippet
3048 # Skip the contents if it's entirely empty.
3049 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3050 # Mention long-running tests at the end.
3052 for word in `func_get_status "$module"`; do
3053 if test "$word" = 'longrunning-test'; then
3058 { echo "## begin gnulib module $module"
3060 cat "$tmp"/amsnippet
3061 echo "## end gnulib module $module"
3065 rm -f "$tmp"/amsnippet
3066 # Test whether there are some source files in subdirectories.
3067 for f in `func_get_filelist "$module"`; do
3069 lib/*/*.c | tests/*/*.c)
3077 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3078 # Generate dependencies here, since it eases the debugging of test failures.
3079 # If there are source files in subdirectories, prevent collision of the
3080 # object files (example: hash.c and libxml/hash.c).
3082 if test -n "$uses_subdirs"; then
3083 subdir_options=' subdir-objects'
3085 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3088 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3091 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3092 # variable is needed to avoid an error from automake:
3093 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3096 echo "XFAIL_TESTS ="
3097 echo "TESTS_ENVIRONMENT ="
3098 echo "noinst_PROGRAMS ="
3099 if ! $for_test; then
3100 echo "check_PROGRAMS ="
3102 echo "noinst_HEADERS ="
3103 echo "noinst_LIBRARIES ="
3104 if $use_libtests; then
3106 echo "noinst_LIBRARIES += libtests.a"
3108 echo "check_LIBRARIES = libtests.a"
3111 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3112 # if you specify pkgdata_DATA to empty. This is a workaround.
3113 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3114 echo "pkgdata_DATA ="
3117 echo "BUILT_SOURCES ="
3119 echo "MOSTLYCLEANFILES = core *.stackdump"
3120 echo "MOSTLYCLEANDIRS ="
3122 echo "DISTCLEANFILES ="
3123 echo "MAINTAINERCLEANFILES ="
3124 # Execute edits that apply to the Makefile.am being generated.
3126 while test $edit != $makefile_am_edits; do
3127 edit=`expr $edit + 1`
3128 eval dir=\"\$makefile_am_edit${edit}_dir\"
3129 eval var=\"\$makefile_am_edit${edit}_var\"
3130 eval val=\"\$makefile_am_edit${edit}_val\"
3131 if test -n "$var"; then
3132 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3133 echo "${var} += ${val}"
3134 eval "makefile_am_edit${edit}_var="
3139 echo "AM_CPPFLAGS = \\"
3141 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3143 if test -n "${witness_macro}"; then
3144 echo " -D@${witness_macro}@=1 \\"
3146 echo " -I. -I\$(srcdir) \\"
3147 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3148 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3150 local_ldadd_before=''
3151 local_ldadd_after=''
3152 if $use_libtests; then
3153 # All test programs need to be linked with libtests.a.
3154 # It needs to be passed to the linker before ${libname}.${libext}, since
3155 # the tests-related modules depend on the main modules.
3156 # It also needs to be passed to the linker after ${libname}.${libext}
3157 # because the latter might contain incomplete modules (such as the 'error'
3158 # module whose dependency to 'progname' is voluntarily omitted).
3159 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3161 local_ldadd_before=' libtests.a'
3162 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3164 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3166 if $use_libtests; then
3167 echo "libtests_a_SOURCES ="
3168 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3169 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3170 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3171 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3172 echo "EXTRA_libtests_a_SOURCES ="
3173 # The circular dependency in LDADD requires this.
3174 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3177 # Many test scripts use ${EXEEXT} or ${srcdir}.
3178 # EXEEXT is defined by AC_PROG_CC through autoconf.
3179 # srcdir is defined by autoconf and automake.
3180 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3182 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3183 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3184 echo "# Clean up after Solaris cc."
3186 echo " rm -rf SunWS_cache"
3188 echo "mostlyclean-local: mostlyclean-generic"
3189 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3190 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3191 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3195 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3198 # func_emit_initmacro_start macro_prefix
3199 # emits the first few statements of the gl_INIT macro to standard output.
3200 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3201 func_emit_initmacro_start ()
3203 macro_prefix_arg="$1"
3204 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3205 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3206 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3207 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3209 # Furthermore it avoids an automake error like this when a Makefile.am
3210 # that uses pieces of gnulib also uses $(LIBOBJ):
3211 # automatically discovered file `error.c' should not be explicitly mentioned
3212 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3213 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3214 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3215 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3216 # automatically discovered file `error.c' should not be explicitly mentioned
3217 # We let automake know about the files to be distributed through the
3218 # EXTRA_lib_SOURCES variable.
3219 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3220 # Create data variables for checking the presence of files that are mentioned
3221 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3222 # because we want the check to happen when the configure file is created,
3223 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3224 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3225 # in which to expect them.
3226 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3227 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3231 # func_emit_initmacro_end macro_prefix
3232 # emits the last few statements of the gl_INIT macro to standard output.
3233 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3234 func_emit_initmacro_end ()
3236 macro_prefix_arg="$1"
3237 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3238 # The check is performed only when autoconf is run from the directory where
3239 # the configure.ac resides; if it is run from a different directory, the
3241 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3242 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3243 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3244 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3245 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3249 echo " m4_if(m4_sysval, [0], [],"
3250 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3252 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3253 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3254 echo " m4_popdef([AC_LIBSOURCES])"
3255 echo " m4_popdef([AC_REPLACE_FUNCS])"
3256 echo " m4_popdef([AC_LIBOBJ])"
3257 echo " AC_CONFIG_COMMANDS_PRE(["
3258 echo " ${macro_prefix_arg}_libobjs="
3259 echo " ${macro_prefix_arg}_ltlibobjs="
3260 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3261 echo " # Remove the extension."
3262 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3263 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3264 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3265 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3268 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3269 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3273 # func_emit_initmacro_done macro_prefix sourcebase
3274 # emits a few statements after the gl_INIT macro to standard output.
3275 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3276 # - sourcebase directory relative to destdir where to place source code
3277 func_emit_initmacro_done ()
3279 macro_prefix_arg="$1"
3282 echo "# Like AC_LIBOBJ, except that the module name goes"
3283 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3284 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3285 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3286 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3289 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3290 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3291 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3292 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3293 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3296 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3297 echo "# expected is derived from the gnulib-tool parameterization,"
3298 echo "# and alloca is special cased (for the alloca-opt module)."
3299 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3300 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3301 echo " m4_foreach([_gl_NAME], [\$1], ["
3302 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3303 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3304 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3310 # func_import modules
3311 # Uses also the variables
3312 # - destdir target directory
3313 # - local_gnulib_dir from --local-dir
3314 # - modcache true or false, from --cache-modules/--no-cache-modules
3315 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3316 # - libname library name
3317 # - sourcebase directory relative to destdir where to place source code
3318 # - m4base directory relative to destdir where to place *.m4 macros
3319 # - pobase directory relative to destdir where to place *.po files
3320 # - docbase directory relative to destdir where to place doc files
3321 # - testsbase directory relative to destdir where to place unit test code
3322 # - auxdir directory relative to destdir where to place build aux files
3323 # - inctests true if --with-tests was given, blank otherwise
3324 # - incobsolete true if --with-obsolete was given, blank otherwise
3325 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3326 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3328 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3330 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3332 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3333 # - avoidlist list of modules to avoid, from --avoid
3334 # - lgpl yes or a number if library's license shall be LGPL,
3336 # - makefile_name from --makefile-name
3337 # - libtool true if --libtool was given, false if --no-libtool was
3338 # given, blank otherwise
3339 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3340 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3341 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3342 # - vc_files true if --vc-files was given, false if --no-vc-files was
3343 # given, blank otherwise
3344 # - autoconf_minversion minimum supported autoconf version
3345 # - doit : if actions shall be executed, false if only to be printed
3346 # - symbolic true if files should be symlinked, copied otherwise
3347 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3349 # - do_copyrights true if copyright notices in files should be replaced,
3353 # Get the cached settings.
3354 cached_local_gnulib_dir=
3355 cached_specified_modules=
3357 cached_inc_cxx_tests=
3358 cached_inc_longrunning_tests=
3359 cached_inc_privileged_tests=
3360 cached_inc_unportable_tests=
3361 cached_inc_all_tests=
3371 cached_makefile_name=
3373 cached_macro_prefix=
3377 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3378 cached_libtool=false
3384 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3394 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3396 /gl_WITH_OBSOLETE/ {
3397 s,^.*$,cached_incobsolete=true,p
3399 /gl_WITH_CXX_TESTS/ {
3400 s,^.*$,cached_inc_cxx_tests=true,p
3402 /gl_WITH_LONGRUNNING_TESTS/ {
3403 s,^.*$,cached_inc_longrunning_tests=true,p
3405 /gl_WITH_PRIVILEGED_TESTS/ {
3406 s,^.*$,cached_inc_privileged_tests=true,p
3408 /gl_WITH_UNPORTABLE_TESTS/ {
3409 s,^.*$,cached_inc_unportable_tests=true,p
3411 /gl_WITH_ALL_TESTS/ {
3412 s,^.*$,cached_inc_all_tests=true,p
3415 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3418 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3421 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3424 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3427 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3430 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3433 s,^.*$,cached_inctests=true,p
3436 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3439 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3442 s,^.*$,cached_lgpl=yes,p
3444 /gl_MAKEFILE_NAME(/ {
3445 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3448 s,^.*$,cached_libtool=true,p
3450 /gl_MACRO_PREFIX(/ {
3451 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3454 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3457 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3459 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3460 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3465 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3466 s,^.*$,cached_files=",p
3479 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3483 # Merge the cached settings with the specified ones.
3484 # The m4base must be the same as expected from the pathname.
3485 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3486 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3488 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3489 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3490 if test -z "$local_gnulib_dir"; then
3491 if test -n "$cached_local_gnulib_dir"; then
3494 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3496 case "$cached_local_gnulib_dir" in
3498 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3500 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3501 local_gnulib_dir="$relconcat" ;;
3506 # Append the cached and the specified module names. So that
3507 # "gnulib-tool --import foo" means to add the module foo.
3508 specified_modules="$cached_specified_modules $1"
3509 # Included obsolete modules among the dependencies if specified either way.
3510 if test -z "$incobsolete"; then
3511 incobsolete="$cached_incobsolete"
3513 # Included special kinds of tests modules among the dependencies if specified
3515 if test -z "$inc_cxx_tests"; then
3516 inc_cxx_tests="$cached_inc_cxx_tests"
3518 if test -z "$inc_longrunning_tests"; then
3519 inc_longrunning_tests="$cached_inc_longrunning_tests"
3521 if test -z "$inc_privileged_tests"; then
3522 inc_privileged_tests="$cached_inc_privileged_tests"
3524 if test -z "$inc_unportable_tests"; then
3525 inc_unportable_tests="$cached_inc_unportable_tests"
3527 if test -z "$inc_all_tests"; then
3528 inc_all_tests="$cached_inc_all_tests"
3530 # --without-*-tests options are not supported here.
3532 excl_longrunning_tests=
3533 excl_privileged_tests=
3534 excl_unportable_tests=
3535 # Append the cached and the specified avoidlist. This is probably better
3536 # than dropping the cached one when --avoid is specified at least once.
3537 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3538 avoidlist=`echo $avoidlist`
3540 # The sourcebase defaults to the cached one.
3541 if test -z "$sourcebase"; then
3542 sourcebase="$cached_sourcebase"
3543 if test -z "$sourcebase"; then
3544 func_fatal_error "missing --source-base option"
3547 # The pobase defaults to the cached one.
3548 if test -z "$pobase"; then
3549 pobase="$cached_pobase"
3551 # The docbase defaults to the cached one.
3552 if test -z "$docbase"; then
3553 docbase="$cached_docbase"
3554 if test -z "$docbase"; then
3555 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."
3558 # The testsbase defaults to the cached one.
3559 if test -z "$testsbase"; then
3560 testsbase="$cached_testsbase"
3561 if test -z "$testsbase"; then
3562 func_fatal_error "missing --tests-base option"
3565 # Require the tests if specified either way.
3566 if test -z "$inctests"; then
3567 inctests="$cached_inctests"
3569 # The libname defaults to the cached one.
3570 if test -z "$supplied_libname"; then
3571 libname="$cached_libname"
3572 if test -z "$libname"; then
3573 func_fatal_error "missing --lib option"
3576 # Require LGPL if specified either way.
3577 if test -z "$lgpl"; then
3580 # The makefile_name defaults to the cached one.
3581 if test -z "$makefile_name"; then
3582 makefile_name="$cached_makefile_name"
3584 # Use libtool if specified either way, or if guessed.
3585 if test -z "$libtool"; then
3586 if test -n "$cached_m4base"; then
3587 libtool="$cached_libtool"
3589 libtool="$guessed_libtool"
3592 # The macro_prefix defaults to the cached one.
3593 if test -z "$macro_prefix"; then
3594 macro_prefix="$cached_macro_prefix"
3595 if test -z "$macro_prefix"; then
3596 func_fatal_error "missing --macro-prefix option"
3599 # The po_domain defaults to the cached one.
3600 if test -z "$po_domain"; then
3601 po_domain="$cached_po_domain"
3603 # The vc_files defaults to the cached one.
3604 if test -z "$vc_files"; then
3605 vc_files="$cached_vc_files"
3608 # Canonicalize the list of specified modules.
3609 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3611 # Include all kinds of tests modules if --with-all-tests was specified.
3612 inc_all_direct_tests="$inc_all_tests"
3613 inc_all_indirect_tests="$inc_all_tests"
3615 # Determine final module list.
3616 modules="$specified_modules"
3617 func_modules_transitive_closure
3618 if test $verbose -ge 0; then
3619 func_show_module_list
3621 final_modules="$modules"
3623 # Determine main module list and tests-related module list separately.
3624 # The main module list is the transitive closure of the specified modules,
3625 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3626 # is specified, it will consist only of LGPLed source.
3627 # The tests-related module list is the transitive closure of the specified
3628 # modules, including tests modules, minus the main module list excluding
3629 # modules of applicability 'all'. Its lib/* sources (brought in through
3630 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3631 # source, even if --lgpl is specified.
3632 # Determine main module list.
3633 saved_inctests="$inctests"
3635 modules="$specified_modules"
3636 func_modules_transitive_closure
3637 main_modules="$modules"
3638 inctests="$saved_inctests"
3639 if test $verbose -ge 1; then
3640 echo "Main module list:"
3641 echo "$main_modules" | sed -e 's/^/ /'
3643 # Determine tests-related module list.
3644 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3645 testsrelated_modules=`for module in $main_modules; do
3646 if test \`func_get_applicability $module\` = main; then
3650 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3651 if test $verbose -ge 1; then
3652 echo "Tests-related module list:"
3653 echo "$testsrelated_modules" | sed -e 's/^/ /'
3656 # Add the dummy module to the main module list if needed.
3657 modules="$main_modules"
3658 func_modules_add_dummy
3659 main_modules="$modules"
3661 # Determine whether a $testsbase/libtests.a is needed.
3663 for module in $testsrelated_modules; do
3664 func_verify_nontests_module
3665 if test -n "$module"; then
3666 all_files=`func_get_filelist $module`
3667 # Test whether some file in $all_files lies in lib/.
3668 for f in $all_files; do
3679 # Add the dummy module to the tests-related module list if needed.
3680 if $use_libtests; then
3681 modules="$testsrelated_modules"
3682 func_modules_add_dummy
3683 testsrelated_modules="$modules"
3686 # If --lgpl, verify that the licenses of modules are compatible.
3687 if test -n "$lgpl"; then
3688 license_incompatibilities=
3689 for module in $main_modules; do
3690 license=`func_get_license $module`
3692 'GPLed build tool') ;;
3693 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3698 LGPL | LGPLv2+ | LGPLv3+) ;;
3699 *) func_append license_incompatibilities "$module $license$nl" ;;
3705 *) func_append license_incompatibilities "$module $license$nl" ;;
3708 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3713 if test -n "$license_incompatibilities"; then
3714 # Format the license incompatibilities as a table.
3715 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3716 s,^\(.................................................[^ ]*\) *, \1 ,'
3717 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3718 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3722 # Show banner notice of every module.
3723 modules="$main_modules"
3726 # Determine script to apply to imported library files.
3727 sed_transform_lib_file=
3728 for module in $main_modules; do
3729 if test $module = config-h; then
3730 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3731 sed_transform_lib_file=$sed_transform_lib_file'
3732 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3737 sed_transform_main_lib_file="$sed_transform_lib_file"
3738 if test -n "$do_copyrights"; then
3739 if test -n "$lgpl"; then
3743 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3744 s/GNU General/GNU Lesser General/g
3748 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3749 s/GNU General/GNU Lesser General/g
3750 s/version [23]\([ ,]\)/version 2.1\1/g
3753 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3757 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3758 s/GNU Lesser General/GNU General/g
3759 s/GNU Library General/GNU General/g
3760 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3765 # Determine script to apply to auxiliary files that go into $auxdir/.
3766 sed_transform_build_aux_file=
3767 if test -n "$do_copyrights"; then
3769 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3770 s/GNU Lesser General/GNU General/g
3771 s/GNU Library General/GNU General/g
3772 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3776 # Determine script to apply to library files that go into $testsbase/.
3777 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3778 if test -n "$do_copyrights"; then
3780 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3781 s/GNU Lesser General/GNU General/g
3782 s/GNU Library General/GNU General/g
3783 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3787 # Determine the final file lists.
3788 # They must be computed separately, because files in lib/* go into
3789 # $sourcebase/ if they are in the main file list but into $testsbase/
3790 # if they are in the tests-related file list. Furthermore lib/dummy.c
3792 # Determine final main file list.
3793 modules="$main_modules"
3794 func_modules_to_filelist
3796 # Determine final tests-related file list.
3797 modules="$testsrelated_modules"
3798 func_modules_to_filelist
3799 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3800 # Merge both file lists.
3801 sed_remove_empty_lines='/^$/d'
3802 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3803 if test $verbose -ge 0; then
3805 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3806 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3810 || func_fatal_error "refusing to do nothing"
3812 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3813 new_files="$files m4/gnulib-tool.m4"
3814 old_files="$cached_files"
3815 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3816 func_append old_files " m4/gnulib-tool.m4"
3819 rewritten='%REWRITTEN%'
3820 sed_rewrite_old_files="\
3821 s,^build-aux/,$rewritten$auxdir/,
3822 s,^doc/,$rewritten$cached_docbase/,
3823 s,^lib/,$rewritten$cached_sourcebase/,
3824 s,^m4/,$rewritten$cached_m4base/,
3825 s,^tests/,$rewritten$cached_testsbase/,
3826 s,^tests=lib/,$rewritten$cached_testsbase/,
3829 sed_rewrite_new_files="\
3830 s,^build-aux/,$rewritten$auxdir/,
3831 s,^doc/,$rewritten$docbase/,
3832 s,^lib/,$rewritten$sourcebase/,
3833 s,^m4/,$rewritten$m4base/,
3834 s,^tests/,$rewritten$testsbase/,
3835 s,^tests=lib/,$rewritten$testsbase/,
3839 # Create directories.
3840 { echo "$sourcebase"
3842 if test -n "$pobase"; then
3845 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3846 if test -n "$docfiles"; then
3849 if test -n "$inctests"; then
3853 for f in $files; do echo $f; done \
3854 | sed -e "$sed_rewrite_new_files" \
3855 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3858 { # Rearrange file descriptors. Needed because "while ... done < ..."
3859 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3860 exec 5<&0 < "$tmp"/dirs
3862 if test ! -d "$destdir/$d"; then
3864 echo "Creating directory $destdir/$d"
3865 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3867 echo "Create directory $destdir/$d"
3874 # Copy files or make symbolic links. Remove obsolete files.
3878 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3879 # representing the files according to the last gnulib-tool invocation.
3880 for f in $old_files; do echo $f; done \
3881 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3884 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3885 # representing the files after this gnulib-tool invocation.
3886 for f in $new_files; do echo $f; done \
3887 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3890 # First the files that are in old-files, but not in new-files:
3891 sed_take_first_column='s,'"$delimiter"'.*,,'
3892 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3893 # Remove the file. Do nothing if the user already removed it.
3894 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3896 echo "Removing file $g (backup in ${g}~)"
3897 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3899 echo "Remove file $g (backup in ${g}~)"
3901 func_append removed_files "$g$nl"
3904 # func_add_or_update handles a file that ought to be present afterwards.
3906 # - f the original file name
3907 # - g the rewritten file name
3908 # - already_present nonempty if the file should already exist, empty
3910 func_add_or_update ()
3914 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3916 func_dest_tmpfilename "$g"
3917 func_lookup_file "$f"
3918 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3919 if test -n "$sed_transform_main_lib_file"; then
3922 sed -e "$sed_transform_main_lib_file" \
3923 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3927 if test -n "$sed_transform_build_aux_file"; then
3930 sed -e "$sed_transform_build_aux_file" \
3931 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3935 if test -n "$sed_transform_testsrelated_lib_file"; then
3938 sed -e "$sed_transform_testsrelated_lib_file" \
3939 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3943 if test -f "$destdir/$g"; then
3944 # The file already exists.
3948 # Don't protest if the file should be there but isn't: it happens
3949 # frequently that developers don't put autogenerated files into CVS.
3951 func_append added_files "$g$nl"
3955 # Then the files that are in new-files, but not in old-files:
3956 sed_take_last_column='s,^.*'"$delimiter"',,'
3958 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3959 | sed -e "$sed_take_last_column" \
3960 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3961 { # Rearrange file descriptors. Needed because "while ... done < ..."
3962 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3963 exec 5<&0 < "$tmp"/added-files
3969 # Then the files that are in new-files and in old-files:
3970 already_present=true
3971 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3972 | sed -e "$sed_take_last_column" \
3973 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3974 { # Rearrange file descriptors. Needed because "while ... done < ..."
3975 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3976 exec 5<&0 < "$tmp"/kept-files
3983 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3984 actioncmd="gnulib-tool --import"
3985 func_append actioncmd " --dir=$destdir"
3986 if test -n "$local_gnulib_dir"; then
3987 func_append actioncmd " --local-dir=$local_gnulib_dir"
3989 func_append actioncmd " --lib=$libname"
3990 func_append actioncmd " --source-base=$sourcebase"
3991 func_append actioncmd " --m4-base=$m4base"
3992 if test -n "$pobase"; then
3993 func_append actioncmd " --po-base=$pobase"
3995 func_append actioncmd " --doc-base=$docbase"
3996 func_append actioncmd " --tests-base=$testsbase"
3997 func_append actioncmd " --aux-dir=$auxdir"
3998 if test -n "$inctests"; then
3999 func_append actioncmd " --with-tests"
4001 if test -n "$incobsolete"; then
4002 func_append actioncmd " --with-obsolete"
4004 if test -n "$inc_cxx_tests"; then
4005 func_append actioncmd " --with-c++-tests"
4007 if test -n "$inc_longrunning_tests"; then
4008 func_append actioncmd " --with-longrunning-tests"
4010 if test -n "$inc_privileged_tests"; then
4011 func_append actioncmd " --with-privileged-tests"
4013 if test -n "$inc_unportable_tests"; then
4014 func_append actioncmd " --with-unportable-tests"
4016 if test -n "$inc_all_tests"; then
4017 func_append actioncmd " --with-all-tests"
4019 for module in $avoidlist; do
4020 func_append actioncmd " --avoid=$module"
4022 if test -n "$lgpl"; then
4023 if test "$lgpl" = yes; then
4024 func_append actioncmd " --lgpl"
4026 func_append actioncmd " --lgpl=$lgpl"
4029 if test -n "$makefile_name"; then
4030 func_append actioncmd " --makefile-name=$makefile_name"
4032 if test "$libtool" = true; then
4033 func_append actioncmd " --libtool"
4035 func_append actioncmd " --no-libtool"
4037 func_append actioncmd " --macro-prefix=$macro_prefix"
4038 if test -n "$po_domain"; then
4039 func_append actioncmd " --po-domain=$po_domain"
4041 if test -n "$vc_files"; then
4042 if test "$vc_files" = true; then
4043 func_append actioncmd " --vc-files"
4045 func_append actioncmd " --no-vc-files"
4048 func_append actioncmd " `echo $specified_modules`"
4050 # Default the makefile name to Makefile.am.
4051 if test -n "$makefile_name"; then
4052 makefile_am=$makefile_name
4054 makefile_am=Makefile.am
4057 # Create normal Makefile.ams.
4060 # Setup list of Makefile.am edits that are to be performed afterwards.
4061 # Some of these edits apply to files that we will generate; others are
4062 # under the responsibility of the developer.
4064 # func_note_Makefile_am_edit dir var value
4065 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4067 func_note_Makefile_am_edit ()
4069 makefile_am_edits=`expr $makefile_am_edits + 1`
4070 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4071 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4072 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4074 if test "$makefile_am" = Makefile.am; then
4075 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4076 sourcebase_base=`basename "$sourcebase"`
4077 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4079 if test -n "$pobase"; then
4080 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4081 pobase_base=`basename "$pobase"`
4082 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4084 if test -n "$inctests"; then
4085 if test "$makefile_am" = Makefile.am; then
4086 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4087 testsbase_base=`basename "$testsbase"`
4088 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4091 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4093 # Find the first parent directory of $m4base that contains or will contain
4095 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4097 sed_butlast='s,[^/][^/]*//*$,,'
4098 dir1="${m4base}/"; dir2=""
4099 while test -n "$dir1" \
4100 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4101 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4102 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4103 || { test -n "$inctests" \
4104 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4105 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4106 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4107 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4109 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4112 # Create library makefile.
4113 func_dest_tmpfilename $sourcebase/$makefile_am
4114 destfile="$sourcebase/$makefile_am"
4115 modules="$main_modules"
4116 func_emit_lib_Makefile_am > "$tmpfile"
4117 if test -f "$destdir"/$sourcebase/$makefile_am; then
4118 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4122 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4123 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4124 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4126 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4132 echo "Creating $sourcebase/$makefile_am"
4133 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4135 echo "Create $sourcebase/$makefile_am"
4138 func_append added_files "$sourcebase/$makefile_am$nl"
4141 # Create po/ directory.
4142 if test -n "$pobase"; then
4143 # Create po makefile and auxiliary files.
4144 for file in Makefile.in.in remove-potcdate.sin; do
4145 func_dest_tmpfilename $pobase/$file
4146 func_lookup_file build-aux/po/$file
4147 cat "$lookedup_file" > "$tmpfile"
4148 if test -f "$destdir"/$pobase/$file; then
4149 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4153 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4154 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4155 mv -f "$tmpfile" "$destdir"/$pobase/$file
4157 echo "Update $pobase/$file (backup in $pobase/$file~)"
4163 echo "Creating $pobase/$file"
4164 mv -f "$tmpfile" "$destdir"/$pobase/$file
4166 echo "Create $pobase/$file"
4169 func_append added_files "$pobase/$file$nl"
4172 # Create po makefile parameterization, part 1.
4173 func_dest_tmpfilename $pobase/Makevars
4174 func_emit_po_Makevars > "$tmpfile"
4175 if test -f "$destdir"/$pobase/Makevars; then
4176 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4180 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4181 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4182 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4184 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4190 echo "Creating $pobase/Makevars"
4191 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4193 echo "Create $pobase/Makevars"
4196 func_append added_files "$pobase/Makevars$nl"
4198 # Create po makefile parameterization, part 2.
4199 func_dest_tmpfilename $pobase/POTFILES.in
4200 func_emit_po_POTFILES_in > "$tmpfile"
4201 if test -f "$destdir"/$pobase/POTFILES.in; then
4202 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4206 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4207 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4208 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4210 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4216 echo "Creating $pobase/POTFILES.in"
4217 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4219 echo "Create $pobase/POTFILES.in"
4222 func_append added_files "$pobase/POTFILES.in$nl"
4225 TP_URL="http://translationproject.org/latest/"
4226 TP_RSYNC_URI="translationproject.org::tp/latest/"
4228 echo "Fetching gnulib PO files from $TP_URL"
4229 (cd "$destdir"/$pobase \
4230 && { # Prefer rsync over wget if it is available, since it consumes
4231 # less network bandwidth, due to compression.
4232 if type rsync 2>/dev/null | grep / > /dev/null; then
4233 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4235 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4240 echo "Fetch gnulib PO files from $TP_URL"
4242 # Create po/LINGUAS.
4244 func_dest_tmpfilename $pobase/LINGUAS
4245 (cd "$destdir"/$pobase \
4246 && { echo '# Set of available languages.'
4247 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4250 if test -f "$destdir"/$pobase/LINGUAS; then
4251 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4254 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4255 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4256 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4259 echo "Creating $pobase/LINGUAS"
4260 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4261 func_append added_files "$pobase/LINGUAS$nl"
4264 if test -f "$destdir"/$pobase/LINGUAS; then
4265 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4267 echo "Create $pobase/LINGUAS"
4272 # Create m4/gnulib-cache.m4.
4273 func_dest_tmpfilename $m4base/gnulib-cache.m4
4275 func_emit_copyright_notice
4277 echo "# This file represents the specification of how gnulib-tool is used."
4278 echo "# It acts as a cache: It is written and read by gnulib-tool."
4279 echo "# In projects using CVS, this file is meant to be stored in CVS,"
4280 echo "# like the configure.ac and various Makefile.am files."
4283 echo "# Specification in the form of a command-line invocation:"
4286 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4287 # Store the local_gnulib_dir relative to destdir.
4288 case "$local_gnulib_dir" in
4290 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4293 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4295 # destdir, local_gnulib_dir are both relative.
4296 func_relativize "$destdir" "$local_gnulib_dir"
4297 relative_local_gnulib_dir="$reldir" ;;
4300 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4302 echo "$specified_modules" | sed -e 's/^/ /g'
4304 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4305 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4306 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4307 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4308 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4309 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4310 echo "gl_AVOID([$avoidlist])"
4311 echo "gl_SOURCE_BASE([$sourcebase])"
4312 echo "gl_M4_BASE([$m4base])"
4313 echo "gl_PO_BASE([$pobase])"
4314 echo "gl_DOC_BASE([$docbase])"
4315 echo "gl_TESTS_BASE([$testsbase])"
4316 test -z "$inctests" || echo "gl_WITH_TESTS"
4317 echo "gl_LIB([$libname])"
4318 if test -n "$lgpl"; then
4319 if test "$lgpl" = yes; then
4322 echo "gl_LGPL([$lgpl])"
4325 echo "gl_MAKEFILE_NAME([$makefile_name])"
4326 if test "$libtool" = true; then
4329 echo "gl_MACRO_PREFIX([$macro_prefix])"
4330 echo "gl_PO_DOMAIN([$po_domain])"
4331 if test -n "$vc_files"; then
4332 echo "gl_VC_FILES([$vc_files])"
4335 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4336 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4340 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4341 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4342 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4344 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4348 echo "# gnulib-cache.m4 ends here"
4355 echo "Creating $m4base/gnulib-cache.m4"
4356 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4358 echo "Create $m4base/gnulib-cache.m4"
4364 # Create m4/gnulib-comp.m4.
4365 func_dest_tmpfilename $m4base/gnulib-comp.m4
4367 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4368 func_emit_copyright_notice
4370 echo "# This file represents the compiled summary of the specification in"
4371 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4372 echo "# to be invoked from configure.ac."
4373 echo "# In projects using CVS, this file can be treated like other built files."
4376 echo "# This macro should be invoked from $configure_ac, in the section"
4377 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4378 echo "# any checks for libraries, header files, types and library functions."
4379 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4381 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4382 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4383 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4384 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4385 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4386 if test -n "$uses_subdirs"; then
4387 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4389 for module in $final_modules; do
4391 if test -n "$module"; then
4392 echo "# Code from module $module:"
4393 func_get_autoconf_early_snippet "$module"
4396 | sed -e '/^$/d;' -e 's/^/ /'
4399 echo "# This macro should be invoked from $configure_ac, in the section"
4400 echo "# \"Check for header files, types and library functions\"."
4401 echo "AC_DEFUN([${macro_prefix}_INIT],"
4403 if test "$libtool" = true; then
4404 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4405 echo " gl_cond_libtool=true"
4407 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4408 echo " gl_cond_libtool=false"
4410 echo " gl_ltlibdeps="
4412 if test "$auxdir" != "build-aux"; then
4413 sed_replace_build_aux='
4415 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4416 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4420 sed_replace_build_aux="$sed_noop"
4422 echo " gl_m4_base='$m4base'"
4423 func_emit_initmacro_start $macro_prefix
4424 echo " gl_source_base='$sourcebase'"
4425 for module in $main_modules; do
4427 if test -n "$module"; then
4428 echo " # Code from module $module:"
4429 func_get_autoconf_snippet "$module" \
4430 | sed -e '/^$/d;' -e 's/^/ /' \
4431 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4432 -e "$sed_replace_build_aux"
4433 if test "$module" = 'alloca' && test "$libtool" = true; then
4434 echo 'changequote(,)dnl'
4435 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4436 echo 'changequote([, ])dnl'
4437 echo 'AC_SUBST([LTALLOCA])'
4441 echo " # End of code from modules"
4442 func_emit_initmacro_end $macro_prefix
4443 echo " gltests_libdeps="
4444 echo " gltests_ltlibdeps="
4445 func_emit_initmacro_start ${macro_prefix}tests
4446 echo " gl_source_base='$testsbase'"
4447 # Define a tests witness macro that depends on the package.
4448 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4449 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4450 echo "changequote(,)dnl"
4451 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"
4452 echo "changequote([, ])dnl"
4453 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4454 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4455 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4456 for module in $testsrelated_modules; do
4458 if test -n "$module"; then
4459 func_get_autoconf_snippet "$module" \
4460 | sed -e '/^$/d;' -e 's/^/ /' \
4461 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4462 -e "$sed_replace_build_aux" \
4463 -e 's/\$gl_cond_libtool/false/g' \
4464 -e 's/gl_libdeps/gltests_libdeps/g' \
4465 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4468 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4469 func_emit_initmacro_end ${macro_prefix}tests
4470 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4471 # created using libtool, because libtool already handles the dependencies.
4472 if test "$libtool" != true; then
4473 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4474 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4475 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4476 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4477 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4479 if $use_libtests; then
4480 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4481 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4484 func_emit_initmacro_done $macro_prefix $sourcebase
4485 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4487 echo "# This macro records the list of files which have been installed by"
4488 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4489 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4490 echo "$files" | sed -e 's,^, ,'
4493 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4494 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4498 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4499 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4500 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4502 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4506 echo "# gnulib-comp.m4 ends here"
4513 echo "Creating $m4base/gnulib-comp.m4"
4514 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4516 echo "Create $m4base/gnulib-comp.m4"
4522 if test -n "$inctests"; then
4523 # Create tests makefile.
4524 func_dest_tmpfilename $testsbase/$makefile_am
4525 destfile="$testsbase/$makefile_am"
4526 modules="$testsrelated_modules"
4527 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4528 if test -f "$destdir"/$testsbase/$makefile_am; then
4529 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4533 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4534 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4535 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4537 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4543 echo "Creating $testsbase/$makefile_am"
4544 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4546 echo "Create $testsbase/$makefile_am"
4549 func_append added_files "$testsbase/$makefile_am$nl"
4553 if test "$vc_files" != false; then
4554 # Update the .cvsignore and .gitignore files.
4555 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4556 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4557 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4558 echo "$m4base/|A|gnulib-comp.m4"
4559 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4560 { # Rearrange file descriptors. Needed because "while ... done < ..."
4561 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4562 exec 5<&0 < "$tmp"/fileset-changes
4563 func_update_ignorelist ()
4566 if test "$ignore" = .gitignore; then
4567 # In a .gitignore file, "foo" applies to the current directory and all
4568 # subdirectories, whereas "/foo" applies to the current directory only.
4571 doubly_escaped_anchor='\\/'
4575 doubly_escaped_anchor=''
4577 if test -f "$destdir/$dir$ignore"; then
4578 if test -n "$dir_added" || test -n "$dir_removed"; then
4579 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4580 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4581 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4582 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4583 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4585 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4587 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4588 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4589 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4590 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4591 } > "$tmp"/sed-ignore-removed
4592 { cat "$destdir/$dir$ignore"~
4593 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4594 } | sed -f "$tmp"/sed-ignore-removed \
4595 > "$destdir/$dir$ignore"
4597 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4602 if test -n "$dir_added"; then
4604 echo "Creating $destdir/$dir$ignore"
4606 if test "$ignore" = .cvsignore; then
4608 # Automake generates Makefile rules that create .dirstamp files.
4611 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4612 } > "$destdir/$dir$ignore"
4614 echo "Create $destdir/$dir$ignore"
4624 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4625 func_update_ignorelist .cvsignore
4627 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4628 func_update_ignorelist .gitignore
4635 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4636 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4637 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4638 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4639 if test "$next_dir" != "$last_dir"; then
4640 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4641 last_dir="$next_dir"
4646 A) func_append last_dir_added "$file$nl";;
4647 R) func_append last_dir_removed "$file$nl";;
4650 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4657 echo "You may need to add #include directives for the following .h files."
4658 # Intersect $specified_modules and $main_modules
4659 # (since $specified_modules is not necessarily of subset of $main_modules
4660 # - some may have been skipped through --avoid, and since the elements of
4661 # $main_modules but not in $specified_modules can go away without explicit
4662 # notice - through changes in the module dependencies).
4663 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4664 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4665 # First the #include <...> directives without #ifs, sorted for convenience,
4666 # then the #include "..." directives without #ifs, sorted for convenience,
4667 # then the #include directives that are surrounded by #ifs. Not sorted.
4668 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4669 include_directive=`func_get_include_directive "$module"`
4670 case "$nl$include_directive" in
4672 echo "$include_directive" 1>&5
4675 echo "$include_directive" | grep -v 'include "' 1>&6
4676 echo "$include_directive" | grep 'include "' 1>&7
4679 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4681 LC_ALL=C sort -u "$tmp"/include-angles
4682 LC_ALL=C sort -u "$tmp"/include-quotes
4683 cat "$tmp"/include-if
4684 ) | sed -e '/^$/d' -e 's/^/ /'
4685 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4687 for module in $main_modules; do
4688 func_get_link_directive "$module"
4690 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4691 if test `wc -l < "$tmp"/link` != 0; then
4693 echo "You may need to use the following Makefile variables when linking."
4694 echo "Use them in <program>_LDADD when linking a program, or"
4695 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4701 echo "Don't forget to"
4702 if test "$makefile_am" = Makefile.am; then
4703 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4705 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4707 if test -n "$pobase"; then
4708 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4710 if test -n "$inctests"; then
4711 if test "$makefile_am" = Makefile.am; then
4712 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4714 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4718 while test $edit != $makefile_am_edits; do
4719 edit=`expr $edit + 1`
4720 eval dir=\"\$makefile_am_edit${edit}_dir\"
4721 eval var=\"\$makefile_am_edit${edit}_var\"
4722 eval val=\"\$makefile_am_edit${edit}_val\"
4723 if test -n "$var"; then
4724 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4727 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4728 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4731 # func_create_testdir testdir modules
4733 # - local_gnulib_dir from --local-dir
4734 # - modcache true or false, from --cache-modules/--no-cache-modules
4735 # - auxdir directory relative to destdir where to place build aux files
4736 # - inctests true if tests should be included, blank otherwise
4737 # - incobsolete true if obsolete modules among dependencies should be
4738 # included, blank otherwise
4739 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
4741 # - excl_longrunning_tests true if long-runnings tests should be excluded,
4743 # - excl_privileged_tests true if tests that require root privileges should be
4744 # excluded, blank otherwise
4745 # - excl_unportable_tests true if tests that fail on some platforms should be
4746 # excluded, blank otherwise
4747 # - avoidlist list of modules to avoid
4748 # - libtool true if --libtool was given, false if --no-libtool was
4749 # given, blank otherwise
4750 # - symbolic true if files should be symlinked, copied otherwise
4751 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4753 func_create_testdir ()
4757 if test -z "$modules"; then
4758 # All modules together.
4759 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4760 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4761 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4762 modules=`func_all_modules`
4763 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4765 specified_modules="$modules"
4767 # Canonicalize the list of specified modules.
4768 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4770 # Unlike in func_import, here we want to include all kinds of tests for the
4771 # directly specified modules, but not for dependencies.
4772 inc_all_direct_tests=true
4773 inc_all_indirect_tests="$inc_all_tests"
4775 # Check that the license of every module is consistent with the license of
4777 saved_inctests="$inctests"
4778 # When computing transitive closures, don't consider $module to depend on
4779 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4780 # on GPL modules - therefore we don't want a warning in this case.
4782 for requested_module in $specified_modules; do
4783 requested_license=`func_get_license "$requested_module"`
4784 if test "$requested_license" != GPL; then
4785 # Here we use func_modules_transitive_closure, not just
4786 # func_get_dependencies, so that we also detect weird situations like
4787 # an LGPL module which depends on a GPLed build tool module which depends
4789 modules="$requested_module"
4790 func_modules_transitive_closure
4791 for module in $modules; do
4792 license=`func_get_license "$module"`
4794 'GPLed build tool') ;;
4795 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4797 case "$requested_license" in
4800 GPLv2+ | LGPLv2+) ;;
4801 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4807 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4813 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4822 inctests="$saved_inctests"
4824 # Subdirectory names.
4834 # Determine final module list.
4835 modules="$specified_modules"
4836 func_modules_transitive_closure
4837 if test $verbose -ge 0; then
4838 func_show_module_list
4841 # Add the dummy module if needed.
4842 func_modules_add_dummy
4844 # Show banner notice of every module.
4847 # Determine final file list.
4848 func_modules_to_filelist
4849 if test $verbose -ge 0; then
4851 echo "$files" | sed -e 's/^/ /'
4854 rewritten='%REWRITTEN%'
4855 sed_rewrite_files="\
4856 s,^build-aux/,$rewritten$auxdir/,
4857 s,^doc/,$rewritten$docbase/,
4858 s,^lib/,$rewritten$sourcebase/,
4859 s,^m4/,$rewritten$m4base/,
4860 s,^tests/,$rewritten$testsbase/,
4864 # Create directories.
4865 for f in $files; do echo $f; done \
4866 | sed -e "$sed_rewrite_files" \
4867 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4868 | LC_ALL=C sort -u \
4870 { # Rearrange file descriptors. Needed because "while ... done < ..."
4871 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4872 exec 5<&0 < "$tmp"/dirs
4874 mkdir -p "$testdir/$d"
4879 # Copy files or make symbolic links.
4881 for f in $files; do echo $f; done \
4882 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4885 { # Rearrange file descriptors. Needed because "while ... done < ..."
4886 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4887 exec 5<&0 < "$tmp"/files
4889 func_lookup_file "$f"
4890 if test -n "$lookedup_tmp"; then
4891 cp -p "$lookedup_file" "$testdir/$g"
4893 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4894 if { test -n "$symbolic" \
4895 || { test -n "$lsymbolic" \
4896 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4897 func_ln "$lookedup_file" "$testdir/$g"
4899 cp -p "$lookedup_file" "$testdir/$g"
4906 # Create Makefile.ams that are for testing.
4909 # No special edits are needed.
4912 # Create $sourcebase/Makefile.am.
4913 mkdir -p "$testdir/$sourcebase"
4914 destfile="$sourcebase/Makefile.am"
4915 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4916 any_uses_subdirs="$uses_subdirs"
4918 # Create $m4base/Makefile.am.
4919 mkdir -p "$testdir/$m4base"
4920 (echo "## Process this file with automake to produce Makefile.in."
4926 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4929 ) > "$testdir/$m4base/Makefile.am"
4931 subdirs="$sourcebase $m4base"
4932 subdirs_with_configure_ac=""
4934 if false && test -f "$testdir"/$m4base/gettext.m4; then
4935 # Avoid stupid error message from automake:
4936 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4937 mkdir -p "$testdir/po"
4938 (echo "## Process this file with automake to produce Makefile.in."
4939 ) > "$testdir/po/Makefile.am"
4940 func_append subdirs " po"
4943 if test -n "$inctests"; then
4944 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4945 # Viewed from the $testsbase subdirectory, $auxdir is different.
4946 saved_auxdir="$auxdir"
4947 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4948 # Create $testsbase/Makefile.am.
4950 destfile="$testsbase/Makefile.am"
4951 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
4952 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4953 # Create $testsbase/configure.ac.
4954 (echo "# Process this file with autoconf to produce a configure script."
4955 echo "AC_INIT([dummy], [0])"
4956 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4957 echo "AM_INIT_AUTOMAKE"
4959 echo "AC_CONFIG_HEADERS([config.h])"
4962 echo "AC_PROG_INSTALL"
4963 echo "AC_PROG_MAKE_SET"
4964 echo "AC_PROG_RANLIB"
4966 if test -n "$uses_subdirs"; then
4967 echo "AM_PROG_CC_C_O"
4970 for module in $modules; do
4972 if test -n "$module"; then
4974 gnumakefile | maintainer-makefile)
4975 # These modules are meant to be used only in the top-level directory.
4978 func_get_autoconf_early_snippet "$module"
4983 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4984 if test "$libtool" = true; then
4985 echo "LT_INIT([win32-dll])"
4986 echo "LT_LANG([C++])"
4987 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4988 echo "gl_cond_libtool=true"
4990 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4991 echo "gl_cond_libtool=false"
4993 echo "gl_ltlibdeps="
4995 # Wrap the set of autoconf snippets into an autoconf macro that is then
4996 # invoked. This is needed because autoconf does not support AC_REQUIRE
4998 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4999 # but we want the AC_REQUIRE to have its normal meaning (provide one
5000 # expansion of the required macro before the current point, and only one
5002 echo "AC_DEFUN([gl_INIT], ["
5003 sed_replace_build_aux='
5005 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5006 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5009 echo "gl_m4_base='../$m4base'"
5010 func_emit_initmacro_start $macro_prefix
5011 # We don't have explicit ordering constraints between the various
5012 # autoconf snippets. It's cleanest to put those of the library before
5013 # those of the tests.
5014 echo "gl_source_base='../$sourcebase'"
5015 for module in $modules; do
5016 func_verify_nontests_module
5017 if test -n "$module"; then
5019 gnumakefile | maintainer-makefile)
5020 # These modules are meant to be used only in the top-level directory.
5023 func_get_autoconf_snippet "$module" \
5024 | sed -e "$sed_replace_build_aux"
5029 echo "gl_source_base='.'"
5030 for module in $modules; do
5031 func_verify_tests_module
5032 if test -n "$module"; then
5033 func_get_autoconf_snippet "$module" \
5034 | sed -e "$sed_replace_build_aux"
5037 func_emit_initmacro_end $macro_prefix
5038 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5039 # created using libtool, because libtool already handles the dependencies.
5040 if test "$libtool" != true; then
5041 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5042 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5043 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5044 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5045 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5048 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5052 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5053 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5054 echo "AH_TOP([#include \"../config.h\"])"
5056 echo "AC_CONFIG_FILES([Makefile])"
5058 ) > "$testdir/$testsbase/configure.ac"
5059 auxdir="$saved_auxdir"
5060 func_append subdirs " $testsbase"
5061 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5064 # Create Makefile.am.
5065 (echo "## Process this file with automake to produce Makefile.in."
5067 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5069 echo "SUBDIRS = $subdirs"
5071 echo "ACLOCAL_AMFLAGS = -I $m4base"
5072 ) > "$testdir/Makefile.am"
5074 # Create configure.ac.
5075 (echo "# Process this file with autoconf to produce a configure script."
5076 echo "AC_INIT([dummy], [0])"
5077 if test "$auxdir" != "."; then
5078 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5080 echo "AM_INIT_AUTOMAKE"
5082 echo "AC_CONFIG_HEADERS([config.h])"
5085 echo "AC_PROG_INSTALL"
5086 echo "AC_PROG_MAKE_SET"
5088 echo "# For autobuild."
5089 echo "AC_CANONICAL_BUILD"
5090 echo "AC_CANONICAL_HOST"
5092 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5093 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5094 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5095 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5097 echo "AC_PROG_RANLIB"
5099 if test -n "$any_uses_subdirs"; then
5100 echo "AM_PROG_CC_C_O"
5103 for module in $modules; do
5104 func_verify_nontests_module
5105 if test -n "$module"; then
5106 func_get_autoconf_early_snippet "$module"
5109 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5110 if test "$libtool" = true; then
5111 echo "LT_INIT([win32-dll])"
5112 echo "LT_LANG([C++])"
5113 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5114 echo "gl_cond_libtool=true"
5116 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5117 echo "gl_cond_libtool=false"
5119 echo "gl_ltlibdeps="
5121 # Wrap the set of autoconf snippets into an autoconf macro that is then
5122 # invoked. This is needed because autoconf does not support AC_REQUIRE
5124 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5125 # but we want the AC_REQUIRE to have its normal meaning (provide one
5126 # expansion of the required macro before the current point, and only one
5128 echo "AC_DEFUN([gl_INIT], ["
5129 if test "$auxdir" != "build-aux"; then
5130 sed_replace_build_aux='
5132 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5133 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5137 sed_replace_build_aux="$sed_noop"
5139 echo "gl_m4_base='$m4base'"
5140 func_emit_initmacro_start $macro_prefix
5141 echo "gl_source_base='$sourcebase'"
5142 for module in $modules; do
5143 func_verify_nontests_module
5144 if test -n "$module"; then
5145 func_get_autoconf_snippet "$module" \
5146 | sed -e "$sed_replace_build_aux"
5149 func_emit_initmacro_end $macro_prefix
5150 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5151 # created using libtool, because libtool already handles the dependencies.
5152 if test "$libtool" != true; then
5153 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5154 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5155 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5156 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5157 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5160 func_emit_initmacro_done $macro_prefix $sourcebase
5164 if test -n "$subdirs_with_configure_ac"; then
5165 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5167 makefiles="Makefile"
5168 for d in $subdirs; do
5169 # For subdirs that have a configure.ac by their own, it's the subdir's
5170 # configure.ac which creates the subdir's Makefile.am, not this one.
5171 case " $subdirs_with_configure_ac " in
5173 *) func_append makefiles " $d/Makefile" ;;
5176 echo "AC_CONFIG_FILES([$makefiles])"
5178 ) > "$testdir/configure.ac"
5180 # Create autogenerated files.
5182 # Do not use "${AUTORECONF} --force --install", because it may invoke
5183 # autopoint, which brings in older versions of some of our .m4 files.
5184 if test -f $m4base/gettext.m4; then
5185 func_execute_command ${AUTOPOINT} --force || func_exit 1
5186 for f in $m4base/*.m4~; do
5188 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5192 if test "$libtool" = true; then
5193 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5195 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5196 if ! test -d build-aux; then
5197 func_execute_command mkdir build-aux || func_exit 1
5199 func_execute_command ${AUTOCONF} || func_exit 1
5200 func_execute_command ${AUTOHEADER} || func_exit 1
5201 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5203 if test -n "$inctests"; then
5204 # Create autogenerated files.
5205 (cd "$testdir/$testsbase" || func_exit 1
5206 # Do not use "${AUTORECONF} --force --install", because it may invoke
5207 # autopoint, which brings in older versions of some of our .m4 files.
5208 if test -f ../$m4base/gettext.m4; then
5209 func_execute_command ${AUTOPOINT} --force || func_exit 1
5210 for f in ../$m4base/*.m4~; do
5212 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5216 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5217 if ! test -d ../build-aux; then
5218 func_execute_command mkdir ../build-aux
5220 func_execute_command ${AUTOCONF} || func_exit 1
5221 func_execute_command ${AUTOHEADER} || func_exit 1
5222 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5225 # Need to run configure and make once, to create built files that are to be
5226 # distributed (such as getdate.c).
5227 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5228 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5229 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5230 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5231 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5232 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5233 # such $(FOO_H) because they don't refer to distributed files.
5234 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5235 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5236 | sed -e "$sed_remove_make_variables"`
5237 distributed_built_sources=`for file in $built_sources; do
5238 case "$cleaned_files" in
5243 tests_distributed_built_sources=
5244 if test -n "$inctests"; then
5245 # Likewise for built files in the $testsbase directory.
5246 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5247 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5248 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5249 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5250 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5251 | sed -e "$sed_remove_make_variables"`
5252 tests_distributed_built_sources=`for file in $tests_built_sources; do
5253 case "$tests_cleaned_files" in
5259 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5261 ./configure || func_exit 1
5262 if test -n "$distributed_built_sources"; then
5264 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5265 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5270 if test -n "$tests_distributed_built_sources"; then
5272 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5273 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5278 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5285 # func_create_megatestdir megatestdir allmodules
5287 # - local_gnulib_dir from --local-dir
5288 # - modcache true or false, from --cache-modules/--no-cache-modules
5289 # - auxdir directory relative to destdir where to place build aux files
5290 func_create_megatestdir ()
5294 if test -z "$allmodules"; then
5295 allmodules=`func_all_modules`
5299 # First, all modules one by one.
5300 for onemodule in $allmodules; do
5301 func_create_testdir "$megatestdir/$onemodule" $onemodule
5302 func_append megasubdirs "$onemodule "
5304 # Then, all modules all together.
5305 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5306 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5307 func_create_testdir "$megatestdir/ALL" "$allmodules"
5308 func_append megasubdirs "ALL"
5311 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5312 vc_witness="$gnulib_dir/CVS/Entries"; \
5314 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5316 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5317 | sed -e 's,January,01,' -e 's,Jan,01,' \
5318 -e 's,February,02,' -e 's,Feb,02,' \
5319 -e 's,March,03,' -e 's,Mar,03,' \
5320 -e 's,April,04,' -e 's,Apr,04,' \
5322 -e 's,June,06,' -e 's,Jun,06,' \
5323 -e 's,July,07,' -e 's,Jul,07,' \
5324 -e 's,August,08,' -e 's,Aug,08,' \
5325 -e 's,September,09,' -e 's,Sep,09,' \
5326 -e 's,October,10,' -e 's,Oct,10,' \
5327 -e 's,November,11,' -e 's,Nov,11,' \
5328 -e 's,December,12,' -e 's,Dec,12,' \
5329 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5330 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5332 echo "CVSDATE=$cvsdate"
5333 echo ": \${MAKE=make}"
5334 echo "test -d logs || mkdir logs"
5335 echo "for module in $megasubdirs; do"
5336 echo " echo \"Working on module \$module...\""
5337 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5338 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5341 echo " : autobuild project... \$module"
5342 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5343 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5344 echo " : autobuild hostname... \`hostname\`"
5345 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5347 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5349 ) > "$megatestdir/do-autobuild"
5350 chmod a+x "$megatestdir/do-autobuild"
5352 # Create Makefile.am.
5353 (echo "## Process this file with automake to produce Makefile.in."
5355 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5357 echo "SUBDIRS = $megasubdirs"
5359 echo "EXTRA_DIST = do-autobuild"
5360 ) > "$megatestdir/Makefile.am"
5362 # Create configure.ac.
5363 (echo "# Process this file with autoconf to produce a configure script."
5364 echo "AC_INIT([dummy], [0])"
5365 if test "$auxdir" != "."; then
5366 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5368 echo "AM_INIT_AUTOMAKE"
5370 echo "AC_PROG_MAKE_SET"
5372 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5373 echo "AC_CONFIG_FILES([Makefile])"
5375 ) > "$megatestdir/configure.ac"
5377 # Create autogenerated files.
5379 # Do not use "${AUTORECONF} --install", because autoreconf operates
5380 # recursively, but the subdirectories are already finished, therefore
5381 # calling autoreconf here would only waste lots of CPU time.
5382 func_execute_command ${ACLOCAL} || func_exit 1
5383 func_execute_command mkdir build-aux
5384 func_execute_command ${AUTOCONF} || func_exit 1
5385 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5391 func_fatal_error "no mode specified" ;;
5398 # sed expression that converts a literal to a basic regular expression.
5399 # Needs to handle . [ \ * ^ $.
5400 sed_literal_to_basic_regex='s/\\/\\\\/g
5406 if test -f "$gnulib_dir/$filename" \
5407 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5408 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5409 filename_line_regex='^'"$filename_anywhere_regex"'$'
5412 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5413 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5414 (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$,,')
5417 | func_sanitize_modulelist \
5420 for module in $module_candidates; do
5421 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5426 func_warning "file $filename does not exist"
5434 if test -z "$destdir"; then
5437 test -d "$destdir" \
5438 || func_fatal_error "destination directory does not exist: $destdir"
5440 # Prefer configure.ac to configure.in.
5441 if test -f "$destdir"/configure.ac; then
5442 configure_ac="$destdir/configure.ac"
5444 if test -f "$destdir"/configure.in; then
5445 configure_ac="$destdir/configure.in"
5447 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5451 # Analyze configure.ac.
5453 guessed_libtool=false
5458 /AC_CONFIG_AUX_DIR/ {
5459 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5461 /A[CM]_PROG_LIBTOOL/ {
5462 s,^.*$,guessed_libtool=true,p
5464 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5466 if test -z "$auxdir"; then
5467 auxdir="$guessed_auxdir"
5470 # Determine where to apply func_import.
5471 if test -n "$m4base"; then
5472 # Apply func_import to a particular gnulib directory.
5473 # Any number of additional modules can be given.
5474 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5475 # First use of gnulib in the given m4base.
5476 test -n "$supplied_libname" || supplied_libname=true
5477 test -n "$sourcebase" || sourcebase="lib"
5478 test -n "$docbase" || docbase="doc"
5479 test -n "$testsbase" || testsbase="tests"
5480 test -n "$macro_prefix" || macro_prefix="gl"
5484 # Apply func_import to all gnulib directories.
5485 # To get this list of directories, look at Makefile.am. (Not at
5486 # configure, because it may be omitted from CVS. Also, don't run
5487 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
5490 if test -f "$destdir"/Makefile.am; then
5491 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5493 for arg in $aclocal_amflags; do
5494 if test -n "$m4dir_is_next"; then
5495 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5499 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5500 func_append m4dirs " $arg"
5501 m4dirs_count=`expr $m4dirs_count + 1`
5507 if test "X$arg" = "X-I"; then
5515 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5516 if test -f "$destdir"/aclocal.m4; then
5517 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5518 sedexpr2='s,^[^/]*$,.,'
5519 sedexpr3='s,/[^/]*$,,'
5520 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5521 m4dirs_count=`printf %s "$m4dirs" | wc -l`
5524 if test $m4dirs_count = 0; then
5525 # First use of gnulib in a package.
5526 # Any number of additional modules can be given.
5527 test -n "$supplied_libname" || supplied_libname=true
5528 test -n "$sourcebase" || sourcebase="lib"
5530 test -n "$docbase" || docbase="doc"
5531 test -n "$testsbase" || testsbase="tests"
5532 test -n "$macro_prefix" || macro_prefix="gl"
5535 if test $m4dirs_count = 1; then
5536 # There's only one use of gnulib here. Assume the user means it.
5537 # Any number of additional modules can be given.
5538 for m4base in $m4dirs; do
5542 # Ambiguous - guess what the user meant.
5543 if test $# = 0; then
5544 # No further arguments. Guess the user wants to update all of them.
5545 for m4base in $m4dirs; do
5546 # Perform func_import in a subshell, so that variable values
5548 # local_gnulib_dir, incobsolete, inc_cxx_tests,
5549 # inc_longrunning_tests, inc_privileged_tests,
5550 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
5551 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
5552 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5553 # don't propagate from one directory to another.
5554 (func_import) || func_exit 1
5558 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5566 if test -z "$destdir"; then
5567 func_fatal_error "please specify --dir option"
5570 test -d "$destdir" \
5571 || func_fatal_error "could not create destination directory"
5572 test -n "$auxdir" || auxdir="build-aux"
5573 func_create_testdir "$destdir" "$*"
5576 create-megatestdir )
5577 if test -z "$destdir"; then
5578 func_fatal_error "please specify --dir option"
5580 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5581 test -n "$auxdir" || auxdir="build-aux"
5582 func_create_megatestdir "$destdir" "$*"
5586 test -n "$destdir" || destdir=testdir$$
5587 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5588 test -n "$auxdir" || auxdir="build-aux"
5589 func_create_testdir "$destdir" "$*"
5593 ../configure || func_exit 1
5594 $MAKE || func_exit 1
5595 $MAKE check || func_exit 1
5596 $MAKE distclean || func_exit 1
5597 remaining=`find . -type f -print`
5598 if test -n "$remaining"; then
5599 echo "Remaining files:" $remaining 1>&2
5600 echo "gnulib-tool: *** Stop." 1>&2
5609 test -n "$destdir" || destdir=testdir$$
5610 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5611 test -n "$auxdir" || auxdir="build-aux"
5612 func_create_megatestdir "$destdir" "$*"
5620 remaining=`find . -type f -print`
5621 if test -n "$remaining"; then
5622 echo "Remaining files:" $remaining 1>&2
5623 echo "gnulib-tool: *** Stop." 1>&2
5631 extract-description )
5635 if test -n "$module"; then
5636 func_get_description "$module"
5645 if test -n "$module"; then
5646 func_get_comment "$module"
5655 if test -n "$module"; then
5656 func_get_status "$module"
5665 if test -n "$module"; then
5666 func_get_notice "$module"
5671 extract-applicability )
5675 if test -n "$module"; then
5676 func_get_applicability "$module"
5685 if test -n "$module"; then
5686 func_get_filelist "$module"
5691 extract-dependencies )
5695 if test -n "$module"; then
5696 func_get_dependencies "$module"
5701 extract-autoconf-snippet )
5705 if test -n "$module"; then
5706 func_get_autoconf_snippet "$module"
5711 extract-automake-snippet )
5715 if test -n "$module"; then
5716 func_get_automake_snippet "$module"
5721 extract-include-directive )
5725 if test -n "$module"; then
5726 func_get_include_directive "$module"
5731 extract-link-directive )
5735 if test -n "$module"; then
5736 func_get_link_directive "$module"
5745 if test -n "$module"; then
5746 func_get_license "$module"
5751 extract-maintainer )
5755 if test -n "$module"; then
5756 func_get_maintainer "$module"
5761 extract-tests-module )
5765 if test -n "$module"; then
5766 func_get_tests_module "$module"
5772 # Verify the number of arguments.
5773 if test $# -lt 1 || test $# -gt 2; then
5774 func_fatal_error "invalid number of arguments for --$mode"
5777 # The first argument is the file to be copied.
5779 # Verify the file exists.
5780 func_lookup_file "$f"
5782 # The second argument is the destination; either a directory ot a file.
5783 # It defaults to the current directory.
5785 test -n "$dest" || dest='.'
5786 test -n "$sourcebase" || sourcebase="lib"
5787 test -n "$m4base" || m4base="m4"
5788 test -n "$docbase" || docbase="doc"
5789 test -n "$testsbase" || testsbase="tests"
5790 test -n "$auxdir" || auxdir="build-aux"
5791 rewritten='%REWRITTEN%'
5792 sed_rewrite_files="\
5793 s,^build-aux/,$rewritten$auxdir/,
5794 s,^doc/,$rewritten$docbase/,
5795 s,^lib/,$rewritten$sourcebase/,
5796 s,^m4/,$rewritten$m4base/,
5797 s,^tests/,$rewritten$testsbase/,
5800 if test -d "$dest"; then
5802 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5804 destdir=`dirname "$dest"`
5805 g=`basename "$dest"`
5808 # Create the directory for destfile.
5809 d=`dirname "$destdir/$g"`
5811 if test -n "$d" && test ! -d "$d"; then
5812 mkdir -p "$d" || func_fatal_error "failed"
5816 func_dest_tmpfilename "$g"
5817 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5818 already_present=true
5819 if test -f "$destdir/$g"; then
5820 # The file already exists.
5824 # Don't protest if the file should be there but isn't: it happens
5825 # frequently that developers don't put autogenerated files into CVS.
5832 func_fatal_error "unknown operation mode --$mode" ;;
5836 # Undo the effect of the previous 'trap' command. Some shellology:
5837 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5838 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5839 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5840 # 128 + signal number and is set before the trap-registered command is run.
5842 trap 'func_exit $?' 1 2 3 13 15
5847 # indent-tabs-mode: nil
5848 # whitespace-check-buffer-indent: nil