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_modules_add_dummy
2465 # - local_gnulib_dir from --local-dir
2466 # - modcache true or false, from --cache-modules/--no-cache-modules
2467 # - modules list of modules, including dependencies
2469 # - modules list of modules, including 'dummy' if needed
2470 func_modules_add_dummy ()
2472 # Determine whether any module provides a lib_SOURCES augmentation.
2474 sed_remove_backslash_newline=':a
2481 for module in $modules; do
2482 func_verify_nontests_module
2483 if test -n "$module"; then
2484 # Extract the value of "lib_SOURCES += ...".
2485 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2486 # Ignore .h files since they are not compiled.
2490 have_lib_SOURCES=yes
2497 # Add the dummy module, to make sure the library will be non-empty.
2498 if test -z "$have_lib_SOURCES"; then
2499 if func_acceptable "dummy"; then
2500 func_append modules " dummy"
2505 # func_modules_notice
2507 # - local_gnulib_dir from --local-dir
2508 # - modcache true or false, from --cache-modules/--no-cache-modules
2509 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2510 # - modules list of modules, including dependencies
2511 func_modules_notice ()
2513 if test $verbose -ge -1; then
2514 for module in $modules; do
2516 if test -n "$module"; then
2517 msg=`func_get_notice $module`
2518 if test -n "$msg"; then
2519 echo "Notice from module $module:"
2520 echo "$msg" | sed -e 's/^/ /'
2527 # func_modules_to_filelist
2529 # - local_gnulib_dir from --local-dir
2530 # - modcache true or false, from --cache-modules/--no-cache-modules
2531 # - modules list of modules, including dependencies
2533 # - files list of files
2534 func_modules_to_filelist ()
2537 for module in $modules; do
2539 if test -n "$module"; then
2540 fs=`func_get_filelist $module`
2541 func_append files " $fs"
2544 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2547 # func_execute_command command [args...]
2548 # Executes a command.
2549 # Uses also the variables
2550 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2551 func_execute_command ()
2553 if test $verbose -ge 0; then
2557 # Commands like automake produce output to stderr even when they succeed.
2558 # Turn this output off if the command succeeds.
2559 "$@" > "$tmp"/cmdout 2>&1
2561 if test $cmdret = 0; then
2565 cat "$tmp"/cmdout 1>&2
2572 # func_dest_tmpfilename file
2573 # determines the name of a temporary file (file is relative to destdir).
2575 # - destdir target directory
2576 # - doit : if actions shall be executed, false if only to be printed
2577 # - tmp pathname of a temporary directory
2579 # - tmpfile absolute filename of the temporary file
2580 func_dest_tmpfilename ()
2583 # Put the new contents of $file in a file in the same directory (needed
2584 # to guarantee that an 'mv' to "$destdir/$file" works).
2585 tmpfile="$destdir/$1.tmp"
2587 # Put the new contents of $file in a file in a temporary directory
2588 # (because the directory of "$file" might not exist).
2589 tmpfile="$tmp"/`basename "$1"`.tmp
2594 # copies a file from gnulib into the destination directory. The destination
2595 # is known to not exist.
2597 # - destdir target directory
2598 # - local_gnulib_dir from --local-dir
2599 # - modcache true or false, from --cache-modules/--no-cache-modules
2600 # - f the original file name
2601 # - lookedup_file name of the merged (combined) file
2602 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2603 # - g the rewritten file name
2604 # - tmpfile absolute filename of the temporary file
2605 # - doit : if actions shall be executed, false if only to be printed
2606 # - symbolic true if files should be symlinked, copied otherwise
2607 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2612 echo "Copying file $g"
2613 if { test -n "$symbolic" \
2614 || { test -n "$lsymbolic" \
2615 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2616 && test -z "$lookedup_tmp" \
2617 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2618 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2620 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2628 # copies a file from gnulib into the destination directory. The destination
2629 # is known to exist.
2631 # - destdir target directory
2632 # - local_gnulib_dir from --local-dir
2633 # - modcache true or false, from --cache-modules/--no-cache-modules
2634 # - f the original file name
2635 # - lookedup_file name of the merged (combined) file
2636 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2637 # - g the rewritten file name
2638 # - tmpfile absolute filename of the temporary file
2639 # - doit : if actions shall be executed, false if only to be printed
2640 # - symbolic true if files should be symlinked, copied otherwise
2641 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2643 # - already_present nonempty if the file should already exist, empty otherwise
2646 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2647 : # The file has not changed.
2651 if test -n "$already_present"; then
2652 echo "Updating file $g (backup in ${g}~)"
2654 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2656 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2657 if { test -n "$symbolic" \
2658 || { test -n "$lsymbolic" \
2659 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2660 && test -z "$lookedup_tmp" \
2661 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2662 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2664 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2667 if test -n "$already_present"; then
2668 echo "Update file $g (backup in ${g}~)"
2670 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2676 # func_emit_lib_Makefile_am
2677 # emits the contents of library makefile to standard output.
2679 # - local_gnulib_dir from --local-dir
2680 # - modcache true or false, from --cache-modules/--no-cache-modules
2681 # - modules list of modules, including dependencies
2682 # - libname library name
2683 # - pobase directory relative to destdir where to place *.po files
2684 # - auxdir directory relative to destdir where to place build aux files
2685 # - makefile_name from --makefile-name
2686 # - libtool true if libtool will be used, false or blank otherwise
2687 # - macro_prefix prefix of gl_LIBOBJS macros to use
2688 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2689 # - actioncmd (optional) command that will reproduce this invocation
2690 # - for_test true if creating a package for testing, false otherwise
2691 # - destfile filename relative to destdir of makefile being generated
2693 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2694 # list of edits to be done to Makefile.am variables
2696 # - uses_subdirs nonempty if object files in subdirs exist
2697 func_emit_lib_Makefile_am ()
2699 # When creating an includable Makefile.am snippet, augment variables with
2700 # += instead of assigning them.
2701 if test -n "$makefile_name"; then
2706 if test "$libtool" = true; then
2709 sed_eliminate_LDFLAGS="$sed_noop"
2713 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2716 # When creating a package for testing: Attempt to provoke failures,
2717 # especially link errors, already during "make" rather than during
2718 # "make check", because "make check" is not possible in a cross-compiling
2719 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2720 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2722 sed_transform_check_PROGRAMS="$sed_noop"
2724 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2725 echo "## Process this file with automake to produce Makefile.in."
2726 func_emit_copyright_notice
2727 if test -n "$actioncmd"; then
2728 # The maximum line length (excluding the terminating newline) of any file
2729 # that is to be preprocessed by config.status is 3070. config.status uses
2730 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2731 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2732 len=`echo "$actioncmd" | wc -c`
2733 if test -n "$len" && test "$len" -le 3000; then
2734 echo "# Reproduce by: $actioncmd"
2740 for module in $modules; do
2741 func_verify_nontests_module
2742 if test -n "$module"; then
2744 func_get_automake_snippet "$module" |
2746 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2747 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2748 -e "$sed_eliminate_LDFLAGS" \
2749 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2750 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2751 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2752 -e "$sed_transform_check_PROGRAMS"
2753 if test "$module" = 'alloca'; then
2754 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2755 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2757 } > "$tmp"/amsnippet
2758 # Skip the contents if it's entirely empty.
2759 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2760 echo "## begin gnulib module $module"
2762 cat "$tmp"/amsnippet
2763 echo "## end gnulib module $module"
2766 rm -f "$tmp"/amsnippet
2767 # Test whether there are some source files in subdirectories.
2768 for f in `func_get_filelist "$module"`; do
2778 } > "$tmp"/allsnippets
2779 if test -z "$makefile_name"; then
2780 # If there are source files in subdirectories, prevent collision of the
2781 # object files (example: hash.c and libxml/hash.c).
2783 if test -n "$uses_subdirs"; then
2784 subdir_options=' subdir-objects'
2786 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2789 if test -z "$makefile_name"; then
2791 echo "noinst_HEADERS ="
2792 echo "noinst_LIBRARIES ="
2793 echo "noinst_LTLIBRARIES ="
2794 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2795 # if you specify pkgdata_DATA to empty. This is a workaround.
2796 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2797 echo "pkgdata_DATA ="
2800 echo "BUILT_SOURCES ="
2803 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2804 if test -z "$makefile_name"; then
2805 echo "MOSTLYCLEANDIRS ="
2807 echo "DISTCLEANFILES ="
2808 echo "MAINTAINERCLEANFILES ="
2810 # Execute edits that apply to the Makefile.am being generated.
2812 while test $edit != $makefile_am_edits; do
2813 edit=`expr $edit + 1`
2814 eval dir=\"\$makefile_am_edit${edit}_dir\"
2815 eval var=\"\$makefile_am_edit${edit}_var\"
2816 eval val=\"\$makefile_am_edit${edit}_val\"
2817 if test -n "$var"; then
2818 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2819 echo "${var} += ${val}"
2820 eval "makefile_am_edit${edit}_var="
2824 if test -z "$makefile_name"; then
2827 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
2829 echo "AM_CPPFLAGS ="
2834 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2835 || { test -n "$makefile_name" \
2836 && test -f "$sourcebase/Makefile.am" \
2837 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2839 # One of the snippets or the user's Makefile.am already specifies an
2840 # installation location for the library. Don't confuse automake by saying
2841 # it should not be installed.
2844 # By default, the generated library should not be installed.
2845 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2848 echo "${libname}_${libext}_SOURCES ="
2849 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2850 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2851 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2852 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2853 echo "EXTRA_${libname}_${libext}_SOURCES ="
2854 if test "$libtool" = true; then
2855 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2858 if test -n "$pobase"; then
2859 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2862 cat "$tmp"/allsnippets \
2863 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2865 echo "mostlyclean-local: mostlyclean-generic"
2866 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2867 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2868 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2872 rm -f "$tmp"/allsnippets
2875 # func_emit_po_Makevars
2876 # emits the contents of po/ makefile parameterization to standard output.
2878 # - local_gnulib_dir from --local-dir
2879 # - modcache true or false, from --cache-modules/--no-cache-modules
2880 # - sourcebase directory relative to destdir where to place source code
2881 # - pobase directory relative to destdir where to place *.po files
2882 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2883 func_emit_po_Makevars ()
2885 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2886 func_emit_copyright_notice
2888 echo "# Usually the message domain is the same as the package name."
2889 echo "# But here it has a '-gnulib' suffix."
2890 echo "DOMAIN = ${po_domain}-gnulib"
2892 echo "# These two variables depend on the location of this directory."
2893 echo "subdir = ${pobase}"
2894 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2897 # These options get passed to xgettext.
2898 XGETTEXT_OPTIONS = \
2899 --keyword=_ --flag=_:1:pass-c-format \
2900 --keyword=N_ --flag=N_:1:pass-c-format \
2901 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2902 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2903 --flag=error:3:c-format --flag=error_at_line:5:c-format
2905 # This is the copyright holder that gets inserted into the header of the
2906 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2907 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2909 # This is the email address or URL to which the translators shall report
2910 # bugs in the untranslated strings:
2911 # - Strings which are not entire sentences, see the maintainer guidelines
2912 # in the GNU gettext documentation, section 'Preparing Strings'.
2913 # - Strings which use unclear terms or require additional context to be
2915 # - Strings which make invalid assumptions about notation of date, time or
2917 # - Pluralisation problems.
2918 # - Incorrect English spelling.
2919 # - Incorrect formatting.
2920 # It can be your email address, or a mailing list address where translators
2921 # can write to without being subscribed, or the URL of a web page through
2922 # which the translators can contact you.
2923 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2925 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2926 # message catalogs shall be used. It is usually empty.
2927 EXTRA_LOCALE_CATEGORIES =
2929 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2930 # context. Possible values are "yes" and "no". Set this to yes if the
2931 # package uses functions taking also a message context, like pgettext(), or
2932 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2937 # func_emit_po_POTFILES_in
2938 # emits the file list to be passed to xgettext to standard output.
2940 # - local_gnulib_dir from --local-dir
2941 # - modcache true or false, from --cache-modules/--no-cache-modules
2942 # - sourcebase directory relative to destdir where to place source code
2943 # - files list of new files
2944 func_emit_po_POTFILES_in ()
2946 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2947 func_emit_copyright_notice
2949 echo "# List of files which contain translatable strings."
2950 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2953 # func_emit_tests_Makefile_am witness_macro
2954 # emits the contents of tests makefile to standard output.
2956 # - local_gnulib_dir from --local-dir
2957 # - modcache true or false, from --cache-modules/--no-cache-modules
2958 # - modules list of modules, including dependencies
2959 # - libname library name
2960 # - auxdir directory relative to destdir where to place build aux files
2961 # - makefile_name from --makefile-name
2962 # - libtool true if libtool will be used, false or blank otherwise
2963 # - sourcebase relative directory containing lib source code
2964 # - m4base relative directory containing autoconf macros
2965 # - testsbase relative directory containing unit test code
2966 # - macro_prefix prefix of gl_LIBOBJS macros to use
2967 # - for_test true if creating a package for testing, false otherwise
2968 # - use_libtests true if a libtests.a should be built, false otherwise
2969 # - destfile filename relative to destdir of makefile being generated
2971 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2972 # list of edits to be done to Makefile.am variables
2974 # - uses_subdirs nonempty if object files in subdirs exist
2975 func_emit_tests_Makefile_am ()
2978 if test "$libtool" = true; then
2980 sed_eliminate_LDFLAGS="$sed_noop"
2983 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2986 # When creating a package for testing: Attempt to provoke failures,
2987 # especially link errors, already during "make" rather than during
2988 # "make check", because "make check" is not possible in a cross-compiling
2989 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2990 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2992 sed_transform_check_PROGRAMS="$sed_noop"
2994 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2995 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2996 echo "## Process this file with automake to produce Makefile.in."
2997 func_emit_copyright_notice
3001 for module in $modules; do
3003 func_verify_tests_module
3007 if test -n "$module"; then
3009 func_get_automake_snippet "$module" |
3011 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3012 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3013 -e "$sed_eliminate_LDFLAGS" \
3014 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3015 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3016 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3017 -e "$sed_transform_check_PROGRAMS"
3018 if $use_libtests && test "$module" = 'alloca'; then
3019 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3020 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3022 } > "$tmp"/amsnippet
3023 # Skip the contents if it's entirely empty.
3024 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3025 # Mention long-running tests at the end.
3027 for word in `func_get_status "$module"`; do
3028 if test "$word" = 'longrunning-test'; then
3033 { echo "## begin gnulib module $module"
3035 cat "$tmp"/amsnippet
3036 echo "## end gnulib module $module"
3040 rm -f "$tmp"/amsnippet
3041 # Test whether there are some source files in subdirectories.
3042 for f in `func_get_filelist "$module"`; do
3044 lib/*/*.c | tests/*/*.c)
3052 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3053 # Generate dependencies here, since it eases the debugging of test failures.
3054 # If there are source files in subdirectories, prevent collision of the
3055 # object files (example: hash.c and libxml/hash.c).
3057 if test -n "$uses_subdirs"; then
3058 subdir_options=' subdir-objects'
3060 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3063 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3066 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3067 # variable is needed to avoid an error from automake:
3068 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3071 echo "XFAIL_TESTS ="
3072 echo "TESTS_ENVIRONMENT ="
3073 echo "noinst_PROGRAMS ="
3074 if ! $for_test; then
3075 echo "check_PROGRAMS ="
3077 echo "noinst_HEADERS ="
3078 echo "noinst_LIBRARIES ="
3079 if $use_libtests; then
3081 echo "noinst_LIBRARIES += libtests.a"
3083 echo "check_LIBRARIES = libtests.a"
3086 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3087 # if you specify pkgdata_DATA to empty. This is a workaround.
3088 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3089 echo "pkgdata_DATA ="
3092 echo "BUILT_SOURCES ="
3094 echo "MOSTLYCLEANFILES = core *.stackdump"
3095 echo "MOSTLYCLEANDIRS ="
3097 echo "DISTCLEANFILES ="
3098 echo "MAINTAINERCLEANFILES ="
3099 # Execute edits that apply to the Makefile.am being generated.
3101 while test $edit != $makefile_am_edits; do
3102 edit=`expr $edit + 1`
3103 eval dir=\"\$makefile_am_edit${edit}_dir\"
3104 eval var=\"\$makefile_am_edit${edit}_var\"
3105 eval val=\"\$makefile_am_edit${edit}_val\"
3106 if test -n "$var"; then
3107 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3108 echo "${var} += ${val}"
3109 eval "makefile_am_edit${edit}_var="
3114 echo "AM_CPPFLAGS = \\"
3116 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3118 if test -n "${witness_macro}"; then
3119 echo " -D@${witness_macro}@=1 \\"
3121 echo " -I. -I\$(srcdir) \\"
3122 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3123 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3125 local_ldadd_before=''
3126 local_ldadd_after=''
3127 if $use_libtests; then
3128 # All test programs need to be linked with libtests.a.
3129 # It needs to be passed to the linker before ${libname}.${libext}, since
3130 # the tests-related modules depend on the main modules.
3131 # It also needs to be passed to the linker after ${libname}.${libext}
3132 # because the latter might contain incomplete modules (such as the 'error'
3133 # module whose dependency to 'progname' is voluntarily omitted).
3134 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3136 local_ldadd_before=' libtests.a'
3137 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3139 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3141 if $use_libtests; then
3142 echo "libtests_a_SOURCES ="
3143 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3144 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3145 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3146 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3147 echo "EXTRA_libtests_a_SOURCES ="
3148 # The circular dependency in LDADD requires this.
3149 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3152 # Many test scripts use ${EXEEXT} or ${srcdir}.
3153 # EXEEXT is defined by AC_PROG_CC through autoconf.
3154 # srcdir is defined by autoconf and automake.
3155 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3157 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3158 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3159 echo "# Clean up after Solaris cc."
3161 echo " rm -rf SunWS_cache"
3163 echo "mostlyclean-local: mostlyclean-generic"
3164 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3165 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3166 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3170 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3173 # func_emit_initmacro_start macro_prefix
3174 # emits the first few statements of the gl_INIT macro to standard output.
3175 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3176 func_emit_initmacro_start ()
3178 macro_prefix_arg="$1"
3179 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3180 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3181 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3182 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3184 # Furthermore it avoids an automake error like this when a Makefile.am
3185 # that uses pieces of gnulib also uses $(LIBOBJ):
3186 # automatically discovered file `error.c' should not be explicitly mentioned
3187 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3188 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3189 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3190 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3191 # automatically discovered file `error.c' should not be explicitly mentioned
3192 # We let automake know about the files to be distributed through the
3193 # EXTRA_lib_SOURCES variable.
3194 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3195 # Create data variables for checking the presence of files that are mentioned
3196 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3197 # because we want the check to happen when the configure file is created,
3198 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3199 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3200 # in which to expect them.
3201 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3202 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3206 # func_emit_initmacro_end macro_prefix
3207 # emits the last few statements of the gl_INIT macro to standard output.
3208 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3209 func_emit_initmacro_end ()
3211 macro_prefix_arg="$1"
3212 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3213 # The check is performed only when autoconf is run from the directory where
3214 # the configure.ac resides; if it is run from a different directory, the
3216 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3217 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3218 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3219 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3220 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3224 echo " m4_if(m4_sysval, [0], [],"
3225 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3227 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3228 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3229 echo " m4_popdef([AC_LIBSOURCES])"
3230 echo " m4_popdef([AC_REPLACE_FUNCS])"
3231 echo " m4_popdef([AC_LIBOBJ])"
3232 echo " AC_CONFIG_COMMANDS_PRE(["
3233 echo " ${macro_prefix_arg}_libobjs="
3234 echo " ${macro_prefix_arg}_ltlibobjs="
3235 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3236 echo " # Remove the extension."
3237 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3238 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3239 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3240 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3243 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3244 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3248 # func_emit_initmacro_done macro_prefix sourcebase
3249 # emits a few statements after the gl_INIT macro to standard output.
3250 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3251 # - sourcebase directory relative to destdir where to place source code
3252 func_emit_initmacro_done ()
3254 macro_prefix_arg="$1"
3257 echo "# Like AC_LIBOBJ, except that the module name goes"
3258 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3259 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3260 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3261 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3264 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3265 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3266 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3267 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3268 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3271 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3272 echo "# expected is derived from the gnulib-tool parameterization,"
3273 echo "# and alloca is special cased (for the alloca-opt module)."
3274 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3275 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3276 echo " m4_foreach([_gl_NAME], [\$1], ["
3277 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3278 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3279 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3285 # func_import modules
3286 # Uses also the variables
3287 # - destdir target directory
3288 # - local_gnulib_dir from --local-dir
3289 # - modcache true or false, from --cache-modules/--no-cache-modules
3290 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3291 # - libname library name
3292 # - sourcebase directory relative to destdir where to place source code
3293 # - m4base directory relative to destdir where to place *.m4 macros
3294 # - pobase directory relative to destdir where to place *.po files
3295 # - docbase directory relative to destdir where to place doc files
3296 # - testsbase directory relative to destdir where to place unit test code
3297 # - auxdir directory relative to destdir where to place build aux files
3298 # - inctests true if --with-tests was given, blank otherwise
3299 # - incobsolete true if --with-obsolete was given, blank otherwise
3300 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3301 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3303 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3305 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3307 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3308 # - avoidlist list of modules to avoid, from --avoid
3309 # - lgpl yes or a number if library's license shall be LGPL,
3311 # - makefile_name from --makefile-name
3312 # - libtool true if --libtool was given, false if --no-libtool was
3313 # given, blank otherwise
3314 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3315 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3316 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3317 # - vc_files true if --vc-files was given, false if --no-vc-files was
3318 # given, blank otherwise
3319 # - autoconf_minversion minimum supported autoconf version
3320 # - doit : if actions shall be executed, false if only to be printed
3321 # - symbolic true if files should be symlinked, copied otherwise
3322 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3324 # - do_copyrights true if copyright notices in files should be replaced,
3328 # Get the cached settings.
3329 cached_local_gnulib_dir=
3330 cached_specified_modules=
3332 cached_inc_cxx_tests=
3333 cached_inc_longrunning_tests=
3334 cached_inc_privileged_tests=
3335 cached_inc_unportable_tests=
3336 cached_inc_all_tests=
3346 cached_makefile_name=
3348 cached_macro_prefix=
3352 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3353 cached_libtool=false
3359 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3369 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3371 /gl_WITH_OBSOLETE/ {
3372 s,^.*$,cached_incobsolete=true,p
3374 /gl_WITH_CXX_TESTS/ {
3375 s,^.*$,cached_inc_cxx_tests=true,p
3377 /gl_WITH_LONGRUNNING_TESTS/ {
3378 s,^.*$,cached_inc_longrunning_tests=true,p
3380 /gl_WITH_PRIVILEGED_TESTS/ {
3381 s,^.*$,cached_inc_privileged_tests=true,p
3383 /gl_WITH_UNPORTABLE_TESTS/ {
3384 s,^.*$,cached_inc_unportable_tests=true,p
3386 /gl_WITH_ALL_TESTS/ {
3387 s,^.*$,cached_inc_all_tests=true,p
3390 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3393 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3396 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3399 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3402 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3405 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3408 s,^.*$,cached_inctests=true,p
3411 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3414 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3417 s,^.*$,cached_lgpl=yes,p
3419 /gl_MAKEFILE_NAME(/ {
3420 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3423 s,^.*$,cached_libtool=true,p
3425 /gl_MACRO_PREFIX(/ {
3426 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3429 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3432 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3434 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3435 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3440 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3441 s,^.*$,cached_files=",p
3454 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3458 # Merge the cached settings with the specified ones.
3459 # The m4base must be the same as expected from the pathname.
3460 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3461 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3463 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3464 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3465 if test -z "$local_gnulib_dir"; then
3466 if test -n "$cached_local_gnulib_dir"; then
3469 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3471 case "$cached_local_gnulib_dir" in
3473 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3475 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3476 local_gnulib_dir="$relconcat" ;;
3481 # Append the cached and the specified module names. So that
3482 # "gnulib-tool --import foo" means to add the module foo.
3483 specified_modules="$cached_specified_modules $1"
3484 # Included obsolete modules among the dependencies if specified either way.
3485 if test -z "$incobsolete"; then
3486 incobsolete="$cached_incobsolete"
3488 # Included special kinds of tests modules among the dependencies if specified
3490 if test -z "$inc_cxx_tests"; then
3491 inc_cxx_tests="$cached_inc_cxx_tests"
3493 if test -z "$inc_longrunning_tests"; then
3494 inc_longrunning_tests="$cached_inc_longrunning_tests"
3496 if test -z "$inc_privileged_tests"; then
3497 inc_privileged_tests="$cached_inc_privileged_tests"
3499 if test -z "$inc_unportable_tests"; then
3500 inc_unportable_tests="$cached_inc_unportable_tests"
3502 if test -z "$inc_all_tests"; then
3503 inc_all_tests="$cached_inc_all_tests"
3505 # --without-*-tests options are not supported here.
3507 excl_longrunning_tests=
3508 excl_privileged_tests=
3509 excl_unportable_tests=
3510 # Append the cached and the specified avoidlist. This is probably better
3511 # than dropping the cached one when --avoid is specified at least once.
3512 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3513 avoidlist=`echo $avoidlist`
3515 # The sourcebase defaults to the cached one.
3516 if test -z "$sourcebase"; then
3517 sourcebase="$cached_sourcebase"
3518 if test -z "$sourcebase"; then
3519 func_fatal_error "missing --source-base option"
3522 # The pobase defaults to the cached one.
3523 if test -z "$pobase"; then
3524 pobase="$cached_pobase"
3526 # The docbase defaults to the cached one.
3527 if test -z "$docbase"; then
3528 docbase="$cached_docbase"
3529 if test -z "$docbase"; then
3530 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."
3533 # The testsbase defaults to the cached one.
3534 if test -z "$testsbase"; then
3535 testsbase="$cached_testsbase"
3536 if test -z "$testsbase"; then
3537 func_fatal_error "missing --tests-base option"
3540 # Require the tests if specified either way.
3541 if test -z "$inctests"; then
3542 inctests="$cached_inctests"
3544 # The libname defaults to the cached one.
3545 if test -z "$supplied_libname"; then
3546 libname="$cached_libname"
3547 if test -z "$libname"; then
3548 func_fatal_error "missing --lib option"
3551 # Require LGPL if specified either way.
3552 if test -z "$lgpl"; then
3555 # The makefile_name defaults to the cached one.
3556 if test -z "$makefile_name"; then
3557 makefile_name="$cached_makefile_name"
3559 # Use libtool if specified either way, or if guessed.
3560 if test -z "$libtool"; then
3561 if test -n "$cached_m4base"; then
3562 libtool="$cached_libtool"
3564 libtool="$guessed_libtool"
3567 # The macro_prefix defaults to the cached one.
3568 if test -z "$macro_prefix"; then
3569 macro_prefix="$cached_macro_prefix"
3570 if test -z "$macro_prefix"; then
3571 func_fatal_error "missing --macro-prefix option"
3574 # The po_domain defaults to the cached one.
3575 if test -z "$po_domain"; then
3576 po_domain="$cached_po_domain"
3578 # The vc_files defaults to the cached one.
3579 if test -z "$vc_files"; then
3580 vc_files="$cached_vc_files"
3583 # Canonicalize the list of specified modules.
3584 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3586 # Include all kinds of tests modules if --with-all-tests was specified.
3587 inc_all_direct_tests="$inc_all_tests"
3588 inc_all_indirect_tests="$inc_all_tests"
3590 # Determine final module list.
3591 modules="$specified_modules"
3592 func_modules_transitive_closure
3593 if test $verbose -ge 0; then
3594 echo "Module list with included dependencies:"
3595 echo "$modules" | sed -e 's/^/ /'
3597 final_modules="$modules"
3599 # Determine main module list and tests-related module list separately.
3600 # The main module list is the transitive closure of the specified modules,
3601 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3602 # is specified, it will consist only of LGPLed source.
3603 # The tests-related module list is the transitive closure of the specified
3604 # modules, including tests modules, minus the main module list excluding
3605 # modules of applicability 'all'. Its lib/* sources (brought in through
3606 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3607 # source, even if --lgpl is specified.
3608 # Determine main module list.
3609 saved_inctests="$inctests"
3611 modules="$specified_modules"
3612 func_modules_transitive_closure
3613 main_modules="$modules"
3614 inctests="$saved_inctests"
3615 if test $verbose -ge 1; then
3616 echo "Main module list:"
3617 echo "$main_modules" | sed -e 's/^/ /'
3619 # Determine tests-related module list.
3620 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3621 testsrelated_modules=`for module in $main_modules; do
3622 if test \`func_get_applicability $module\` = main; then
3626 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3627 if test $verbose -ge 1; then
3628 echo "Tests-related module list:"
3629 echo "$testsrelated_modules" | sed -e 's/^/ /'
3632 # Add the dummy module to the main module list if needed.
3633 modules="$main_modules"
3634 func_modules_add_dummy
3635 main_modules="$modules"
3637 # Determine whether a $testsbase/libtests.a is needed.
3639 for module in $testsrelated_modules; do
3640 func_verify_nontests_module
3641 if test -n "$module"; then
3642 all_files=`func_get_filelist $module`
3643 # Test whether some file in $all_files lies in lib/.
3644 for f in $all_files; do
3655 # Add the dummy module to the tests-related module list if needed.
3656 if $use_libtests; then
3657 modules="$testsrelated_modules"
3658 func_modules_add_dummy
3659 testsrelated_modules="$modules"
3662 # If --lgpl, verify that the licenses of modules are compatible.
3663 if test -n "$lgpl"; then
3664 license_incompatibilities=
3665 for module in $main_modules; do
3666 license=`func_get_license $module`
3668 'GPLed build tool') ;;
3669 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3674 LGPL | LGPLv2+ | LGPLv3+) ;;
3675 *) func_append license_incompatibilities "$module $license$nl" ;;
3681 *) func_append license_incompatibilities "$module $license$nl" ;;
3684 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3689 if test -n "$license_incompatibilities"; then
3690 # Format the license incompatibilities as a table.
3691 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3692 s,^\(.................................................[^ ]*\) *, \1 ,'
3693 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3694 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3698 # Show banner notice of every module.
3699 modules="$main_modules"
3702 # Determine script to apply to imported library files.
3703 sed_transform_lib_file=
3704 for module in $main_modules; do
3705 if test $module = config-h; then
3706 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3707 sed_transform_lib_file=$sed_transform_lib_file'
3708 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3713 sed_transform_main_lib_file="$sed_transform_lib_file"
3714 if test -n "$do_copyrights"; then
3715 if test -n "$lgpl"; then
3719 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3720 s/GNU General/GNU Lesser General/g
3724 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3725 s/GNU General/GNU Lesser General/g
3726 s/version [23]\([ ,]\)/version 2.1\1/g
3729 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3733 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3734 s/GNU Lesser General/GNU General/g
3735 s/GNU Library General/GNU General/g
3736 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3741 # Determine script to apply to auxiliary files that go into $auxdir/.
3742 sed_transform_build_aux_file=
3743 if test -n "$do_copyrights"; then
3745 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3746 s/GNU Lesser General/GNU General/g
3747 s/GNU Library General/GNU General/g
3748 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3752 # Determine script to apply to library files that go into $testsbase/.
3753 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3754 if test -n "$do_copyrights"; then
3756 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3757 s/GNU Lesser General/GNU General/g
3758 s/GNU Library General/GNU General/g
3759 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3763 # Determine the final file lists.
3764 # They must be computed separately, because files in lib/* go into
3765 # $sourcebase/ if they are in the main file list but into $testsbase/
3766 # if they are in the tests-related file list. Furthermore lib/dummy.c
3768 # Determine final main file list.
3769 modules="$main_modules"
3770 func_modules_to_filelist
3772 # Determine final tests-related file list.
3773 modules="$testsrelated_modules"
3774 func_modules_to_filelist
3775 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3776 # Merge both file lists.
3777 sed_remove_empty_lines='/^$/d'
3778 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3779 if test $verbose -ge 0; then
3781 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3782 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3786 || func_fatal_error "refusing to do nothing"
3788 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3789 new_files="$files m4/gnulib-tool.m4"
3790 old_files="$cached_files"
3791 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3792 func_append old_files " m4/gnulib-tool.m4"
3795 rewritten='%REWRITTEN%'
3796 sed_rewrite_old_files="\
3797 s,^build-aux/,$rewritten$auxdir/,
3798 s,^doc/,$rewritten$cached_docbase/,
3799 s,^lib/,$rewritten$cached_sourcebase/,
3800 s,^m4/,$rewritten$cached_m4base/,
3801 s,^tests/,$rewritten$cached_testsbase/,
3802 s,^tests=lib/,$rewritten$cached_testsbase/,
3805 sed_rewrite_new_files="\
3806 s,^build-aux/,$rewritten$auxdir/,
3807 s,^doc/,$rewritten$docbase/,
3808 s,^lib/,$rewritten$sourcebase/,
3809 s,^m4/,$rewritten$m4base/,
3810 s,^tests/,$rewritten$testsbase/,
3811 s,^tests=lib/,$rewritten$testsbase/,
3815 # Create directories.
3816 { echo "$sourcebase"
3818 if test -n "$pobase"; then
3821 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3822 if test -n "$docfiles"; then
3825 if test -n "$inctests"; then
3829 for f in $files; do echo $f; done \
3830 | sed -e "$sed_rewrite_new_files" \
3831 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3834 { # Rearrange file descriptors. Needed because "while ... done < ..."
3835 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3836 exec 5<&0 < "$tmp"/dirs
3838 if test ! -d "$destdir/$d"; then
3840 echo "Creating directory $destdir/$d"
3841 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3843 echo "Create directory $destdir/$d"
3850 # Copy files or make symbolic links. Remove obsolete files.
3854 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3855 # representing the files according to the last gnulib-tool invocation.
3856 for f in $old_files; do echo $f; done \
3857 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3860 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3861 # representing the files after this gnulib-tool invocation.
3862 for f in $new_files; do echo $f; done \
3863 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3866 # First the files that are in old-files, but not in new-files:
3867 sed_take_first_column='s,'"$delimiter"'.*,,'
3868 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3869 # Remove the file. Do nothing if the user already removed it.
3870 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3872 echo "Removing file $g (backup in ${g}~)"
3873 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3875 echo "Remove file $g (backup in ${g}~)"
3877 func_append removed_files "$g$nl"
3880 # func_add_or_update handles a file that ought to be present afterwards.
3882 # - f the original file name
3883 # - g the rewritten file name
3884 # - already_present nonempty if the file should already exist, empty
3886 func_add_or_update ()
3890 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3892 func_dest_tmpfilename "$g"
3893 func_lookup_file "$f"
3894 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3895 if test -n "$sed_transform_main_lib_file"; then
3898 sed -e "$sed_transform_main_lib_file" \
3899 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3903 if test -n "$sed_transform_build_aux_file"; then
3906 sed -e "$sed_transform_build_aux_file" \
3907 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3911 if test -n "$sed_transform_testsrelated_lib_file"; then
3914 sed -e "$sed_transform_testsrelated_lib_file" \
3915 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3919 if test -f "$destdir/$g"; then
3920 # The file already exists.
3924 # Don't protest if the file should be there but isn't: it happens
3925 # frequently that developers don't put autogenerated files into CVS.
3927 func_append added_files "$g$nl"
3931 # Then the files that are in new-files, but not in old-files:
3932 sed_take_last_column='s,^.*'"$delimiter"',,'
3934 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3935 | sed -e "$sed_take_last_column" \
3936 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3937 { # Rearrange file descriptors. Needed because "while ... done < ..."
3938 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3939 exec 5<&0 < "$tmp"/added-files
3945 # Then the files that are in new-files and in old-files:
3946 already_present=true
3947 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3948 | sed -e "$sed_take_last_column" \
3949 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3950 { # Rearrange file descriptors. Needed because "while ... done < ..."
3951 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3952 exec 5<&0 < "$tmp"/kept-files
3959 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3960 actioncmd="gnulib-tool --import"
3961 func_append actioncmd " --dir=$destdir"
3962 if test -n "$local_gnulib_dir"; then
3963 func_append actioncmd " --local-dir=$local_gnulib_dir"
3965 func_append actioncmd " --lib=$libname"
3966 func_append actioncmd " --source-base=$sourcebase"
3967 func_append actioncmd " --m4-base=$m4base"
3968 if test -n "$pobase"; then
3969 func_append actioncmd " --po-base=$pobase"
3971 func_append actioncmd " --doc-base=$docbase"
3972 func_append actioncmd " --tests-base=$testsbase"
3973 func_append actioncmd " --aux-dir=$auxdir"
3974 if test -n "$inctests"; then
3975 func_append actioncmd " --with-tests"
3977 if test -n "$incobsolete"; then
3978 func_append actioncmd " --with-obsolete"
3980 if test -n "$inc_cxx_tests"; then
3981 func_append actioncmd " --with-c++-tests"
3983 if test -n "$inc_longrunning_tests"; then
3984 func_append actioncmd " --with-longrunning-tests"
3986 if test -n "$inc_privileged_tests"; then
3987 func_append actioncmd " --with-privileged-tests"
3989 if test -n "$inc_unportable_tests"; then
3990 func_append actioncmd " --with-unportable-tests"
3992 if test -n "$inc_all_tests"; then
3993 func_append actioncmd " --with-all-tests"
3995 for module in $avoidlist; do
3996 func_append actioncmd " --avoid=$module"
3998 if test -n "$lgpl"; then
3999 if test "$lgpl" = yes; then
4000 func_append actioncmd " --lgpl"
4002 func_append actioncmd " --lgpl=$lgpl"
4005 if test -n "$makefile_name"; then
4006 func_append actioncmd " --makefile-name=$makefile_name"
4008 if test "$libtool" = true; then
4009 func_append actioncmd " --libtool"
4011 func_append actioncmd " --no-libtool"
4013 func_append actioncmd " --macro-prefix=$macro_prefix"
4014 if test -n "$po_domain"; then
4015 func_append actioncmd " --po-domain=$po_domain"
4017 if test -n "$vc_files"; then
4018 if test "$vc_files" = true; then
4019 func_append actioncmd " --vc-files"
4021 func_append actioncmd " --no-vc-files"
4024 func_append actioncmd " `echo $specified_modules`"
4026 # Default the makefile name to Makefile.am.
4027 if test -n "$makefile_name"; then
4028 makefile_am=$makefile_name
4030 makefile_am=Makefile.am
4033 # Create normal Makefile.ams.
4036 # Setup list of Makefile.am edits that are to be performed afterwards.
4037 # Some of these edits apply to files that we will generate; others are
4038 # under the responsibility of the developer.
4040 # func_note_Makefile_am_edit dir var value
4041 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4043 func_note_Makefile_am_edit ()
4045 makefile_am_edits=`expr $makefile_am_edits + 1`
4046 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4047 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4048 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4050 if test "$makefile_am" = Makefile.am; then
4051 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4052 sourcebase_base=`basename "$sourcebase"`
4053 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4055 if test -n "$pobase"; then
4056 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4057 pobase_base=`basename "$pobase"`
4058 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4060 if test -n "$inctests"; then
4061 if test "$makefile_am" = Makefile.am; then
4062 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4063 testsbase_base=`basename "$testsbase"`
4064 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4067 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4069 # Find the first parent directory of $m4base that contains or will contain
4071 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4073 sed_butlast='s,[^/][^/]*//*$,,'
4074 dir1="${m4base}/"; dir2=""
4075 while test -n "$dir1" \
4076 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4077 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4078 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4079 || { test -n "$inctests" \
4080 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4081 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4082 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4083 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4085 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4088 # Create library makefile.
4089 func_dest_tmpfilename $sourcebase/$makefile_am
4090 destfile="$sourcebase/$makefile_am"
4091 modules="$main_modules"
4092 func_emit_lib_Makefile_am > "$tmpfile"
4093 if test -f "$destdir"/$sourcebase/$makefile_am; then
4094 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4098 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4099 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4100 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4102 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4108 echo "Creating $sourcebase/$makefile_am"
4109 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4111 echo "Create $sourcebase/$makefile_am"
4114 func_append added_files "$sourcebase/$makefile_am$nl"
4117 # Create po/ directory.
4118 if test -n "$pobase"; then
4119 # Create po makefile and auxiliary files.
4120 for file in Makefile.in.in remove-potcdate.sin; do
4121 func_dest_tmpfilename $pobase/$file
4122 func_lookup_file build-aux/po/$file
4123 cat "$lookedup_file" > "$tmpfile"
4124 if test -f "$destdir"/$pobase/$file; then
4125 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4129 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4130 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4131 mv -f "$tmpfile" "$destdir"/$pobase/$file
4133 echo "Update $pobase/$file (backup in $pobase/$file~)"
4139 echo "Creating $pobase/$file"
4140 mv -f "$tmpfile" "$destdir"/$pobase/$file
4142 echo "Create $pobase/$file"
4145 func_append added_files "$pobase/$file$nl"
4148 # Create po makefile parameterization, part 1.
4149 func_dest_tmpfilename $pobase/Makevars
4150 func_emit_po_Makevars > "$tmpfile"
4151 if test -f "$destdir"/$pobase/Makevars; then
4152 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4156 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4157 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4158 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4160 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4166 echo "Creating $pobase/Makevars"
4167 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4169 echo "Create $pobase/Makevars"
4172 func_append added_files "$pobase/Makevars$nl"
4174 # Create po makefile parameterization, part 2.
4175 func_dest_tmpfilename $pobase/POTFILES.in
4176 func_emit_po_POTFILES_in > "$tmpfile"
4177 if test -f "$destdir"/$pobase/POTFILES.in; then
4178 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4182 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4183 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4184 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4186 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4192 echo "Creating $pobase/POTFILES.in"
4193 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4195 echo "Create $pobase/POTFILES.in"
4198 func_append added_files "$pobase/POTFILES.in$nl"
4201 TP_URL="http://translationproject.org/latest/"
4202 TP_RSYNC_URI="translationproject.org::tp/latest/"
4204 echo "Fetching gnulib PO files from $TP_URL"
4205 (cd "$destdir"/$pobase \
4206 && { # Prefer rsync over wget if it is available, since it consumes
4207 # less network bandwidth, due to compression.
4208 if type rsync 2>/dev/null | grep / > /dev/null; then
4209 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4211 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4216 echo "Fetch gnulib PO files from $TP_URL"
4218 # Create po/LINGUAS.
4220 func_dest_tmpfilename $pobase/LINGUAS
4221 (cd "$destdir"/$pobase \
4222 && { echo '# Set of available languages.'
4223 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4226 if test -f "$destdir"/$pobase/LINGUAS; then
4227 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4230 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4231 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4232 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4235 echo "Creating $pobase/LINGUAS"
4236 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4237 func_append added_files "$pobase/LINGUAS$nl"
4240 if test -f "$destdir"/$pobase/LINGUAS; then
4241 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4243 echo "Create $pobase/LINGUAS"
4248 # Create m4/gnulib-cache.m4.
4249 func_dest_tmpfilename $m4base/gnulib-cache.m4
4251 func_emit_copyright_notice
4253 echo "# This file represents the specification of how gnulib-tool is used."
4254 echo "# It acts as a cache: It is written and read by gnulib-tool."
4255 echo "# In projects using CVS, this file is meant to be stored in CVS,"
4256 echo "# like the configure.ac and various Makefile.am files."
4259 echo "# Specification in the form of a command-line invocation:"
4262 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4263 # Store the local_gnulib_dir relative to destdir.
4264 case "$local_gnulib_dir" in
4266 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4269 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4271 # destdir, local_gnulib_dir are both relative.
4272 func_relativize "$destdir" "$local_gnulib_dir"
4273 relative_local_gnulib_dir="$reldir" ;;
4276 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4278 echo "$specified_modules" | sed -e 's/^/ /g'
4280 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4281 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4282 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4283 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4284 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4285 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4286 echo "gl_AVOID([$avoidlist])"
4287 echo "gl_SOURCE_BASE([$sourcebase])"
4288 echo "gl_M4_BASE([$m4base])"
4289 echo "gl_PO_BASE([$pobase])"
4290 echo "gl_DOC_BASE([$docbase])"
4291 echo "gl_TESTS_BASE([$testsbase])"
4292 test -z "$inctests" || echo "gl_WITH_TESTS"
4293 echo "gl_LIB([$libname])"
4294 if test -n "$lgpl"; then
4295 if test "$lgpl" = yes; then
4298 echo "gl_LGPL([$lgpl])"
4301 echo "gl_MAKEFILE_NAME([$makefile_name])"
4302 if test "$libtool" = true; then
4305 echo "gl_MACRO_PREFIX([$macro_prefix])"
4306 echo "gl_PO_DOMAIN([$po_domain])"
4307 if test -n "$vc_files"; then
4308 echo "gl_VC_FILES([$vc_files])"
4311 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4312 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4316 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4317 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4318 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4320 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4324 echo "# gnulib-cache.m4 ends here"
4331 echo "Creating $m4base/gnulib-cache.m4"
4332 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4334 echo "Create $m4base/gnulib-cache.m4"
4340 # Create m4/gnulib-comp.m4.
4341 func_dest_tmpfilename $m4base/gnulib-comp.m4
4343 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4344 func_emit_copyright_notice
4346 echo "# This file represents the compiled summary of the specification in"
4347 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4348 echo "# to be invoked from configure.ac."
4349 echo "# In projects using CVS, this file can be treated like other built files."
4352 echo "# This macro should be invoked from $configure_ac, in the section"
4353 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4354 echo "# any checks for libraries, header files, types and library functions."
4355 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4357 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4358 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4359 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4360 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4361 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4362 if test -n "$uses_subdirs"; then
4363 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4365 for module in $final_modules; do
4367 if test -n "$module"; then
4368 echo "# Code from module $module:"
4369 func_get_autoconf_early_snippet "$module"
4372 | sed -e '/^$/d;' -e 's/^/ /'
4375 echo "# This macro should be invoked from $configure_ac, in the section"
4376 echo "# \"Check for header files, types and library functions\"."
4377 echo "AC_DEFUN([${macro_prefix}_INIT],"
4379 if test "$libtool" = true; then
4380 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4381 echo " gl_cond_libtool=true"
4383 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4384 echo " gl_cond_libtool=false"
4386 echo " gl_ltlibdeps="
4388 if test "$auxdir" != "build-aux"; then
4389 sed_replace_build_aux='
4391 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4392 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4396 sed_replace_build_aux="$sed_noop"
4398 echo " gl_m4_base='$m4base'"
4399 func_emit_initmacro_start $macro_prefix
4400 echo " gl_source_base='$sourcebase'"
4401 for module in $main_modules; do
4403 if test -n "$module"; then
4404 echo " # Code from module $module:"
4405 func_get_autoconf_snippet "$module" \
4406 | sed -e '/^$/d;' -e 's/^/ /' \
4407 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4408 -e "$sed_replace_build_aux"
4409 if test "$module" = 'alloca' && test "$libtool" = true; then
4410 echo 'changequote(,)dnl'
4411 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4412 echo 'changequote([, ])dnl'
4413 echo 'AC_SUBST([LTALLOCA])'
4417 echo " # End of code from modules"
4418 func_emit_initmacro_end $macro_prefix
4419 echo " gltests_libdeps="
4420 echo " gltests_ltlibdeps="
4421 func_emit_initmacro_start ${macro_prefix}tests
4422 echo " gl_source_base='$testsbase'"
4423 # Define a tests witness macro that depends on the package.
4424 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4425 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4426 echo "changequote(,)dnl"
4427 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"
4428 echo "changequote([, ])dnl"
4429 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4430 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4431 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4432 for module in $testsrelated_modules; do
4434 if test -n "$module"; then
4435 func_get_autoconf_snippet "$module" \
4436 | sed -e '/^$/d;' -e 's/^/ /' \
4437 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4438 -e "$sed_replace_build_aux" \
4439 -e 's/\$gl_cond_libtool/false/g' \
4440 -e 's/gl_libdeps/gltests_libdeps/g' \
4441 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4444 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4445 func_emit_initmacro_end ${macro_prefix}tests
4446 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4447 # created using libtool, because libtool already handles the dependencies.
4448 if test "$libtool" != true; then
4449 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4450 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4451 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4452 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4453 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4455 if $use_libtests; then
4456 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4457 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4460 func_emit_initmacro_done $macro_prefix $sourcebase
4461 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4463 echo "# This macro records the list of files which have been installed by"
4464 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4465 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4466 echo "$files" | sed -e 's,^, ,'
4469 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4470 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4474 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4475 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4476 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4478 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4482 echo "# gnulib-comp.m4 ends here"
4489 echo "Creating $m4base/gnulib-comp.m4"
4490 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4492 echo "Create $m4base/gnulib-comp.m4"
4498 if test -n "$inctests"; then
4499 # Create tests makefile.
4500 func_dest_tmpfilename $testsbase/$makefile_am
4501 destfile="$testsbase/$makefile_am"
4502 modules="$testsrelated_modules"
4503 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4504 if test -f "$destdir"/$testsbase/$makefile_am; then
4505 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4509 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4510 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4511 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4513 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4519 echo "Creating $testsbase/$makefile_am"
4520 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4522 echo "Create $testsbase/$makefile_am"
4525 func_append added_files "$testsbase/$makefile_am$nl"
4529 if test "$vc_files" != false; then
4530 # Update the .cvsignore and .gitignore files.
4531 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4532 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4533 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4534 echo "$m4base/|A|gnulib-comp.m4"
4535 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4536 { # Rearrange file descriptors. Needed because "while ... done < ..."
4537 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4538 exec 5<&0 < "$tmp"/fileset-changes
4539 func_update_ignorelist ()
4542 if test "$ignore" = .gitignore; then
4543 # In a .gitignore file, "foo" applies to the current directory and all
4544 # subdirectories, whereas "/foo" applies to the current directory only.
4547 doubly_escaped_anchor='\\/'
4551 doubly_escaped_anchor=''
4553 if test -f "$destdir/$dir$ignore"; then
4554 if test -n "$dir_added" || test -n "$dir_removed"; then
4555 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4556 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4557 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4558 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4559 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4561 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4563 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4564 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4565 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4566 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4567 } > "$tmp"/sed-ignore-removed
4568 { cat "$destdir/$dir$ignore"~
4569 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4570 } | sed -f "$tmp"/sed-ignore-removed \
4571 > "$destdir/$dir$ignore"
4573 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4578 if test -n "$dir_added"; then
4580 echo "Creating $destdir/$dir$ignore"
4582 if test "$ignore" = .cvsignore; then
4584 # Automake generates Makefile rules that create .dirstamp files.
4587 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4588 } > "$destdir/$dir$ignore"
4590 echo "Create $destdir/$dir$ignore"
4600 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4601 func_update_ignorelist .cvsignore
4603 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4604 func_update_ignorelist .gitignore
4611 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4612 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4613 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4614 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4615 if test "$next_dir" != "$last_dir"; then
4616 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4617 last_dir="$next_dir"
4622 A) func_append last_dir_added "$file$nl";;
4623 R) func_append last_dir_removed "$file$nl";;
4626 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4633 echo "You may need to add #include directives for the following .h files."
4634 # Intersect $specified_modules and $main_modules
4635 # (since $specified_modules is not necessarily of subset of $main_modules
4636 # - some may have been skipped through --avoid, and since the elements of
4637 # $main_modules but not in $specified_modules can go away without explicit
4638 # notice - through changes in the module dependencies).
4639 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4640 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4641 # First the #include <...> directives without #ifs, sorted for convenience,
4642 # then the #include "..." directives without #ifs, sorted for convenience,
4643 # then the #include directives that are surrounded by #ifs. Not sorted.
4644 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4645 include_directive=`func_get_include_directive "$module"`
4646 case "$nl$include_directive" in
4648 echo "$include_directive" 1>&5
4651 echo "$include_directive" | grep -v 'include "' 1>&6
4652 echo "$include_directive" | grep 'include "' 1>&7
4655 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4657 LC_ALL=C sort -u "$tmp"/include-angles
4658 LC_ALL=C sort -u "$tmp"/include-quotes
4659 cat "$tmp"/include-if
4660 ) | sed -e '/^$/d' -e 's/^/ /'
4661 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4663 for module in $main_modules; do
4664 func_get_link_directive "$module"
4666 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4667 if test `wc -l < "$tmp"/link` != 0; then
4669 echo "You may need to use the following Makefile variables when linking."
4670 echo "Use them in <program>_LDADD when linking a program, or"
4671 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4677 echo "Don't forget to"
4678 if test "$makefile_am" = Makefile.am; then
4679 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4681 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4683 if test -n "$pobase"; then
4684 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4686 if test -n "$inctests"; then
4687 if test "$makefile_am" = Makefile.am; then
4688 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4690 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4694 while test $edit != $makefile_am_edits; do
4695 edit=`expr $edit + 1`
4696 eval dir=\"\$makefile_am_edit${edit}_dir\"
4697 eval var=\"\$makefile_am_edit${edit}_var\"
4698 eval val=\"\$makefile_am_edit${edit}_val\"
4699 if test -n "$var"; then
4700 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4703 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4704 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4707 # func_create_testdir testdir modules
4709 # - local_gnulib_dir from --local-dir
4710 # - modcache true or false, from --cache-modules/--no-cache-modules
4711 # - auxdir directory relative to destdir where to place build aux files
4712 # - inctests true if tests should be included, blank otherwise
4713 # - incobsolete true if obsolete modules among dependencies should be
4714 # included, blank otherwise
4715 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
4717 # - excl_longrunning_tests true if long-runnings tests should be excluded,
4719 # - excl_privileged_tests true if tests that require root privileges should be
4720 # excluded, blank otherwise
4721 # - excl_unportable_tests true if tests that fail on some platforms should be
4722 # excluded, blank otherwise
4723 # - avoidlist list of modules to avoid
4724 # - libtool true if --libtool was given, false if --no-libtool was
4725 # given, blank otherwise
4726 # - symbolic true if files should be symlinked, copied otherwise
4727 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4729 func_create_testdir ()
4733 if test -z "$modules"; then
4734 # All modules together.
4735 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4736 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4737 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4738 modules=`func_all_modules`
4739 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4741 specified_modules="$modules"
4743 # Canonicalize the list of specified modules.
4744 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4746 # Unlike in func_import, here we want to include all kinds of tests for the
4747 # directly specified modules, but not for dependencies.
4748 inc_all_direct_tests=true
4749 inc_all_indirect_tests="$inc_all_tests"
4751 # Check that the license of every module is consistent with the license of
4753 saved_inctests="$inctests"
4754 # When computing transitive closures, don't consider $module to depend on
4755 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4756 # on GPL modules - therefore we don't want a warning in this case.
4758 for requested_module in $specified_modules; do
4759 requested_license=`func_get_license "$requested_module"`
4760 if test "$requested_license" != GPL; then
4761 # Here we use func_modules_transitive_closure, not just
4762 # func_get_dependencies, so that we also detect weird situations like
4763 # an LGPL module which depends on a GPLed build tool module which depends
4765 modules="$requested_module"
4766 func_modules_transitive_closure
4767 for module in $modules; do
4768 license=`func_get_license "$module"`
4770 'GPLed build tool') ;;
4771 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4773 case "$requested_license" in
4776 GPLv2+ | LGPLv2+) ;;
4777 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4783 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4789 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4798 inctests="$saved_inctests"
4800 # Subdirectory names.
4810 # Determine final module list.
4811 modules="$specified_modules"
4812 func_modules_transitive_closure
4813 if test $verbose -ge 0; then
4814 echo "Module list with included dependencies:"
4815 echo "$modules" | sed -e 's/^/ /'
4818 # Add the dummy module if needed.
4819 func_modules_add_dummy
4821 # Show banner notice of every module.
4824 # Determine final file list.
4825 func_modules_to_filelist
4826 if test $verbose -ge 0; then
4828 echo "$files" | sed -e 's/^/ /'
4831 rewritten='%REWRITTEN%'
4832 sed_rewrite_files="\
4833 s,^build-aux/,$rewritten$auxdir/,
4834 s,^doc/,$rewritten$docbase/,
4835 s,^lib/,$rewritten$sourcebase/,
4836 s,^m4/,$rewritten$m4base/,
4837 s,^tests/,$rewritten$testsbase/,
4841 # Create directories.
4842 for f in $files; do echo $f; done \
4843 | sed -e "$sed_rewrite_files" \
4844 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4845 | LC_ALL=C sort -u \
4847 { # Rearrange file descriptors. Needed because "while ... done < ..."
4848 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4849 exec 5<&0 < "$tmp"/dirs
4851 mkdir -p "$testdir/$d"
4856 # Copy files or make symbolic links.
4858 for f in $files; do echo $f; done \
4859 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4862 { # Rearrange file descriptors. Needed because "while ... done < ..."
4863 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4864 exec 5<&0 < "$tmp"/files
4866 func_lookup_file "$f"
4867 if test -n "$lookedup_tmp"; then
4868 cp -p "$lookedup_file" "$testdir/$g"
4870 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4871 if { test -n "$symbolic" \
4872 || { test -n "$lsymbolic" \
4873 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4874 func_ln "$lookedup_file" "$testdir/$g"
4876 cp -p "$lookedup_file" "$testdir/$g"
4883 # Create Makefile.ams that are for testing.
4886 # No special edits are needed.
4889 # Create $sourcebase/Makefile.am.
4890 mkdir -p "$testdir/$sourcebase"
4891 destfile="$sourcebase/Makefile.am"
4892 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4893 any_uses_subdirs="$uses_subdirs"
4895 # Create $m4base/Makefile.am.
4896 mkdir -p "$testdir/$m4base"
4897 (echo "## Process this file with automake to produce Makefile.in."
4903 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4906 ) > "$testdir/$m4base/Makefile.am"
4908 subdirs="$sourcebase $m4base"
4909 subdirs_with_configure_ac=""
4911 if false && test -f "$testdir"/$m4base/gettext.m4; then
4912 # Avoid stupid error message from automake:
4913 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4914 mkdir -p "$testdir/po"
4915 (echo "## Process this file with automake to produce Makefile.in."
4916 ) > "$testdir/po/Makefile.am"
4917 func_append subdirs " po"
4920 if test -n "$inctests"; then
4921 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4922 # Viewed from the $testsbase subdirectory, $auxdir is different.
4923 saved_auxdir="$auxdir"
4924 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4925 # Create $testsbase/Makefile.am.
4927 destfile="$testsbase/Makefile.am"
4928 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
4929 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4930 # Create $testsbase/configure.ac.
4931 (echo "# Process this file with autoconf to produce a configure script."
4932 echo "AC_INIT([dummy], [0])"
4933 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4934 echo "AM_INIT_AUTOMAKE"
4936 echo "AC_CONFIG_HEADERS([config.h])"
4939 echo "AC_PROG_INSTALL"
4940 echo "AC_PROG_MAKE_SET"
4941 echo "AC_PROG_RANLIB"
4943 if test -n "$uses_subdirs"; then
4944 echo "AM_PROG_CC_C_O"
4947 for module in $modules; do
4949 if test -n "$module"; then
4951 gnumakefile | maintainer-makefile)
4952 # These modules are meant to be used only in the top-level directory.
4955 func_get_autoconf_early_snippet "$module"
4960 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4961 if test "$libtool" = true; then
4962 echo "LT_INIT([win32-dll])"
4963 echo "LT_LANG([C++])"
4964 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4965 echo "gl_cond_libtool=true"
4967 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4968 echo "gl_cond_libtool=false"
4970 echo "gl_ltlibdeps="
4972 # Wrap the set of autoconf snippets into an autoconf macro that is then
4973 # invoked. This is needed because autoconf does not support AC_REQUIRE
4975 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4976 # but we want the AC_REQUIRE to have its normal meaning (provide one
4977 # expansion of the required macro before the current point, and only one
4979 echo "AC_DEFUN([gl_INIT], ["
4980 sed_replace_build_aux='
4982 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4983 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4986 echo "gl_m4_base='../$m4base'"
4987 func_emit_initmacro_start $macro_prefix
4988 # We don't have explicit ordering constraints between the various
4989 # autoconf snippets. It's cleanest to put those of the library before
4990 # those of the tests.
4991 echo "gl_source_base='../$sourcebase'"
4992 for module in $modules; do
4993 func_verify_nontests_module
4994 if test -n "$module"; then
4996 gnumakefile | maintainer-makefile)
4997 # These modules are meant to be used only in the top-level directory.
5000 func_get_autoconf_snippet "$module" \
5001 | sed -e "$sed_replace_build_aux"
5006 echo "gl_source_base='.'"
5007 for module in $modules; do
5008 func_verify_tests_module
5009 if test -n "$module"; then
5010 func_get_autoconf_snippet "$module" \
5011 | sed -e "$sed_replace_build_aux"
5014 func_emit_initmacro_end $macro_prefix
5015 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5016 # created using libtool, because libtool already handles the dependencies.
5017 if test "$libtool" != true; then
5018 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5019 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5020 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5021 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5022 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5025 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5029 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5030 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5031 echo "AH_TOP([#include \"../config.h\"])"
5033 echo "AC_CONFIG_FILES([Makefile])"
5035 ) > "$testdir/$testsbase/configure.ac"
5036 auxdir="$saved_auxdir"
5037 func_append subdirs " $testsbase"
5038 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5041 # Create Makefile.am.
5042 (echo "## Process this file with automake to produce Makefile.in."
5044 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5046 echo "SUBDIRS = $subdirs"
5048 echo "ACLOCAL_AMFLAGS = -I $m4base"
5049 ) > "$testdir/Makefile.am"
5051 # Create configure.ac.
5052 (echo "# Process this file with autoconf to produce a configure script."
5053 echo "AC_INIT([dummy], [0])"
5054 if test "$auxdir" != "."; then
5055 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5057 echo "AM_INIT_AUTOMAKE"
5059 echo "AC_CONFIG_HEADERS([config.h])"
5062 echo "AC_PROG_INSTALL"
5063 echo "AC_PROG_MAKE_SET"
5065 echo "# For autobuild."
5066 echo "AC_CANONICAL_BUILD"
5067 echo "AC_CANONICAL_HOST"
5069 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5070 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5071 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5072 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5074 echo "AC_PROG_RANLIB"
5076 if test -n "$any_uses_subdirs"; then
5077 echo "AM_PROG_CC_C_O"
5080 for module in $modules; do
5081 func_verify_nontests_module
5082 if test -n "$module"; then
5083 func_get_autoconf_early_snippet "$module"
5086 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5087 if test "$libtool" = true; then
5088 echo "LT_INIT([win32-dll])"
5089 echo "LT_LANG([C++])"
5090 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5091 echo "gl_cond_libtool=true"
5093 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5094 echo "gl_cond_libtool=false"
5096 echo "gl_ltlibdeps="
5098 # Wrap the set of autoconf snippets into an autoconf macro that is then
5099 # invoked. This is needed because autoconf does not support AC_REQUIRE
5101 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5102 # but we want the AC_REQUIRE to have its normal meaning (provide one
5103 # expansion of the required macro before the current point, and only one
5105 echo "AC_DEFUN([gl_INIT], ["
5106 if test "$auxdir" != "build-aux"; then
5107 sed_replace_build_aux='
5109 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5110 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5114 sed_replace_build_aux="$sed_noop"
5116 echo "gl_m4_base='$m4base'"
5117 func_emit_initmacro_start $macro_prefix
5118 echo "gl_source_base='$sourcebase'"
5119 for module in $modules; do
5120 func_verify_nontests_module
5121 if test -n "$module"; then
5122 func_get_autoconf_snippet "$module" \
5123 | sed -e "$sed_replace_build_aux"
5126 func_emit_initmacro_end $macro_prefix
5127 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5128 # created using libtool, because libtool already handles the dependencies.
5129 if test "$libtool" != true; then
5130 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5131 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5132 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5133 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5134 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5137 func_emit_initmacro_done $macro_prefix $sourcebase
5141 if test -n "$subdirs_with_configure_ac"; then
5142 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5144 makefiles="Makefile"
5145 for d in $subdirs; do
5146 # For subdirs that have a configure.ac by their own, it's the subdir's
5147 # configure.ac which creates the subdir's Makefile.am, not this one.
5148 case " $subdirs_with_configure_ac " in
5150 *) func_append makefiles " $d/Makefile" ;;
5153 echo "AC_CONFIG_FILES([$makefiles])"
5155 ) > "$testdir/configure.ac"
5157 # Create autogenerated files.
5159 # Do not use "${AUTORECONF} --force --install", because it may invoke
5160 # autopoint, which brings in older versions of some of our .m4 files.
5161 if test -f $m4base/gettext.m4; then
5162 func_execute_command ${AUTOPOINT} --force || func_exit 1
5163 for f in $m4base/*.m4~; do
5165 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5169 if test "$libtool" = true; then
5170 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5172 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5173 if ! test -d build-aux; then
5174 func_execute_command mkdir build-aux || func_exit 1
5176 func_execute_command ${AUTOCONF} || func_exit 1
5177 func_execute_command ${AUTOHEADER} || func_exit 1
5178 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5180 if test -n "$inctests"; then
5181 # Create autogenerated files.
5182 (cd "$testdir/$testsbase" || func_exit 1
5183 # Do not use "${AUTORECONF} --force --install", because it may invoke
5184 # autopoint, which brings in older versions of some of our .m4 files.
5185 if test -f ../$m4base/gettext.m4; then
5186 func_execute_command ${AUTOPOINT} --force || func_exit 1
5187 for f in ../$m4base/*.m4~; do
5189 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5193 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5194 if ! test -d ../build-aux; then
5195 func_execute_command mkdir ../build-aux
5197 func_execute_command ${AUTOCONF} || func_exit 1
5198 func_execute_command ${AUTOHEADER} || func_exit 1
5199 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5202 # Need to run configure and make once, to create built files that are to be
5203 # distributed (such as getdate.c).
5204 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5205 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5206 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5207 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5208 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5209 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5210 # such $(FOO_H) because they don't refer to distributed files.
5211 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5212 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5213 | sed -e "$sed_remove_make_variables"`
5214 distributed_built_sources=`for file in $built_sources; do
5215 case "$cleaned_files" in
5220 tests_distributed_built_sources=
5221 if test -n "$inctests"; then
5222 # Likewise for built files in the $testsbase directory.
5223 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5224 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5225 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5226 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5227 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5228 | sed -e "$sed_remove_make_variables"`
5229 tests_distributed_built_sources=`for file in $tests_built_sources; do
5230 case "$tests_cleaned_files" in
5236 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5238 ./configure || func_exit 1
5239 if test -n "$distributed_built_sources"; then
5241 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5242 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5247 if test -n "$tests_distributed_built_sources"; then
5249 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5250 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5255 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5262 # func_create_megatestdir megatestdir allmodules
5264 # - local_gnulib_dir from --local-dir
5265 # - modcache true or false, from --cache-modules/--no-cache-modules
5266 # - auxdir directory relative to destdir where to place build aux files
5267 func_create_megatestdir ()
5271 if test -z "$allmodules"; then
5272 allmodules=`func_all_modules`
5276 # First, all modules one by one.
5277 for onemodule in $allmodules; do
5278 func_create_testdir "$megatestdir/$onemodule" $onemodule
5279 func_append megasubdirs "$onemodule "
5281 # Then, all modules all together.
5282 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5283 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5284 func_create_testdir "$megatestdir/ALL" "$allmodules"
5285 func_append megasubdirs "ALL"
5288 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5289 vc_witness="$gnulib_dir/CVS/Entries"; \
5291 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5293 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5294 | sed -e 's,January,01,' -e 's,Jan,01,' \
5295 -e 's,February,02,' -e 's,Feb,02,' \
5296 -e 's,March,03,' -e 's,Mar,03,' \
5297 -e 's,April,04,' -e 's,Apr,04,' \
5299 -e 's,June,06,' -e 's,Jun,06,' \
5300 -e 's,July,07,' -e 's,Jul,07,' \
5301 -e 's,August,08,' -e 's,Aug,08,' \
5302 -e 's,September,09,' -e 's,Sep,09,' \
5303 -e 's,October,10,' -e 's,Oct,10,' \
5304 -e 's,November,11,' -e 's,Nov,11,' \
5305 -e 's,December,12,' -e 's,Dec,12,' \
5306 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5307 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5309 echo "CVSDATE=$cvsdate"
5310 echo ": \${MAKE=make}"
5311 echo "test -d logs || mkdir logs"
5312 echo "for module in $megasubdirs; do"
5313 echo " echo \"Working on module \$module...\""
5314 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5315 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5318 echo " : autobuild project... \$module"
5319 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5320 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5321 echo " : autobuild hostname... \`hostname\`"
5322 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5324 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5326 ) > "$megatestdir/do-autobuild"
5327 chmod a+x "$megatestdir/do-autobuild"
5329 # Create Makefile.am.
5330 (echo "## Process this file with automake to produce Makefile.in."
5332 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5334 echo "SUBDIRS = $megasubdirs"
5336 echo "EXTRA_DIST = do-autobuild"
5337 ) > "$megatestdir/Makefile.am"
5339 # Create configure.ac.
5340 (echo "# Process this file with autoconf to produce a configure script."
5341 echo "AC_INIT([dummy], [0])"
5342 if test "$auxdir" != "."; then
5343 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5345 echo "AM_INIT_AUTOMAKE"
5347 echo "AC_PROG_MAKE_SET"
5349 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5350 echo "AC_CONFIG_FILES([Makefile])"
5352 ) > "$megatestdir/configure.ac"
5354 # Create autogenerated files.
5356 # Do not use "${AUTORECONF} --install", because autoreconf operates
5357 # recursively, but the subdirectories are already finished, therefore
5358 # calling autoreconf here would only waste lots of CPU time.
5359 func_execute_command ${ACLOCAL} || func_exit 1
5360 func_execute_command mkdir build-aux
5361 func_execute_command ${AUTOCONF} || func_exit 1
5362 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5368 func_fatal_error "no mode specified" ;;
5375 # sed expression that converts a literal to a basic regular expression.
5376 # Needs to handle . [ \ * ^ $.
5377 sed_literal_to_basic_regex='s/\\/\\\\/g
5383 if test -f "$gnulib_dir/$filename" \
5384 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5385 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5386 filename_line_regex='^'"$filename_anywhere_regex"'$'
5389 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5390 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5391 (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$,,')
5394 | func_sanitize_modulelist \
5397 for module in $module_candidates; do
5398 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5403 func_warning "file $filename does not exist"
5411 if test -z "$destdir"; then
5414 test -d "$destdir" \
5415 || func_fatal_error "destination directory does not exist: $destdir"
5417 # Prefer configure.ac to configure.in.
5418 if test -f "$destdir"/configure.ac; then
5419 configure_ac="$destdir/configure.ac"
5421 if test -f "$destdir"/configure.in; then
5422 configure_ac="$destdir/configure.in"
5424 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5428 # Analyze configure.ac.
5430 guessed_libtool=false
5435 /AC_CONFIG_AUX_DIR/ {
5436 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5438 /A[CM]_PROG_LIBTOOL/ {
5439 s,^.*$,guessed_libtool=true,p
5441 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5443 if test -z "$auxdir"; then
5444 auxdir="$guessed_auxdir"
5447 # Determine where to apply func_import.
5448 if test -n "$m4base"; then
5449 # Apply func_import to a particular gnulib directory.
5450 # Any number of additional modules can be given.
5451 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5452 # First use of gnulib in the given m4base.
5453 test -n "$supplied_libname" || supplied_libname=true
5454 test -n "$sourcebase" || sourcebase="lib"
5455 test -n "$docbase" || docbase="doc"
5456 test -n "$testsbase" || testsbase="tests"
5457 test -n "$macro_prefix" || macro_prefix="gl"
5461 # Apply func_import to all gnulib directories.
5462 # To get this list of directories, look at Makefile.am. (Not at
5463 # configure, because it may be omitted from CVS. Also, don't run
5464 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
5467 if test -f "$destdir"/Makefile.am; then
5468 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5470 for arg in $aclocal_amflags; do
5471 if test -n "$m4dir_is_next"; then
5472 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5476 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5477 func_append m4dirs " $arg"
5478 m4dirs_count=`expr $m4dirs_count + 1`
5484 if test "X$arg" = "X-I"; then
5492 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5493 if test -f "$destdir"/aclocal.m4; then
5494 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5495 sedexpr2='s,^[^/]*$,.,'
5496 sedexpr3='s,/[^/]*$,,'
5497 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5498 m4dirs_count=`printf %s "$m4dirs" | wc -l`
5501 if test $m4dirs_count = 0; then
5502 # First use of gnulib in a package.
5503 # Any number of additional modules can be given.
5504 test -n "$supplied_libname" || supplied_libname=true
5505 test -n "$sourcebase" || sourcebase="lib"
5507 test -n "$docbase" || docbase="doc"
5508 test -n "$testsbase" || testsbase="tests"
5509 test -n "$macro_prefix" || macro_prefix="gl"
5512 if test $m4dirs_count = 1; then
5513 # There's only one use of gnulib here. Assume the user means it.
5514 # Any number of additional modules can be given.
5515 for m4base in $m4dirs; do
5519 # Ambiguous - guess what the user meant.
5520 if test $# = 0; then
5521 # No further arguments. Guess the user wants to update all of them.
5522 for m4base in $m4dirs; do
5523 # Perform func_import in a subshell, so that variable values
5525 # local_gnulib_dir, incobsolete, inc_cxx_tests,
5526 # inc_longrunning_tests, inc_privileged_tests,
5527 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
5528 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
5529 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5530 # don't propagate from one directory to another.
5531 (func_import) || func_exit 1
5535 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5543 if test -z "$destdir"; then
5544 func_fatal_error "please specify --dir option"
5547 test -d "$destdir" \
5548 || func_fatal_error "could not create destination directory"
5549 test -n "$auxdir" || auxdir="build-aux"
5550 func_create_testdir "$destdir" "$*"
5553 create-megatestdir )
5554 if test -z "$destdir"; then
5555 func_fatal_error "please specify --dir option"
5557 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5558 test -n "$auxdir" || auxdir="build-aux"
5559 func_create_megatestdir "$destdir" "$*"
5563 test -n "$destdir" || destdir=testdir$$
5564 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5565 test -n "$auxdir" || auxdir="build-aux"
5566 func_create_testdir "$destdir" "$*"
5570 ../configure || func_exit 1
5571 $MAKE || func_exit 1
5572 $MAKE check || func_exit 1
5573 $MAKE distclean || func_exit 1
5574 remaining=`find . -type f -print`
5575 if test -n "$remaining"; then
5576 echo "Remaining files:" $remaining 1>&2
5577 echo "gnulib-tool: *** Stop." 1>&2
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_megatestdir "$destdir" "$*"
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
5608 extract-description )
5612 if test -n "$module"; then
5613 func_get_description "$module"
5622 if test -n "$module"; then
5623 func_get_comment "$module"
5632 if test -n "$module"; then
5633 func_get_status "$module"
5642 if test -n "$module"; then
5643 func_get_notice "$module"
5648 extract-applicability )
5652 if test -n "$module"; then
5653 func_get_applicability "$module"
5662 if test -n "$module"; then
5663 func_get_filelist "$module"
5668 extract-dependencies )
5672 if test -n "$module"; then
5673 func_get_dependencies "$module"
5678 extract-autoconf-snippet )
5682 if test -n "$module"; then
5683 func_get_autoconf_snippet "$module"
5688 extract-automake-snippet )
5692 if test -n "$module"; then
5693 func_get_automake_snippet "$module"
5698 extract-include-directive )
5702 if test -n "$module"; then
5703 func_get_include_directive "$module"
5708 extract-link-directive )
5712 if test -n "$module"; then
5713 func_get_link_directive "$module"
5722 if test -n "$module"; then
5723 func_get_license "$module"
5728 extract-maintainer )
5732 if test -n "$module"; then
5733 func_get_maintainer "$module"
5738 extract-tests-module )
5742 if test -n "$module"; then
5743 func_get_tests_module "$module"
5749 # Verify the number of arguments.
5750 if test $# -lt 1 || test $# -gt 2; then
5751 func_fatal_error "invalid number of arguments for --$mode"
5754 # The first argument is the file to be copied.
5756 # Verify the file exists.
5757 func_lookup_file "$f"
5759 # The second argument is the destination; either a directory ot a file.
5760 # It defaults to the current directory.
5762 test -n "$dest" || dest='.'
5763 test -n "$sourcebase" || sourcebase="lib"
5764 test -n "$m4base" || m4base="m4"
5765 test -n "$docbase" || docbase="doc"
5766 test -n "$testsbase" || testsbase="tests"
5767 test -n "$auxdir" || auxdir="build-aux"
5768 rewritten='%REWRITTEN%'
5769 sed_rewrite_files="\
5770 s,^build-aux/,$rewritten$auxdir/,
5771 s,^doc/,$rewritten$docbase/,
5772 s,^lib/,$rewritten$sourcebase/,
5773 s,^m4/,$rewritten$m4base/,
5774 s,^tests/,$rewritten$testsbase/,
5777 if test -d "$dest"; then
5779 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5781 destdir=`dirname "$dest"`
5782 g=`basename "$dest"`
5785 # Create the directory for destfile.
5786 d=`dirname "$destdir/$g"`
5788 if test -n "$d" && test ! -d "$d"; then
5789 mkdir -p "$d" || func_fatal_error "failed"
5793 func_dest_tmpfilename "$g"
5794 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5795 already_present=true
5796 if test -f "$destdir/$g"; then
5797 # The file already exists.
5801 # Don't protest if the file should be there but isn't: it happens
5802 # frequently that developers don't put autogenerated files into CVS.
5809 func_fatal_error "unknown operation mode --$mode" ;;
5813 # Undo the effect of the previous 'trap' command. Some shellology:
5814 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5815 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5816 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5817 # 128 + signal number and is set before the trap-registered command is run.
5819 trap 'func_exit $?' 1 2 3 13 15
5824 # indent-tabs-mode: nil
5825 # whitespace-check-buffer-indent: nil